diff --git a/.gitignore b/.gitignore index 53a21490..4b7085e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,15 @@ +# System and IDE files +Thumbs.db .DS_Store .idea Phaser OSX.sublime-project Phaser OSX.sublime-workspace Phaser.sublime-project Phaser.sublime-workspace -node_modules +*.suo + +# Vendors +node_modules/ + +# Build +dist/ diff --git a/Docs/API/api.js b/Docs/API/api.js deleted file mode 100644 index 12711933..00000000 --- a/Docs/API/api.js +++ /dev/null @@ -1,16 +0,0 @@ -YUI.add("yuidoc-meta", function(Y) { - Y.YUIDoc = { meta: { - "classes": [ - "TimeManager" - ], - "modules": [ - "Phaser" - ], - "allModules": [ - { - "displayName": "Phaser", - "name": "Phaser" - } - ] -} }; -}); \ No newline at end of file diff --git a/Docs/API/assets/css/external-small.png b/Docs/API/assets/css/external-small.png deleted file mode 100644 index 759a1cdc..00000000 Binary files a/Docs/API/assets/css/external-small.png and /dev/null differ diff --git a/Docs/API/assets/css/logo.png b/Docs/API/assets/css/logo.png deleted file mode 100644 index 609b336c..00000000 Binary files a/Docs/API/assets/css/logo.png and /dev/null differ diff --git a/Docs/API/assets/css/main.css b/Docs/API/assets/css/main.css deleted file mode 100644 index d745d443..00000000 --- a/Docs/API/assets/css/main.css +++ /dev/null @@ -1,783 +0,0 @@ -/* -Font sizes for all selectors other than the body are given in percentages, -with 100% equal to 13px. To calculate a font size percentage, multiply the -desired size in pixels by 7.6923076923. - -Here's a quick lookup table: - -10px - 76.923% -11px - 84.615% -12px - 92.308% -13px - 100% -14px - 107.692% -15px - 115.385% -16px - 123.077% -17px - 130.769% -18px - 138.462% -19px - 146.154% -20px - 153.846% -*/ - -html { - background: #fff; - color: #333; - overflow-y: scroll; -} - -body { - /*font: 13px/1.4 'Lucida Grande', 'Lucida Sans Unicode', 'DejaVu Sans', 'Bitstream Vera Sans', 'Helvetica', 'Arial', sans-serif;*/ - font: 13px/1.4 'Helvetica', 'Arial', sans-serif; - margin: 0; - padding: 0; -} - -/* -- Links ----------------------------------------------------------------- */ -a { - color: #356de4; - text-decoration: none; -} - -.hidden { - display: none; -} - -a:hover { text-decoration: underline; } - -/* "Jump to Table of Contents" link is shown to assistive tools, but hidden from - sight until it's focused. */ -.jump { - position: absolute; - padding: 3px 6px; - left: -99999px; - top: 0; -} - -.jump:focus { left: 40%; } - -/* -- Paragraphs ------------------------------------------------------------ */ -p { margin: 1.3em 0; } -dd p, td p { margin-bottom: 0; } -dd p:first-child, td p:first-child { margin-top: 0; } - -/* -- Headings -------------------------------------------------------------- */ -h1, h2, h3, h4, h5, h6 { - color: #D98527;/*was #f80*/ - font-family: 'Trebuchet MS', sans-serif; - font-weight: bold; - line-height: 1.1; - margin: 1.1em 0 0.5em; -} - -h1 { - font-size: 184.6%; - color: #30418C; - margin: 0.75em 0 0.5em; -} - -h2 { - font-size: 153.846%; - color: #E48A2B; -} - -h3 { font-size: 138.462%; } - -h4 { - border-bottom: 1px solid #DBDFEA; - color: #E48A2B; - font-size: 115.385%; - font-weight: normal; - padding-bottom: 2px; -} - -h5, h6 { font-size: 107.692%; } - -/* -- Code and examples ----------------------------------------------------- */ -code, kbd, pre, samp { - font-family: Menlo, Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; - font-size: 92.308%; - line-height: 1.35; -} - -p code, p kbd, p samp { - background: #FCFBFA; - border: 1px solid #EFEEED; - padding: 0 3px; -} - -a code, a kbd, a samp, -pre code, pre kbd, pre samp, -table code, table kbd, table samp, -.intro code, .intro kbd, .intro samp, -.toc code, .toc kbd, .toc samp { - background: none; - border: none; - padding: 0; -} - -pre.code, pre.terminal, pre.cmd { - overflow-x: auto; - *overflow-x: scroll; - padding: 0.3em 0.6em; -} - -pre.code { - background: #FCFBFA; - border: 1px solid #EFEEED; - border-left-width: 5px; -} - -pre.terminal, pre.cmd { - background: #F0EFFC; - border: 1px solid #D0CBFB; - border-left: 5px solid #D0CBFB; -} - -/* Don't reduce the font size of // elements inside
-   blocks. */
-pre code, pre kbd, pre samp { font-size: 100%; }
-
-/* Used to denote text that shouldn't be selectable, such as line numbers or
-   shell prompts. Guess which browser this doesn't work in. */
-.noselect {
-    -moz-user-select: -moz-none;
-    -khtml-user-select: none;
-    -webkit-user-select: none;
-    -o-user-select: none;
-    user-select: none;
-}
-
-/* -- Lists ----------------------------------------------------------------- */
-dd { margin: 0.2em 0 0.7em 1em; }
-dl { margin: 1em 0; }
-dt { font-weight: bold; }
-
-/* -- Tables ---------------------------------------------------------------- */
-caption, th { text-align: left; }
-
-table {
-    border-collapse: collapse;
-    width: 100%;
-}
-
-td, th {
-    border: 1px solid #fff;
-    padding: 5px 12px;
-    vertical-align: top;
-}
-
-td { background: #E6E9F5; }
-td dl { margin: 0; }
-td dl dl { margin: 1em 0; }
-td pre:first-child { margin-top: 0; }
-
-th {
-    background: #D2D7E6;/*#97A0BF*/
-    border-bottom: none;
-    border-top: none;
-    color: #000;/*#FFF1D5*/
-    font-family: 'Trebuchet MS', sans-serif;
-    font-weight: bold;
-    line-height: 1.3;
-    white-space: nowrap;
-}
-
-
-/* -- Layout and Content ---------------------------------------------------- */
-#doc {
-    margin: auto;
-    min-width: 1024px;
-}
-
-.content { padding: 0 20px 0 25px; }
-
-.sidebar {
-    padding: 0 15px 0 10px;
-}
-#bd {
-    padding: 7px 0 130px;
-    position: relative;
-    width: 99%;
-}
-
-/* -- Table of Contents ----------------------------------------------------- */
-
-/* The #toc id refers to the single global table of contents, while the .toc
-   class refers to generic TOC lists that could be used throughout the page. */
-
-.toc code, .toc kbd, .toc samp { font-size: 100%; }
-.toc li { font-weight: bold; }
-.toc li li { font-weight: normal; }
-
-/* -- Intro and Example Boxes ----------------------------------------------- */
-/*
-.intro, .example { margin-bottom: 2em; }
-.example {
-    -moz-border-radius: 4px;
-    -webkit-border-radius: 4px;
-    border-radius: 4px;
-    -moz-box-shadow: 0 0 5px #bfbfbf;
-    -webkit-box-shadow: 0 0 5px #bfbfbf;
-    box-shadow: 0 0 5px #bfbfbf;
-    padding: 1em;
-}
-.intro {
-    background: none repeat scroll 0 0 #F0F1F8; border: 1px solid #D4D8EB; padding: 0 1em;
-}
-*/
-
-/* -- Other Styles ---------------------------------------------------------- */
-
-/* These are probably YUI-specific, and should be moved out of Selleck's default
-   theme. */
-
-.button {
-    border: 1px solid #dadada;
-    -moz-border-radius: 3px;
-    -webkit-border-radius: 3px;
-    border-radius: 3px;
-    color: #444;
-    display: inline-block;
-    font-family: Helvetica, Arial, sans-serif;
-    font-size: 92.308%;
-    font-weight: bold;
-    padding: 4px 13px 3px;
-    -moz-text-shadow: 1px 1px 0 #fff;
-    -webkit-text-shadow: 1px 1px 0 #fff;
-    text-shadow: 1px 1px 0 #fff;
-    white-space: nowrap;
-
-    background: #EFEFEF; /* old browsers */
-    background: -moz-linear-gradient(top, #f5f5f5 0%, #efefef 50%, #e5e5e5 51%, #dfdfdf 100%); /* firefox */
-    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(50%,#efefef), color-stop(51%,#e5e5e5), color-stop(100%,#dfdfdf)); /* webkit */
-    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#dfdfdf',GradientType=0 ); /* ie */
-}
-
-.button:hover {
-    border-color: #466899;
-    color: #fff;
-    text-decoration: none;
-    -moz-text-shadow: 1px 1px 0 #222;
-    -webkit-text-shadow: 1px 1px 0 #222;
-    text-shadow: 1px 1px 0 #222;
-
-    background: #6396D8; /* old browsers */
-    background: -moz-linear-gradient(top, #6396D8 0%, #5A83BC 50%, #547AB7 51%, #466899 100%); /* firefox */
-    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6396D8), color-stop(50%,#5A83BC), color-stop(51%,#547AB7), color-stop(100%,#466899)); /* webkit */
-    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6396D8', endColorstr='#466899',GradientType=0 ); /* ie */
-}
-
-.newwindow { text-align: center; }
-
-.header .version em {
-    display: block;
-    text-align: right;
-}
-
-
-#classdocs .item {
-    border-bottom: 1px solid #466899;
-    margin: 1em 0;
-    padding: 1.5em;
-}
-
-#classdocs .item .params p,
-    #classdocs .item .returns p,{
-    display: inline;
-}
-
-#classdocs .item em code, #classdocs .item em.comment {
-    color: green;
-}
-
-#classdocs .item em.comment a {
-    color: green;
-    text-decoration: underline;
-}
-
-#classdocs .foundat {
-    font-size: 11px;
-    font-style: normal;
-}
-
-.attrs .emits {
-    margin-left: 2em;
-    padding: .5em;
-    border-left: 1px dashed #ccc;
-}
-
-abbr {
-    border-bottom: 1px dashed #ccc;
-    font-size: 80%;
-    cursor: help;
-}
-
-.prettyprint li.L0, 
-.prettyprint li.L1, 
-.prettyprint li.L2, 
-.prettyprint li.L3, 
-.prettyprint li.L5, 
-.prettyprint li.L6, 
-.prettyprint li.L7, 
-.prettyprint li.L8 {
-    list-style: decimal;
-}
-
-ul li p {
-    margin-top: 0;
-}
-
-.method .name {
-    font-size: 110%;
-}
-
-.apidocs .methods .extends .method,
-.apidocs .properties .extends .property,
-.apidocs .attrs .extends .attr,
-.apidocs .events .extends .event {
-    font-weight: bold;
-}
-
-.apidocs .methods .extends .inherited,
-.apidocs .properties .extends .inherited,
-.apidocs .attrs .extends .inherited,
-.apidocs .events .extends .inherited {
-    font-weight: normal;
-}
-
-#hd {
-    background: whiteSmoke;
-    background: -moz-linear-gradient(top,#DCDBD9 0,#F6F5F3 100%);
-    background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#DCDBD9),color-stop(100%,#F6F5F3));
-    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#dcdbd9',endColorstr='#F6F5F3',GradientType=0);
-    border-bottom: 1px solid #DFDFDF;
-    padding: 0 15px 1px 20px;
-    margin-bottom: 15px;
-}
-
-#hd img {
-    margin-right: 10px;
-    vertical-align: middle;
-}
-
-
-/* -- API Docs CSS ---------------------------------------------------------- */
-
-/*
-This file is organized so that more generic styles are nearer the top, and more
-specific styles are nearer the bottom of the file. This allows us to take full
-advantage of the cascade to avoid redundant style rules. Please respect this
-convention when making changes.
-*/
-
-/* -- Generic TabView styles ------------------------------------------------ */
-
-/*
-These styles apply to all API doc tabviews. To change styles only for a
-specific tabview, see the other sections below.
-*/
-
-.yui3-js-enabled .apidocs .tabview {
-    visibility: hidden; /* Hide until the TabView finishes rendering. */
-    _visibility: visible;
-}
-
-.apidocs .tabview.yui3-tabview-content { visibility: visible; }
-.apidocs .tabview .yui3-tabview-panel { background: #fff; }
-
-/* -- Generic Content Styles ------------------------------------------------ */
-
-/* Headings */
-h2, h3, h4, h5, h6 {
-    border: none;
-    color: #30418C;
-    font-weight: bold;
-    text-decoration: none;
-}
-
-.link-docs {
-    float: right;
-    font-size: 15px;
-    margin: 4px 4px 6px;
-    padding: 6px 30px 5px;
-}
-
-.apidocs { zoom: 1; }
-
-/* Generic box styles. */
-.apidocs .box {
-    border: 1px solid;
-    border-radius: 3px;
-    margin: 1em 0;
-    padding: 0 1em;
-}
-
-/* A flag is a compact, capsule-like indicator of some kind. It's used to
-   indicate private and protected items, item return types, etc. in an
-   attractive and unobtrusive way. */
-.apidocs .flag {
-    background: #bababa;
-    border-radius: 3px;
-    color: #fff;
-    font-size: 11px;
-    margin: 0 0.5em;
-    padding: 2px 4px 1px;
-}
-
-/* Class/module metadata such as "Uses", "Extends", "Defined in", etc. */
-.apidocs .meta {
-    background: #f9f9f9;
-    border-color: #efefef;
-    color: #555;
-    font-size: 11px;
-    padding: 3px 6px;
-}
-
-.apidocs .meta p { margin: 0; }
-
-/* Deprecation warning. */
-.apidocs .box.deprecated,
-.apidocs .flag.deprecated {
-    background: #fdac9f;
-    border: 1px solid #fd7775;
-}
-
-.apidocs .box.deprecated p { margin: 0.5em 0; }
-.apidocs .flag.deprecated { color: #333; }
-
-/* Module/Class intro description. */
-.apidocs .intro {
-    background: #f0f1f8;
-    border-color: #d4d8eb;
-}
-
-/* Loading spinners. */
-#bd.loading .apidocs,
-#api-list.loading .yui3-tabview-panel {
-    background: #fff url(../img/spinner.gif) no-repeat center 70px;
-    min-height: 150px;
-}
-
-#bd.loading .apidocs .content,
-#api-list.loading .yui3-tabview-panel .apis {
-    display: none;
-}
-
-.apidocs .no-visible-items { color: #666; }
-
-/* Generic inline list. */
-.apidocs ul.inline {
-    display: inline;
-    list-style: none;
-    margin: 0;
-    padding: 0;
-}
-
-.apidocs ul.inline li { display: inline; }
-
-/* Comma-separated list. */
-.apidocs ul.commas li:after { content: ','; }
-.apidocs ul.commas li:last-child:after { content: ''; }
-
-/* Keyboard shortcuts. */
-kbd .cmd { font-family: Monaco, Helvetica; }
-
-/* -- Generic Access Level styles ------------------------------------------- */
-.apidocs .item.protected,
-.apidocs .item.private,
-.apidocs .index-item.protected,
-.apidocs .index-item.deprecated,
-.apidocs .index-item.private {
-    display: none;
-}
-
-.show-deprecated .item.deprecated,
-.show-deprecated .index-item.deprecated,
-.show-protected .item.protected,
-.show-protected .index-item.protected,
-.show-private .item.private,
-.show-private .index-item.private {
-    display: block;
-}
-
-.hide-inherited .item.inherited,
-.hide-inherited .index-item.inherited {
-    display: none;
-}
-
-/* -- Generic Item Index styles --------------------------------------------- */
-.apidocs .index { margin: 1.5em 0 3em; }
-
-.apidocs .index h3 {
-    border-bottom: 1px solid #efefef;
-    color: #333;
-    font-size: 13px;
-    margin: 2em 0 0.6em;
-    padding-bottom: 2px;
-}
-
-.apidocs .index .no-visible-items { margin-top: 2em; }
-
-.apidocs .index-list {
-    border-color: #efefef;
-    font-size: 12px;
-    list-style: none;
-    margin: 0;
-    padding: 0;
-    -moz-column-count: 4;
-    -moz-column-gap: 10px;
-    -moz-column-width: 170px;
-    -ms-column-count: 4;
-    -ms-column-gap: 10px;
-    -ms-column-width: 170px;
-    -o-column-count: 4;
-    -o-column-gap: 10px;
-    -o-column-width: 170px;
-    -webkit-column-count: 4;
-    -webkit-column-gap: 10px;
-    -webkit-column-width: 170px;
-    column-count: 4;
-    column-gap: 10px;
-    column-width: 170px;
-}
-
-.apidocs .no-columns .index-list {
-    -moz-column-count: 1;
-    -ms-column-count: 1;
-    -o-column-count: 1;
-    -webkit-column-count: 1;
-    column-count: 1;
-}
-
-.apidocs .index-item { white-space: nowrap; }
-
-.apidocs .index-item .flag {
-    background: none;
-    border: none;
-    color: #afafaf;
-    display: inline;
-    margin: 0 0 0 0.2em;
-    padding: 0;
-}
-
-/* -- Generic API item styles ----------------------------------------------- */
-.apidocs .args {
-    display: inline;
-    margin: 0 0.5em;
-}
-
-.apidocs .flag.chainable { background: #46ca3b; }
-.apidocs .flag.protected { background: #9b86fc; }
-.apidocs .flag.private { background: #fd6b1b; }
-.apidocs .flag.async { background: #356de4; }
-.apidocs .flag.required { background: #e60923; }
-
-.apidocs .item {
-    border-bottom: 1px solid #efefef;
-    margin: 1.5em 0 2em;
-    padding-bottom: 2em;
-}
-
-.apidocs .item h4,
-.apidocs .item h5,
-.apidocs .item h6 {
-    color: #333;
-    font-family: inherit;
-    font-size: 100%;
-}
-
-.apidocs .item .description p,
-.apidocs .item pre.code {
-    margin: 1em 0 0;
-}
-
-.apidocs .item .meta {
-    background: none;
-    border: none;
-    padding: 0;
-}
-
-.apidocs .item .name {
-    display: inline;
-    font-size: 14px;
-}
-
-.apidocs .item .type,
-.apidocs .item .type a,
-.apidocs .returns-inline {
-    color: #555;
-}
-
-.apidocs .item .type,
-.apidocs .returns-inline {
-    font-size: 11px;
-    margin: 0 0 0 0;
-}
-
-.apidocs .item .type a { border-bottom: 1px dotted #afafaf; }
-.apidocs .item .type a:hover { border: none; }
-
-/* -- Item Parameter List --------------------------------------------------- */
-.apidocs .params-list {
-    list-style: square;
-    margin: 1em 0 0 2em;
-    padding: 0;
-}
-
-.apidocs .param { margin-bottom: 1em; }
-
-.apidocs .param .type,
-.apidocs .param .type a {
-    color: #666;
-}
-
-.apidocs .param .type {
-    margin: 0 0 0 0.5em;
-    *margin-left: 0.5em;
-}
-
-.apidocs .param-name { font-weight: bold; }
-
-/* -- Item "Emits" block ---------------------------------------------------- */
-.apidocs .item .emits {
-    background: #f9f9f9;
-    border-color: #eaeaea;
-}
-
-/* -- Item "Returns" block -------------------------------------------------- */
-.apidocs .item .returns .type,
-.apidocs .item .returns .type a {
-    font-size: 100%;
-    margin: 0;
-}
-
-/* -- Class Constructor block ----------------------------------------------- */
-.apidocs .constructor .item {
-    border: none;
-    padding-bottom: 0;
-}
-
-/* -- File Source View ------------------------------------------------------ */
-.apidocs .file pre.code,
-#doc .apidocs .file pre.prettyprint {
-    background: inherit;
-    border: none;
-    overflow: visible;
-    padding: 0;
-}
-
-.apidocs .L0,
-.apidocs .L1,
-.apidocs .L2,
-.apidocs .L3,
-.apidocs .L4,
-.apidocs .L5,
-.apidocs .L6,
-.apidocs .L7,
-.apidocs .L8,
-.apidocs .L9 {
-    background: inherit;
-}
-
-/* -- Submodule List -------------------------------------------------------- */
-.apidocs .module-submodule-description {
-    font-size: 12px;
-    margin: 0.3em 0 1em;
-}
-
-.apidocs .module-submodule-description p:first-child { margin-top: 0; }
-
-/* -- Sidebar TabView ------------------------------------------------------- */
-#api-tabview { margin-top: 0.6em; }
-
-#api-tabview-filter,
-#api-tabview-panel {
-    border: 1px solid #dfdfdf;
-}
-
-#api-tabview-filter {
-    border-bottom: none;
-    border-top: none;
-    padding: 0.6em 10px 0 10px;
-}
-
-#api-tabview-panel { border-top: none; }
-#api-filter { width: 97%; }
-
-/* -- Content TabView ------------------------------------------------------- */
-#classdocs .yui3-tabview-panel { border: none; }
-
-/* -- Source File Contents -------------------------------------------------- */
-.prettyprint li.L0,
-.prettyprint li.L1,
-.prettyprint li.L2,
-.prettyprint li.L3,
-.prettyprint li.L5,
-.prettyprint li.L6,
-.prettyprint li.L7,
-.prettyprint li.L8 {
-    list-style: decimal;
-}
-
-/* -- API options ----------------------------------------------------------- */
-#api-options {
-    font-size: 11px;
-    margin-top: 2.2em;
-    position: absolute;
-    right: 1.5em;
-}
-
-/*#api-options label { margin-right: 0.6em; }*/
-
-/* -- API list -------------------------------------------------------------- */
-#api-list {
-    margin-top: 1.5em;
-    *zoom: 1;
-}
-
-.apis {
-    font-size: 12px;
-    line-height: 1.4;
-    list-style: none;
-    margin: 0;
-    padding: 0.5em 0 0.5em 0.4em;
-}
-
-.apis a {
-    border: 1px solid transparent;
-    display: block;
-    margin: 0 0 0 -4px;
-    padding: 1px 4px 0;
-    text-decoration: none;
-    _border: none;
-    _display: inline;
-}
-
-.apis a:hover,
-.apis a:focus {
-    background: #E8EDFC;
-    background: -moz-linear-gradient(top, #e8edfc 0%, #becef7 100%);
-    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#E8EDFC), color-stop(100%,#BECEF7));
-    border-color: #AAC0FA;
-    border-radius: 3px;
-    color: #333;
-    outline: none;
-}
-
-.api-list-item a:hover,
-.api-list-item a:focus {
-    font-weight: bold;
-    text-shadow: 1px 1px 1px #fff;
-}
-
-.apis .message { color: #888; }
-.apis .result a { padding: 3px 5px 2px; }
-
-.apis .result .type {
-    right: 4px;
-    top: 7px;
-}
-
-.api-list-item .yui3-highlight {
-    font-weight: bold;
-}
-
diff --git a/Docs/API/assets/favicon.png b/Docs/API/assets/favicon.png
deleted file mode 100644
index 5a95ddab..00000000
Binary files a/Docs/API/assets/favicon.png and /dev/null differ
diff --git a/Docs/API/assets/img/spinner.gif b/Docs/API/assets/img/spinner.gif
deleted file mode 100644
index 44f96ba6..00000000
Binary files a/Docs/API/assets/img/spinner.gif and /dev/null differ
diff --git a/Docs/API/assets/index.html b/Docs/API/assets/index.html
deleted file mode 100644
index 487fe15b..00000000
--- a/Docs/API/assets/index.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-    
-        Redirector
-        
-    
-    
-        Click here to redirect
-    
-
diff --git a/Docs/API/assets/js/api-filter.js b/Docs/API/assets/js/api-filter.js
deleted file mode 100644
index 37aefbab..00000000
--- a/Docs/API/assets/js/api-filter.js
+++ /dev/null
@@ -1,52 +0,0 @@
-YUI.add('api-filter', function (Y) {
-
-Y.APIFilter = Y.Base.create('apiFilter', Y.Base, [Y.AutoCompleteBase], {
-    // -- Initializer ----------------------------------------------------------
-    initializer: function () {
-        this._bindUIACBase();
-        this._syncUIACBase();
-    },
-    getDisplayName: function(name) {
-
-        Y.each(Y.YUIDoc.meta.allModules, function(i) {
-            if (i.name === name && i.displayName) {
-                name = i.displayName;
-            }
-        });
-
-        return name;
-    }
-
-}, {
-    // -- Attributes -----------------------------------------------------------
-    ATTRS: {
-        resultHighlighter: {
-            value: 'phraseMatch'
-        },
-
-        // May be set to "classes" or "modules".
-        queryType: {
-            value: 'classes'
-        },
-
-        source: {
-            valueFn: function() {
-                var self = this;
-                return function(q) {
-                    var data = Y.YUIDoc.meta[self.get('queryType')],
-                        out = [];
-                    Y.each(data, function(v) {
-                        if (v.toLowerCase().indexOf(q.toLowerCase()) > -1) {
-                            out.push(v);
-                        }
-                    });
-                    return out;
-                };
-            }
-        }
-    }
-});
-
-}, '3.4.0', {requires: [
-    'autocomplete-base', 'autocomplete-highlighters', 'autocomplete-sources'
-]});
diff --git a/Docs/API/assets/js/api-list.js b/Docs/API/assets/js/api-list.js
deleted file mode 100644
index 88905b52..00000000
--- a/Docs/API/assets/js/api-list.js
+++ /dev/null
@@ -1,251 +0,0 @@
-YUI.add('api-list', function (Y) {
-
-var Lang   = Y.Lang,
-    YArray = Y.Array,
-
-    APIList = Y.namespace('APIList'),
-
-    classesNode    = Y.one('#api-classes'),
-    inputNode      = Y.one('#api-filter'),
-    modulesNode    = Y.one('#api-modules'),
-    tabviewNode    = Y.one('#api-tabview'),
-
-    tabs = APIList.tabs = {},
-
-    filter = APIList.filter = new Y.APIFilter({
-        inputNode : inputNode,
-        maxResults: 1000,
-
-        on: {
-            results: onFilterResults
-        }
-    }),
-
-    search = APIList.search = new Y.APISearch({
-        inputNode : inputNode,
-        maxResults: 100,
-
-        on: {
-            clear  : onSearchClear,
-            results: onSearchResults
-        }
-    }),
-
-    tabview = APIList.tabview = new Y.TabView({
-        srcNode  : tabviewNode,
-        panelNode: '#api-tabview-panel',
-        render   : true,
-
-        on: {
-            selectionChange: onTabSelectionChange
-        }
-    }),
-
-    focusManager = APIList.focusManager = tabviewNode.plug(Y.Plugin.NodeFocusManager, {
-        circular   : true,
-        descendants: '#api-filter, .yui3-tab-panel-selected .api-list-item a, .yui3-tab-panel-selected .result a',
-        keys       : {next: 'down:40', previous: 'down:38'}
-    }).focusManager,
-
-    LIST_ITEM_TEMPLATE =
-        '
  • ' + - '{displayName}' + - '
  • '; - -// -- Init --------------------------------------------------------------------- - -// Duckpunch FocusManager's key event handling to prevent it from handling key -// events when a modifier is pressed. -Y.before(function (e, activeDescendant) { - if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { - return new Y.Do.Prevent(); - } -}, focusManager, '_focusPrevious', focusManager); - -Y.before(function (e, activeDescendant) { - if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { - return new Y.Do.Prevent(); - } -}, focusManager, '_focusNext', focusManager); - -// Create a mapping of tabs in the tabview so we can refer to them easily later. -tabview.each(function (tab, index) { - var name = tab.get('label').toLowerCase(); - - tabs[name] = { - index: index, - name : name, - tab : tab - }; -}); - -// Switch tabs on Ctrl/Cmd-Left/Right arrows. -tabviewNode.on('key', onTabSwitchKey, 'down:37,39'); - -// Focus the filter input when the `/` key is pressed. -Y.one(Y.config.doc).on('key', onSearchKey, 'down:83'); - -// Keep the Focus Manager up to date. -inputNode.on('focus', function () { - focusManager.set('activeDescendant', inputNode); -}); - -// Update all tabview links to resolved URLs. -tabview.get('panelNode').all('a').each(function (link) { - link.setAttribute('href', link.get('href')); -}); - -// -- Private Functions -------------------------------------------------------- -function getFilterResultNode() { - return filter.get('queryType') === 'classes' ? classesNode : modulesNode; -} - -// -- Event Handlers ----------------------------------------------------------- -function onFilterResults(e) { - var frag = Y.one(Y.config.doc.createDocumentFragment()), - resultNode = getFilterResultNode(), - typePlural = filter.get('queryType'), - typeSingular = typePlural === 'classes' ? 'class' : 'module'; - - if (e.results.length) { - YArray.each(e.results, function (result) { - frag.append(Lang.sub(LIST_ITEM_TEMPLATE, { - rootPath : APIList.rootPath, - displayName : filter.getDisplayName(result.highlighted), - name : result.text, - typePlural : typePlural, - typeSingular: typeSingular - })); - }); - } else { - frag.append( - '
  • ' + - 'No ' + typePlural + ' found.' + - '
  • ' - ); - } - - resultNode.empty(true); - resultNode.append(frag); - - focusManager.refresh(); -} - -function onSearchClear(e) { - - focusManager.refresh(); -} - -function onSearchKey(e) { - var target = e.target; - - if (target.test('input,select,textarea') - || target.get('isContentEditable')) { - return; - } - - e.preventDefault(); - - inputNode.focus(); - focusManager.refresh(); -} - -function onSearchResults(e) { - var frag = Y.one(Y.config.doc.createDocumentFragment()); - - if (e.results.length) { - YArray.each(e.results, function (result) { - frag.append(result.display); - }); - } else { - frag.append( - '
  • ' + - 'No results found. Maybe you\'ll have better luck with a ' + - 'different query?' + - '
  • ' - ); - } - - - focusManager.refresh(); -} - -function onTabSelectionChange(e) { - var tab = e.newVal, - name = tab.get('label').toLowerCase(); - - tabs.selected = { - index: tab.get('index'), - name : name, - tab : tab - }; - - switch (name) { - case 'classes': // fallthru - case 'modules': - filter.setAttrs({ - minQueryLength: 0, - queryType : name - }); - - search.set('minQueryLength', -1); - - // Only send a request if this isn't the initially-selected tab. - if (e.prevVal) { - filter.sendRequest(filter.get('value')); - } - break; - - case 'everything': - filter.set('minQueryLength', -1); - search.set('minQueryLength', 1); - - if (search.get('value')) { - search.sendRequest(search.get('value')); - } else { - inputNode.focus(); - } - break; - - default: - // WTF? We shouldn't be here! - filter.set('minQueryLength', -1); - search.set('minQueryLength', -1); - } - - if (focusManager) { - setTimeout(function () { - focusManager.refresh(); - }, 1); - } -} - -function onTabSwitchKey(e) { - var currentTabIndex = tabs.selected.index; - - if (!(e.ctrlKey || e.metaKey)) { - return; - } - - e.preventDefault(); - - switch (e.keyCode) { - case 37: // left arrow - if (currentTabIndex > 0) { - tabview.selectChild(currentTabIndex - 1); - inputNode.focus(); - } - break; - - case 39: // right arrow - if (currentTabIndex < (Y.Object.size(tabs) - 2)) { - tabview.selectChild(currentTabIndex + 1); - inputNode.focus(); - } - break; - } -} - -}, '3.4.0', {requires: [ - 'api-filter', 'api-search', 'event-key', 'node-focusmanager', 'tabview' -]}); diff --git a/Docs/API/assets/js/api-search.js b/Docs/API/assets/js/api-search.js deleted file mode 100644 index 175f6a61..00000000 --- a/Docs/API/assets/js/api-search.js +++ /dev/null @@ -1,98 +0,0 @@ -YUI.add('api-search', function (Y) { - -var Lang = Y.Lang, - Node = Y.Node, - YArray = Y.Array; - -Y.APISearch = Y.Base.create('apiSearch', Y.Base, [Y.AutoCompleteBase], { - // -- Public Properties ---------------------------------------------------- - RESULT_TEMPLATE: - '
  • ' + - '' + - '

    {name}

    ' + - '{resultType}' + - '
    {description}
    ' + - '{class}' + - '
    ' + - '
  • ', - - // -- Initializer ---------------------------------------------------------- - initializer: function () { - this._bindUIACBase(); - this._syncUIACBase(); - }, - - // -- Protected Methods ---------------------------------------------------- - _apiResultFilter: function (query, results) { - // Filter components out of the results. - return YArray.filter(results, function (result) { - return result.raw.resultType === 'component' ? false : result; - }); - }, - - _apiResultFormatter: function (query, results) { - return YArray.map(results, function (result) { - var raw = Y.merge(result.raw), // create a copy - desc = raw.description || ''; - - // Convert description to text and truncate it if necessary. - desc = Node.create('
    ' + desc + '
    ').get('text'); - - if (desc.length > 65) { - desc = Y.Escape.html(desc.substr(0, 65)) + ' …'; - } else { - desc = Y.Escape.html(desc); - } - - raw['class'] || (raw['class'] = ''); - raw.description = desc; - - // Use the highlighted result name. - raw.name = result.highlighted; - - return Lang.sub(this.RESULT_TEMPLATE, raw); - }, this); - }, - - _apiTextLocator: function (result) { - return result.displayName || result.name; - } -}, { - // -- Attributes ----------------------------------------------------------- - ATTRS: { - resultFormatter: { - valueFn: function () { - return this._apiResultFormatter; - } - }, - - resultFilters: { - valueFn: function () { - return this._apiResultFilter; - } - }, - - resultHighlighter: { - value: 'phraseMatch' - }, - - resultListLocator: { - value: 'data.results' - }, - - resultTextLocator: { - valueFn: function () { - return this._apiTextLocator; - } - }, - - source: { - value: '/api/v1/search?q={query}&count={maxResults}' - } - } -}); - -}, '3.4.0', {requires: [ - 'autocomplete-base', 'autocomplete-highlighters', 'autocomplete-sources', - 'escape' -]}); diff --git a/Docs/API/assets/js/apidocs.js b/Docs/API/assets/js/apidocs.js deleted file mode 100644 index c64bb463..00000000 --- a/Docs/API/assets/js/apidocs.js +++ /dev/null @@ -1,370 +0,0 @@ -YUI().use( - 'yuidoc-meta', - 'api-list', 'history-hash', 'node-screen', 'node-style', 'pjax', -function (Y) { - -var win = Y.config.win, - localStorage = win.localStorage, - - bdNode = Y.one('#bd'), - - pjax, - defaultRoute, - - classTabView, - selectedTab; - -// Kill pjax functionality unless serving over HTTP. -if (!Y.getLocation().protocol.match(/^https?\:/)) { - Y.Router.html5 = false; -} - -// Create the default route with middleware which enables syntax highlighting -// on the loaded content. -defaultRoute = Y.Pjax.defaultRoute.concat(function (req, res, next) { - prettyPrint(); - bdNode.removeClass('loading'); - - next(); -}); - -pjax = new Y.Pjax({ - container : '#docs-main', - contentSelector: '#docs-main > .content', - linkSelector : '#bd a', - titleSelector : '#xhr-title', - - navigateOnHash: true, - root : '/', - routes : [ - // -- / ---------------------------------------------------------------- - { - path : '/(index.html)?', - callbacks: defaultRoute - }, - - // -- /classes/* ------------------------------------------------------- - { - path : '/classes/:class.html*', - callbacks: [defaultRoute, 'handleClasses'] - }, - - // -- /files/* --------------------------------------------------------- - { - path : '/files/*file', - callbacks: [defaultRoute, 'handleFiles'] - }, - - // -- /modules/* ------------------------------------------------------- - { - path : '/modules/:module.html*', - callbacks: defaultRoute - } - ] -}); - -// -- Utility Functions -------------------------------------------------------- - -pjax.checkVisibility = function (tab) { - tab || (tab = selectedTab); - - if (!tab) { return; } - - var panelNode = tab.get('panelNode'), - visibleItems; - - // If no items are visible in the tab panel due to the current visibility - // settings, display a message to that effect. - visibleItems = panelNode.all('.item,.index-item').some(function (itemNode) { - if (itemNode.getComputedStyle('display') !== 'none') { - return true; - } - }); - - panelNode.all('.no-visible-items').remove(); - - if (!visibleItems) { - if (Y.one('#index .index-item')) { - panelNode.append( - '
    ' + - '

    ' + - 'Some items are not shown due to the current visibility ' + - 'settings. Use the checkboxes at the upper right of this ' + - 'page to change the visibility settings.' + - '

    ' + - '
    ' - ); - } else { - panelNode.append( - '
    ' + - '

    ' + - 'This class doesn\'t provide any methods, properties, ' + - 'attributes, or events.' + - '

    ' + - '
    ' - ); - } - } - - // Hide index sections without any visible items. - Y.all('.index-section').each(function (section) { - var items = 0, - visibleItems = 0; - - section.all('.index-item').each(function (itemNode) { - items += 1; - - if (itemNode.getComputedStyle('display') !== 'none') { - visibleItems += 1; - } - }); - - section.toggleClass('hidden', !visibleItems); - section.toggleClass('no-columns', visibleItems < 4); - }); -}; - -pjax.initClassTabView = function () { - if (!Y.all('#classdocs .api-class-tab').size()) { - return; - } - - if (classTabView) { - classTabView.destroy(); - selectedTab = null; - } - - classTabView = new Y.TabView({ - srcNode: '#classdocs', - - on: { - selectionChange: pjax.onTabSelectionChange - } - }); - - pjax.updateTabState(); - classTabView.render(); -}; - -pjax.initLineNumbers = function () { - var hash = win.location.hash.substring(1), - container = pjax.get('container'), - hasLines, node; - - // Add ids for each line number in the file source view. - container.all('.linenums>li').each(function (lineNode, index) { - lineNode.set('id', 'l' + (index + 1)); - lineNode.addClass('file-line'); - hasLines = true; - }); - - // Scroll to the desired line. - if (hasLines && /^l\d+$/.test(hash)) { - if ((node = container.getById(hash))) { - win.scroll(0, node.getY()); - } - } -}; - -pjax.initRoot = function () { - var terminators = /^(?:classes|files|modules)$/, - parts = pjax._getPathRoot().split('/'), - root = [], - i, len, part; - - for (i = 0, len = parts.length; i < len; i += 1) { - part = parts[i]; - - if (part.match(terminators)) { - // Makes sure the path will end with a "/". - root.push(''); - break; - } - - root.push(part); - } - - pjax.set('root', root.join('/')); -}; - -pjax.updateTabState = function (src) { - var hash = win.location.hash.substring(1), - defaultTab, node, tab, tabPanel; - - function scrollToNode() { - if (node.hasClass('protected')) { - Y.one('#api-show-protected').set('checked', true); - pjax.updateVisibility(); - } - - if (node.hasClass('private')) { - Y.one('#api-show-private').set('checked', true); - pjax.updateVisibility(); - } - - setTimeout(function () { - // For some reason, unless we re-get the node instance here, - // getY() always returns 0. - var node = Y.one('#classdocs').getById(hash); - win.scrollTo(0, node.getY() - 70); - }, 1); - } - - if (!classTabView) { - return; - } - - if (src === 'hashchange' && !hash) { - defaultTab = 'index'; - } else { - if (localStorage) { - defaultTab = localStorage.getItem('tab_' + pjax.getPath()) || - 'index'; - } else { - defaultTab = 'index'; - } - } - - if (hash && (node = Y.one('#classdocs').getById(hash))) { - if ((tabPanel = node.ancestor('.api-class-tabpanel', true))) { - if ((tab = Y.one('#classdocs .api-class-tab.' + tabPanel.get('id')))) { - if (classTabView.get('rendered')) { - Y.Widget.getByNode(tab).set('selected', 1); - } else { - tab.addClass('yui3-tab-selected'); - } - } - } - - // Scroll to the desired element if this is a hash URL. - if (node) { - if (classTabView.get('rendered')) { - scrollToNode(); - } else { - classTabView.once('renderedChange', scrollToNode); - } - } - } else { - tab = Y.one('#classdocs .api-class-tab.' + defaultTab); - - // When the `defaultTab` node isn't found, `localStorage` is stale. - if (!tab && defaultTab !== 'index') { - tab = Y.one('#classdocs .api-class-tab.index'); - } - - if (classTabView.get('rendered')) { - Y.Widget.getByNode(tab).set('selected', 1); - } else { - tab.addClass('yui3-tab-selected'); - } - } -}; - -pjax.updateVisibility = function () { - var container = pjax.get('container'); - - container.toggleClass('hide-inherited', - !Y.one('#api-show-inherited').get('checked')); - - container.toggleClass('show-deprecated', - Y.one('#api-show-deprecated').get('checked')); - - container.toggleClass('show-protected', - Y.one('#api-show-protected').get('checked')); - - container.toggleClass('show-private', - Y.one('#api-show-private').get('checked')); - - pjax.checkVisibility(); -}; - -// -- Route Handlers ----------------------------------------------------------- - -pjax.handleClasses = function (req, res, next) { - var status = res.ioResponse.status; - - // Handles success and local filesystem XHRs. - if (!status || (status >= 200 && status < 300)) { - pjax.initClassTabView(); - } - - next(); -}; - -pjax.handleFiles = function (req, res, next) { - var status = res.ioResponse.status; - - // Handles success and local filesystem XHRs. - if (!status || (status >= 200 && status < 300)) { - pjax.initLineNumbers(); - } - - next(); -}; - -// -- Event Handlers ----------------------------------------------------------- - -pjax.onNavigate = function (e) { - var hash = e.hash, - originTarget = e.originEvent && e.originEvent.target, - tab; - - if (hash) { - tab = originTarget && originTarget.ancestor('.yui3-tab', true); - - if (hash === win.location.hash) { - pjax.updateTabState('hashchange'); - } else if (!tab) { - win.location.hash = hash; - } - - e.preventDefault(); - return; - } - - // Only scroll to the top of the page when the URL doesn't have a hash. - this.set('scrollToTop', !e.url.match(/#.+$/)); - - bdNode.addClass('loading'); -}; - -pjax.onOptionClick = function (e) { - pjax.updateVisibility(); -}; - -pjax.onTabSelectionChange = function (e) { - var tab = e.newVal, - tabId = tab.get('contentBox').getAttribute('href').substring(1); - - selectedTab = tab; - - // If switching from a previous tab (i.e., this is not the default tab), - // replace the history entry with a hash URL that will cause this tab to - // be selected if the user navigates away and then returns using the back - // or forward buttons. - if (e.prevVal && localStorage) { - localStorage.setItem('tab_' + pjax.getPath(), tabId); - } - - pjax.checkVisibility(tab); -}; - -// -- Init --------------------------------------------------------------------- - -pjax.on('navigate', pjax.onNavigate); - -pjax.initRoot(); -pjax.upgrade(); -pjax.initClassTabView(); -pjax.initLineNumbers(); -pjax.updateVisibility(); - -Y.APIList.rootPath = pjax.get('root'); - -Y.one('#api-options').delegate('click', pjax.onOptionClick, 'input'); - -Y.on('hashchange', function (e) { - pjax.updateTabState('hashchange'); -}, win); - -}); diff --git a/Docs/API/assets/js/yui-prettify.js b/Docs/API/assets/js/yui-prettify.js deleted file mode 100644 index 18de8649..00000000 --- a/Docs/API/assets/js/yui-prettify.js +++ /dev/null @@ -1,17 +0,0 @@ -YUI().use('node', function(Y) { - var code = Y.all('.prettyprint.linenums'); - if (code.size()) { - code.each(function(c) { - var lis = c.all('ol li'), - l = 1; - lis.each(function(n) { - n.prepend(''); - l++; - }); - }); - var h = location.hash; - location.hash = ''; - h = h.replace('LINE_', 'LINENUM_'); - location.hash = h; - } -}); diff --git a/Docs/API/assets/vendor/prettify/CHANGES.html b/Docs/API/assets/vendor/prettify/CHANGES.html deleted file mode 100644 index b50b8414..00000000 --- a/Docs/API/assets/vendor/prettify/CHANGES.html +++ /dev/null @@ -1,130 +0,0 @@ - - - - Change Log - - - README - -

    Known Issues

    - - -

    Change Log

    -

    29 March 2007

    - -

    4 Jul 2008

    - -

    5 Jul 2008

    -
    -

    14 Jul 2008

    - -

    6 Jan 2009

    - -

    21 May 2009

    - -

    14 August 2009

    - -

    3 October 2009

    - -

    19 July 2010

    - - - diff --git a/Docs/API/assets/vendor/prettify/README.html b/Docs/API/assets/vendor/prettify/README.html deleted file mode 100644 index c6fe1a32..00000000 --- a/Docs/API/assets/vendor/prettify/README.html +++ /dev/null @@ -1,203 +0,0 @@ - - - - - Javascript code prettifier - - - - - - - - - - Languages : CH -

    Javascript code prettifier

    - -

    Setup

    -
      -
    1. Download a distribution -
    2. Include the script and stylesheets in your document - (you will need to make sure the css and js file are on your server, and - adjust the paths in the script and link tag) -
      -<link href="prettify.css" type="text/css" rel="stylesheet" />
      -<script type="text/javascript" src="prettify.js"></script>
      -
    3. Add onload="prettyPrint()" to your - document's body tag. -
    4. Modify the stylesheet to get the coloring you prefer
    5. -
    - -

    Usage

    -

    Put code snippets in - <pre class="prettyprint">...</pre> - or <code class="prettyprint">...</code> - and it will automatically be pretty printed. - - - - -
    The original - Prettier -
    class Voila {
    -public:
    -  // Voila
    -  static const string VOILA = "Voila";
    -
    -  // will not interfere with embedded tags.
    -}
    - -
    class Voila {
    -public:
    -  // Voila
    -  static const string VOILA = "Voila";
    -
    -  // will not interfere with embedded tags.
    -}
    -
    - -

    FAQ

    -

    Which languages does it work for?

    -

    The comments in prettify.js are authoritative but the lexer - should work on a number of languages including C and friends, - Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles. - It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl - and Ruby, but, because of commenting conventions, doesn't work on - Smalltalk, or CAML-like languages.

    - -

    LISPy languages are supported via an extension: - lang-lisp.js.

    -

    And similarly for - CSS, - Haskell, - Lua, - OCAML, SML, F#, - Visual Basic, - SQL, - Protocol Buffers, and - WikiText.. - -

    If you'd like to add an extension for your favorite language, please - look at src/lang-lisp.js and file an - issue including your language extension, and a testcase.

    - -

    How do I specify which language my code is in?

    -

    You don't need to specify the language since prettyprint() - will guess. You can specify a language by specifying the language extension - along with the prettyprint class like so:

    -
    <pre class="prettyprint lang-html">
    -  The lang-* class specifies the language file extensions.
    -  File extensions supported by default include
    -    "bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html",
    -    "java", "js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh",
    -    "xhtml", "xml", "xsl".
    -</pre>
    - -

    It doesn't work on <obfuscated code sample>?

    -

    Yes. Prettifying obfuscated code is like putting lipstick on a pig - — i.e. outside the scope of this tool.

    - -

    Which browsers does it work with?

    -

    It's been tested with IE 6, Firefox 1.5 & 2, and Safari 2.0.4. - Look at the test page to see if it - works in your browser.

    - -

    What's changed?

    -

    See the change log

    - -

    Why doesn't Prettyprinting of strings work on WordPress?

    -

    Apparently wordpress does "smart quoting" which changes close quotes. - This causes end quotes to not match up with open quotes. -

    This breaks prettifying as well as copying and pasting of code samples. - See - WordPress's help center for info on how to stop smart quoting of code - snippets.

    - -

    How do I put line numbers in my code?

    -

    You can use the linenums class to turn on line - numbering. If your code doesn't start at line number 1, you can - add a colon and a line number to the end of that class as in - linenums:52. - -

    For example -

    <pre class="prettyprint linenums:4"
    ->// This is line 4.
    -foo();
    -bar();
    -baz();
    -boo();
    -far();
    -faz();
    -<pre>
    - produces -
    // This is line 4.
    -foo();
    -bar();
    -baz();
    -boo();
    -far();
    -faz();
    -
    - -

    How do I prevent a portion of markup from being marked as code?

    -

    You can use the nocode class to identify a span of markup - that is not code. -

    <pre class=prettyprint>
    -int x = foo();  /* This is a comment  <span class="nocode">This is not code</span>
    -  Continuation of comment */
    -int y = bar();
    -</pre>
    -produces -
    -int x = foo();  /* This is a comment  This is not code
    -  Continuation of comment */
    -int y = bar();
    -
    - -

    For a more complete example see the issue22 - testcase.

    - -

    I get an error message "a is not a function" or "opt_whenDone is not a function"

    -

    If you are calling prettyPrint via an event handler, wrap it in a function. - Instead of doing -

    - addEventListener('load', prettyPrint, false); -
    - wrap it in a closure like -
    - addEventListener('load', function (event) { prettyPrint() }, false); -
    - so that the browser does not pass an event object to prettyPrint which - will confuse it. - -


    - - - - diff --git a/Docs/API/assets/vendor/prettify/prettify-min.js b/Docs/API/assets/vendor/prettify/prettify-min.js deleted file mode 100644 index 4845d05d..00000000 --- a/Docs/API/assets/vendor/prettify/prettify-min.js +++ /dev/null @@ -1 +0,0 @@ -window.PR_SHOULD_USE_CONTINUATION=true;var prettyPrintOne;var prettyPrint;(function(){var O=window;var j=["break,continue,do,else,for,if,return,while"];var v=[j,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var q=[v,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var m=[q,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var y=[q,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var T=[y,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"];var s="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes";var x=[q,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var t="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var J=[j,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var g=[j,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var I=[j,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var B=[m,T,x,t+J,g,I];var f=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/;var D="str";var A="kwd";var k="com";var Q="typ";var H="lit";var M="pun";var G="pln";var n="tag";var F="dec";var K="src";var R="atn";var o="atv";var P="nocode";var N="(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function l(ab){var af=0;var U=false;var ae=false;for(var X=0,W=ab.length;X122)){if(!(am<65||ai>90)){ah.push([Math.max(65,ai)|32,Math.min(am,90)|32])}if(!(am<97||ai>122)){ah.push([Math.max(97,ai)&~32,Math.min(am,122)&~32])}}}}ah.sort(function(aw,av){return(aw[0]-av[0])||(av[1]-aw[1])});var ak=[];var aq=[];for(var at=0;atau[0]){if(au[1]+1>au[0]){ao.push("-")}ao.push(V(au[1]))}}ao.push("]");return ao.join("")}function Y(an){var al=an.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var aj=al.length;var ap=[];for(var am=0,ao=0;am=2&&ak==="["){al[am]=Z(ai)}else{if(ak!=="\\"){al[am]=ai.replace(/[a-zA-Z]/g,function(aq){var ar=aq.charCodeAt(0);return"["+String.fromCharCode(ar&~32,ar|32)+"]"})}}}}return al.join("")}var ac=[];for(var X=0,W=ab.length;X=0;){U[ae.charAt(ag)]=aa}}var ah=aa[1];var ac=""+ah;if(!ai.hasOwnProperty(ac)){aj.push(ah);ai[ac]=null}}aj.push(/[\0-\uffff]/);X=l(aj)})();var Z=V.length;var Y=function(aj){var ab=aj.sourceCode,aa=aj.basePos;var af=[aa,G];var ah=0;var ap=ab.match(X)||[];var al={};for(var ag=0,at=ap.length;ag=5&&"lang-"===ar.substring(0,5);if(ao&&!(ak&&typeof ak[1]==="string")){ao=false;ar=K}if(!ao){al[ai]=ar}}var ad=ah;ah+=ai.length;if(!ao){af.push(aa+ad,ar)}else{var an=ak[1];var am=ai.indexOf(an);var ae=am+an.length;if(ak[2]){ae=ai.length-ak[2].length;am=ae-an.length}var au=ar.substring(5);C(aa+ad,ai.substring(0,am),Y,af);C(aa+ad+am,an,r(au,an),af);C(aa+ad+ae,ai.substring(ae),Y,af)}}aj.decorations=af};return Y}function i(V){var Y=[],U=[];if(V.tripleQuotedStrings){Y.push([D,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(V.multiLineStrings){Y.push([D,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{Y.push([D,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(V.verbatimStrings){U.push([D,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var ab=V.hashComments;if(ab){if(V.cStyleComments){if(ab>1){Y.push([k,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{Y.push([k,/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}U.push([D,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,null])}else{Y.push([k,/^#[^\r\n]*/,null,"#"])}}if(V.cStyleComments){U.push([k,/^\/\/[^\r\n]*/,null]);U.push([k,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(V.regexLiterals){var aa=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");U.push(["lang-regex",new RegExp("^"+N+"("+aa+")")])}var X=V.types;if(X){U.push([Q,X])}var W=(""+V.keywords).replace(/^ | $/g,"");if(W.length){U.push([A,new RegExp("^(?:"+W.replace(/[\s,]+/g,"|")+")\\b"),null])}Y.push([G,/^\s+/,null," \r\n\t\xA0"]);var Z=/^.[^\s\w\.$@\'\"\`\/\\]*/;U.push([H,/^@[a-z_$][a-z_$@0-9]*/i,null],[Q,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[G,/^[a-z_$][a-z_$@0-9]*/i,null],[H,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[G,/^\\[\s\S]?/,null],[M,Z,null]);return h(Y,U)}var L=i({keywords:B,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function S(W,ah,aa){var V=/(?:^|\s)nocode(?:\s|$)/;var ac=/\r\n?|\n/;var ad=W.ownerDocument;var ag=ad.createElement("li");while(W.firstChild){ag.appendChild(W.firstChild)}var X=[ag];function af(am){switch(am.nodeType){case 1:if(V.test(am.className)){break}if("br"===am.nodeName){ae(am);if(am.parentNode){am.parentNode.removeChild(am)}}else{for(var ao=am.firstChild;ao;ao=ao.nextSibling){af(ao)}}break;case 3:case 4:if(aa){var an=am.nodeValue;var ak=an.match(ac);if(ak){var aj=an.substring(0,ak.index);am.nodeValue=aj;var ai=an.substring(ak.index+ak[0].length);if(ai){var al=am.parentNode;al.insertBefore(ad.createTextNode(ai),am.nextSibling)}ae(am);if(!aj){am.parentNode.removeChild(am)}}}break}}function ae(al){while(!al.nextSibling){al=al.parentNode;if(!al){return}}function aj(am,at){var ar=at?am.cloneNode(false):am;var ap=am.parentNode;if(ap){var aq=aj(ap,1);var ao=am.nextSibling;aq.appendChild(ar);for(var an=ao;an;an=ao){ao=an.nextSibling;aq.appendChild(an)}}return ar}var ai=aj(al.nextSibling,0);for(var ak;(ak=ai.parentNode)&&ak.nodeType===1;){ai=ak}X.push(ai)}for(var Z=0;Z=U){aj+=2}if(Y>=ar){ac+=2}}}finally{if(au){au.style.display=ak}}}var u={};function d(W,X){for(var U=X.length;--U>=0;){var V=X[U];if(!u.hasOwnProperty(V)){u[V]=W}else{if(O.console){console.warn("cannot override language handler %s",V)}}}}function r(V,U){if(!(V&&u.hasOwnProperty(V))){V=/^\s*]*(?:>|$)/],[k,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[M,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);d(h([[G,/^[\s]+/,null," \t\r\n"],[o,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[n,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[R,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[M,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);d(h([],[[o,/^[\s\S]+/]]),["uq.val"]);d(i({keywords:m,hashComments:true,cStyleComments:true,types:f}),["c","cc","cpp","cxx","cyc","m"]);d(i({keywords:"null,true,false"}),["json"]);d(i({keywords:T,hashComments:true,cStyleComments:true,verbatimStrings:true,types:f}),["cs"]);d(i({keywords:y,cStyleComments:true}),["java"]);d(i({keywords:I,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);d(i({keywords:J,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);d(i({keywords:t,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);d(i({keywords:g,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);d(i({keywords:x,cStyleComments:true,regexLiterals:true}),["js"]);d(i({keywords:s,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);d(h([],[[D,/^[\s\S]+/]]),["regex"]);function e(X){var W=X.langExtension;try{var U=b(X.sourceNode,X.pre);var V=U.sourceCode;X.sourceCode=V;X.spans=U.spans;X.basePos=0;r(W,V)(X);E(X)}catch(Y){if(O.console){console.log(Y&&Y.stack?Y.stack:Y)}}}function z(Y,X,W){var U=document.createElement("pre");U.innerHTML=Y;if(W){S(U,W,true)}var V={langExtension:X,numberLines:W,sourceNode:U,pre:1};e(V);return U.innerHTML}function c(aj){function ab(al){return document.getElementsByTagName(al)}var ah=[ab("pre"),ab("code"),ab("xmp")];var V=[];for(var ae=0;ae]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); \ No newline at end of file diff --git a/Docs/API/classes/TimeManager.html b/Docs/API/classes/TimeManager.html deleted file mode 100644 index 07505d5b..00000000 --- a/Docs/API/classes/TimeManager.html +++ /dev/null @@ -1,1744 +0,0 @@ - - - - - TimeManager - Phaser - - - - - - - - -
    -
    -
    - -

    - -
    -
    - API Docs for: 1.0.0 -
    -
    -
    - -
    - -
    -
    -
    - Show: - - - - - - - -
    - - -
    -
    -
    -

    TimeManager Class

    -
    - - - - - - - - - - - Module: Phaser - - - - -
    - - - -
    -

    This is the core internal game clock. It manages the elapsed time and calculation of delta values, -used for game object motion and tweens.

    - -
    - - -
    -

    Constructor

    -
    -

    TimeManager

    - - -
    - (
      - -
    • - - game - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:13 - -

    - - - - - -
    - -
    - -
    - - -
    -

    Parameters:

    - -
      - -
    • - - game - Phaser.Game - - - - -
      -

      A reference to the currently running game.

      - -
      - - -
    • - -
    -
    - - - - - -
    - -
    - - -
    - - -
    -
    -

    Item Index

    - - -
    -

    Methods

    - - -
    - - - -
    -

    Properties

    - - -
    - - - - - -
    - - -
    -

    Methods

    - - -
    -

    elapsedSecondsSince

    - - -
    - (
      - -
    • - - since - -
    • - -
    ) -
    - - - - - Number - - - - - - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:239 - -

    - - - - - -
    - -
    -

    How long has passed since the given time (in seconds).

    - -
    - - -
    -

    Parameters:

    - -
      - -
    • - - since - Number - - - - -
      -

      The time you want to measure (in seconds).

      - -
      - - -
    • - -
    -
    - - - -
    -

    Returns:

    - -
    - - - Number: - -

    Duration between given time and now (in seconds).

    - - -
    -
    - - - -
    - - -
    -

    elapsedSince

    - - -
    - (
      - -
    • - - since - -
    • - -
    ) -
    - - - - - Number - - - - - - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:227 - -

    - - - - - -
    - -
    -

    How long has passed since the given time.

    - -
    - - -
    -

    Parameters:

    - -
      - -
    • - - since - Number - - - - -
      -

      The time you want to measure against.

      - -
      - - -
    • - -
    -
    - - - -
    -

    Returns:

    - -
    - - - Number: - -

    The difference between the given time and now.

    - - -
    -
    - - - -
    - - -
    -

    gamePaused

    - - - () - - - - - - - - private - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:192 - -

    - - - - - -
    - -
    -

    Called when the game enters a paused state.

    - -
    - - - - - - -
    - - -
    -

    gameResumed

    - - - () - - - - - - - - private - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:201 - -

    - - - - - -
    - -
    -

    Called when the game resumes from a paused state.

    - -
    - - - - - - -
    - - -
    -

    reset

    - - - () - - - - - - - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:251 - -

    - - - - - -
    - -
    -

    Resets the private _started value to now.

    - -
    - - - - - - -
    - - -
    -

    totalElapsedSeconds

    - - - () - - - - - Number - - - - - - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:89 - -

    - - - - - -
    - -
    -

    The number of seconds that have elapsed since the game was started.

    - -
    - - - - -
    -

    Returns:

    - -
    - - - Number: - - -
    -
    - - - -
    - - -
    -

    update

    - - -
    - (
      - -
    • - - raf - -
    • - -
    ) -
    - - - - - - - - - - - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:156 - -

    - - - - - -
    - -
    -

    Update clock and calculate the fps. -This is called automatically by Game._raf

    - -
    - - -
    -

    Parameters:

    - -
      - -
    • - - raf - Number - - - - -
      -

      The current timestamp, either performance.now or Date.now

      - -
      - - -
    • - -
    -
    - - - - - -
    - - -
    - - - -
    -

    Properties

    - - -
    -

    _pauseStarted

    - Number - - - - - private - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:219 - -

    - - - - -
    - -
    -

    The time the game started being paused.

    - -
    - - - - - - -
    - - -
    -

    _started

    - Number - - - - - private - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:41 - -

    - - - - -
    - -
    -

    The time at which the Game instance started.

    - -
    - - - - - - -
    - - -
    -

    _timeLastSecond

    - Number - - - - - private - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:148 - -

    - - - - -
    - -
    -

    The time (in ms) that the last second counter ticked over.

    - -
    - - - - - - -
    - - -
    -

    delta

    - Number - - - - - public - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:81 - -

    - - - - -
    - -
    -

    Elapsed time since the last frame.

    - -
    - - - - - - -
    - - -
    -

    elapsed

    - Number - - - - - public - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:49 - -

    - - - - -
    - -
    -

    Number of milliseconds elapsed since the last frame update.

    - -
    - - - - - - -
    - - -
    -

    fps

    - Number - - - - - public - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:100 - -

    - - - - -
    - -
    -

    Frames per second.

    - -
    - - - - - - -
    - - -
    -

    fpsMax

    - Number - - - - - public - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:116 - -

    - - - - -
    - -
    -

    The highest rate the fps has reached (usually no higher than 60fps).

    - -
    - - - - - - -
    - - -
    -

    fpsMin

    - Number - - - - - public - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:108 - -

    - - - - -
    - -
    -

    The lowest rate the fps has dropped to.

    - -
    - - - - - - -
    - - -
    -

    frames

    - Number - - - - - public - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:140 - -

    - - - - -
    - -
    -

    The number of frames record in the last second.

    - -
    - - - - - - -
    - - -
    -

    game

    - Phaser.Game - - - - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:34 - -

    - - - - -
    - -
    -

    A reference to the currently running Game.

    - -
    - - - - - - -
    - - -
    -

    msMax

    - Number - - - - - public - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:132 - -

    - - - - -
    - -
    -

    The maximum amount of time the game has taken between two frames.

    - -
    - - - - - - -
    - - -
    -

    msMin

    - Number - - - - - public - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:124 - -

    - - - - -
    - -
    -

    The minimum amount of time the game has taken between two frames.

    - -
    - - - - - - -
    - - -
    -

    now

    - Number - - - - - public - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:73 - -

    - - - - -
    - -
    -

    The time right now.

    - -
    - - - - - - -
    - - -
    -

    pausedTime

    - Number - - - - - public - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:65 - -

    - - - - -
    - -
    -

    Records how long the game has been paused for. Is reset each time the game pauses.

    - -
    - - - - - - -
    - - -
    -

    pauseDuration

    - Number - - - - - public - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:211 - -

    - - - - -
    - -
    -

    Records how long the game was paused for in miliseconds.

    - -
    - - - - - - -
    - - -
    -

    time

    - Number - - - - - public - - - - - - -
    - - - -

    - - Defined in - - - - - ..\Phaser\time\TimeManager.ts:57 - -

    - - - - -
    - -
    -

    Game time counter.

    - -
    - - - - - - -
    - - -
    - - - - - -
    -
    - -
    -
    -
    -
    -
    -
    - - - - - - - - - - diff --git a/Docs/API/data.json b/Docs/API/data.json deleted file mode 100644 index 3e65bc60..00000000 --- a/Docs/API/data.json +++ /dev/null @@ -1,364 +0,0 @@ -{ - "project": { - "name": "Phaser", - "description": "HTML5 Game Framework", - "version": "1.0.0", - "url": "http://www.phaser.io/" - }, - "files": { - "..\\Phaser\\time\\TimeManager.ts": { - "name": "..\\Phaser\\time\\TimeManager.ts", - "modules": { - "Phaser": 1 - }, - "classes": { - "TimeManager": 1 - }, - "fors": {}, - "namespaces": {} - } - }, - "modules": { - "Phaser": { - "name": "Phaser", - "submodules": {}, - "classes": { - "TimeManager": 1 - }, - "fors": {}, - "namespaces": {}, - "tag": "module", - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 13, - "author": "Richard Davey ", - "copyright": "2013 Photon Storm Ltd.", - "license": "https://github.com/photonstorm/phaser/blob/master/license.txt MIT License" - } - }, - "classes": { - "TimeManager": { - "name": "TimeManager", - "shortname": "TimeManager", - "classitems": [], - "plugins": [], - "extensions": [], - "plugin_for": [], - "extension_for": [], - "module": "Phaser", - "namespace": "", - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 13, - "description": "This is the core internal game clock. It manages the elapsed time and calculation of delta values,\nused for game object motion and tweens.", - "is_constructor": 1, - "params": [ - { - "name": "game", - "description": "A reference to the currently running game.", - "type": "Phaser.Game" - } - ] - } - }, - "classitems": [ - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 34, - "description": "A reference to the currently running Game.", - "itemtype": "property", - "name": "game", - "type": "{Phaser.Game}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 41, - "description": "The time at which the Game instance started.", - "itemtype": "property", - "name": "_started", - "access": "private", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 49, - "description": "Number of milliseconds elapsed since the last frame update.", - "itemtype": "property", - "name": "elapsed", - "access": "public", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 57, - "description": "Game time counter.", - "itemtype": "property", - "name": "time", - "access": "public", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 65, - "description": "Records how long the game has been paused for. Is reset each time the game pauses.", - "itemtype": "property", - "name": "pausedTime", - "access": "public", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 73, - "description": "The time right now.", - "itemtype": "property", - "name": "now", - "access": "public", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 81, - "description": "Elapsed time since the last frame.", - "itemtype": "property", - "name": "delta", - "access": "public", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 89, - "description": "The number of seconds that have elapsed since the game was started.", - "itemtype": "method", - "name": "totalElapsedSeconds", - "return": { - "description": "", - "type": "Number" - }, - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 100, - "description": "Frames per second.", - "itemtype": "property", - "name": "fps", - "access": "public", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 108, - "description": "The lowest rate the fps has dropped to.", - "itemtype": "property", - "name": "fpsMin", - "access": "public", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 116, - "description": "The highest rate the fps has reached (usually no higher than 60fps).", - "itemtype": "property", - "name": "fpsMax", - "access": "public", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 124, - "description": "The minimum amount of time the game has taken between two frames.", - "itemtype": "property", - "name": "msMin", - "access": "public", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 132, - "description": "The maximum amount of time the game has taken between two frames.", - "itemtype": "property", - "name": "msMax", - "access": "public", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 140, - "description": "The number of frames record in the last second.", - "itemtype": "property", - "name": "frames", - "access": "public", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 148, - "description": "The time (in ms) that the last second counter ticked over.", - "itemtype": "property", - "name": "_timeLastSecond", - "access": "private", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 156, - "description": "Update clock and calculate the fps.\nThis is called automatically by Game._raf", - "itemtype": "method", - "name": "update", - "params": [ - { - "name": "raf", - "description": "The current timestamp, either performance.now or Date.now", - "type": "Number" - } - ], - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 192, - "description": "Called when the game enters a paused state.", - "itemtype": "method", - "name": "gamePaused", - "access": "private", - "tagname": "", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 201, - "description": "Called when the game resumes from a paused state.", - "itemtype": "method", - "name": "gameResumed", - "access": "private", - "tagname": "", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 211, - "description": "Records how long the game was paused for in miliseconds.", - "itemtype": "property", - "name": "pauseDuration", - "access": "public", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 219, - "description": "The time the game started being paused.", - "itemtype": "property", - "name": "_pauseStarted", - "access": "private", - "tagname": "", - "type": "{Number}", - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 227, - "description": "How long has passed since the given time.", - "itemtype": "method", - "name": "elapsedSince", - "params": [ - { - "name": "since", - "description": "The time you want to measure against.", - "type": "Number" - } - ], - "return": { - "description": "The difference between the given time and now.", - "type": "Number" - }, - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 239, - "description": "How long has passed since the given time (in seconds).", - "itemtype": "method", - "name": "elapsedSecondsSince", - "params": [ - { - "name": "since", - "description": "The time you want to measure (in seconds).", - "type": "Number" - } - ], - "return": { - "description": "Duration between given time and now (in seconds).", - "type": "Number" - }, - "class": "TimeManager", - "module": "Phaser" - }, - { - "file": "..\\Phaser\\time\\TimeManager.ts", - "line": 251, - "description": "Resets the private _started value to now.", - "itemtype": "method", - "name": "reset", - "class": "TimeManager", - "module": "Phaser" - } - ], - "warnings": [ - { - "message": "unknown tag: copyright", - "line": " ..\\Phaser\\time\\TimeManager.ts:3" - }, - { - "message": "unknown tag: license", - "line": " ..\\Phaser\\time\\TimeManager.ts:3" - } - ] -} \ No newline at end of file diff --git a/Docs/API/files/.._Phaser_time_TimeManager.ts.html b/Docs/API/files/.._Phaser_time_TimeManager.ts.html deleted file mode 100644 index f38ce3ec..00000000 --- a/Docs/API/files/.._Phaser_time_TimeManager.ts.html +++ /dev/null @@ -1,372 +0,0 @@ - - - - - ..\Phaser\time\TimeManager.ts - Phaser - - - - - - - - -
    -
    -
    - -

    - -
    -
    - API Docs for: 1.0.0 -
    -
    -
    - -
    - -
    -
    -
    - Show: - - - - - - - -
    - - -
    -
    -
    -

    File: ..\Phaser\time\TimeManager.ts

    - -
    -
    -/// <reference path="../_definitions.ts" />
    -
    -/**
    -* @author       Richard Davey <rich@photonstorm.com>
    -* @copyright    2013 Photon Storm Ltd.
    -* @license      https://github.com/photonstorm/phaser/blob/master/license.txt  MIT License
    -* @module       Phaser
    -*/
    -module Phaser {
    -
    -    export class TimeManager {
    -
    -        /**
    -        * This is the core internal game clock. It manages the elapsed time and calculation of delta values,
    -        * used for game object motion and tweens.
    -        *
    -        * @class TimeManager
    -        * @constructor
    -        * @param {Phaser.Game} game A reference to the currently running game.
    -        */
    -        constructor(game: Phaser.Game) {
    -
    -            this.game = game;
    -
    -            this._started = 0;
    -            this._timeLastSecond = this._started;
    -            this.time = this._started;
    -
    -            this.game.onPause.add(this.gamePaused, this);
    -            this.game.onResume.add(this.gameResumed, this);
    -
    -        }
    -
    -        /**
    -        * A reference to the currently running Game.
    -        * @property game
    -        * @type {Phaser.Game}
    -        */
    -        public game: Phaser.Game;
    -
    -        /**
    -        * The time at which the Game instance started.
    -        * @property _started
    -        * @private
    -        * @type {Number}
    -        */
    -        private _started: number;
    -
    -        /**
    -        * Number of milliseconds elapsed since the last frame update.
    -        * @property elapsed
    -        * @public
    -        * @type {Number}
    -        */
    -        public elapsed: number = 0;
    -
    -        /**
    -        * Game time counter.
    -        * @property time
    -        * @public
    -        * @type {Number}
    -        */
    -        public time: number = 0;
    -
    -        /**
    -        * Records how long the game has been paused for. Is reset each time the game pauses.
    -        * @property pausedTime
    -        * @public
    -        * @type {Number}
    -        */
    -        public pausedTime: number = 0;
    -
    -        /**
    -        * The time right now.
    -        * @property now
    -        * @public
    -        * @type {Number}
    -        */
    -        public now: number = 0;
    -
    -        /**
    -        * Elapsed time since the last frame.
    -        * @property delta
    -        * @public
    -        * @type {Number}
    -        */
    -        public delta: number = 0;
    -
    -        /**
    -        * The number of seconds that have elapsed since the game was started.
    -        * @method totalElapsedSeconds
    -        * @return {Number}
    -        */
    -        public get totalElapsedSeconds(): number {
    -
    -            return (this.now - this._started) * 0.001;
    -
    -        }
    -
    -        /**
    -        * Frames per second.
    -        * @property fps
    -        * @public
    -        * @type {Number}
    -        */
    -        public fps: number = 0;
    -
    -        /**
    -        * The lowest rate the fps has dropped to.
    -        * @property fpsMin
    -        * @public
    -        * @type {Number}
    -        */
    -        public fpsMin: number = 1000;
    -
    -        /**
    -        * The highest rate the fps has reached (usually no higher than 60fps).
    -        * @property fpsMax
    -        * @public
    -        * @type {Number}
    -        */
    -        public fpsMax: number = 0;
    -
    -        /**
    -        * The minimum amount of time the game has taken between two frames.
    -        * @property msMin
    -        * @public
    -        * @type {Number}
    -        */
    -        public msMin: number = 1000;
    -
    -        /**
    -        * The maximum amount of time the game has taken between two frames.
    -        * @property msMax
    -        * @public
    -        * @type {Number}
    -        */
    -        public msMax: number = 0;
    -
    -        /**
    -        * The number of frames record in the last second.
    -        * @property frames
    -        * @public
    -        * @type {Number}
    -        */
    -        public frames: number = 0;
    -
    -        /**
    -        * The time (in ms) that the last second counter ticked over.
    -        * @property _timeLastSecond
    -        * @private
    -        * @type {Number}
    -        */
    -        private _timeLastSecond: number = 0;
    -
    -        /**
    -         * Update clock and calculate the fps.
    -         * This is called automatically by Game._raf
    -         * @method update
    -         * @param {Number} raf The current timestamp, either performance.now or Date.now
    -         */
    -        public update(raf: number) {
    -
    -            this.now = raf; // mark
    -            this.delta = this.now - this.time; // elapsedMS
    -
    -            this.msMin = Math.min(this.msMin, this.delta);
    -            this.msMax = Math.max(this.msMax, this.delta);
    -
    -            this.frames++;
    -
    -            if (this.now > this._timeLastSecond + 1000)
    -            {
    -                this.fps = Math.round((this.frames * 1000) / (this.now - this._timeLastSecond));
    -                this.fpsMin = Math.min(this.fpsMin, this.fps);
    -                this.fpsMax = Math.max(this.fpsMax, this.fps);
    -
    -                this._timeLastSecond = this.now;
    -                this.frames = 0;
    -            }
    -
    -            this.time = this.now; // _total
    -
    -            //  Paused?
    -            if (this.game.paused)
    -            {
    -                this.pausedTime = this.now - this._pauseStarted;
    -            }
    -
    -        }
    -
    -        /**
    -        * Called when the game enters a paused state.
    -        * @method gamePaused
    -        * @private
    -        */
    -        private gamePaused() {
    -            this._pauseStarted = this.now;
    -        }
    -
    -        /**
    -        * Called when the game resumes from a paused state.
    -        * @method gameResumed
    -        * @private
    -        */
    -        private gameResumed() {
    -            //  Level out the delta timer to avoid spikes
    -            this.pauseDuration = this.pausedTime;
    -        }
    -
    -        /**
    -        * Records how long the game was paused for in miliseconds.
    -        * @property pauseDuration
    -        * @public
    -        * @type {Number}
    -        */
    -        public pauseDuration: number = 0;
    -
    -        /**
    -        * The time the game started being paused.
    -        * @property _pauseStarted
    -        * @private
    -        * @type {Number}
    -        */
    -        private _pauseStarted: number = 0;
    -
    -        /**
    -        * How long has passed since the given time.
    -        * @method elapsedSince
    -        * @param {Number} since The time you want to measure against.
    -        * @return {Number} The difference between the given time and now.
    -        */
    -        public elapsedSince(since: number): number {
    -
    -            return this.now - since;
    -
    -        }
    -
    -        /**
    -        * How long has passed since the given time (in seconds).
    -        * @method elapsedSecondsSince
    -        * @param {Number} since The time you want to measure (in seconds).
    -        * @return {Number} Duration between given time and now (in seconds).
    -        */
    -        public elapsedSecondsSince(since: number): number {
    -
    -            return (this.now - since) * 0.001;
    -
    -        }
    -
    -        /**
    -        * Resets the private _started value to now.
    -        * @method reset
    -        */
    -        public reset() {
    -
    -            this._started = this.now;
    -
    -        }
    -
    -    }
    -
    -}
    -    
    -
    - -
    -
    -
    -
    -
    -
    - - - - - - - - - - diff --git a/Docs/API/index.html b/Docs/API/index.html deleted file mode 100644 index ca852ea6..00000000 --- a/Docs/API/index.html +++ /dev/null @@ -1,124 +0,0 @@ - - - - - Phaser - - - - - - - - -
    -
    -
    - -

    - -
    -
    - API Docs for: 1.0.0 -
    -
    -
    - -
    - -
    -
    -
    - Show: - - - - - - - -
    - - -
    -
    -
    -
    -
    -

    - Browse to a module or class using the sidebar to view its API documentation. -

    - -

    Keyboard Shortcuts

    - -
      -
    • Press s to focus the API search box.

    • - -
    • Use Up and Down to select classes, modules, and search results.

    • - -
    • With the API search box or sidebar focused, use -Left or -Right to switch sidebar tabs.

    • - -
    • With the API search box or sidebar focused, use Ctrl+Left and Ctrl+Right to switch sidebar tabs.

    • -
    -
    -
    - - - -
    -
    -
    -
    -
    -
    - - - - - - - - - - diff --git a/Docs/API/modules/Phaser.html b/Docs/API/modules/Phaser.html deleted file mode 100644 index d6337ff1..00000000 --- a/Docs/API/modules/Phaser.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Phaser - Phaser - - - - - - - - -
    -
    -
    - -

    - -
    -
    - API Docs for: 1.0.0 -
    -
    -
    - -
    - -
    -
    -
    - Show: - - - - - - - -
    - - -
    -
    -
    -

    Phaser Module

    -
    - - - - - - - - - -
    - - - -
    - -
    - - - -
    -
    - -

    This module provides the following classes:

    - - - -
    - -
    - -
    -
    - -
    -
    -
    -
    -
    -
    - - - - - - - - - - diff --git a/Docs/Documentation Checklist.xlsx b/Docs/Documentation Checklist.xlsx deleted file mode 100644 index 292dcd33..00000000 Binary files a/Docs/Documentation Checklist.xlsx and /dev/null differ diff --git a/Docs/Hello Phaser/index.html b/Docs/Hello Phaser/index.html deleted file mode 100644 index 2f1124bb..00000000 --- a/Docs/Hello Phaser/index.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - phaser - hello world - - - - - - - - \ No newline at end of file diff --git a/Docs/Hello Phaser/phaser-min.js b/Docs/Hello Phaser/phaser-min.js deleted file mode 100644 index 048fae73..00000000 --- a/Docs/Hello Phaser/phaser-min.js +++ /dev/null @@ -1 +0,0 @@ -var PIXI=PIXI||{};var Phaser=Phaser||{VERSION:"1.0.0",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,SPRITE:0,BUTTON:1,BULLET:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11};PIXI.InteractionManager=function(b){};Phaser.Utils={pad:function(g,b,f,c){if(typeof(b)=="undefined"){var b=0}if(typeof(f)=="undefined"){var f=" "}if(typeof(c)=="undefined"){var c=3}if(b+1>=g.length){switch(c){case 1:g=Array(b+1-g.length).join(f)+g;break;case 3:var d=Math.ceil((padlen=b-g.length)/2);var e=padlen-d;g=Array(e+1).join(f)+g+Array(d+1).join(f);break;default:g=g+Array(b+1-g.length).join(f);break}}return g},isPlainObject:function(c){if(typeof(c)!=="object"||c.nodeType||c===c.window){return false}try{if(c.constructor&&!hasOwn.call(c.constructor.prototype,"isPrototypeOf")){return false}}catch(b){return false}return true},extend:function(){var l,d,b,c,h,j,g=arguments[0]||{},f=1,e=arguments.length,k=false;if(typeof g==="boolean"){k=g;g=arguments[1]||{};f=2}if(e===f){g=this;--f}for(;f>16&255)/255,(b>>8&255)/255,(b&255)/255]}if(typeof Function.prototype.bind!="function"){Function.prototype.bind=(function(){var b=Array.prototype.slice;return function(c){var f=this,g=b.call(arguments,1);if(typeof f!="function"){throw new TypeError()}function d(){var h=g.concat(b.call(arguments));f.apply(this instanceof d?this:c,h)}d.prototype=(function e(h){h&&(e.prototype=h);if(!(this instanceof e)){return new e}})(f.prototype);return d}})()}function determineMatrixArrayType(){PIXI.Matrix=(typeof Float32Array!=="undefined")?Float32Array:Array;return PIXI.Matrix}determineMatrixArrayType();PIXI.mat3={};PIXI.mat3.create=function(){var b=new PIXI.Matrix(9);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=1;b[5]=0;b[6]=0;b[7]=0;b[8]=1;return b};PIXI.mat3.identity=function(b){b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=1;b[5]=0;b[6]=0;b[7]=0;b[8]=1;return b};PIXI.mat4={};PIXI.mat4.create=function(){var b=new PIXI.Matrix(16);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};PIXI.mat3.multiply=function(q,h,i){if(!i){i=q}var v=q[0],u=q[1],t=q[2],g=q[3],f=q[4],e=q[5],o=q[6],n=q[7],m=q[8],l=h[0],k=h[1],j=h[2],s=h[3],r=h[4],p=h[5],d=h[6],c=h[7],b=h[8];i[0]=l*v+k*g+j*o;i[1]=l*u+k*f+j*n;i[2]=l*t+k*e+j*m;i[3]=s*v+r*g+p*o;i[4]=s*u+r*f+p*n;i[5]=s*t+r*e+p*m;i[6]=d*v+c*g+b*o;i[7]=d*u+c*f+b*n;i[8]=d*t+c*e+b*m;return i};PIXI.mat3.clone=function(c){var b=new PIXI.Matrix(9);b[0]=c[0];b[1]=c[1];b[2]=c[2];b[3]=c[3];b[4]=c[4];b[5]=c[5];b[6]=c[6];b[7]=c[7];b[8]=c[8];return b};PIXI.mat3.transpose=function(d,c){if(!c||d===c){var f=d[1],e=d[2],b=d[5];d[1]=d[3];d[2]=d[6];d[3]=f;d[5]=d[7];d[6]=e;d[7]=b;return d}c[0]=d[0];c[1]=d[3];c[2]=d[6];c[3]=d[1];c[4]=d[4];c[5]=d[7];c[6]=d[2];c[7]=d[5];c[8]=d[8];return c};PIXI.mat3.toMat4=function(c,b){if(!b){b=PIXI.mat4.create()}b[15]=1;b[14]=0;b[13]=0;b[12]=0;b[11]=0;b[10]=c[8];b[9]=c[7];b[8]=c[6];b[7]=0;b[6]=c[5];b[5]=c[4];b[4]=c[3];b[3]=0;b[2]=c[2];b[1]=c[1];b[0]=c[0];return b};PIXI.mat4.create=function(){var b=new PIXI.Matrix(16);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};PIXI.mat4.transpose=function(e,d){if(!d||e===d){var i=e[1],g=e[2],f=e[3],b=e[6],h=e[7],c=e[11];e[1]=e[4];e[2]=e[8];e[3]=e[12];e[4]=i;e[6]=e[9];e[7]=e[13];e[8]=g;e[9]=b;e[11]=e[14];e[12]=f;e[13]=h;e[14]=c;return e}d[0]=e[0];d[1]=e[4];d[2]=e[8];d[3]=e[12];d[4]=e[1];d[5]=e[5];d[6]=e[9];d[7]=e[13];d[8]=e[2];d[9]=e[6];d[10]=e[10];d[11]=e[14];d[12]=e[3];d[13]=e[7];d[14]=e[11];d[15]=e[15];return d};PIXI.mat4.multiply=function(p,i,k){if(!k){k=p}var v=p[0],u=p[1],s=p[2],q=p[3];var h=p[4],f=p[5],d=p[6],b=p[7];var o=p[8],n=p[9],m=p[10],l=p[11];var z=p[12],w=p[13],t=p[14],r=p[15];var j=i[0],g=i[1],e=i[2],c=i[3];k[0]=j*v+g*h+e*o+c*z;k[1]=j*u+g*f+e*n+c*w;k[2]=j*s+g*d+e*m+c*t;k[3]=j*q+g*b+e*l+c*r;j=i[4];g=i[5];e=i[6];c=i[7];k[4]=j*v+g*h+e*o+c*z;k[5]=j*u+g*f+e*n+c*w;k[6]=j*s+g*d+e*m+c*t;k[7]=j*q+g*b+e*l+c*r;j=i[8];g=i[9];e=i[10];c=i[11];k[8]=j*v+g*h+e*o+c*z;k[9]=j*u+g*f+e*n+c*w;k[10]=j*s+g*d+e*m+c*t;k[11]=j*q+g*b+e*l+c*r;j=i[12];g=i[13];e=i[14];c=i[15];k[12]=j*v+g*h+e*o+c*z;k[13]=j*u+g*f+e*n+c*w;k[14]=j*s+g*d+e*m+c*t;k[15]=j*q+g*b+e*l+c*r;return k};PIXI.Point=function(b,c){this.x=b||0;this.y=c||0};PIXI.Point.prototype.clone=function(){return new PIXI.Point(this.x,this.y)};PIXI.Point.prototype.constructor=PIXI.Point;PIXI.Rectangle=function(c,e,d,b){this.x=c||0;this.y=e||0;this.width=d||0;this.height=b||0};PIXI.Rectangle.prototype.clone=function(){return new PIXI.Rectangle(this.x,this.y,this.width,this.height)};PIXI.Rectangle.prototype.contains=function(b,e){if(this.width<=0||this.height<=0){return false}var c=this.x;if(b>=c&&b<=c+this.width){var d=this.y;if(e>=d&&e<=d+this.height){return true}}return false};PIXI.Rectangle.prototype.constructor=PIXI.Rectangle;PIXI.DisplayObject=function(){this.last=this;this.first=this;this.position=new PIXI.Point();this.scale=new PIXI.Point(1,1);this.pivot=new PIXI.Point(0,0);this.rotation=0;this.alpha=1;this.visible=true;this.hitArea=null;this.buttonMode=false;this.renderable=false;this.parent=null;this.stage=null;this.worldAlpha=1;this._interactive=false;this.worldTransform=PIXI.mat3.create();this.localTransform=PIXI.mat3.create();this.color=[];this.dynamic=true;this._sr=0;this._cr=1};PIXI.DisplayObject.prototype.constructor=PIXI.DisplayObject;PIXI.DisplayObject.prototype.setInteractive=function(b){this.interactive=b};Object.defineProperty(PIXI.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(b){this._interactive=b;if(this.stage){this.stage.dirty=true}}});Object.defineProperty(PIXI.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(b){this._mask=b;if(b){this.addFilter(b)}else{this.removeFilter()}}});PIXI.DisplayObject.prototype.addFilter=function(j){if(this.filter){return}this.filter=true;var b=new PIXI.FilterBlock();var e=new PIXI.FilterBlock();b.mask=j;e.mask=j;b.first=b.last=this;e.first=e.last=this;b.open=true;var d=b;var f=b;var i;var h;h=this.first._iPrev;if(h){i=h._iNext;d._iPrev=h;h._iNext=d}else{i=this}if(i){i._iPrev=f;f._iNext=i}var d=e;var f=e;var i=null;var h=null;h=this.last;i=h._iNext;if(i){i._iPrev=f;f._iNext=i}d._iPrev=h;h._iNext=d;var c=this;var g=this.last;while(c){if(c.last==g){c.last=e}c=c.parent}this.first=b;if(this.__renderGroup){this.__renderGroup.addFilterBlocks(b,e)}j.renderable=false};PIXI.DisplayObject.prototype.removeFilter=function(){if(!this.filter){return}this.filter=false;var d=this.first;var g=d._iNext;var h=d._iPrev;if(g){g._iPrev=h}if(h){h._iNext=g}this.first=d._iNext;var e=this.last;var g=e._iNext;var h=e._iPrev;if(g){g._iPrev=h}h._iNext=g;var f=e._iPrev;var c=this;while(c.last==e){c.last=f;c=c.parent;if(!c){break}}var b=d.mask;b.renderable=true;if(this.__renderGroup){this.__renderGroup.removeFilterBlocks(d,e)}};PIXI.DisplayObject.prototype.updateTransform=function(){if(this.rotation!==this.rotationCache){this.rotationCache=this.rotation;this._sr=Math.sin(this.rotation);this._cr=Math.cos(this.rotation)}var r=this.localTransform;var f=this.parent.worldTransform;var b=this.worldTransform;r[0]=this._cr*this.scale.x;r[1]=-this._sr*this.scale.y;r[3]=this._sr*this.scale.x;r[4]=this._cr*this.scale.y;var n=this.pivot.x;var m=this.pivot.y;var i=r[0],h=r[1],g=this.position.x-r[0]*n-m*r[1],q=r[3],p=r[4],o=this.position.y-r[4]*m-n*r[3],l=f[0],k=f[1],j=f[2],e=f[3],d=f[4],c=f[5];r[2]=g;r[5]=o;b[0]=l*i+k*q;b[1]=l*h+k*p;b[2]=l*g+k*o+j;b[3]=e*i+d*q;b[4]=e*h+d*p;b[5]=e*g+d*o+c;this.worldAlpha=this.alpha*this.parent.worldAlpha;this.vcount=PIXI.visibleCount};PIXI.visibleCount=0;PIXI.DisplayObjectContainer=function(){PIXI.DisplayObject.call(this);this.children=[]};PIXI.DisplayObjectContainer.prototype=Object.create(PIXI.DisplayObject.prototype);PIXI.DisplayObjectContainer.prototype.constructor=PIXI.DisplayObjectContainer;PIXI.DisplayObjectContainer.prototype.addChild=function(i){if(i.parent!=undefined){i.parent.removeChild(i)}i.parent=this;this.children.push(i);if(this.stage){var f=i;do{if(f.interactive){this.stage.dirty=true}f.stage=this.stage;f=f._iNext}while(f)}var e=i.first;var d=i.last;var g;var h;if(this.filter){h=this.last._iPrev}else{h=this.last}g=h._iNext;var c=this;var b=h;while(c){if(c.last==b){c.last=i.last}c=c.parent}if(g){g._iPrev=d;d._iNext=g}e._iPrev=h;h._iNext=e;if(this.__renderGroup){if(i.__renderGroup){i.__renderGroup.removeDisplayObjectAndChildren(i)}this.__renderGroup.addDisplayObjectAndChildren(i)}};PIXI.DisplayObjectContainer.prototype.addChildAt=function(c,f){if(f>=0&&f<=this.children.length){if(c.parent!=undefined){c.parent.removeChild(c)}c.parent=this;if(this.stage){var e=c;do{if(e.interactive){this.stage.dirty=true}e.stage=this.stage;e=e._iNext}while(e)}var d=c.first;var g=c.last;var j;var i;if(f==this.children.length){i=this.last;var b=this;var h=this.last;while(b){if(b.last==h){b.last=c.last}b=b.parent}}else{if(f==0){i=this}else{i=this.children[f-1].last}}j=i._iNext;if(j){j._iPrev=g;g._iNext=j}d._iPrev=i;i._iNext=d;this.children.splice(f,0,c);if(this.__renderGroup){if(c.__renderGroup){c.__renderGroup.removeDisplayObjectAndChildren(c)}this.__renderGroup.addDisplayObjectAndChildren(c)}}else{throw new Error(c+" The index "+f+" supplied is out of bounds "+this.children.length)}};PIXI.DisplayObjectContainer.prototype.swapChildren=function(c,b){return};PIXI.DisplayObjectContainer.prototype.getChildAt=function(b){if(b>=0&&b1){h=1}var d=Math.sqrt(c.x*c.x+c.y*c.y);var f=this.texture.height/2;c.x/=d;c.y/=d;c.x*=f;c.y*=f;b[g]=m.x+c.x;b[g+1]=m.y+c.y;b[g+2]=m.x-c.x;b[g+3]=m.y-c.y;l=m}PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)};PIXI.Rope.prototype.setTexture=function(b){this.texture=b;this.updateFrame=true};PIXI.TilingSprite=function(d,c,b){PIXI.DisplayObjectContainer.call(this);this.texture=d;this.width=c;this.height=b;this.tileScale=new PIXI.Point(1,1);this.tilePosition=new PIXI.Point(0,0);this.renderable=true;this.blendMode=PIXI.blendModes.NORMAL};PIXI.TilingSprite.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);PIXI.TilingSprite.prototype.constructor=PIXI.TilingSprite;PIXI.TilingSprite.prototype.setTexture=function(b){this.texture=b;this.updateFrame=true};PIXI.TilingSprite.prototype.onTextureUpdate=function(b){this.updateFrame=true};PIXI.FilterBlock=function(b){this.graphics=b;this.visible=true;this.renderable=true};PIXI.MaskFilter=function(b){this.graphics};PIXI.Graphics=function(){PIXI.DisplayObjectContainer.call(this);this.renderable=true;this.fillAlpha=1;this.lineWidth=0;this.lineColor="black";this.graphicsData=[];this.currentPath={points:[]}};PIXI.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);PIXI.Graphics.prototype.constructor=PIXI.Graphics;PIXI.Graphics.prototype.lineStyle=function(b,c,d){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.lineWidth=b||0;this.lineColor=c||0;this.lineAlpha=(d==undefined)?1:d;this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:PIXI.Graphics.POLY};this.graphicsData.push(this.currentPath)};PIXI.Graphics.prototype.moveTo=function(b,c){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath=this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:PIXI.Graphics.POLY};this.currentPath.points.push(b,c);this.graphicsData.push(this.currentPath)};PIXI.Graphics.prototype.lineTo=function(b,c){this.currentPath.points.push(b,c);this.dirty=true};PIXI.Graphics.prototype.beginFill=function(b,c){this.filling=true;this.fillColor=b||0;this.fillAlpha=(c==undefined)?1:c};PIXI.Graphics.prototype.endFill=function(){this.filling=false;this.fillColor=null;this.fillAlpha=1};PIXI.Graphics.prototype.drawRect=function(c,e,d,b){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[c,e,d,b],type:PIXI.Graphics.RECT};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.drawCircle=function(c,d,b){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[c,d,b,b],type:PIXI.Graphics.CIRC};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.drawElipse=function(c,e,d,b){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[c,e,d,b],type:PIXI.Graphics.ELIP};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.clear=function(){this.lineWidth=0;this.filling=false;this.dirty=true;this.clearDirty=true;this.graphicsData=[]};PIXI.Graphics.POLY=0;PIXI.Graphics.RECT=1;PIXI.Graphics.CIRC=2;PIXI.Graphics.ELIP=3;PIXI.CanvasGraphics=function(){};PIXI.CanvasGraphics.renderGraphics=function(u,c){var p=u.worldAlpha;for(var s=0;s1){t=1;console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object")}for(var s=0;s<1;s++){var A=v.graphicsData[s];var r=A.points;if(A.type==PIXI.Graphics.POLY){c.beginPath();c.moveTo(r[0],r[1]);for(var q=1;q0){PIXI.Texture.frameUpdates=[]}};PIXI.CanvasRenderer.prototype.resize=function(c,b){this.width=c;this.height=b;this.view.width=c;this.view.height=b};PIXI.CanvasRenderer.prototype.renderDisplayObject=function(h){var e;var f=this.context;f.globalCompositeOperation="source-over";var d=h.last._iNext;h=h.first;do{e=h.worldTransform;if(!h.visible){h=h.last._iNext;continue}if(!h.renderable){h=h._iNext;continue}if(h instanceof PIXI.Sprite){var g=h.texture.frame;if(g){f.globalAlpha=h.worldAlpha;f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);f.drawImage(h.texture.baseTexture.source,g.x,g.y,g.width,g.height,(h.anchor.x)*-g.width,(h.anchor.y)*-g.height,g.width,g.height)}}else{if(h instanceof PIXI.Strip){f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);this.renderStrip(h)}else{if(h instanceof PIXI.TilingSprite){f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);this.renderTilingSprite(h)}else{if(h instanceof PIXI.CustomRenderable){h.renderCanvas(this)}else{if(h instanceof PIXI.Graphics){f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);PIXI.CanvasGraphics.renderGraphics(h,f)}else{if(h instanceof PIXI.FilterBlock){if(h.open){f.save();var c=h.mask.alpha;var b=h.mask.worldTransform;f.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]);h.mask.worldAlpha=0.5;f.worldAlpha=0;PIXI.CanvasGraphics.renderGraphicsMask(h.mask,f);f.clip();h.mask.worldAlpha=c}else{f.restore()}}}}}}}h=h._iNext}while(h!=d)};PIXI.CanvasRenderer.prototype.renderStripFlat=function(d){var e=this.context;var f=d.verticies;var j=d.uvs;var g=f.length/2;this.count++;e.beginPath();for(var k=1;k3){PIXI.WebGLGraphics.buildPoly(d,b._webGL)}}if(d.lineWidth>0){PIXI.WebGLGraphics.buildLine(d,b._webGL)}}else{if(d.type==PIXI.Graphics.RECT){PIXI.WebGLGraphics.buildRectangle(d,b._webGL)}else{if(d.type==PIXI.Graphics.CIRC||d.type==PIXI.Graphics.ELIP){PIXI.WebGLGraphics.buildCircle(d,b._webGL)}}}}b._webGL.lastIndex=b.graphicsData.length;var e=PIXI.gl;b._webGL.glPoints=new Float32Array(b._webGL.points);e.bindBuffer(e.ARRAY_BUFFER,b._webGL.buffer);e.bufferData(e.ARRAY_BUFFER,b._webGL.glPoints,e.STATIC_DRAW);b._webGL.glIndicies=new Uint16Array(b._webGL.indices);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,b._webGL.indexBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,b._webGL.glIndicies,e.STATIC_DRAW)};PIXI.WebGLGraphics.buildRectangle=function(s,i){var f=s.points;var n=f[0];var m=f[1];var d=f[2];var q=f[3];if(s.fill){var h=HEXtoRGB(s.fillColor);var e=s.fillAlpha;var c=h[0]*e;var j=h[1]*e;var l=h[2]*e;var o=i.points;var p=i.indices;var k=o.length/6;o.push(n,m);o.push(c,j,l,e);o.push(n+d,m);o.push(c,j,l,e);o.push(n,m+q);o.push(c,j,l,e);o.push(n+d,m+q);o.push(c,j,l,e);p.push(k,k,k+1,k+2,k+3,k+3)}if(s.lineWidth){s.points=[n,m,n+d,m,n+d,m+q,n,m+q,n,m];PIXI.WebGLGraphics.buildLine(s,i)}};PIXI.WebGLGraphics.buildCircle=function(k,w){var f=k.points;var j=f[0];var h=f[1];var o=f[2];var n=f[3];var l=40;var t=(Math.PI*2)/l;if(k.fill){var p=HEXtoRGB(k.fillColor);var d=k.fillAlpha;var m=p[0]*d;var s=p[1]*d;var u=p[2]*d;var v=w.points;var e=w.indices;var c=v.length/6;e.push(c);for(var q=0;q140*140){h=L-z;f=K-w;m=Math.sqrt(h*h+f*f);h/=m;f/=m;h*=c;f*=c;S.push(B-h,A-f);S.push(M,T,W,Q);S.push(B+h,A+f);S.push(M,T,W,Q);S.push(B-h,A-f);S.push(M,T,W,Q);q++}else{S.push(px,py);S.push(M,T,W,Q);S.push(B-(px-B),A-(py-A));S.push(M,T,W,Q)}}J=H[(u-2)*2];I=H[(u-2)*2+1];B=H[(u-1)*2];A=H[(u-1)*2+1];L=-(I-A);K=J-B;m=Math.sqrt(L*L+K*K);L/=m;K/=m;L*=c;K*=c;S.push(B-L,A-K);S.push(M,T,W,Q);S.push(B+L,A+K);S.push(M,T,W,Q);l.push(U);for(var R=0;R>16&255)/255,(b>>8&255)/255,(b&255)/255]}PIXI._defaultFrame=new PIXI.Rectangle(0,0,1,1);PIXI.gl;PIXI.WebGLRenderer=function(g,b,d,j,c){this.transparent=!!j;this.width=g||800;this.height=b||600;this.view=d||document.createElement("canvas");this.view.width=this.width;this.view.height=this.height;var f=this;this.view.addEventListener("webglcontextlost",function(e){f.handleContextLost(e)},false);this.view.addEventListener("webglcontextrestored",function(e){f.handleContextRestored(e)},false);this.batchs=[];try{PIXI.gl=this.gl=this.view.getContext("experimental-webgl",{alpha:this.transparent,antialias:!!c,premultipliedAlpha:false,stencil:true})}catch(h){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}PIXI.initPrimitiveShader();PIXI.initDefaultShader();PIXI.initDefaultStripShader();PIXI.activateDefaultShader();var i=this.gl;PIXI.WebGLRenderer.gl=i;this.batch=new PIXI.WebGLBatch(i);i.disable(i.DEPTH_TEST);i.disable(i.CULL_FACE);i.enable(i.BLEND);i.colorMask(true,true,true,this.transparent);PIXI.projection=new PIXI.Point(400,300);this.resize(this.width,this.height);this.contextLost=false;this.stageRenderGroup=new PIXI.WebGLRenderGroup(this.gl)};PIXI.WebGLRenderer.prototype.constructor=PIXI.WebGLRenderer;PIXI.WebGLRenderer.getBatch=function(){if(PIXI._batchs.length==0){return new PIXI.WebGLBatch(PIXI.WebGLRenderer.gl)}else{return PIXI._batchs.pop()}};PIXI.WebGLRenderer.returnBatch=function(b){b.clean();PIXI._batchs.push(b)};PIXI.WebGLRenderer.prototype.render=function(b){if(this.contextLost){return}if(this.__stage!==b){this.__stage=b;this.stageRenderGroup.setRenderable(b)}PIXI.WebGLRenderer.updateTextures();PIXI.visibleCount++;b.updateTransform();var d=this.gl;d.colorMask(true,true,true,this.transparent);d.viewport(0,0,this.width,this.height);d.bindFramebuffer(d.FRAMEBUFFER,null);d.clearColor(b.backgroundColorSplit[0],b.backgroundColorSplit[1],b.backgroundColorSplit[2],!this.transparent);d.clear(d.COLOR_BUFFER_BIT);this.stageRenderGroup.backgroundColor=b.backgroundColorSplit;this.stageRenderGroup.render(PIXI.projection);if(b.interactive){if(!b._interactiveEventsAdded){b._interactiveEventsAdded=true;b.interactionManager.setTarget(this)}}if(PIXI.Texture.frameUpdates.length>0){for(var c=0;c0){n=n.children[n.children.length-1];if(n.renderable){b=n}}if(b instanceof PIXI.Sprite){c=b.batch;var l=c.head;if(l==b){h=0}else{h=1;while(l.__next!=b){h++;l=l.__next}}}else{c=b}if(m==c){if(m instanceof PIXI.WebGLBatch){m.render(p,h+1)}else{this.renderSpecial(m,j)}return}d=this.batchs.indexOf(m);q=this.batchs.indexOf(c);if(m instanceof PIXI.WebGLBatch){m.render(p)}else{this.renderSpecial(m,j)}for(var e=d+1;e=2?parseInt(b[b.length-2],10):PIXI.BitmapText.fonts[this.fontName].size;this.dirty=true};PIXI.BitmapText.prototype.updateText=function(){var h=PIXI.BitmapText.fonts[this.fontName];var m=new PIXI.Point();var j=null;var l=[];var q=0;var e=[];var p=0;var f=this.fontSize/h.size;for(var g=0;g0){this.removeChild(this.getChildAt(0))}this.updateText();this.dirty=false}PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)};PIXI.BitmapText.fonts={};PIXI.Text=function(c,b){this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");PIXI.Sprite.call(this,PIXI.Texture.fromCanvas(this.canvas));this.setText(c);this.setStyle(b);this.updateText();this.dirty=false};PIXI.Text.prototype=Object.create(PIXI.Sprite.prototype);PIXI.Text.prototype.constructor=PIXI.Text;PIXI.Text.prototype.setStyle=function(b){b=b||{};b.font=b.font||"bold 20pt Arial";b.fill=b.fill||"black";b.align=b.align||"left";b.stroke=b.stroke||"black";b.strokeThickness=b.strokeThickness||0;b.wordWrap=b.wordWrap||false;b.wordWrapWidth=b.wordWrapWidth||100;this.style=b;this.dirty=true};PIXI.Sprite.prototype.setText=function(b){this.text=b.toString()||" ";this.dirty=true};PIXI.Text.prototype.updateText=function(){this.context.font=this.style.font;var g=this.text;if(this.style.wordWrap){g=this.wordWrap(this.text)}var f=g.split(/(?:\r\n|\r|\n)/);var d=[];var c=0;for(var h=0;hj){return k}else{return arguments.callee(i,l,k,h,j)}}else{return arguments.callee(i,l,m,k,j)}};var f=function(h,j,i){if(h.measureText(j).width<=i||j.length<1){return j}var k=e(h,j,0,j.length,i);return j.substring(0,k)+"\n"+arguments.callee(h,j.substring(k),i)};var b="";var c=g.split("\n");for(var d=0;dthis.baseTexture.width||b.y+b.height>this.baseTexture.height){throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this)}this.updateFrame=true;PIXI.Texture.frameUpdates.push(this)};PIXI.Texture.fromImage=function(c,b){var d=PIXI.TextureCache[c];if(!d){d=new PIXI.Texture(PIXI.BaseTexture.fromImage(c,b));PIXI.TextureCache[c]=d}return d};PIXI.Texture.fromFrame=function(c){var b=PIXI.TextureCache[c];if(!b){throw new Error("The frameId '"+c+"' does not exist in the texture cache "+this)}return b};PIXI.Texture.fromCanvas=function(b){var c=new PIXI.BaseTexture(b);return new PIXI.Texture(c)};PIXI.Texture.addTextureToCache=function(b,c){PIXI.TextureCache[c]=b};PIXI.Texture.removeTextureFromCache=function(c){var b=PIXI.TextureCache[c];PIXI.TextureCache[c]=null;return b};PIXI.Texture.frameUpdates=[];PIXI.RenderTexture=function(c,b){PIXI.EventTarget.call(this);this.width=c||100;this.height=b||100;this.indetityMatrix=PIXI.mat3.create();this.frame=new PIXI.Rectangle(0,0,this.width,this.height);if(PIXI.gl){this.initWebGL()}else{this.initCanvas()}};PIXI.RenderTexture.prototype=Object.create(PIXI.Texture.prototype);PIXI.RenderTexture.prototype.constructor=PIXI.RenderTexture;PIXI.RenderTexture.prototype.initWebGL=function(){var b=PIXI.gl;this.glFramebuffer=b.createFramebuffer();b.bindFramebuffer(b.FRAMEBUFFER,this.glFramebuffer);this.glFramebuffer.width=this.width;this.glFramebuffer.height=this.height;this.baseTexture=new PIXI.BaseTexture();this.baseTexture.width=this.width;this.baseTexture.height=this.height;this.baseTexture._glTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,this.baseTexture._glTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,this.width,this.height,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);this.baseTexture.isRender=true;b.bindFramebuffer(b.FRAMEBUFFER,this.glFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,this.baseTexture._glTexture,0);this.projection=new PIXI.Point(this.width/2,this.height/2);this.render=this.renderWebGL};PIXI.RenderTexture.prototype.resize=function(c,b){this.width=c;this.height=b;if(PIXI.gl){this.projection.x=this.width/2;this.projection.y=this.height/2;var d=PIXI.gl;d.bindTexture(d.TEXTURE_2D,this.baseTexture._glTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,this.width,this.height,0,d.RGBA,d.UNSIGNED_BYTE,null)}else{this.frame.width=this.width;this.frame.height=this.height;this.renderer.resize(this.width,this.height)}};PIXI.RenderTexture.prototype.initCanvas=function(){this.renderer=new PIXI.CanvasRenderer(this.width,this.height,null,0);this.baseTexture=new PIXI.BaseTexture(this.renderer.view);this.frame=new PIXI.Rectangle(0,0,this.width,this.height);this.render=this.renderCanvas};PIXI.RenderTexture.prototype.renderWebGL=function(k,g,h){var f=PIXI.gl;f.colorMask(true,true,true,true);f.viewport(0,0,this.width,this.height);f.bindFramebuffer(f.FRAMEBUFFER,this.glFramebuffer);if(h){f.clearColor(0,0,0,0);f.clear(f.COLOR_BUFFER_BIT)}var c=k.children;var b=k.worldTransform;k.worldTransform=PIXI.mat3.create();k.worldTransform[4]=-1;k.worldTransform[5]=this.projection.y*2;if(g){k.worldTransform[2]=g.x;k.worldTransform[5]-=g.y}PIXI.visibleCount++;k.vcount=PIXI.visibleCount;for(var e=0,d=c.length;e>1;if(k<3){return[]}var u=[];var g=[];for(var s=0;s3){var q=g[(s+0)%o];var m=g[(s+1)%o];var l=g[(s+2)%o];var f=h[2*q],d=h[2*q+1];var v=h[2*m],t=h[2*m+1];var c=h[2*l],b=h[2*l+1];var e=false;if(PIXI.PolyK._convex(f,d,v,t,c,b,z)){e=true;for(var r=0;r3*o){if(z){var u=[];g=[];for(var s=0;s=0)&&(m>=0)&&(n+m<1)};PIXI.PolyK._convex=function(e,d,g,f,b,h,c){return((d-f)*(b-g)+(g-e)*(h-f)>=0)==c};Phaser.Camera=function(d,g,c,f,e,b){this.game=d;this.world=d.world;this.id=0;this.view=new Phaser.Rectangle(c,f,e,b);this.screenView=new Phaser.Rectangle(c,f,e,b);this.deadzone=null;this.visible=true;this.atLimit={x:false,y:false};this.target=null;this._edge=0};Phaser.Camera.FOLLOW_LOCKON=0;Phaser.Camera.FOLLOW_PLATFORMER=1;Phaser.Camera.FOLLOW_TOPDOWN=2;Phaser.Camera.FOLLOW_TOPDOWN_TIGHT=3;Phaser.Camera.prototype={follow:function(f,d){if(typeof d==="undefined"){d=Phaser.Camera.FOLLOW_LOCKON}this.target=f;var e;switch(d){case Phaser.Camera.FOLLOW_PLATFORMER:var b=this.width/8;var c=this.height/3;this.deadzone=new Phaser.Rectangle((this.width-b)/2,(this.height-c)/2-c*0.25,b,c);break;case Phaser.Camera.FOLLOW_TOPDOWN:e=Math.max(this.width,this.height)/4;this.deadzone=new Phaser.Rectangle((this.width-e)/2,(this.height-e)/2,e,e);break;case Phaser.Camera.FOLLOW_TOPDOWN_TIGHT:e=Math.max(this.width,this.height)/8;this.deadzone=new Phaser.Rectangle((this.width-e)/2,(this.height-e)/2,e,e);break;case Phaser.Camera.FOLLOW_LOCKON:default:this.deadzone=null;break}},focusOnXY:function(b,c){this.view.x=Math.round(b-this.view.halfWidth);this.view.y=Math.round(c-this.view.halfHeight)},update:function(){if(this.target!==null){if(this.deadzone){this._edge=this.target.x-this.deadzone.x;if(this.view.x>this._edge){this.view.x=this._edge}this._edge=this.target.x+this.target.width-this.deadzone.x-this.deadzone.width;if(this.view.xthis._edge){this.view.y=this._edge}this._edge=this.target.y+this.target.height-this.deadzone.y-this.deadzone.height;if(this.view.ythis.world.bounds.right-this.width){this.atLimit.x=true;this.view.x=(this.world.bounds.right-this.width)+1}if(this.view.ythis.world.bounds.bottom-this.height){this.atLimit.y=true;this.view.y=(this.world.bounds.bottom-this.height)+1}this.view.floor()},setPosition:function(b,c){this.view.x=b;this.view.y=c;this.checkWorldBounds()},setSize:function(c,b){this.view.width=c;this.view.height=b}};Object.defineProperty(Phaser.Camera.prototype,"x",{get:function(){return this.view.x},set:function(b){this.view.x=b;this.checkWorldBounds()}});Object.defineProperty(Phaser.Camera.prototype,"y",{get:function(){return this.view.y},set:function(b){this.view.y=b;this.checkWorldBounds()}});Object.defineProperty(Phaser.Camera.prototype,"width",{get:function(){return this.view.width},set:function(b){this.view.width=b}});Object.defineProperty(Phaser.Camera.prototype,"height",{get:function(){return this.view.height},set:function(b){this.view.height=b}});Phaser.State=function(){this.game=null;this.add=null;this.camera=null;this.cache=null;this.input=null;this.load=null;this.sound=null;this.stage=null;this.time=null;this.tweens=null;this.world=null;this.particles=null;this.physics=null};Phaser.State.prototype={link:function(b){this.game=b;this.add=b.add;this.camera=b.camera;this.cache=b.cache;this.input=b.input;this.load=b.load;this.sound=b.sound;this.stage=b.stage;this.time=b.time;this.tweens=b.tweens;this.world=b.world;this.particles=b.particles;this.physics=b.physics},preload:function(){},create:function(){},update:function(){},render:function(){},paused:function(){},destroy:function(){}};Phaser.StateManager=function(c,b){this.game=c;this.states={};if(b!==null){this._pendingState=b}};Phaser.StateManager.prototype={game:null,_pendingState:null,_created:false,states:{},current:"",onInitCallback:null,onPreloadCallback:null,onCreateCallback:null,onUpdateCallback:null,onRenderCallback:null,onPreRenderCallback:null,onLoadUpdateCallback:null,onLoadRenderCallback:null,onPausedCallback:null,onShutDownCallback:null,boot:function(){if(this._pendingState!==null){if(typeof this._pendingState==="string"){this.start(this._pendingState,false,false)}else{this.add("default",this._pendingState,true)}}},add:function(c,d,b){if(typeof b==="undefined"){b=false}var e;if(d instanceof Phaser.State){e=d;e.link(this.game)}else{if(typeof d==="object"){e=d}else{if(typeof d==="function"){e=new d(this.game)}}}this.states[c]=e;if(b){if(this.game.isBooted){this.start(c)}else{this._pendingState=c}}return e},remove:function(b){if(this.current==b){this.callbackContext=null;this.onInitCallback=null;this.onShutDownCallback=null;this.onPreloadCallback=null;this.onLoadRenderCallback=null;this.onLoadUpdateCallback=null;this.onCreateCallback=null;this.onUpdateCallback=null;this.onRenderCallback=null;this.onPausedCallback=null;this.onDestroyCallback=null}delete this.states[b]},start:function(c,b,d){if(typeof b==="undefined"){b=true}if(typeof d==="undefined"){d=false}if(this.game.isBooted==false){this._pendingState=c;return}if(this.checkState(c)==false){return}else{if(this.current){this.onShutDownCallback.call(this.callbackContext)}if(b){if(d==true){this.game.cache.destroy()}}this.setCurrentState(c)}if(this.onPreloadCallback){this.game.load.reset();this.onPreloadCallback.call(this.callbackContext);if(this.game.load.queueSize==0){this.game.loadComplete();if(this.onCreateCallback){this.onCreateCallback.call(this.callbackContext)}this._created=true}else{this.game.load.start()}}else{if(this.onCreateCallback){this.onCreateCallback.call(this.callbackContext)}this._created=true;this.game.loadComplete()}},dummy:function(){},checkState:function(b){if(this.states[b]){var c=false;if(this.states[b]["preload"]){c=true}if(c==false&&this.states[b]["loadRender"]){c=true}if(c==false&&this.states[b]["loadUpdate"]){c=true}if(c==false&&this.states[b]["create"]){c=true}if(c==false&&this.states[b]["update"]){c=true}if(c==false&&this.states[b]["preRender"]){c=true}if(c==false&&this.states[b]["render"]){c=true}if(c==false&&this.states[b]["paused"]){c=true}if(c==false){console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions.");return false}return true}else{console.warn("Phaser.StateManager - No state found with the key: "+b);return false}},setCurrentState:function(b){this.callbackContext=this.states[b];this.onInitCallback=this.states[b]["init"]||this.dummy;this.onPreloadCallback=this.states[b]["preload"]||null;this.onLoadRenderCallback=this.states[b]["loadRender"]||null;this.onLoadUpdateCallback=this.states[b]["loadUpdate"]||null;this.onCreateCallback=this.states[b]["create"]||null;this.onUpdateCallback=this.states[b]["update"]||null;this.onPreRenderCallback=this.states[b]["preRender"]||null;this.onRenderCallback=this.states[b]["render"]||null;this.onPausedCallback=this.states[b]["paused"]||null;this.onShutDownCallback=this.states[b]["shutdown"]||this.dummy;this.current=b;this._created=false;this.onInitCallback.call(this.callbackContext)},loadComplete:function(){if(this._created==false&&this.onCreateCallback){this.onCreateCallback.call(this.callbackContext);this._created=true}},update:function(){if(this._created&&this.onUpdateCallback){this.onUpdateCallback.call(this.callbackContext)}else{if(this.onLoadUpdateCallback){this.onLoadUpdateCallback.call(this.callbackContext)}}},preRender:function(){if(this.onPreRenderCallback){this.onPreRenderCallback.call(this.callbackContext)}},render:function(){if(this._created&&this.onRenderCallback){this.onRenderCallback.call(this.callbackContext)}else{if(this.onLoadRenderCallback){this.onLoadRenderCallback.call(this.callbackContext)}}},destroy:function(){this.callbackContext=null;this.onInitCallback=null;this.onShutDownCallback=null;this.onPreloadCallback=null;this.onLoadRenderCallback=null;this.onLoadUpdateCallback=null;this.onCreateCallback=null;this.onUpdateCallback=null;this.onRenderCallback=null;this.onPausedCallback=null;this.onDestroyCallback=null;this.game=null;this.states={};this._pendingState=null}};Phaser.LinkedList=function(){this.next=null;this.prev=null;this.first=null;this.last=null;this.total=0};Phaser.LinkedList.prototype={add:function(b){if(this.total==0&&this.first==null&&this.last==null){this.first=b;this.last=b;this.next=b;b.prev=this;this.total++;return}this.last.next=b;b.prev=this.last;this.last=b;this.total++;return b},remove:function(c){if(this.first==null&&this.last==null){return}this.total--;if(this.first==c&&this.last==c){this.first=null;this.last=null;this.next=null;c.next=null;c.prev=null;return}var b=c.prev;if(c.next){c.next.prev=c.prev}b.next=c.next},callAll:function(c){var b=this.first;do{if(b[c]){b[c].call(b)}b=b.next}while(b!=this.last.next)},dump:function(){var j=20;var e="\n"+Phaser.Utils.pad("Node",j)+"|"+Phaser.Utils.pad("Next",j)+"|"+Phaser.Utils.pad("Previous",j)+"|"+Phaser.Utils.pad("First",j)+"|"+Phaser.Utils.pad("Last",j);console.log(e);var e=Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j);console.log(e);var g=this;var c=g.last.next;g=g.first;do{var d=g.sprite.name||"*";var f="-";var b="-";var h="-";var i="-";if(g.next){f=g.next.sprite.name}if(g.prev){b=g.prev.sprite.name}if(g.first){h=g.first.sprite.name}if(g.last){i=g.last.sprite.name}if(typeof f==="undefined"){f="-"}if(typeof b==="undefined"){b="-"}if(typeof h==="undefined"){h="-"}if(typeof i==="undefined"){i="-"}var e=Phaser.Utils.pad(d,j)+"|"+Phaser.Utils.pad(f,j)+"|"+Phaser.Utils.pad(b,j)+"|"+Phaser.Utils.pad(h,j)+"|"+Phaser.Utils.pad(i,j);console.log(e);g=g.next}while(g!=c)}};Phaser.Signal=function(){this._bindings=[];this._prevParams=null;var b=this;this.dispatch=function(){Phaser.Signal.prototype.dispatch.apply(b,arguments)}};Phaser.Signal.prototype={memorize:false,_shouldPropagate:true,active:true,validateListener:function(b,c){if(typeof b!=="function"){throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",c))}},_registerListener:function(f,d,e,c){var b=this._indexOfListener(f,e),g;if(b!==-1){g=this._bindings[b];if(g.isOnce()!==d){throw new Error("You cannot add"+(d?"":"Once")+"() then add"+(!d?"":"Once")+"() the same listener without removing the relationship first.")}}else{g=new Phaser.SignalBinding(this,f,d,e,c);this._addBinding(g)}if(this.memorize&&this._prevParams){g.execute(this._prevParams)}return g},_addBinding:function(b){var c=this._bindings.length;do{--c}while(this._bindings[c]&&b._priority<=this._bindings[c]._priority);this._bindings.splice(c+1,0,b)},_indexOfListener:function(c,b){var e=this._bindings.length,d;while(e--){d=this._bindings[e];if(d._listener===c&&d.context===b){return e}}return -1},has:function(c,b){return this._indexOfListener(c,b)!==-1},add:function(d,c,b){this.validateListener(d,"add");return this._registerListener(d,false,c,b)},addOnce:function(d,c,b){this.validateListener(d,"addOnce");return this._registerListener(d,true,c,b)},remove:function(d,c){this.validateListener(d,"remove");var b=this._indexOfListener(d,c);if(b!==-1){this._bindings[b]._destroy();this._bindings.splice(b,1)}return d},removeAll:function(){var b=this._bindings.length;while(b--){this._bindings[b]._destroy()}this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=false},dispatch:function(c){if(!this.active){return}var b=Array.prototype.slice.call(arguments),e=this._bindings.length,d;if(this.memorize){this._prevParams=b}if(!e){return}d=this._bindings.slice();this._shouldPropagate=true;do{e--}while(d[e]&&this._shouldPropagate&&d[e].execute(b)!==false)},forget:function(){this._prevParams=null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};Phaser.SignalBinding=function(f,e,c,d,b){this._listener=e;this._isOnce=c;this.context=d;this._signal=f;this._priority=b||0};Phaser.SignalBinding.prototype={active:true,params:null,execute:function(b){var d,c;if(this.active&&!!this._listener){c=this.params?this.params.concat(b):b;d=this._listener.apply(this.context,c);if(this._isOnce){this.detach()}}return d},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return(!!this._signal&&!!this._listener)},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal;delete this._listener;delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};Phaser.Plugin=function(b,c){this.game=b;this.parent=c;this.active=false;this.visible=false;this.hasPreUpdate=false;this.hasUpdate=false;this.hasRender=false;this.hasPostRender=false};Phaser.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null;this.parent=null;this.active=false;this.visible=false}};Phaser.PluginManager=function(b,c){this.game=b;this._parent=c;this.plugins=[];this._pluginsLength=0};Phaser.PluginManager.prototype={add:function(c){var b=false;if(typeof c==="function"){c=new c(this.game,this._parent)}else{c.game=this.game;c.parent=this._parent}if(typeof c.preUpdate==="function"){c.hasPreUpdate=true;b=true}if(typeof c.update==="function"){c.hasUpdate=true;b=true}if(typeof c.render==="function"){c.hasRender=true;b=true}if(typeof c.postRender==="function"){c.hasPostRender=true;b=true}if(b){if(c.hasPreUpdate||c.hasUpdate){c.active=true}if(c.hasRender||c.hasPostRender){c.visible=true}this._pluginsLength=this.plugins.push(c);return c}else{return null}},remove:function(b){this._pluginsLength--},preUpdate:function(){if(this._pluginsLength==0){return}for(this._p=0;this._p0)},removeBetween:function(d,c){if(d>c||d<0||c>this._container.children.length){return false}for(var b=d;b=this.game.width){this.bounds.width=c}if(b>=this.game.height){this.bounds.height=b}}};Object.defineProperty(Phaser.World.prototype,"width",{get:function(){return this.bounds.width},set:function(b){this.bounds.width=b}});Object.defineProperty(Phaser.World.prototype,"height",{get:function(){return this.bounds.height},set:function(b){this.bounds.height=b}});Object.defineProperty(Phaser.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth}});Object.defineProperty(Phaser.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight}});Object.defineProperty(Phaser.World.prototype,"randomX",{get:function(){return Math.round(Math.random()*this.bounds.width)}});Object.defineProperty(Phaser.World.prototype,"randomY",{get:function(){return Math.round(Math.random()*this.bounds.height)}});Phaser.Game=function(e,b,g,d,f,h,c){e=e||800;b=b||600;g=g||Phaser.AUTO;d=d||"";f=f||null;h=h||false;c=c||true;this.id=Phaser.GAMES.push(this)-1;this.parent=d;this.width=e;this.height=b;this.transparent=h;this.antialias=c;this.renderer=null;this.state=new Phaser.StateManager(this,f);this._paused=false;this.renderType=g;this._loadComplete=false;this.isBooted=false;this.isRunning=false;this.raf=null;this.add=null;this.cache=null;this.input=null;this.load=null;this.math=null;this.net=null;this.sound=null;this.stage=null;this.time=null;this.tweens=null;this.world=null;this.physics=null;this.rnd=null;this.device=null;this.camera=null;this.canvas=null;this.context=null;this.debug=null;this.particles=null;var i=this;this._onBoot=function(){return i.boot()};if(document.readyState==="complete"||document.readyState==="interactive"){window.setTimeout(this._onBoot,0)}else{document.addEventListener("DOMContentLoaded",this._onBoot,false);window.addEventListener("load",this._onBoot,false)}return this};Phaser.Game.prototype={boot:function(){if(this.isBooted){return}if(!document.body){window.setTimeout(this._onBoot,20)}else{document.removeEventListener("DOMContentLoaded",this._onBoot);window.removeEventListener("load",this._onBoot);this.onPause=new Phaser.Signal;this.onResume=new Phaser.Signal;this.isBooted=true;this.device=new Phaser.Device();this.math=Phaser.Math;this.rnd=new Phaser.RandomDataGenerator([(Date.now()*Math.random()).toString()]);this.stage=new Phaser.Stage(this,this.width,this.height);this.setUpRenderer();this.world=new Phaser.World(this);this.add=new Phaser.GameObjectFactory(this);this.cache=new Phaser.Cache(this);this.load=new Phaser.Loader(this);this.time=new Phaser.Time(this);this.tweens=new Phaser.TweenManager(this);this.input=new Phaser.Input(this);this.sound=new Phaser.SoundManager(this);this.physics=new Phaser.Physics.Arcade(this);this.particles=new Phaser.Particles(this);this.plugins=new Phaser.PluginManager(this,this);this.net=new Phaser.Net(this);this.debug=new Phaser.Utils.Debug(this);this.load.onLoadComplete.add(this.loadComplete,this);this.stage.boot();this.world.boot();this.state.boot();this.input.boot();this.sound.boot();if(this.renderType==Phaser.CANVAS){console.log("%cPhaser "+Phaser.VERSION+" initialized. Rendering to Canvas","color: #ffff33; background: #000000")}else{console.log("%cPhaser "+Phaser.VERSION+" initialized. Rendering to WebGL","color: #ffff33; background: #000000")}this.isRunning=true;this._loadComplete=false;this.raf=new Phaser.RequestAnimationFrame(this);this.raf.start()}},setUpRenderer:function(){if(this.renderType===Phaser.CANVAS||(this.renderType===Phaser.AUTO&&this.device.webGL==false)){if(this.device.canvas){this.renderType=Phaser.CANVAS;this.renderer=new PIXI.CanvasRenderer(this.width,this.height,this.stage.canvas,this.transparent);Phaser.Canvas.setSmoothingEnabled(this.renderer.context,this.antialias);this.canvas=this.renderer.view;this.context=this.renderer.context}else{throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.")}}else{this.renderType=Phaser.WEBGL;this.renderer=new PIXI.WebGLRenderer(this.width,this.height,this.stage.canvas,this.transparent,this.antialias);this.canvas=this.renderer.view;this.context=null}Phaser.Canvas.addToDOM(this.renderer.view,this.parent,true);Phaser.Canvas.setTouchAction(this.renderer.view)},loadComplete:function(){this._loadComplete=true;this.state.loadComplete()},update:function(b){this.time.update(b);if(!this._paused){this.plugins.preUpdate();this.physics.preUpdate();this.input.update();this.tweens.update();this.sound.update();this.world.update();this.particles.update();this.state.update();this.plugins.update();this.renderer.render(this.stage._stage);this.plugins.render();this.state.render();this.plugins.postRender()}},destroy:function(){this.state.destroy();this.state=null;this.cache=null;this.input=null;this.load=null;this.sound=null;this.stage=null;this.time=null;this.world=null;this.isBooted=false}};Object.defineProperty(Phaser.Game.prototype,"paused",{get:function(){return this._paused},set:function(b){if(b===true){if(this._paused==false){this._paused=true;this.onPause.dispatch(this)}}else{if(this._paused){this._paused=false;this.onResume.dispatch(this)}}}});Phaser.Input=function(b){this.game=b;this.hitCanvas=null;this.hitContext=null};Phaser.Input.MOUSE_OVERRIDES_TOUCH=0;Phaser.Input.TOUCH_OVERRIDES_MOUSE=1;Phaser.Input.MOUSE_TOUCH_COMBINE=2;Phaser.Input.prototype={game:null,pollRate:0,_pollCounter:0,_oldPosition:null,_x:0,_y:0,disabled:false,multiInputOverride:Phaser.Input.MOUSE_TOUCH_COMBINE,position:null,speed:null,circle:null,scale:null,maxPointers:10,currentPointers:0,tapRate:200,doubleTapRate:300,holdRate:2000,justPressedRate:200,justReleasedRate:200,recordPointerHistory:false,recordRate:100,recordLimit:100,pointer1:null,pointer2:null,pointer3:null,pointer4:null,pointer5:null,pointer6:null,pointer7:null,pointer8:null,pointer9:null,pointer10:null,activePointer:null,mousePointer:null,mouse:null,keyboard:null,touch:null,mspointer:null,onDown:null,onUp:null,onTap:null,onHold:null,interactiveItems:new Phaser.LinkedList(),boot:function(){this.mousePointer=new Phaser.Pointer(this.game,0);this.pointer1=new Phaser.Pointer(this.game,1);this.pointer2=new Phaser.Pointer(this.game,2);this.mouse=new Phaser.Mouse(this.game);this.keyboard=new Phaser.Keyboard(this.game);this.touch=new Phaser.Touch(this.game);this.mspointer=new Phaser.MSPointer(this.game);this.onDown=new Phaser.Signal();this.onUp=new Phaser.Signal();this.onTap=new Phaser.Signal();this.onHold=new Phaser.Signal();this.scale=new Phaser.Point(1,1);this.speed=new Phaser.Point();this.position=new Phaser.Point();this._oldPosition=new Phaser.Point();this.circle=new Phaser.Circle(0,0,44);this.activePointer=this.mousePointer;this.currentPointers=0;this.hitCanvas=document.createElement("canvas");this.hitCanvas.width=1;this.hitCanvas.height=1;this.hitContext=this.hitCanvas.getContext("2d");this.mouse.start();this.keyboard.start();this.touch.start();this.mspointer.start();this.mousePointer.active=true},addPointer:function(){var c=0;for(var b=10;b>0;b--){if(this["pointer"+b]===null){c=b}}if(c==0){console.warn("You can only have 10 Pointer objects");return null}else{this["pointer"+c]=new Phaser.Pointer(this.game,c);return this["pointer"+c]}},update:function(){if(this.pollRate>0&&this._pollCounter0&&this._pollCounter=this.game.input.holdRate){if(this.game.input.multiInputOverride==Phaser.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==Phaser.Input.MOUSE_TOUCH_COMBINE||(this.game.input.multiInputOverride==Phaser.Input.TOUCH_OVERRIDES_MOUSE&&this.game.input.currentPointers==0)){this.game.input.onHold.dispatch(this)}this._holdSent=true}if(this.game.input.recordPointerHistory&&this.game.time.now>=this._nextDrop){this._nextDrop=this.game.time.now+this.game.input.recordRate;this._history.push({x:this.position.x,y:this.position.y});if(this._history.length>this.game.input.recordLimit){this._history.shift()}}}},move:function(c){if(this.game.input.pollLocked){return}if(c.button){this.button=c.button}this.clientX=c.clientX;this.clientY=c.clientY;this.pageX=c.pageX;this.pageY=c.pageY;this.screenX=c.screenX;this.screenY=c.screenY;this.x=(this.pageX-this.game.stage.offset.x)*this.game.input.scale.x;this.y=(this.pageY-this.game.stage.offset.y)*this.game.input.scale.y;this.position.setTo(this.x,this.y);this.circle.x=this.x;this.circle.y=this.y;if(this.game.input.multiInputOverride==Phaser.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==Phaser.Input.MOUSE_TOUCH_COMBINE||(this.game.input.multiInputOverride==Phaser.Input.TOUCH_OVERRIDES_MOUSE&&this.game.input.currentPointers==0)){this.game.input.activePointer=this;this.game.input.x=this.x;this.game.input.y=this.y;this.game.input.position.setTo(this.game.input.x,this.game.input.y);this.game.input.circle.x=this.game.input.x;this.game.input.circle.y=this.game.input.y}if(this.game.paused){return this}if(this.targetObject!==null&&this.targetObject.isDragged==true){if(this.targetObject.update(this)==false){this.targetObject=null}return this}this._highestRenderOrderID=-1;this._highestRenderObject=null;this._highestInputPriorityID=-1;if(this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do{if(b.priorityID>this._highestInputPriorityID||(b.priorityID==this._highestInputPriorityID&&b.sprite.renderOrderID>this._highestRenderOrderID)){if(b.checkPointerOver(this)){this._highestRenderOrderID=b.sprite.renderOrderID;this._highestInputPriorityID=b.priorityID;this._highestRenderObject=b}}b=b.next}while(b!=null)}if(this._highestRenderObject==null){if(this.targetObject){this.targetObject._pointerOutHandler(this);this.targetObject=null}}else{if(this.targetObject==null){this.targetObject=this._highestRenderObject;this._highestRenderObject._pointerOverHandler(this)}else{if(this.targetObject==this._highestRenderObject){if(this._highestRenderObject.update(this)==false){this.targetObject=null}}else{this.targetObject._pointerOutHandler(this);this.targetObject=this._highestRenderObject;this.targetObject._pointerOverHandler(this)}}}return this},leave:function(b){this.withinGame=false;this.move(b)},stop:function(c){if(this._stateReset){c.preventDefault();return}this.timeUp=this.game.time.now;if(this.game.input.multiInputOverride==Phaser.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==Phaser.Input.MOUSE_TOUCH_COMBINE||(this.game.input.multiInputOverride==Phaser.Input.TOUCH_OVERRIDES_MOUSE&&this.game.input.currentPointers==0)){this.game.input.onUp.dispatch(this);if(this.duration>=0&&this.duration<=this.game.input.tapRate){if(this.timeUp-this.previousTapTime0){this.active=false}this.withinGame=false;this.isDown=false;this.isUp=true;if(this.isMouse==false){this.game.input.currentPointers--}if(this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do{if(b){b._releasedHandler(this)}b=b.next}while(b!=null)}if(this.targetObject){this.targetObject._releasedHandler(this)}this.targetObject=null;return this},justPressed:function(b){b=b||this.game.input.justPressedRate;return(this.isDown===true&&(this.timeDown+b)>this.game.time.now)},justReleased:function(b){b=b||this.game.input.justReleasedRate;return(this.isUp===true&&(this.timeUp+b)>this.game.time.now)},reset:function(){if(this.isMouse==false){this.active=false}this.identifier=null;this.isDown=false;this.isUp=true;this.totalTouches=0;this._holdSent=false;this._history.length=0;this._stateReset=true;if(this.targetObject){this.targetObject._releasedHandler(this)}this.targetObject=null},toString:function(){return"[{Pointer (id="+this.id+" identifer="+this.identifier+" active="+this.active+" duration="+this.duration+" withinGame="+this.withinGame+" x="+this.x+" y="+this.y+" clientX="+this.clientX+" clientY="+this.clientY+" screenX="+this.screenX+" screenY="+this.screenY+" pageX="+this.pageX+" pageY="+this.pageY+")}]"}};Object.defineProperty(Phaser.Pointer.prototype,"duration",{get:function(){if(this.isUp){return -1}return this.game.time.now-this.timeDown}});Object.defineProperty(Phaser.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}});Object.defineProperty(Phaser.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}});Phaser.Touch=function(b){this.game=b;this.callbackContext=this.game;this.touchStartCallback=null;this.touchMoveCallback=null;this.touchEndCallback=null;this.touchEnterCallback=null;this.touchLeaveCallback=null;this.touchCancelCallback=null;this.preventDefault=true};Phaser.Touch.prototype={game:null,disabled:false,_onTouchStart:null,_onTouchMove:null,_onTouchEnd:null,_onTouchEnter:null,_onTouchLeave:null,_onTouchCancel:null,_onTouchMove:null,start:function(){var b=this;if(this.game.device.touch){this._onTouchStart=function(c){return b.onTouchStart(c)};this._onTouchMove=function(c){return b.onTouchMove(c)};this._onTouchEnd=function(c){return b.onTouchEnd(c)};this._onTouchEnter=function(c){return b.onTouchEnter(c)};this._onTouchLeave=function(c){return b.onTouchLeave(c)};this._onTouchCancel=function(c){return b.onTouchCancel(c)};this.game.renderer.view.addEventListener("touchstart",this._onTouchStart,false);this.game.renderer.view.addEventListener("touchmove",this._onTouchMove,false);this.game.renderer.view.addEventListener("touchend",this._onTouchEnd,false);this.game.renderer.view.addEventListener("touchenter",this._onTouchEnter,false);this.game.renderer.view.addEventListener("touchleave",this._onTouchLeave,false);this.game.renderer.view.addEventListener("touchcancel",this._onTouchCancel,false)}},consumeDocumentTouches:function(){this._documentTouchMove=function(b){b.preventDefault()};document.addEventListener("touchmove",this._documentTouchMove,false)},onTouchStart:function(c){if(this.touchStartCallback){this.touchStartCallback.call(this.callbackContext,c)}if(this.game.input.disabled||this.disabled){return}if(this.preventDefault){c.preventDefault()}for(var b=0;bb&&this._tempPoint.xc&&this._tempPoint.y=this.pixelPerfectAlpha){return true}}return false},update:function(b){if(this.enabled==false||this.sprite.visible==false){this._pointerOutHandler(b);return false}if(this.draggable&&this._draggedPointerID==b.id){return this.updateDrag(b)}else{if(this._pointerData[b.id].isOver==true){if(this.checkPointerOver(b)){this._pointerData[b.id].x=b.x-this.sprite.x;this._pointerData[b.id].y=b.y-this.sprite.y;return true}else{this._pointerOutHandler(b);return false}}}},_pointerOverHandler:function(b){if(this._pointerData[b.id].isOver==false){this._pointerData[b.id].isOver=true;this._pointerData[b.id].isOut=false;this._pointerData[b.id].timeOver=this.game.time.now;this._pointerData[b.id].x=b.x-this.sprite.x;this._pointerData[b.id].y=b.y-this.sprite.y;if(this.useHandCursor&&this._pointerData[b.id].isDragged==false){this.game.stage.canvas.style.cursor="pointer"}this.sprite.events.onInputOver.dispatch(this.sprite,b)}},_pointerOutHandler:function(b){this._pointerData[b.id].isOver=false;this._pointerData[b.id].isOut=true;this._pointerData[b.id].timeOut=this.game.time.now;if(this.useHandCursor&&this._pointerData[b.id].isDragged==false){this.game.stage.canvas.style.cursor="default"}this.sprite.events.onInputOut.dispatch(this.sprite,b)},_touchedHandler:function(b){if(this._pointerData[b.id].isDown==false&&this._pointerData[b.id].isOver==true){this._pointerData[b.id].isDown=true;this._pointerData[b.id].isUp=false;this._pointerData[b.id].timeDown=this.game.time.now;this.sprite.events.onInputDown.dispatch(this.sprite,b);if(this.draggable&&this.isDragged==false){this.startDrag(b)}if(this.bringToTop){this.sprite.bringToTop()}}return this.consumePointerEvent},_releasedHandler:function(b){if(this._pointerData[b.id].isDown&&b.isUp){this._pointerData[b.id].isDown=false;this._pointerData[b.id].isUp=true;this._pointerData[b.id].timeUp=this.game.time.now;this._pointerData[b.id].downDuration=this._pointerData[b.id].timeUp-this._pointerData[b.id].timeDown;if(this.checkPointerOver(b)){this.sprite.events.onInputUp.dispatch(this.sprite,b)}else{if(this.useHandCursor){this.game.stage.canvas.style.cursor="default"}}if(this.draggable&&this.isDragged&&this._draggedPointerID==b.id){this.stopDrag(b)}}},updateDrag:function(b){if(b.isUp){this.stopDrag(b);return false}if(this.allowHorizontalDrag){this.sprite.x=b.x+this._dragPoint.x+this.dragOffset.x}if(this.allowVerticalDrag){this.sprite.y=b.y+this._dragPoint.y+this.dragOffset.y}if(this.boundsRect){this.checkBoundsRect()}if(this.boundsSprite){this.checkBoundsSprite()}if(this.snapOnDrag){this.sprite.x=Math.floor(this.sprite.x/this.snapX)*this.snapX;this.sprite.y=Math.floor(this.sprite.y/this.snapY)*this.snapY}return true},justOver:function(c,b){c=c||0;b=b||500;return(this._pointerData[c].isOver&&this.overDuration(c)this.boundsRect.right){this.sprite.x=this.boundsRect.right-this.sprite.width}}if(this.sprite.ythis.boundsRect.bottom){this.sprite.y=this.boundsRect.bottom-this.sprite.height}}},checkBoundsSprite:function(){if(this.sprite.x(this.boundsSprite.x+this.boundsSprite.width)){this.sprite.x=(this.boundsSprite.x+this.boundsSprite.width)-this.sprite.width}}if(this.sprite.y(this.boundsSprite.y+this.boundsSprite.height)){this.sprite.y=(this.boundsSprite.y+this.boundsSprite.height)-this.sprite.height}}}};Phaser.Canvas={create:function(d,b){d=d||256;b=b||256;var c=document.createElement("canvas");c.width=d;c.height=b;c.style.display="block";return c},getOffset:function(c,b){b=b||new Phaser.Point;var d=c.getBoundingClientRect();var h=c.clientTop||document.body.clientTop||0;var g=c.clientLeft||document.body.clientLeft||0;var e=window.pageYOffset||c.scrollTop||document.body.scrollTop;var f=window.pageXOffset||c.scrollLeft||document.body.scrollLeft;b.x=d.left+f-g;b.y=d.top+e-h;return b},getAspectRatio:function(b){return b.width/b.height},setBackgroundColor:function(c,b){b=b||"rgb(0,0,0)";c.style.backgroundColor=b;return c},setTouchAction:function(b,c){c=c||"none";b.style.msTouchAction=c;b.style["ms-touch-action"]=c;b.style["touch-action"]=c;return b},addToDOM:function(b,c,d){c=c||"";d=d||true;if(c!==""){if(document.getElementById(c)){document.getElementById(c).appendChild(b)}else{document.body.appendChild(b)}if(d){document.getElementById(c).style.overflow="hidden"}}else{document.body.appendChild(b)}return b},setTransform:function(f,h,g,d,b,e,c){f.setTransform(d,e,c,b,h,g);return f},setSmoothingEnabled:function(b,c){b.imageSmoothingEnabled=c;b.mozImageSmoothingEnabled=c;b.oImageSmoothingEnabled=c;b.webkitImageSmoothingEnabled=c;b.msImageSmoothingEnabled=c;return b},setImageRenderingCrisp:function(b){b.style["image-rendering"]="crisp-edges";b.style["image-rendering"]="-moz-crisp-edges";b.style["image-rendering"]="-webkit-optimize-contrast";b.style.msInterpolationMode="nearest-neighbor";return b},setImageRenderingBicubic:function(b){b.style["image-rendering"]="auto";b.style.msInterpolationMode="bicubic";return b}};Phaser.Events=function(b){this.parent=b;this.onAddedToGroup=new Phaser.Signal;this.onRemovedFromGroup=new Phaser.Signal;this.onKilled=new Phaser.Signal;this.onRevived=new Phaser.Signal;this.onOutOfBounds=new Phaser.Signal;this.onInputOver=null;this.onInputOut=null;this.onInputDown=null;this.onInputUp=null;this.onDragStart=null;this.onDragStop=null;this.onAnimationStart=null;this.onAnimationComplete=null;this.onAnimationLoop=null};Phaser.GameObjectFactory=function(b){this.game=b;this.world=this.game.world};Phaser.GameObjectFactory.prototype={game:null,world:null,existing:function(b){return this.world.group.add(b)},sprite:function(b,e,c,d){return this.world.group.add(new Phaser.Sprite(this.game,b,e,c,d))},child:function(d,b,g,c,e){var f=this.world.group.add(new Phaser.Sprite(this.game,b,g,c,e));d.addChild(f);return f},tween:function(b){return this.game.tweens.create(b)},group:function(c,b){return new Phaser.Group(this.game,c,b)},audio:function(c,d,b){return this.game.sound.add(c,d,b)},tileSprite:function(c,g,e,b,d,f){return this.world.group.add(new Phaser.TileSprite(this.game,c,g,e,b,d,f))},text:function(b,e,d,c){return this.world.group.add(new Phaser.Text(this.game,b,e,d,c))},button:function(b,i,g,h,e,d,f,c){return this.world.group.add(new Phaser.Button(this.game,b,i,g,h,e,d,f,c))},graphics:function(b,c){return this.world.group.add(new Phaser.Graphics(this.game,b,c))},emitter:function(b,d,c){return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game,b,d,c))},bitmapText:function(b,e,d,c){return this.world.group.add(new Phaser.BitmapText(this.game,b,e,d,c))},tilemap:function(b,g,d,e,f,c){return this.world.group.add(new Phaser.Tilemap(this.game,d,b,g,e,f,c))},renderTexture:function(c,d,b){var e=new Phaser.RenderTexture(this.game,c,d,b);this.game.cache.addRenderTexture(c,e);return e}};Phaser.Sprite=function(c,b,f,d,e){b=b||0;f=f||0;d=d||null;e=e||null;this.game=c;this.exists=true;this.alive=true;this.group=null;this.name="";this.type=Phaser.SPRITE;this.renderOrderID=-1;this.lifespan=0;this.events=new Phaser.Events(this);this.animations=new Phaser.AnimationManager(this);this.input=new Phaser.InputHandler(this);this.key=d;if(d instanceof Phaser.RenderTexture){PIXI.Sprite.call(this,d);this.currentFrame=this.game.cache.getTextureFrame(d.name)}else{if(d==null||this.game.cache.checkImageKey(d)==false){d="__default"}PIXI.Sprite.call(this,PIXI.TextureCache[d]);if(this.game.cache.isSpriteSheet(d)){this.animations.loadFrameData(this.game.cache.getFrameData(d));if(e!==null){if(typeof e==="string"){this.frameName=e}else{this.frame=e}}}else{this.currentFrame=this.game.cache.getFrame(d)}}this.anchor=new Phaser.Point();this._cropUUID=null;this._cropRect=null;this.x=b;this.y=f;this.position.x=b;this.position.y=f;this.autoCull=false;this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:f,id:1,i01:0,i10:0,idi:1,left:null,right:null,top:null,bottom:null,x:-1,y:-1,scaleX:1,scaleY:1,width:this.currentFrame.sourceSizeW,height:this.currentFrame.sourceSizeH,halfWidth:Math.floor(this.currentFrame.sourceSizeW/2),halfHeight:Math.floor(this.currentFrame.sourceSizeH/2),frameID:this.currentFrame.uuid,frameWidth:this.currentFrame.width,frameHeight:this.currentFrame.height,boundsX:0,boundsY:0,cameraVisible:true};this.offset=new Phaser.Point;this.center=new Phaser.Point(b+Math.floor(this._cache.width/2),f+Math.floor(this._cache.height/2));this.topLeft=new Phaser.Point(b,f);this.topRight=new Phaser.Point(b+this._cache.width,f);this.bottomRight=new Phaser.Point(b+this._cache.width,f+this._cache.height);this.bottomLeft=new Phaser.Point(b,f+this._cache.height);this.bounds=new Phaser.Rectangle(b,f,this._cache.width,this._cache.height);this.body=new Phaser.Physics.Arcade.Body(this);this.velocity=this.body.velocity;this.acceleration=this.body.acceleration;this.inWorld=Phaser.Rectangle.intersects(this.bounds,this.game.world.bounds);this.inWorldThreshold=0;this._outOfBoundsFired=false};Phaser.Sprite.prototype=Object.create(PIXI.Sprite.prototype);Phaser.Sprite.prototype.constructor=Phaser.Sprite;Phaser.Sprite.prototype.preUpdate=function(){if(!this.exists){this.renderOrderID=-1;return}if(this.lifespan>0){this.lifespan-=this.game.time.elapsed;if(this.lifespan<=0){this.kill();return}}this._cache.dirty=false;if(this.animations.update()){this._cache.dirty=true}this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);if(this.position.x!=this._cache.x||this.position.y!=this._cache.y){this.position.x=this._cache.x;this.position.y=this._cache.y;this._cache.dirty=true}if(this.visible){this.renderOrderID=this.game.world.currentRenderOrderID++;if(this.worldTransform[0]!=this._cache.a00||this.worldTransform[1]!=this._cache.a01){this._cache.a00=this.worldTransform[0];this._cache.a01=this.worldTransform[1];this._cache.i01=this.worldTransform[1];this._cache.scaleX=Math.sqrt((this._cache.a00*this._cache.a00)+(this._cache.a01*this._cache.a01));this._cache.a01*=-1;this._cache.dirty=true}if(this.worldTransform[3]!=this._cache.a10||this.worldTransform[4]!=this._cache.a11){this._cache.a10=this.worldTransform[3];this._cache.i10=this.worldTransform[3];this._cache.a11=this.worldTransform[4];this._cache.scaleY=Math.sqrt((this._cache.a10*this._cache.a10)+(this._cache.a11*this._cache.a11));this._cache.a10*=-1;this._cache.dirty=true}if(this.worldTransform[2]!=this._cache.a02||this.worldTransform[5]!=this._cache.a12){this._cache.a02=this.worldTransform[2];this._cache.a12=this.worldTransform[5];this._cache.dirty=true}if(this.currentFrame.uuid!=this._cache.frameID){this._cache.frameWidth=this.texture.frame.width;this._cache.frameHeight=this.texture.frame.height;this._cache.frameID=this.currentFrame.uuid;this._cache.dirty=true}if(this._cache.dirty){this._cache.width=Math.floor(this.currentFrame.sourceSizeW*this._cache.scaleX);this._cache.height=Math.floor(this.currentFrame.sourceSizeH*this._cache.scaleY);this._cache.halfWidth=Math.floor(this._cache.width/2);this._cache.halfHeight=Math.floor(this._cache.height/2);this._cache.id=1/(this._cache.a00*this._cache.a11+this._cache.a01*-this._cache.a10);this._cache.idi=1/(this._cache.a00*this._cache.a11+this._cache.i01*-this._cache.i10);this.updateBounds()}}else{if(this._cache.dirty&&this.visible==false){this.bounds.x-=this._cache.boundsX-this._cache.x;this._cache.boundsX=this._cache.x;this.bounds.y-=this._cache.boundsy-this._cache.y;this._cache.boundsY=this._cache.y}}if(this._cache.dirty){this._cache.cameraVisible=Phaser.Rectangle.intersects(this.game.world.camera.screenView,this.bounds,0);if(this.autoCull==true){this.visible=this._cache.cameraVisible}this.body.updateBounds(this.center.x,this.center.y,this._cache.scaleX,this._cache.scaleY)}this.body.update()};Phaser.Sprite.prototype.revive=function(){this.alive=true;this.exists=true;this.visible=true;this.events.onRevived.dispatch(this)};Phaser.Sprite.prototype.kill=function(){this.alive=false;this.exists=false;this.visible=false;this.events.onKilled.dispatch(this)};Phaser.Sprite.prototype.reset=function(b,c){this.x=b;this.y=c;this.position.x=b;this.position.y=c;this.alive=true;this.exists=true;this.visible=true;this._outOfBoundsFired=false;this.body.reset()};Phaser.Sprite.prototype.updateBounds=function(){this.offset.setTo(this._cache.a02-(this.anchor.x*this._cache.width),this._cache.a12-(this.anchor.y*this._cache.height));this.getLocalPosition(this.center,this.offset.x+this._cache.halfWidth,this.offset.y+this._cache.halfHeight);this.getLocalPosition(this.topLeft,this.offset.x,this.offset.y);this.getLocalPosition(this.topRight,this.offset.x+this._cache.width,this.offset.y);this.getLocalPosition(this.bottomLeft,this.offset.x,this.offset.y+this._cache.height);this.getLocalPosition(this.bottomRight,this.offset.x+this._cache.width,this.offset.y+this._cache.height);this._cache.left=Phaser.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);this._cache.right=Phaser.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);this._cache.top=Phaser.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);this._cache.bottom=Phaser.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);this.bounds.setTo(this._cache.left,this._cache.top,this._cache.right-this._cache.left,this._cache.bottom-this._cache.top);this._cache.boundsX=this._cache.x;this._cache.boundsY=this._cache.y;if(this.inWorld==false){this.inWorld=Phaser.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold);if(this.inWorld){this._outOfBoundsFired=false}}else{this.inWorld=Phaser.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold);if(this.inWorld==false){this.events.onOutOfBounds.dispatch(this);this._outOfBoundsFired=true}}};Phaser.Sprite.prototype.getLocalPosition=function(c,b,d){c.x=((this._cache.a11*this._cache.id*b+-this._cache.a01*this._cache.id*d+(this._cache.a12*this._cache.a01-this._cache.a02*this._cache.a11)*this._cache.id)*this._cache.scaleX)+this._cache.a02;c.y=((this._cache.a00*this._cache.id*d+-this._cache.a10*this._cache.id*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.a10)*this._cache.id)*this._cache.scaleY)+this._cache.a12;return c};Phaser.Sprite.prototype.getLocalUnmodifiedPosition=function(c,b,d){c.x=this._cache.a11*this._cache.idi*b+-this._cache.i01*this._cache.idi*d+(this._cache.a12*this._cache.i01-this._cache.a02*this._cache.a11)*this._cache.idi;c.y=this._cache.a00*this._cache.idi*d+-this._cache.i10*this._cache.idi*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.i10)*this._cache.idi;return c};Phaser.Sprite.prototype.bringToTop=function(){if(this.group){this.group.bringToTop(this)}else{this.game.world.bringToTop(this)}};Phaser.Sprite.prototype.getBounds=function(d){d=d||new Phaser.Rectangle;var f=Phaser.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);var c=Phaser.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);var e=Phaser.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);var b=Phaser.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);d.x=f;d.y=e;d.width=c-f;d.height=b-e;return d};Object.defineProperty(Phaser.Sprite.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.Sprite.prototype,"frame",{get:function(){return this.animations.frame},set:function(b){this.animations.frame=b}});Object.defineProperty(Phaser.Sprite.prototype,"frameName",{get:function(){return this.animations.frameName},set:function(b){this.animations.frameName=b}});Object.defineProperty(Phaser.Sprite.prototype,"inCamera",{get:function(){return this._cache.cameraVisible}});Object.defineProperty(Phaser.Sprite.prototype,"crop",{get:function(){return this._cropRect},set:function(b){if(b instanceof Phaser.Rectangle){if(this._cropUUID==null){this._cropUUID=this.game.rnd.uuid();PIXI.TextureCache[this._cropUUID]=new PIXI.Texture(PIXI.BaseTextureCache[this.key],{x:b.x,y:b.y,width:b.width,height:b.height})}else{PIXI.TextureCache[this._cropUUID].frame=b}this._cropRect=b;this.setTexture(PIXI.TextureCache[this._cropUUID])}}});Object.defineProperty(Phaser.Sprite.prototype,"inputEnabled",{get:function(){return(this.input.enabled)},set:function(b){if(b){if(this.input.enabled==false){this.input.start()}}else{if(this.input.enabled){this.input.stop()}}}});Phaser.TileSprite=function(d,c,h,f,b,e,g){c=c||0;h=h||0;f=f||256;b=b||256;e=e||null;g=g||null;Phaser.Sprite.call(this,d,c,h,e,g);this.texture=PIXI.TextureCache[e];PIXI.TilingSprite.call(this,this.texture,f,b);this.type=Phaser.TILESPRITE;this.tileScale=new Phaser.Point(1,1);this.tilePosition=new Phaser.Point(0,0)};Phaser.TileSprite.prototype=Phaser.Utils.extend(true,PIXI.TilingSprite.prototype,Phaser.Sprite.prototype);Phaser.TileSprite.prototype.constructor=Phaser.TileSprite;Phaser.Text=function(c,b,g,f,d){b=b||0;g=g||0;f=f||"";d=d||"";this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");var e=c.rnd.uuid();PIXI.TextureCache[e]=new PIXI.Texture(new PIXI.BaseTexture(this.canvas));Phaser.Sprite.call(this,c,b,g,e);this.type=Phaser.TEXT;this.setText(f);this.setStyle(d);this.updateText();this.dirty=false};Phaser.Text.prototype=Phaser.Utils.extend(true,Phaser.Sprite.prototype,PIXI.Text.prototype);Phaser.Text.prototype.constructor=Phaser.Text;Phaser.Button=function(j,g,f,h,i,c,d,b,e){g=g||0;f=f||0;h=h||null;i=i||null;c=c||this;Phaser.Sprite.call(this,j,g,f,h,b);this.type=Phaser.BUTTON;this._onOverFrameName=null;this._onOutFrameName=null;this._onDownFrameName=null;this._onUpFrameName=null;this._onOverFrameID=null;this._onOutFrameID=null;this._onDownFrameID=null;this._onUpFrameID=null;this.onInputOver=new Phaser.Signal;this.onInputOut=new Phaser.Signal;this.onInputDown=new Phaser.Signal;this.onInputUp=new Phaser.Signal;this.setFrames(d,b,e);if(i!==null){this.onInputUp.add(i,c)}this.input.start(0,false,true);this.events.onInputOver.add(this.onInputOverHandler,this);this.events.onInputOut.add(this.onInputOutHandler,this);this.events.onInputDown.add(this.onInputDownHandler,this);this.events.onInputUp.add(this.onInputUpHandler,this)};Phaser.Button.prototype=Phaser.Utils.extend(true,Phaser.Sprite.prototype,PIXI.Sprite.prototype);Phaser.Button.prototype.constructor=Phaser.Button;Phaser.Button.prototype.setFrames=function(c,d,b){if(c!==null){if(typeof c==="string"){this._onOverFrameName=c}else{this._onOverFrameID=c}}if(d!==null){if(typeof d==="string"){this._onOutFrameName=d;this._onUpFrameName=d}else{this._onOutFrameID=d;this._onUpFrameID=d}}if(b!==null){if(typeof b==="string"){this._onDownFrameName=b}else{this._onDownFrameID=b}}};Phaser.Button.prototype.onInputOverHandler=function(b){if(this._onOverFrameName!=null){this.frameName=this._onOverFrameName}else{if(this._onOverFrameID!=null){this.frame=this._onOverFrameID}}if(this.onInputOver){this.onInputOver.dispatch(this,b)}};Phaser.Button.prototype.onInputOutHandler=function(b){if(this._onOutFrameName!=null){this.frameName=this._onOutFrameName}else{if(this._onOutFrameID!=null){this.frame=this._onOutFrameID}}if(this.onInputOut){this.onInputOut.dispatch(this,b)}};Phaser.Button.prototype.onInputDownHandler=function(b){if(this._onDownFrameName!=null){this.frameName=this._onDownFrameName}else{if(this._onDownFrameID!=null){this.frame=this._onDownFrameID}}if(this.onInputDown){this.onInputDown.dispatch(this,b)}};Phaser.Button.prototype.onInputUpHandler=function(b){if(this._onUpFrameName!=null){this.frameName=this._onUpFrameName}else{if(this._onUpFrameID!=null){this.frame=this._onUpFrameID}}if(this.onInputUp){this.onInputUp.dispatch(this,b)}};Phaser.Graphics=function(c,b,d){this.exists=true;this.alive=true;this.group=null;this.name="";this.game=c;PIXI.DisplayObjectContainer.call(this);this.type=Phaser.GRAPHICS;this.position.x=b;this.position.y=d;this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:d,id:1,x:-1,y:-1,scaleX:1,scaleY:1};this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);this.renderable=true;this.fillAlpha=1;this.lineWidth=0;this.lineColor="black";this.graphicsData=[];this.currentPath={points:[]}};Phaser.Graphics.prototype=Phaser.Utils.extend(true,PIXI.Graphics.prototype,PIXI.DisplayObjectContainer.prototype,Phaser.Sprite.prototype);Phaser.Graphics.prototype.constructor=Phaser.Graphics;Phaser.Graphics.prototype.update=function(){if(!this.exists){return}this._cache.dirty=false;this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);if(this.position.x!=this._cache.x||this.position.y!=this._cache.y){this.position.x=this._cache.x;this.position.y=this._cache.y;this._cache.dirty=true}};Object.defineProperty(Phaser.Graphics.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.Graphics.prototype,"x",{get:function(){return this.position.x},set:function(b){this.position.x=b}});Object.defineProperty(Phaser.Graphics.prototype,"y",{get:function(){return this.position.y},set:function(b){this.position.y=b}});Phaser.RenderTexture=function(c,d,e,b){this.game=c;this.name=d;PIXI.EventTarget.call(this);this.width=e||100;this.height=b||100;this.indetityMatrix=PIXI.mat3.create();this.frame=new PIXI.Rectangle(0,0,this.width,this.height);this.type=Phaser.RENDERTEXTURE;if(PIXI.gl){this.initWebGL()}else{this.initCanvas()}};Phaser.RenderTexture.prototype=Phaser.Utils.extend(true,PIXI.RenderTexture.prototype);Phaser.RenderTexture.prototype.constructor=Phaser.RenderTexture;Phaser.BitmapText=function(c,b,f,e,d){b=b||0;f=f||0;e=e||"";d=d||"";this.exists=true;this.alive=true;this.group=null;this.name="";this.game=c;PIXI.BitmapText.call(this,e,d);this.position.x=b;this.position.y=f;this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:f,id:1,x:-1,y:-1,scaleX:1,scaleY:1};this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);this.renderable=true};Phaser.BitmapText.prototype=Phaser.Utils.extend(true,PIXI.BitmapText.prototype);Phaser.BitmapText.prototype.constructor=Phaser.BitmapText;Phaser.BitmapText.prototype.update=function(){if(!this.exists){return}this._cache.dirty=false;this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);if(this.position.x!=this._cache.x||this.position.y!=this._cache.y){this.position.x=this._cache.x;this.position.y=this._cache.y;this._cache.dirty=true}};Object.defineProperty(Phaser.BitmapText.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.BitmapText.prototype,"x",{get:function(){return this.position.x},set:function(b){this.position.x=b}});Object.defineProperty(Phaser.BitmapText.prototype,"y",{get:function(){return this.position.y},set:function(b){this.position.y=b}});Phaser.Canvas={create:function(d,b){d=d||256;b=b||256;var c=document.createElement("canvas");c.width=d;c.height=b;c.style.display="block";return c},getOffset:function(c,b){b=b||new Phaser.Point;var d=c.getBoundingClientRect();var h=c.clientTop||document.body.clientTop||0;var g=c.clientLeft||document.body.clientLeft||0;var e=window.pageYOffset||c.scrollTop||document.body.scrollTop;var f=window.pageXOffset||c.scrollLeft||document.body.scrollLeft;b.x=d.left+f-g;b.y=d.top+e-h;return b},getAspectRatio:function(b){return b.width/b.height},setBackgroundColor:function(c,b){b=b||"rgb(0,0,0)";c.style.backgroundColor=b;return c},setTouchAction:function(b,c){c=c||"none";b.style.msTouchAction=c;b.style["ms-touch-action"]=c;b.style["touch-action"]=c;return b},addToDOM:function(b,c,d){c=c||"";d=d||true;if(c!==""){if(document.getElementById(c)){document.getElementById(c).appendChild(b)}else{document.body.appendChild(b)}if(d){document.getElementById(c).style.overflow="hidden"}}else{document.body.appendChild(b)}return b},setTransform:function(f,h,g,d,b,e,c){f.setTransform(d,e,c,b,h,g);return f},setSmoothingEnabled:function(b,c){b.imageSmoothingEnabled=c;b.mozImageSmoothingEnabled=c;b.oImageSmoothingEnabled=c;b.webkitImageSmoothingEnabled=c;b.msImageSmoothingEnabled=c;return b},setImageRenderingCrisp:function(b){b.style["image-rendering"]="crisp-edges";b.style["image-rendering"]="-moz-crisp-edges";b.style["image-rendering"]="-webkit-optimize-contrast";b.style.msInterpolationMode="nearest-neighbor";return b},setImageRenderingBicubic:function(b){b.style["image-rendering"]="auto";b.style.msInterpolationMode="bicubic";return b}};Phaser.StageScaleMode=function(c,d,b){this._startHeight=0;this.forceLandscape=false;this.forcePortrait=false;this.incorrectOrientation=false;this.pageAlignHorizontally=false;this.pageAlignVeritcally=false;this.minWidth=null;this.maxWidth=null;this.minHeight=null;this.maxHeight=null;this.width=0;this.height=0;this.maxIterations=5;this.game=c;this.enterLandscape=new Phaser.Signal();this.enterPortrait=new Phaser.Signal();if(window.orientation){this.orientation=window.orientation}else{if(window.outerWidth>window.outerHeight){this.orientation=90}else{this.orientation=0}}this.scaleFactor=new Phaser.Point(1,1);this.aspectRatio=0;var e=this;window.addEventListener("orientationchange",function(f){return e.checkOrientation(f)},false);window.addEventListener("resize",function(f){return e.checkResize(f)},false)};Phaser.StageScaleMode.EXACT_FIT=0;Phaser.StageScaleMode.NO_SCALE=1;Phaser.StageScaleMode.SHOW_ALL=2;Phaser.StageScaleMode.prototype={startFullScreen:function(){if(this.isFullScreen){return}var b=this.game.canvas;if(b.requestFullScreen){b.requestFullScreen()}else{if(b.mozRequestFullScreen){b.mozRequestFullScreen()}else{if(b.webkitRequestFullScreen){b.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}}}this.game.stage.canvas.style.width="100%";this.game.stage.canvas.style.height="100%"},stopFullScreen:function(){if(document.cancelFullScreen){document.cancelFullScreen()}else{if(document.mozCancelFullScreen){document.mozCancelFullScreen()}else{if(document.webkitCancelFullScreen){document.webkitCancelFullScreen()}}}},checkOrientationState:function(){if(this.incorrectOrientation){if((this.forceLandscape&&window.innerWidth>window.innerHeight)||(this.forcePortrait&&window.innerHeight>window.innerWidth)){this.game.paused=false;this.incorrectOrientation=false;this.refresh()}}else{if((this.forceLandscape&&window.innerWidthwindow.outerHeight){this.orientation=90}else{this.orientation=0}if(this.isLandscape){this.enterLandscape.dispatch(this.orientation,true,false)}else{this.enterPortrait.dispatch(this.orientation,false,true)}if(this.game.stage.scaleMode!==Phaser.StageScaleMode.NO_SCALE){this.refresh()}},refresh:function(){var b=this;if(this.game.device.iPad==false&&this.game.device.webApp==false&&this.game.device.desktop==false){if(this.game.device.android&&this.game.device.chrome==false){window.scrollTo(0,1)}else{window.scrollTo(0,0)}}if(this._check==null&&this.maxIterations>0){this._iterations=this.maxIterations;this._check=window.setInterval(function(){return b.setScreenSize()},10);this.setScreenSize()}},setScreenSize:function(b){if(typeof b=="undefined"){b=false}if(this.game.device.iPad==false&&this.game.device.webApp==false&&this.game.device.desktop==false){if(this.game.device.android&&this.game.device.chrome==false){window.scrollTo(0,1)}else{window.scrollTo(0,0)}}this._iterations--;if(b||window.innerHeight>this._startHeight||this._iterations<0){document.documentElement.style.minHeight=window.innerHeight+"px";if(this.incorrectOrientation==true){this.setMaximum()}else{if(this.game.stage.scaleMode==Phaser.StageScaleMode.EXACT_FIT){this.setExactFit()}else{if(this.game.stage.scaleMode==Phaser.StageScaleMode.SHOW_ALL){this.setShowAll()}}}this.setSize();clearInterval(this._check);this._check=null}},setSize:function(){if(this.incorrectOrientation==false){if(this.maxWidth&&this.width>this.maxWidth){this.width=this.maxWidth}if(this.maxHeight&&this.height>this.maxHeight){this.height=this.maxHeight}if(this.minWidth&&this.widththis.maxWidth){this.width=this.maxWidth}else{this.width=b}if(this.maxHeight&&c>this.maxHeight){this.height=this.maxHeight}else{this.height=c}console.log("setExactFit",this.width,this.height,this.game.stage.offset)}};Object.defineProperty(Phaser.StageScaleMode.prototype,"isFullScreen",{get:function(){if(document.fullscreenElement===null||document.mozFullScreenElement===null||document.webkitFullscreenElement===null){return false}return true}});Object.defineProperty(Phaser.StageScaleMode.prototype,"isPortrait",{get:function(){return this.orientation==0||this.orientation==180}});Object.defineProperty(Phaser.StageScaleMode.prototype,"isLandscape",{get:function(){return this.orientation===90||this.orientation===-90}});Phaser.Device=function(){this.patchAndroidClearRectBug=false;this.desktop=false;this.iOS=false;this.android=false;this.chromeOS=false;this.linux=false;this.macOS=false;this.windows=false;this.canvas=false;this.file=false;this.fileSystem=false;this.localStorage=false;this.webGL=false;this.worker=false;this.touch=false;this.mspointer=false;this.css3D=false;this.pointerLock=false;this.arora=false;this.chrome=false;this.epiphany=false;this.firefox=false;this.ie=false;this.ieVersion=0;this.mobileSafari=false;this.midori=false;this.opera=false;this.safari=false;this.webApp=false;this.audioData=false;this.webAudio=false;this.ogg=false;this.opus=false;this.mp3=false;this.wav=false;this.m4a=false;this.webm=false;this.iPhone=false;this.iPhone4=false;this.iPad=false;this.pixelRatio=0;this._checkAudio();this._checkBrowser();this._checkCSS3D();this._checkDevice();this._checkFeatures();this._checkOS()};Phaser.Device.prototype={_checkOS:function(){var b=navigator.userAgent;if(/Android/.test(b)){this.android=true}else{if(/CrOS/.test(b)){this.chromeOS=true}else{if(/iP[ao]d|iPhone/i.test(b)){this.iOS=true}else{if(/Linux/.test(b)){this.linux=true}else{if(/Mac OS/.test(b)){this.macOS=true}else{if(/Windows/.test(b)){this.windows=true}}}}}}if(this.windows||this.macOS||this.linux){this.desktop=true}},_checkFeatures:function(){this.canvas=!!window.CanvasRenderingContext2D;try{this.localStorage=!!localStorage.getItem}catch(b){this.localStorage=false}this.file=!!window.File&&!!window.FileReader&&!!window.FileList&&!!window.Blob;this.fileSystem=!!window.requestFileSystem;this.webGL=(function(){try{return !!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(c){return false}})();this.worker=!!window.Worker;if("ontouchstart" in document.documentElement||window.navigator.msPointerEnabled){this.touch=true}if(window.navigator.msPointerEnabled){this.mspointer=true}this.pointerLock="pointerLockElement" in document||"mozPointerLockElement" in document||"webkitPointerLockElement" in document},_checkBrowser:function(){var b=navigator.userAgent;if(/Arora/.test(b)){this.arora=true}else{if(/Chrome/.test(b)){this.chrome=true}else{if(/Epiphany/.test(b)){this.epiphany=true}else{if(/Firefox/.test(b)){this.firefox=true}else{if(/Mobile Safari/.test(b)){this.mobileSafari=true}else{if(/MSIE (\d+\.\d+);/.test(b)){this.ie=true;this.ieVersion=parseInt(RegExp.$1)}else{if(/Midori/.test(b)){this.midori=true}else{if(/Opera/.test(b)){this.opera=true}else{if(/Safari/.test(b)){this.safari=true}}}}}}}}}if(navigator.standalone){this.webApp=true}},_checkAudio:function(){this.audioData=!!(window.Audio);this.webAudio=!!(window.webkitAudioContext||window.AudioContext);var d=document.createElement("audio");var b=false;try{if(b=!!d.canPlayType){if(d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")){this.ogg=true}if(d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")){this.opus=true}if(d.canPlayType("audio/mpeg;").replace(/^no$/,"")){this.mp3=true}if(d.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")){this.wav=true}if(d.canPlayType("audio/x-m4a;")||d.canPlayType("audio/aac;").replace(/^no$/,"")){this.m4a=true}if(d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")){this.webm=true}}}catch(c){}},_checkDevice:function(){this.pixelRatio=window.devicePixelRatio||1;this.iPhone=navigator.userAgent.toLowerCase().indexOf("iphone")!=-1;this.iPhone4=(this.pixelRatio==2&&this.iPhone);this.iPad=navigator.userAgent.toLowerCase().indexOf("ipad")!=-1},_checkCSS3D:function(){var d=document.createElement("p");var e;var c={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(d,null);for(var b in c){if(d.style[b]!==undefined){d.style[b]="translate3d(1px,1px,1px)";e=window.getComputedStyle(d).getPropertyValue(c[b])}}document.body.removeChild(d);this.css3D=(e!==undefined&&e.length>0&&e!=="none")},canPlayAudio:function(b){if(b=="mp3"&&this.mp3){return true}else{if(b=="ogg"&&(this.ogg||this.opus)){return true}else{if(b=="m4a"&&this.m4a){return true}else{if(b=="wav"&&this.wav){return true}else{if(b=="webm"&&this.webm){return true}}}}}return false},isConsoleOpen:function(){if(window.console&&window.console.firebug){return true}if(window.console){console.profile();console.profileEnd();if(console.clear){console.clear()}return console.profiles.length>0}return false}};Phaser.RequestAnimationFrame=function(c){this.game=c;this._isSetTimeOut=false;this.isRunning=false;var d=["ms","moz","webkit","o"];for(var b=0;b>>0;c-=e;c*=e;e=c>>>0;c-=e;e+=c*4294967296}return(e>>>0)*2.3283064365386963e-10},integer:function(){return this.rnd.apply(this)*4294967296},frac:function(){return this.rnd.apply(this)+(this.rnd.apply(this)*2097152|0)*1.1102230246251565e-16},real:function(){return this.integer()+this.frac()},integerInRange:function(c,b){return Math.floor(this.realInRange(c,b))},realInRange:function(c,b){c=c||0;b=b||0;return this.frac()*(b-c)+c},normal:function(){return 1-2*this.frac()},uuid:function(){var d,c;for(c=d="";d++<36;c+=~d%5|d*3&4?(d^15?8^this.frac()*(d^20?16:4):4).toString(16):"-"){}return c},pick:function(b){return b[this.integerInRange(0,b.length)]},weightedPick:function(b){return b[~~(Math.pow(this.frac(),2)*b.length)]},timestamp:function(d,c){return this.realInRange(d||946684800000,c||1577862000000)},angle:function(){return this.integerInRange(-180,180)}};Phaser.Math={PI2:Math.PI*2,fuzzyEqual:function(d,c,e){if(typeof e==="undefined"){e=0.0001}return Math.abs(d-c)c-e},fuzzyCeil:function(b,c){if(typeof c==="undefined"){c=0.0001}return Math.ceil(b-c)},fuzzyFloor:function(b,c){if(typeof c==="undefined"){c=0.0001}return Math.floor(b+c)},average:function(){var b=[];for(var d=0;d<(arguments.length-0);d++){b[d]=arguments[d+0]}var e=0;for(var c=0;c0)?Math.floor(b):Math.ceil(b)},shear:function(b){return b%1},snapTo:function(b,d,c){if(typeof c==="undefined"){c=0}if(d==0){return b}b-=c;b=d*Math.round(b/d);return c+b},snapToFloor:function(b,d,c){if(typeof c==="undefined"){c=0}if(d==0){return b}b-=c;b=d*Math.floor(b/d);return c+b},snapToCeil:function(b,d,c){if(typeof c==="undefined"){c=0}if(d==0){return b}b-=c;b=d*Math.ceil(b/d);return c+b},snapToInArray:function(d,c,f){if(typeof f==="undefined"){f=true}if(f){c.sort()}if(dd/2){c+=d*2}if(b<-d/2&&c>d/2){b+=d*2}return b-c},interpolateAngles:function(c,b,d,e,f){if(typeof e==="undefined"){e=true}if(typeof f==="undefined"){f=null}c=this.normalizeAngle(c,e);b=this.normalizeAngleToAnother(b,c,e);return(typeof f==="function")?f(d,c,b-c,1):this.interpolateFloat(c,b,d)},chanceRoll:function(b){if(typeof b==="undefined"){b=50}if(b<=0){return false}else{if(b>=100){return true}else{if(Math.random()*100>=b){return false}else{return true}}}},maxAdd:function(d,c,b){d+=c;if(d>b){d=b}return d},minSub:function(d,c,b){d-=c;if(d0.5)?1:-1},isOdd:function(b){return(b&1)},isEven:function(b){if(b&1){return false}else{return true}},max:function(){for(var d=1,c=0,b=arguments.length;d=-180&&c<=180){return c}b=(c+180)%360;if(b<0){b+=360}return b-180},angleLimit:function(e,d,c){var b=e;if(e>c){b=c}else{if(e1){return this.linear(d[b],d[b-1],b-g)}return this.linear(d[e],d[e+1>b?b:e+1],g-e)},bezierInterpolation:function(e,d){var c=0;var g=e.length-1;for(var f=0;f<=g;f++){c+=Math.pow(1-d,g-f)*Math.pow(d,f)*e[f]*this.bernstein(g,f)}return c},catmullRomInterpolation:function(d,c){var b=d.length-1;var g=b*c;var e=Math.floor(g);if(d[0]===d[b]){if(c<0){e=Math.floor(g=b*(1+c))}return this.catmullRom(d[(e-1+b)%b],d[e],d[(e+1)%b],d[(e+2)%b],g-e)}else{if(c<0){return d[0]-(this.catmullRom(d[0],d[0],d[1],d[1],-g)-d[0])}if(c>1){return d[b]-(this.catmullRom(d[b],d[b],d[b-1],d[b-1],g-b)-d[b])}return this.catmullRom(d[e?e-1:0],d[e],d[bd.length-e)){b=d.length-e}if(b>0){return d[e+Math.floor(Math.random()*b)]}}return null},floor:function(b){var c=b|0;return(b>0)?(c):((c!=b)?(c-1):(c))},ceil:function(b){var c=b|0;return(b>0)?((c!=b)?(c+1):(c)):(c)},sinCosGenerator:function(b,j,d,h){if(typeof j==="undefined"){j=1}if(typeof d==="undefined"){d=1}if(typeof h==="undefined"){h=1}var i=j;var l=d;var f=h*Math.PI/b;var e=[];var k=[];for(var g=0;g0;d--){var c=Math.floor(Math.random()*(d+1));var b=e[d];e[d]=e[c];e[c]=b}return e},distance:function(e,g,d,f){var c=e-d;var b=g-f;return Math.sqrt(c*c+b*b)},distanceRounded:function(c,e,b,d){return Math.round(Phaser.Math.distance(c,e,b,d))},clamp:function(d,e,c){return(dc)?c:d)},clampBottom:function(b,c){return b=b){return 1}c=(c-d)/(b-d);return c*c*(3-2*c)},smootherstep:function(c,d,b){if(c<=d){return 0}if(c>=b){return 1}c=(c-d)/(b-d);return c*c*c*(c*(c*6-15)+10)},sign:function(b){return(b<0)?-1:((b>0)?1:0)},degToRad:function(){var b=Math.PI/180;return function(c){return c*b}}(),radToDeg:function(){var b=180/Math.PI;return function(c){return c*b}}()};Phaser.QuadTree=function(g,c,i,f,b,e,d,h){this.physicsManager=g;this.ID=g.quadTreeID;g.quadTreeID++;this.maxObjects=e||10;this.maxLevels=d||4;this.level=h||0;this.bounds={x:Math.round(c),y:Math.round(i),width:f,height:b,subWidth:Math.floor(f/2),subHeight:Math.floor(b/2),right:Math.round(c)+Math.floor(f/2),bottom:Math.round(i)+Math.floor(b/2)};this.objects=[];this.nodes=[]};Phaser.QuadTree.prototype={split:function(){this.level++;this.nodes[0]=new Phaser.QuadTree(this.physicsManager,this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[1]=new Phaser.QuadTree(this.physicsManager,this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[2]=new Phaser.QuadTree(this.physicsManager,this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[3]=new Phaser.QuadTree(this.physicsManager,this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level)},insert:function(b){var d=0;var c;if(this.nodes[0]!=null){c=this.getIndex(b);if(c!==-1){this.nodes[c].insert(b);return}}this.objects.push(b);if(this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom)){b=2}}}else{if(c.x>this.bounds.right){if((c.ythis.bounds.bottom)){b=3}}}}return b},retrieve:function(b){var c=this.objects;b.body.quadTreeIndex=this.getIndex(b.body);b.body.quadTreeIDs.push(this.ID);if(this.nodes[0]){if(b.body.quadTreeIndex!==-1){c=c.concat(this.nodes[b.body.quadTreeIndex].retrieve(b))}else{c=c.concat(this.nodes[0].retrieve(b));c=c.concat(this.nodes[1].retrieve(b));c=c.concat(this.nodes[2].retrieve(b));c=c.concat(this.nodes[3].retrieve(b))}}return c},clear:function(){this.objects=[];for(var c=0,b=this.nodes.length;c0){this._radius=c*0.5}else{this._radius=0}};Phaser.Circle.prototype={circumference:function(){return 2*(Math.PI*this._radius)},setTo:function(b,d,c){this.x=b;this.y=d;this._diameter=c;this._radius=c*0.5;return this},copyFrom:function(b){return this.setTo(b.x,b.y,b.diameter)},copyTo:function(b){b[x]=this.x;b[y]=this.y;b[diameter]=this._diameter;return b},distance:function(c,b){if(typeof b==="undefined"){b=false}if(b){return Phaser.Math.distanceRound(this.x,this.y,c.x,c.y)}else{return Phaser.Math.distance(this.x,this.y,c.x,c.y)}},clone:function(b){if(typeof b==="undefined"){b=new Phaser.Circle()}return b.setTo(a.x,a.y,a.diameter)},contains:function(b,c){return Phaser.Circle.contains(this,b,c)},circumferencePoint:function(d,c,b){return Phaser.Circle.circumferencePoint(this,d,c,b)},offset:function(c,b){this.x+=c;this.y+=b;return this},offsetPoint:function(b){return this.offset(b.x,b.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}};Object.defineProperty(Phaser.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(b){if(b>0){this._diameter=b;this._radius=b*0.5}}});Object.defineProperty(Phaser.Circle.prototype,"radius",{get:function(){return this._radius},set:function(b){if(b>0){this._radius=b;this._diameter=b*2}}});Object.defineProperty(Phaser.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(b){if(b>this.x){this._radius=0;this._diameter=0}else{this.radius=this.x-b}}});Object.defineProperty(Phaser.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(b){if(bthis.y){this._radius=0;this._diameter=0}else{this.radius=this.y-b}}});Object.defineProperty(Phaser.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(b){if(b0){return Math.PI*this._radius*this._radius}else{return 0}}});Object.defineProperty(Phaser.Circle.prototype,"empty",{get:function(){return(this._diameter==0)},set:function(b){this.setTo(0,0,0)}});Phaser.Circle.contains=function(d,b,f){if(b>=d.left&&b<=d.right&&f>=d.top&&f<=d.bottom){var e=(d.x-b)*(d.x-b);var c=(d.y-f)*(d.y-f);return(e+c)<=(d.radius*d.radius)}return false};Phaser.Circle.equals=function(d,c){return(d.x==c.x&&d.y==c.y&&d.diameter==c.diameter)};Phaser.Circle.intersects=function(d,c){return(Phaser.Math.distance(d.x,d.y,c.x,c.y)<=(d.radius+c.radius))};Phaser.Circle.circumferencePoint=function(b,e,d,c){if(typeof d==="undefined"){d=false}if(typeof c==="undefined"){c=new Phaser.Point()}if(d===true){e=Phaser.Math.radToDeg(e)}c.x=b.x+b.radius*Math.cos(e);c.y=b.y+b.radius*Math.sin(e);return c};Phaser.Circle.intersectsRectangle=function(m,d){var g=Math.abs(m.x-d.x-d.halfWidth);var l=d.halfWidth+m.radius;if(g>l){return false}var f=Math.abs(m.y-d.y-d.halfHeight);var j=d.halfHeight+m.radius;if(f>j){return false}if(g<=d.halfWidth||f<=d.halfHeight){return true}var h=g-d.halfWidth;var e=f-d.halfHeight;var k=h*h;var b=e*e;var i=m.radius*m.radius;return k+b<=i};Phaser.Point=function(b,c){b=b||0;c=c||0;this.x=b;this.y=c};Phaser.Point.prototype={copyFrom:function(b){return this.setTo(b.x,b.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(b,c){this.x=b;this.y=c;return this},add:function(b,c){this.x+=b;this.y+=c;return this},subtract:function(b,c){this.x-=b;this.y-=c;return this},multiply:function(b,c){this.x*=b;this.y*=c;return this},divide:function(b,c){this.x/=b;this.y/=c;return this},clampX:function(c,b){this.x=Phaser.Math.clamp(this.x,c,b);return this},clampY:function(c,b){this.y=Phaser.Math.clamp(this.y,c,b);return this},clamp:function(c,b){this.x=Phaser.Math.clamp(this.x,c,b);this.y=Phaser.Math.clamp(this.y,c,b);return this},clone:function(b){if(typeof b==="undefined"){b=new Phaser.Point}return b.setTo(this.x,this.y)},copyFrom:function(b){return this.setTo(b.x,b.y)},copyTo:function(b){b[x]=this.x;b[y]=this.y;return b},distance:function(c,b){return Phaser.Point.distance(this,c,b)},equals:function(b){return(b.x==this.x&&b.y==this.y)},rotate:function(b,f,d,c,e){return Phaser.Point.rotate(this,b,f,d,c,e)},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}};Phaser.Point.add=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x+c.x;e.y=d.y+c.y;return e};Phaser.Point.subtract=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x-c.x;e.y=d.y-c.y;return e};Phaser.Point.multiply=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x*c.x;e.y=d.y*c.y;return e};Phaser.Point.divide=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x/c.x;e.y=d.y/c.y;return e};Phaser.Point.equals=function(d,c){return(d.x==c.x&&d.y==c.y)};Phaser.Point.distance=function(d,c,e){if(typeof e==="undefined"){e=false}if(e){return Phaser.Math.distanceRound(d.x,d.y,c.x,c.y)}else{return Phaser.Math.distance(d.x,d.y,c.x,c.y)}},Phaser.Point.rotate=function(c,b,g,e,d,f){d=d||false;f=f||null;if(d){e=Phaser.Math.radToDeg(e)}if(f===null){f=Math.sqrt(((b-c.x)*(b-c.x))+((g-c.y)*(g-c.y)))}return c.setTo(b+f*Math.cos(e),g+f*Math.sin(e))};Phaser.Rectangle=function(c,e,d,b){c=c||0;e=e||0;d=d||0;b=b||0;this.x=c;this.y=e;this.width=d;this.height=b};Phaser.Rectangle.prototype={offset:function(c,b){this.x+=c;this.y+=b;return this},offsetPoint:function(b){return this.offset(b.x,b.y)},setTo:function(c,e,d,b){this.x=c;this.y=e;this.width=d;this.height=b;return this},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y)},copyFrom:function(b){return this.setTo(b.x,b.y,b.width,b.height)},copyTo:function(b){b.x=this.x;b.y=this.y;b.width=this.width;b.height=this.height;return b},inflate:function(c,b){return Phaser.Rectangle.inflate(this,c,b)},size:function(b){return Phaser.Rectangle.size(this,b)},clone:function(b){return Phaser.Rectangle.clone(this,b)},contains:function(b,c){return Phaser.Rectangle.contains(this,b,c)},containsRect:function(c){return Phaser.Rectangle.containsRect(this,c)},equals:function(c){return Phaser.Rectangle.equals(this,c)},intersection:function(c,d){return Phaser.Rectangle.intersection(this,c,output)},intersects:function(c,d){return Phaser.Rectangle.intersects(this,c,d)},intersectsRaw:function(f,d,e,c,b){return Phaser.Rectangle.intersectsRaw(this,f,d,e,c,b)},union:function(c,d){return Phaser.Rectangle.union(this,c,d)},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}};Object.defineProperty(Phaser.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}});Object.defineProperty(Phaser.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}});Object.defineProperty(Phaser.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(b){if(b<=this.y){this.height=0}else{this.height=(this.y-b)}}});Object.defineProperty(Phaser.Rectangle.prototype,"bottomRight",{get:function(){return new Phaser.Point(this.right,this.bottom)},set:function(b){this.right=b.x;this.bottom=b.y}});Object.defineProperty(Phaser.Rectangle.prototype,"left",{get:function(){return this.x},set:function(b){if(b>=this.right){this.width=0}else{this.width=this.right-b}this.x=b}});Object.defineProperty(Phaser.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(b){if(b<=this.x){this.width=0}else{this.width=this.x+b}}});Object.defineProperty(Phaser.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}});Object.defineProperty(Phaser.Rectangle.prototype,"perimeter",{get:function(){return(this.width*2)+(this.height*2)}});Object.defineProperty(Phaser.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(b){this.x=b-this.halfWidth}});Object.defineProperty(Phaser.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(b){this.y=b-this.halfHeight}});Object.defineProperty(Phaser.Rectangle.prototype,"top",{get:function(){return this.y},set:function(b){if(b>=this.bottom){this.height=0;this.y=b}else{this.height=(this.bottom-b)}}});Object.defineProperty(Phaser.Rectangle.prototype,"topLeft",{get:function(){return new Phaser.Point(this.x,this.y)},set:function(b){this.x=b.x;this.y=b.y}});Object.defineProperty(Phaser.Rectangle.prototype,"empty",{get:function(){return(!this.width||!this.height)},set:function(b){this.setTo(0,0,0,0)}});Phaser.Rectangle.inflate=function(c,d,b){c.x-=d;c.width+=2*d;c.y-=b;c.height+=2*b;return c};Phaser.Rectangle.inflatePoint=function(c,b){return Phaser.Phaser.Rectangle.inflate(c,b.x,b.y)};Phaser.Rectangle.size=function(b,c){if(typeof c==="undefined"){c=new Phaser.Point()}return c.setTo(b.width,b.height)};Phaser.Rectangle.clone=function(b,c){if(typeof c==="undefined"){c=new Phaser.Rectangle()}return c.setTo(b.x,b.y,b.width,b.height)};Phaser.Rectangle.contains=function(c,b,d){return(b>=c.x&&b<=c.right&&d>=c.y&&d<=c.bottom)};Phaser.Rectangle.containsPoint=function(c,b){return Phaser.Phaser.Rectangle.contains(c,b.x,b.y)};Phaser.Rectangle.containsRect=function(d,c){if(d.volume>c.volume){return false}return(d.x>=c.x&&d.y>=c.y&&d.right<=c.right&&d.bottom<=c.bottom)};Phaser.Rectangle.equals=function(d,c){return(d.x==c.x&&d.y==c.y&&d.width==c.width&&d.height==c.height)};Phaser.Rectangle.intersection=function(d,c,e){e=e||new Phaser.Rectangle;if(Phaser.Rectangle.intersects(d,c)){e.x=Math.max(d.x,c.x);e.y=Math.max(d.y,c.y);e.width=Math.min(d.right,c.right)-e.x;e.height=Math.min(d.bottom,c.bottom)-e.y}return e};Phaser.Rectangle.intersects=function(d,c,e){e=e||0;return !(d.left>c.right+e||d.rightc.bottom+e||d.bottomb.right+c||eb.bottom+c||d1){if(f&&f==this.decodeURI(d[0])){return this.decodeURI(d[1])}else{c[this.decodeURI(d[0])]=this.decodeURI(d[1])}}}return c},decodeURI:function(b){return decodeURIComponent(b.replace(/\+/g," "))}};Phaser.TweenManager=function(b){this.game=b;this._tweens=[];this.game.onPause.add(this.pauseAll,this);this.game.onResume.add(this.resumeAll,this)};Phaser.TweenManager.prototype={REVISION:"11dev",getAll:function(){return this._tweens},removeAll:function(){this._tweens=[]},add:function(b){this._tweens.push(b)},create:function(b){return new Phaser.Tween(b,this.game)},remove:function(c){var b=this._tweens.indexOf(c);if(b!==-1){this._tweens.splice(b,1)}},update:function(){if(this._tweens.length===0){return false}var b=0,c=this._tweens.length;while(b=0;b--){this._tweens[b].pause()}},resumeAll:function(){for(var b=this._tweens.length-1;b>=0;b--){this._tweens[b].resume()}}};Phaser.Tween=function(c,b){this._object=c;this.game=b;this._manager=this.game.tweens;this._valuesStart={};this._valuesEnd={};this._valuesStartRepeat={};this._duration=1000;this._repeat=0;this._yoyo=false;this._reversed=false;this._delayTime=0;this._startTime=null;this._easingFunction=Phaser.Easing.Linear.None;this._interpolationFunction=Phaser.Math.linearInterpolation;this._chainedTweens=[];this._onStartCallback=null;this._onStartCallbackFired=false;this._onUpdateCallback=null;this._onCompleteCallback=null;this._pausedTime=0;for(var d in c){this._valuesStart[d]=parseFloat(c[d],10)}this.onStart=new Phaser.Signal();this.onComplete=new Phaser.Signal();this.isRunning=false};Phaser.Tween.prototype={to:function(d,g,h,c,b,f,e){g=g||1000;h=h||null;c=c||false;b=b||0;f=f||0;e=e||false;this._repeat=f;this._duration=g;this._valuesEnd=d;if(h!==null){this._easingFunction=h}if(b>0){this._delayTime=b}this._yoyo=e;if(c){return this.start()}else{return this}},start:function(c){if(this.game===null||this._object===null){return}this._manager.add(this);this.onStart.dispatch(this._object);this.isRunning=true;this._onStartCallbackFired=false;this._startTime=this.game.time.now+this._delayTime;for(var b in this._valuesEnd){if(this._valuesEnd[b] instanceof Array){if(this._valuesEnd[b].length===0){continue}this._valuesEnd[b]=[this._object[b]].concat(this._valuesEnd[b])}this._valuesStart[b]=this._object[b];if((this._valuesStart[b] instanceof Array)===false){this._valuesStart[b]*=1}this._valuesStartRepeat[b]=this._valuesStart[b]||0}return this},stop:function(){this._manager.remove(this);this.isRunning=false;return this},delay:function(b){this._delayTime=b;return this},repeat:function(b){this._repeat=b;return this},yoyo:function(b){this._yoyo=b;return this},easing:function(b){this._easingFunction=b;return this},interpolation:function(b){this._interpolationFunction=b;return this},chain:function(){this._chainedTweens=arguments;return this},onStart:function(b){this._onStartCallback=b;return this},onUpdate:function(b){this._onUpdateCallback=b;return this},onComplete:function(b){this._onCompleteCallback=b;return this},pause:function(){this._paused=true},resume:function(){this._paused=false;this._startTime+=this.game.time.pauseDuration},update:function(c){if(this._paused||c1?1:k;var h=this._easingFunction(k);for(j in this._valuesEnd){var b=this._valuesStart[j]||0;var d=this._valuesEnd[j];if(d instanceof Array){this._object[j]=this._interpolationFunction(d,h)}else{if(typeof(d)==="string"){d=b+parseFloat(d,10)}if(typeof(d)==="number"){this._object[j]=b+(d-b)*h}}}if(this._onUpdateCallback!==null){this._onUpdateCallback.call(this._object,h)}if(k==1){if(this._repeat>0){if(isFinite(this._repeat)){this._repeat--}for(j in this._valuesStartRepeat){if(typeof(this._valuesEnd[j])==="string"){this._valuesStartRepeat[j]=this._valuesStartRepeat[j]+parseFloat(this._valuesEnd[j],10)}if(this._yoyo){var e=this._valuesStartRepeat[j];this._valuesStartRepeat[j]=this._valuesEnd[j];this._valuesEnd[j]=e;this._reversed=!this._reversed}this._valuesStart[j]=this._valuesStartRepeat[j]}this._startTime=c+this._delayTime;this.onComplete.dispatch(this._object);if(this._onCompleteCallback!==null){this._onCompleteCallback.call(this._object)}return true}else{this.onComplete.dispatch(this._object);if(this._onCompleteCallback!==null){this._onCompleteCallback.call(this._object)}for(var f=0,g=this._chainedTweens.length;fthis._timeLastSecond+1000){this.fps=Math.round((this.frames*1000)/(this.now-this._timeLastSecond));this.fpsMin=this.game.math.min(this.fpsMin,this.fps);this.fpsMax=this.game.math.max(this.fpsMax,this.fps);this._timeLastSecond=this.now;this.frames=0}this.time=this.now;this.lastTime=b+this.timeToCall;this.physicsElapsed=1*(this.elapsed/1000);if(this.game.paused){this.pausedTime=this.now-this._pauseStarted}},gamePaused:function(){this._pauseStarted=this.now},gameResumed:function(){this.time=Date.now();this.pauseDuration=this.pausedTime;this._justResumed=true},elapsedSince:function(b){return this.now-b},elapsedSecondsSince:function(b){return(this.now-b)*0.001},reset:function(){this._started=this.now}};Phaser.AnimationManager=function(b){this._frameData=null;this.currentFrame=null;this.sprite=b;this.game=b.game;this._anims={};this.updateIfVisible=true};Phaser.AnimationManager.prototype={loadFrameData:function(b){this._frameData=b;this.frame=0},add:function(e,f,d,c,b){f=f||null;d=d||60;c=c||false;b=b||true;if(this._frameData==null){console.warn("No frameData available for Phaser.Animation "+e);return}if(this.sprite.events.onAnimationStart==null){this.sprite.events.onAnimationStart=new Phaser.Signal();this.sprite.events.onAnimationComplete=new Phaser.Signal();this.sprite.events.onAnimationLoop=new Phaser.Signal()}if(f==null){f=this._frameData.getFrameIndexes()}else{if(this.validateFrames(f,b)==false){console.warn("Invalid frames given to Phaser.Animation "+e);return}}if(b==false){f=this._frameData.getFrameIndexesByName(f)}this._anims[e]=new Phaser.Animation(this.game,this.sprite,this._frameData,e,f,d,c);this.currentAnim=this._anims[e];this.currentFrame=this.currentAnim.currentFrame;this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);return this._anims[e]},validateFrames:function(d,b){for(var c=0;cthis._frameData.total){return false}}else{if(this._frameData.checkFrameName(d[c])==false){return false}}}return true},play:function(d,c,b){c=c||null;b=b||null;if(this._anims[d]){if(this.currentAnim==this._anims[d]){if(this.currentAnim.isPlaying==false){return this.currentAnim.play(c,b)}}else{this.currentAnim=this._anims[d];return this.currentAnim.play(c,b)}}},stop:function(b){if(this._anims[b]){this.currentAnim=this._anims[b];this.currentAnim.stop()}},update:function(){if(this.updateIfVisible&&this.sprite.visible==false){return false}if(this.currentAnim&&this.currentAnim.update()==true){this.currentFrame=this.currentAnim.currentFrame;this.sprite.currentFrame=this.currentFrame;return true}return false},destroy:function(){this._anims={};this._frameData=null;this._frameIndex=0;this.currentAnim=null;this.currentFrame=null}};Object.defineProperty(Phaser.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}});Object.defineProperty(Phaser.AnimationManager.prototype,"frameTotal",{get:function(){if(this._frameData){return this._frameData.total}else{return -1}}});Object.defineProperty(Phaser.AnimationManager.prototype,"frame",{get:function(){if(this.currentFrame){return this._frameIndex}},set:function(b){if(this._frameData&&this._frameData.getFrame(b)!==null){this.currentFrame=this._frameData.getFrame(b);this._frameIndex=b;this.sprite.currentFrame=this.currentFrame;this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}}});Object.defineProperty(Phaser.AnimationManager.prototype,"frameName",{get:function(){if(this.currentFrame){return this.currentFrame.name}},set:function(b){if(this._frameData&&this._frameData.getFrameByName(b)){this.currentFrame=this._frameData.getFrameByName(b);this._frameIndex=this.currentFrame.index;this.sprite.currentFrame=this.currentFrame;this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}else{console.warn("Cannot set frameName: "+b)}}});Phaser.Animation=function(c,g,f,e,h,d,b){this.game=c;this._parent=g;this._frames=h;this._frameData=f;this.name=e;this.delay=1000/d;this.looped=b;this.isFinished=false;this.isPlaying=false;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])};Phaser.Animation.prototype={play:function(c,b){c=c||null;b=b||null;if(c!==null){this.delay=1000/c}if(b!==null){this.looped=b}this.isPlaying=true;this.isFinished=false;this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);this._parent.events.onAnimationStart.dispatch(this._parent,this);return this},restart:function(){this.isPlaying=true;this.isFinished=false;this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])},stop:function(){this.isPlaying=false;this.isFinished=true},update:function(){if(this.isPlaying==true&&this.game.time.now>=this._timeNextFrame){this._frameIndex++;if(this._frameIndex==this._frames.length){if(this.looped){this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);this._parent.events.onAnimationLoop.dispatch(this._parent,this)}else{this.onComplete()}}else{this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;return true}return false},destroy:function(){this.game=null;this._parent=null;this._frames=null;this._frameData=null;this.currentFrame=null;this.isPlaying=false},onComplete:function(){this.isPlaying=false;this.isFinished=true;this._parent.events.onAnimationComplete.dispatch(this._parent,this)}};Object.defineProperty(Phaser.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}});Object.defineProperty(Phaser.Animation.prototype,"frame",{get:function(){if(this.currentFrame!==null){return this.currentFrame.index}else{return this._frameIndex}},set:function(b){this.currentFrame=this._frameData.getFrame(b);if(this.currentFrame!==null){this._frameIndex=b;this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}}});Phaser.Animation.Frame=function(c,g,f,b,d,e){this.x=c;this.y=g;this.width=f;this.height=b;this.centerX=Math.floor(f/2);this.centerY=Math.floor(b/2);this.index=0;this.name=d;this.uuid=e;this.distance=Phaser.Math.distance(0,0,f,b);this.rotated=false;this.rotationDirection="cw";this.trimmed=false;this.sourceSizeW=f;this.sourceSizeH=b;this.spriteSourceSizeX=0;this.spriteSourceSizeY=0;this.spriteSourceSizeW=0;this.spriteSourceSizeH=0};Phaser.Animation.Frame.prototype={setTrim:function(f,e,h,c,b,d,g){this.trimmed=f;if(f){this.width=e;this.height=h;this.sourceSizeW=e;this.sourceSizeH=h;this.centerX=Math.floor(e/2);this.centerY=Math.floor(h/2);this.spriteSourceSizeX=c;this.spriteSourceSizeY=b;this.spriteSourceSizeW=d;this.spriteSourceSizeH=g}}};Phaser.Animation.FrameData=function(){this._frames=[];this._frameNames=[]};Phaser.Animation.FrameData.prototype={addFrame:function(b){b.index=this._frames.length;this._frames.push(b);if(b.name!==""){this._frameNames[b.name]=b.index}return b},getFrame:function(b){if(this._frames[b]){return this._frames[b]}return null},getFrameByName:function(b){if(this._frameNames[b]!==""){return this._frames[this._frameNames[b]]}return null},checkFrameName:function(b){if(this._frameNames[b]==null){return false}return true},getFrameRange:function(e,b,c){if(typeof c==="undefined"){c=[]}for(var d=e;d<=b;d++){c.push(this._frames[d])}return c},getFrameIndexes:function(b){if(typeof b==="undefined"){b=[]}for(var c=0;c tag");return}var d=new Phaser.Animation.FrameData();var j=g.getElementsByTagName("SubTexture");var f;for(var e=0;e0){this._progressChunk=100/this._keys.length;this.loadFile()}else{this.progress=100;this.hasLoaded=true;this.onLoadComplete.dispatch()}},loadFile:function(){var b=this._fileList[this._keys.shift()];var c=this;switch(b.type){case"image":case"spritesheet":case"textureatlas":case"bitmapfont":case"tilemap":b.data=new Image();b.data.name=b.key;b.data.onload=function(){return c.fileComplete(b.key)};b.data.onerror=function(){return c.fileError(b.key)};b.data.crossOrigin=this.crossOrigin;b.data.src=this.baseURL+b.url;break;case"audio":b.url=this.getAudioURL(b.url);if(b.url!==null){if(this.game.sound.usingWebAudio){this._xhr.open("GET",this.baseURL+b.url,true);this._xhr.responseType="arraybuffer";this._xhr.onload=function(){return c.fileComplete(b.key)};this._xhr.onerror=function(){return c.fileError(b.key)};this._xhr.send()}else{if(this.game.sound.usingAudioTag){if(this.game.sound.touchLocked){b.data=new Audio();b.data.name=b.key;b.data.preload="auto";b.data.src=this.baseURL+b.url;this.fileComplete(b.key)}else{b.data=new Audio();b.data.name=b.key;b.data.onerror=function(){return c.fileError(b.key)};b.data.preload="auto";b.data.src=this.baseURL+b.url;b.data.addEventListener("canplaythrough",Phaser.GAMES[this.game.id].load.fileComplete(b.key),false);b.data.load()}}}}else{this.fileError(b.key)}break;case"text":this._xhr.open("GET",this.baseURL+b.url,true);this._xhr.responseType="text";this._xhr.onload=function(){return c.fileComplete(b.key)};this._xhr.onerror=function(){return c.fileError(b.key)};this._xhr.send();break}},getAudioURL:function(c){var d;for(var b=0;b100){this.progress=100}this.onFileComplete.dispatch(this.progress,b,c,this.queueSize-this._keys.length,this.queueSize);if(this._keys.length>0){this.loadFile()}else{this.hasLoaded=true;this.isLoading=false;this.removeAll();this.onLoadComplete.dispatch()}}};Phaser.Loader.Parser={bitmapFont:function(q,h,l){if(!h.getElementsByTagName("font")){console.warn("Phaser.Loader.Parser.bitmapFont: Invalid XML given, missing tag");return}var m=PIXI.TextureCache[l];var e={};var c=h.getElementsByTagName("info")[0];var j=h.getElementsByTagName("common")[0];e.font=c.attributes.getNamedItem("face").nodeValue;e.size=parseInt(c.attributes.getNamedItem("size").nodeValue,10);e.lineHeight=parseInt(j.attributes.getNamedItem("lineHeight").nodeValue,10);e.chars={};var k=h.getElementsByTagName("char");for(var d=0;d=this.duration){if(this.usingWebAudio){if(this.loop){this.onLoop.dispatch(this);if(this.currentMarker==""){this.currentTime=0;this.startTime=this.game.time.now}else{this.play(this.currentMarker,0,this.volume,true,true)}}else{this.stop()}}else{if(this.loop){this.onLoop.dispatch(this);this.play(this.currentMarker,0,this.volume,true,true)}else{this.stop()}}}}},play:function(d,b,f,c,e){d=d||"";b=b||0;f=f||1;c=c||false;e=e||false;if(this.isPlaying==true&&e==false&&this.override==false){return}if(this.isPlaying&&this.override){if(this.usingWebAudio){if(typeof this._sound.stop==="undefined"){this._sound.noteOff(0)}else{this._sound.stop(0)}}else{if(this.usingAudioTag){this._sound.pause();this._sound.currentTime=0}}}this.currentMarker=d;if(d!==""&&this.markers[d]){this.position=this.markers[d].start;this.volume=this.markers[d].volume;this.loop=this.markers[d].loop;this.duration=this.markers[d].duration*1000;this._tempMarker=d;this._tempPosition=this.position;this._tempVolume=this.volume;this._tempLoop=this.loop}else{this.position=b;this.volume=f;this.loop=c;this.duration=0;this._tempMarker=d;this._tempPosition=b;this._tempVolume=f;this._tempLoop=c}if(this.usingWebAudio){if(this.game.cache.isSoundDecoded(this.key)){if(this._buffer==null){this._buffer=this.game.cache.getSoundData(this.key)}this._sound=this.context.createBufferSource();this._sound.buffer=this._buffer;this._sound.connect(this.gainNode);this.totalDuration=this._sound.buffer.duration;if(this.duration==0){this.duration=this.totalDuration*1000}if(this.loop&&d==""){this._sound.loop=true}if(typeof this._sound.start==="undefined"){this._sound.noteGrainOn(0,this.position,this.duration/1000)}else{this._sound.start(0,this.position,this.duration/1000)}this.isPlaying=true;this.startTime=this.game.time.now;this.currentTime=0;this.stopTime=this.startTime+this.duration;this.onPlay.dispatch(this)}else{this.pendingPlayback=true;if(this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).isDecoding==false){this.game.sound.decode(this.key,this)}}}else{if(this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked){this.game.cache.reloadSound(this.key);this.pendingPlayback=true}else{if(this._sound&&this._sound.readyState==4){this._sound.play();this.totalDuration=this._sound.duration;if(this.duration==0){this.duration=this.totalDuration*1000}this._sound.currentTime=this.position;this._sound.muted=this._muted;if(this._muted){this._sound.volume=0}else{this._sound.volume=this._volume}this.isPlaying=true;this.startTime=this.game.time.now;this.currentTime=0;this.stopTime=this.startTime+this.duration;this.onPlay.dispatch(this)}else{this.pendingPlayback=true}}}},restart:function(d,b,e,c){d=d||"";b=b||0;e=e||1;c=c||false;this.play(d,b,e,c,true)},pause:function(){if(this.isPlaying&&this._sound){this.stop();this.isPlaying=false;this.paused=true;this.onPause.dispatch(this)}},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){if(typeof this._sound.start==="undefined"){this._sound.noteGrainOn(0,this.position,this.duration)}else{this._sound.start(0,this.position,this.duration)}}else{this._sound.play()}this.isPlaying=true;this.paused=false;this.onResume.dispatch(this)}},stop:function(){if(this.isPlaying&&this._sound){if(this.usingWebAudio){if(typeof this._sound.stop==="undefined"){this._sound.noteOff(0)}else{this._sound.stop(0)}}else{if(this.usingAudioTag){this._sound.pause();this._sound.currentTime=0}}}this.isPlaying=false;var b=this.currentMarker;this.currentMarker="";this.onStop.dispatch(this,b)}};Object.defineProperty(Phaser.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}});Object.defineProperty(Phaser.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}});Object.defineProperty(Phaser.Sound.prototype,"mute",{get:function(){return this._muted},set:function(b){b=b||null;if(b){this._muted=true;if(this.usingWebAudio){this._muteVolume=this.gainNode.gain.value;this.gainNode.gain.value=0}else{if(this.usingAudioTag&&this._sound){this._muteVolume=this._sound.volume;this._sound.volume=0}}}else{this._muted=false;if(this.usingWebAudio){this.gainNode.gain.value=this._muteVolume}else{if(this.usingAudioTag&&this._sound){this._sound.volume=this._muteVolume}}}this.onMute.dispatch(this)}});Object.defineProperty(Phaser.Sound.prototype,"volume",{get:function(){return this._volume},set:function(b){if(this.usingWebAudio){this._volume=b;this.gainNode.gain.value=b}else{if(this.usingAudioTag&&this._sound){if(b>=0&&b<=1){this._volume=b;this._sound.volume=b}}}}});Phaser.SoundManager=function(b){this.game=b;this.onSoundDecode=new Phaser.Signal;this._muted=false;this._unlockSource=null;this._volume=1;this._muted=false;this._sounds=[];this.context=null;this.usingWebAudio=true;this.usingAudioTag=false;this.noAudio=false;this.touchLocked=false;this.channels=32};Phaser.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&this.game.device.webAudio==false){this.channels=1}if(this.game.device.iOS||(window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)){this.game.input.touch.callbackContext=this;this.game.input.touch.touchStartCallback=this.unlock;this.game.input.mouse.callbackContext=this;this.game.input.mouse.mouseDownCallback=this.unlock;this.touchLocked=true}else{this.touchLocked=false}if(window.PhaserGlobal){if(window.PhaserGlobal.disableAudio==true){this.usingWebAudio=false;this.noAudio=true;return}if(window.PhaserGlobal.disableWebAudio==true){this.usingWebAudio=false;this.usingAudioTag=true;this.noAudio=false;return}}if(!!window.AudioContext){this.context=new window.AudioContext()}else{if(!!window.webkitAudioContext){this.context=new window.webkitAudioContext()}else{if(!!window.Audio){this.usingWebAudio=false;this.usingAudioTag=true}else{this.usingWebAudio=false;this.noAudio=true}}}if(this.context!==null){if(typeof this.context.createGain==="undefined"){this.masterGain=this.context.createGainNode()}else{this.masterGain=this.context.createGain()}this.masterGain.gain.value=1;this.masterGain.connect(this.context.destination)}},unlock:function(){if(this.touchLocked==false){return}if(this.game.device.webAudio==false||(window.PhaserGlobal&&window.PhaserGlobal.disableWebAudio==true)){this.touchLocked=false;this._unlockSource=null;this.game.input.touch.callbackContext=null;this.game.input.touch.touchStartCallback=null;this.game.input.mouse.callbackContext=null;this.game.input.mouse.mouseDownCallback=null}else{var b=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource();this._unlockSource.buffer=b;this._unlockSource.connect(this.context.destination);this._unlockSource.noteOn(0)}},stopAll:function(){for(var b=0;b255){return Phaser.Color.getColor(255,255,255)}if(d>c){return Phaser.Color.getColor(255,255,255)}var f=d+Math.round(Math.random()*(c-d));var e=d+Math.round(Math.random()*(c-d));var b=d+Math.round(Math.random()*(c-d));return Phaser.Color.getColor32(g,f,e,b)},getRGB:function(b){return{alpha:b>>>24,red:b>>16&255,green:b>>8&255,blue:b&255}},getWebRGB:function(c){var f=(c>>>24)/255;var e=c>>16&255;var d=c>>8&255;var b=c&255;return"rgba("+e.toString()+","+d.toString()+","+b.toString()+","+f.toString()+")"},getAlpha:function(b){return b>>>24},getAlphaFloat:function(b){return(b>>>24)/255},getRed:function(b){return b>>16&255},getGreen:function(b){return b>>8&255},getBlue:function(b){return b&255}};Phaser.Physics={};Phaser.Physics.Arcade=function(b){this.game=b;this.gravity=new Phaser.Point;this.bounds=new Phaser.Rectangle(0,0,b.world.width,b.world.height);this.maxObjects=10;this.maxLevels=4;this.OVERLAP_BIAS=4;this.TILE_OVERLAP=false;this.quadTree=new Phaser.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels);this.quadTreeID=0;this._bounds1=new Phaser.Rectangle;this._bounds2=new Phaser.Rectangle;this._overlap=0;this._maxOverlap=0;this._velocity1=0;this._velocity2=0;this._newVelocity1=0;this._newVelocity2=0;this._average=0;this._mapData=[];this._result=false;this._total=0};Phaser.Physics.Arcade.prototype={updateMotion:function(b){this._velocityDelta=(this.computeVelocity(0,false,b.angularVelocity,b.angularAcceleration,b.angularDrag,b.maxAngular)-b.angularVelocity)/2;b.angularVelocity+=this._velocityDelta;b.rotation+=b.angularVelocity*this.game.time.physicsElapsed;this._velocityDelta=(this.computeVelocity(1,b,b.velocity.x,b.acceleration.x,b.drag.x)-b.velocity.x)/2;b.velocity.x+=this._velocityDelta;this._delta=b.velocity.x*this.game.time.physicsElapsed;b.x+=this._delta;this._velocityDelta=(this.computeVelocity(2,b,b.velocity.y,b.acceleration.y,b.drag.y)-b.velocity.y)/2;b.velocity.y+=this._velocityDelta;this._delta=b.velocity.y*this.game.time.physicsElapsed;b.y+=this._delta},computeVelocity:function(e,c,g,f,d,b){b=b||10000;if(e==1&&c.allowGravity){g+=this.gravity.x+c.gravity.x}else{if(e==2&&c.allowGravity){g+=this.gravity.y+c.gravity.y}}if(f!==0){g+=f*this.game.time.physicsElapsed}else{if(d!==0){this._drag=d*this.game.time.physicsElapsed;if(g-this._drag>0){g=g-this._drag}else{if(g+this._drag<0){g+=this._drag}else{g=0}}}}if(g!=0){if(g>b){g=b}else{if(g<-b){g=-b}}}return g},preUpdate:function(){this.quadTree.clear();this.quadTreeID=0;this.quadTree=new Phaser.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels)},postUpdate:function(){this.quadTree.clear()},collide:function(f,e,d,c,b){d=d||null;c=c||null;b=b||d;this._result=false;this._total=0;if(f&&e&&f.exists&&e.exists){if(f.type==Phaser.SPRITE&&e.type==Phaser.SPRITE){this.collideSpriteVsSprite(f,e,d,c,b)}else{if(f.type==Phaser.SPRITE&&e.type==Phaser.GROUP){this.collideSpriteVsGroup(f,e,d,c,b)}else{if(f.type==Phaser.GROUP&&e.type==Phaser.SPRITE){this.collideSpriteVsGroup(e,f,d,c,b)}else{if(f.type==Phaser.GROUP&&e.type==Phaser.GROUP){this.collideGroupVsGroup(f,e,d,c,b)}else{if(f.type==Phaser.SPRITE&&e.type==Phaser.TILEMAP){this.collideSpriteVsTilemap(f,e,d,c,b)}else{if(f.type==Phaser.TILEMAP&&e.type==Phaser.SPRITE){this.collideSpriteVsTilemap(e,f,d,c,b)}else{if(f.type==Phaser.GROUP&&e.type==Phaser.TILEMAP){this.collideGroupVsTilemap(f,e,d,c,b)}else{if(f.type==Phaser.TILEMAP&&e.type==Phaser.GROUP){this.collideGroupVsTilemap(e,f,d,c,b)}else{if(f.type==Phaser.EMITTER&&e.type==Phaser.TILEMAP){this.collideGroupVsTilemap(f,e,d,c,b)}else{if(f.type==Phaser.TILEMAP&&e.type==Phaser.EMITTER){this.collideGroupVsTilemap(e,f,d,c,b)}}}}}}}}}}}return(this._total>0)},collideSpriteVsSprite:function(f,e,d,c,b){this.separate(f.body,e.body);if(this._result){if(c){if(c.call(b,f,e)){this._total++;if(d){d.call(b,f,e)}}}else{this._total++;if(d){d.call(b,f,e)}}}},collideGroupVsTilemap:function(g,f,e,d,b){if(g._container.first._iNext){var c=g._container.first._iNext;do{if(c.exists){this.collideSpriteVsTilemap(c,f,e,d,b)}c=c._iNext}while(c!=g._container.last._iNext)}},collideSpriteVsTilemap:function(d,g,f,e,b){this._mapData=g.collisionLayer.getTileOverlaps(d);var c=this._mapData.length;while(c--){if(e){if(e.call(b,d,this._mapData[c].tile)){this._total++;if(f){f.call(b,d,this._mapData[c].tile)}}}else{this._total++;if(f){f.call(b,d,this._mapData[c].tile)}}}},collideSpriteVsGroup:function(e,h,g,f,c){this._potentials=this.quadTree.retrieve(e);for(var d=0,b=this._potentials.length;d0)?c.deltaX():0),c.lastY,c.width+((c.deltaX()>0)?c.deltaX():-c.deltaX()),c.height);this._bounds2.setTo(b.x-((b.deltaX()>0)?b.deltaX():0),b.lastY,b.width+((b.deltaX()>0)?b.deltaX():-b.deltaX()),b.height);if((this._bounds1.right>this._bounds2.x)&&(this._bounds1.xthis._bounds2.y)&&(this._bounds1.yb.deltaX()){this._overlap=c.x+c.width-b.x;if((this._overlap>this._maxOverlap)||c.allowCollision.right==false||b.allowCollision.left==false){this._overlap=0}else{c.touching.right=true;b.touching.left=true}}else{if(c.deltaX()this._maxOverlap)||c.allowCollision.left==false||b.allowCollision.right==false){this._overlap=0}else{c.touching.left=true;b.touching.right=true}}}}}if(this._overlap!=0){c.overlapX=this._overlap;b.overlapX=this._overlap;if(c.customSeparateX||b.customSeparateX){return true}this._velocity1=c.velocity.x;this._velocity2=b.velocity.x;if(!c.immovable&&!b.immovable){this._overlap*=0.5;c.x=c.x-this._overlap;b.x+=this._overlap;this._newVelocity1=Math.sqrt((this._velocity2*this._velocity2*b.mass)/c.mass)*((this._velocity2>0)?1:-1);this._newVelocity2=Math.sqrt((this._velocity1*this._velocity1*c.mass)/b.mass)*((this._velocity1>0)?1:-1);this._average=(this._newVelocity1+this._newVelocity2)*0.5;this._newVelocity1-=this._average;this._newVelocity2-=this._average;c.velocity.x=this._average+this._newVelocity1*c.bounce.x;b.velocity.x=this._average+this._newVelocity2*b.bounce.x}else{if(!c.immovable){c.x=c.x-this._overlap;c.velocity.x=this._velocity2-this._velocity1*c.bounce.x}else{if(!b.immovable){b.x+=this._overlap;b.velocity.x=this._velocity1-this._velocity2*b.bounce.x}}}return true}else{return false}},separateY:function(c,b){if(c.immovable&&b.immovable){return false}this._overlap=0;if(c.deltaY()!=b.deltaY()){this._bounds1.setTo(c.x,c.y-((c.deltaY()>0)?c.deltaY():0),c.width,c.height+c.deltaAbsY());this._bounds2.setTo(b.x,b.y-((b.deltaY()>0)?b.deltaY():0),b.width,b.height+b.deltaAbsY());if((this._bounds1.right>this._bounds2.x)&&(this._bounds1.xthis._bounds2.y)&&(this._bounds1.yb.deltaY()){this._overlap=c.y+c.height-b.y;if((this._overlap>this._maxOverlap)||c.allowCollision.down==false||b.allowCollision.up==false){this._overlap=0}else{c.touching.down=true;b.touching.up=true}}else{if(c.deltaY()this._maxOverlap)||c.allowCollision.up==false||b.allowCollision.down==false){this._overlap=0}else{c.touching.up=true;b.touching.down=true}}}}}if(this._overlap!=0){c.overlapY=this._overlap;b.overlapY=this._overlap;if(c.customSeparateY||b.customSeparateY){return true}this._velocity1=c.velocity.y;this._velocity2=b.velocity.y;if(!c.immovable&&!b.immovable){this._overlap*=0.5;c.y=c.y-this._overlap;b.y+=this._overlap;this._newVelocity1=Math.sqrt((this._velocity2*this._velocity2*b.mass)/c.mass)*((this._velocity2>0)?1:-1);this._newVelocity2=Math.sqrt((this._velocity1*this._velocity1*c.mass)/b.mass)*((this._velocity1>0)?1:-1);this._average=(this._newVelocity1+this._newVelocity2)*0.5;this._newVelocity1-=this._average;this._newVelocity2-=this._average;c.velocity.y=this._average+this._newVelocity1*c.bounce.y;b.velocity.y=this._average+this._newVelocity2*b.bounce.y}else{if(!c.immovable){c.y=c.y-this._overlap;c.velocity.y=this._velocity2-this._velocity1*c.bounce.y;if(b.active&&b.moves&&(c.deltaY()>b.deltaY())){c.x+=b.x-b.lastX}}else{if(!b.immovable){b.y+=this._overlap;b.velocity.y=this._velocity1-this._velocity2*b.bounce.y;if(c.sprite.active&&c.moves&&(c.deltaY()h)&&(this._bounds1.xg)&&(this._bounds1.yh)&&(this._bounds1.xg)&&(this._bounds1.y0){this._overlap=d.bottom-g;if(d.allowCollision.down&&b&&this._overlap0){var h=this.distanceBetween(g,e);f=h/(c/1000)}g.body.velocity.x=Math.cos(b)*f;g.body.velocity.y=Math.sin(b)*f},accelerateTowardsObject:function(f,d,e,b,g){b=b||1000;g=g||1000;var c=this.angleBetween(f,d);f.body.velocity.x=0;f.body.velocity.y=0;f.body.acceleration.x=Math.cos(c)*e;f.body.acceleration.y=Math.sin(c)*e;f.body.maxVelocity.x=b;f.body.maxVelocity.y=g},moveTowardsMouse:function(f,e,c){e=e||60;c=c||0;var b=this.angleBetweenMouse(f);if(c>0){var g=this.distanceToMouse(f);e=g/(c/1000)}f.body.velocity.x=Math.cos(b)*e;f.body.velocity.y=Math.sin(b)*e},accelerateTowardsMouse:function(e,d,b,f){b=b||1000;f=f||1000;var c=this.angleBetweenMouse(e);e.body.velocity.x=0;e.body.velocity.y=0;e.body.acceleration.x=Math.cos(c)*d;e.body.acceleration.y=Math.sin(c)*d;e.body.maxVelocity.x=b;e.body.maxVelocity.y=f},moveTowardsPoint:function(f,g,e,c){e=e||60;c=c||0;var b=this.angleBetweenPoint(f,g);if(c>0){var h=this.distanceToPoint(f,g);e=h/(c/1000)}f.body.velocity.x=Math.cos(b)*e;f.body.velocity.y=Math.sin(b)*e},accelerateTowardsPoint:function(e,f,d,b,g){b=b||1000;g=g||1000;var c=this.angleBetweenPoint(e,f);e.body.velocity.x=0;e.body.velocity.y=0;e.body.acceleration.x=Math.cos(c)*d;e.body.acceleration.y=Math.sin(c)*d;e.body.maxVelocity.x=b;e.body.maxVelocity.y=g},distanceBetween:function(e,c){var f=e.center.x-c.center.x;var d=e.center.y-c.center.y;return Math.sqrt(f*f+d*d)},distanceToPoint:function(c,e){var d=c.center.x-e.x;var b=c.center.y-e.y;return Math.sqrt(d*d+b*b)},distanceToMouse:function(c){var d=c.center.x-this.game.input.x;var b=c.center.y-this.game.input.y;return Math.sqrt(d*d+b*b)},angleBetweenPoint:function(c,f,e){e=e||false;var d=f.x-c.center.x;var b=f.y-c.center.y;if(e){return this.game.math.radToDeg(Math.atan2(b,d))}else{return Math.atan2(b,d)}},angleBetween:function(e,c,g){g=g||false;var f=c.center.x-e.center.x;var d=c.center.y-e.center.y;if(g){return this.game.math.radToDeg(Math.atan2(d,f))}else{return Math.atan2(d,f)}},velocityFromFacing:function(b,c){},angleBetweenMouse:function(c,e){e=e||false;var d=this.game.input.x-c.bounds.x;var b=this.game.input.y-c.bounds.y;if(e){return this.game.math.radToDeg(Math.atan2(b,d))}else{return Math.atan2(b,d)}}};Phaser.Physics.Arcade.Body=function(b){this.sprite=b;this.game=b.game;this.offset=new Phaser.Point;this.x=b.x;this.y=b.y;this.sourceWidth=b.currentFrame.sourceSizeW;this.sourceHeight=b.currentFrame.sourceSizeH;this.width=b.currentFrame.sourceSizeW;this.height=b.currentFrame.sourceSizeH;this.halfWidth=Math.floor(b.currentFrame.sourceSizeW/2);this.halfHeight=Math.floor(b.currentFrame.sourceSizeH/2);this._sx=b.scale.x;this._sy=b.scale.y;this.velocity=new Phaser.Point;this.acceleration=new Phaser.Point;this.drag=new Phaser.Point;this.gravity=new Phaser.Point;this.bounce=new Phaser.Point;this.maxVelocity=new Phaser.Point(10000,10000);this.angularVelocity=0;this.angularAcceleration=0;this.angularDrag=0;this.maxAngular=1000;this.mass=1;this.quadTreeIDs=[];this.quadTreeIndex=-1;this.allowCollision={none:false,any:true,up:true,down:true,left:true,right:true};this.touching={none:true,up:false,down:false,left:false,right:false};this.wasTouching={none:true,up:false,down:false,left:false,right:false};this.immovable=false;this.moves=true;this.rotation=0;this.allowRotation=true;this.allowGravity=true;this.customSeparateX=false;this.customSeparateY=false;this.overlapX=0;this.overlapY=0;this.collideWorldBounds=false;this.lastX=b.x;this.lastY=b.y};Phaser.Physics.Arcade.Body.prototype={updateBounds:function(e,d,c,b){if(c!=this._sx||b!=this._sy){this.width=this.sourceWidth*c;this.height=this.sourceHeight*b;this.halfWidth=Math.floor(this.width/2);this.halfHeight=Math.floor(this.height/2);this._sx=c;this._sy=b}},update:function(){this.wasTouching.none=this.touching.none;this.wasTouching.up=this.touching.up;this.wasTouching.down=this.touching.down;this.wasTouching.left=this.touching.left;this.wasTouching.right=this.touching.right;this.touching.none=true;this.touching.up=false;this.touching.down=false;this.touching.left=false;this.touching.right=false;this.lastX=this.x;this.lastY=this.y;this.rotation=this.sprite.angle;this.x=(this.sprite.x-(this.sprite.anchor.x*this.width))+this.offset.x;this.y=(this.sprite.y-(this.sprite.anchor.y*this.height))+this.offset.y;if(this.moves){this.game.physics.updateMotion(this)}if(this.collideWorldBounds){this.checkWorldBounds()}if(this.allowCollision.none==false&&this.sprite.visible&&this.sprite.alive){this.quadTreeIDs=[];this.quadTreeIndex=-1;this.game.physics.quadTree.insert(this)}this.sprite.x=this.x-this.offset.x+(this.sprite.anchor.x*this.width);this.sprite.y=this.y-this.offset.y+(this.sprite.anchor.y*this.height);if(this.allowRotation){this.sprite.angle=this.rotation}},postUpdate:function(){this.sprite.x=this.x-this.offset.x+(this.sprite.anchor.x*this.width);this.sprite.y=this.y-this.offset.y+(this.sprite.anchor.y*this.height);if(this.allowRotation){this.sprite.angle=this.rotation}},checkWorldBounds:function(){if(this.xthis.game.world.bounds.right){this.x=this.game.world.bounds.right-this.width;this.velocity.x*=-this.bounce.x}}if(this.ythis.game.world.bounds.bottom){this.y=this.game.world.bounds.bottom-this.height;this.velocity.y*=-this.bounce.y}}},setSize:function(d,c,b,e){b=b||this.offset.x;e=e||this.offset.y;this.sourceWidth=d;this.sourceHeight=c;this.width=this.sourceWidth*this._sx;this.height=this.sourceHeight*this._sy;this.halfWidth=Math.floor(this.width/2);this.halfHeight=Math.floor(this.height/2);this.offset.setTo(b,e)},reset:function(){this.velocity.setTo(0,0);this.acceleration.setTo(0,0);this.angularVelocity=0;this.angularAcceleration=0;this.x=(this.sprite.x-(this.sprite.anchor.x*this.width))+this.offset.x;this.y=(this.sprite.y-(this.sprite.anchor.y*this.height))+this.offset.y;this.lastX=this.x;this.lastY=this.y},deltaAbsX:function(){return(this.deltaX()>0?this.deltaX():-this.deltaX())},deltaAbsY:function(){return(this.deltaY()>0?this.deltaY():-this.deltaY())},deltaX:function(){return this.x-this.lastX},deltaY:function(){return this.y-this.lastY}};Object.defineProperty(Phaser.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.y+this.height},set:function(b){if(b<=this.y){this.height=0}else{this.height=(this.y-b)}}});Object.defineProperty(Phaser.Physics.Arcade.Body.prototype,"right",{get:function(){return this.x+this.width},set:function(b){if(b<=this.x){this.width=0}else{this.width=this.x+b}}});Phaser.Particles=function(b){this.emitters={};this.ID=0};Phaser.Particles.prototype={emitters:null,add:function(b){this.emitters[b.name]=b;return b},remove:function(b){delete this.emitters[b.name]},update:function(){for(var b in this.emitters){if(this.emitters[b].exists){this.emitters[b].update()}}}};Phaser.Particles.Arcade={};Phaser.Particles.Arcade.Emitter=function(c,b,e,d){d=d||50;Phaser.Group.call(this,c);this.name="emitter"+this.game.particles.ID++;this.type=Phaser.EMITTER;this.x=0;this.y=0;this.width=1;this.height=1;this.minParticleSpeed=new Phaser.Point(-100,-100);this.maxParticleSpeed=new Phaser.Point(100,100);this.minParticleScale=1;this.maxParticleScale=1;this.minRotation=-360;this.maxRotation=360;this.gravity=2;this.particleClass=null;this.particleDrag=new Phaser.Point();this.frequency=100;this.maxParticles=d;this.lifespan=2000;this.bounce=0;this._quantity=0;this._timer=0;this._counter=0;this._explode=true;this.on=false;this.exists=true;this.emitX=b;this.emitY=e};Phaser.Particles.Arcade.Emitter.prototype=Object.create(Phaser.Group.prototype);Phaser.Particles.Arcade.Emitter.prototype.constructor=Phaser.Particles.Arcade.Emitter;Phaser.Particles.Arcade.Emitter.prototype.update=function(){if(this.on){if(this._explode){this._counter=0;do{this.emitParticle();this._counter++}while(this._counter=this._timer){this.emitParticle();this._counter++;if(this._quantity>0){if(this._counter>=this._quantity){this.on=false}}this._timer=this.game.time.now+this.frequency}}}};Phaser.Particles.Arcade.Emitter.prototype.makeParticles=function(d,h,f,e){if(typeof h=="undefined"){h=0}f=f||this.maxParticles;e=e||0;var j;var b=0;var c=d;var g=0;while(b0){j.body.allowCollision.any=true;j.body.allowCollision.none=false}else{j.body.allowCollision.none=true}j.exists=false;j.visible=false;j.anchor.setTo(0.5,0.5);this.add(j);b++}return this};Phaser.Particles.Arcade.Emitter.prototype.kill=function(){this.on=false;this.alive=false;this.exists=false};Phaser.Particles.Arcade.Emitter.prototype.revive=function(){this.alive=true;this.exists=true};Phaser.Particles.Arcade.Emitter.prototype.start=function(b,e,d,c){if(typeof b!=="boolean"){b=true}e=e||0;d=d||250;c=c||0;this.revive();this.visible=true;this.on=true;this._explode=b;this.lifespan=e;this.frequency=d;this._quantity+=c;this._counter=0;this._timer=this.game.time.now+d};Phaser.Particles.Arcade.Emitter.prototype.emitParticle=function(){var c=this.getFirstExists(false);if(c==null){return}if(this.width>1||this.height>1){c.reset(this.emiteX-this.game.rnd.integerInRange(this.left,this.right),this.emiteY-this.game.rnd.integerInRange(this.top,this.bottom))}else{c.reset(this.emitX,this.emitY)}c.lifespan=this.lifespan;c.body.bounce.setTo(this.bounce,this.bounce);if(this.minParticleSpeed.x!=this.maxParticleSpeed.x){c.body.velocity.x=this.game.rnd.integerInRange(this.minParticleSpeed.x,this.maxParticleSpeed.x)}else{c.body.velocity.x=this.minParticleSpeed.x}if(this.minParticleSpeed.y!=this.maxParticleSpeed.y){c.body.velocity.y=this.game.rnd.integerInRange(this.minParticleSpeed.y,this.maxParticleSpeed.y)}else{c.body.velocity.y=this.minParticleSpeed.y}c.body.gravity.y=this.gravity;if(this.minRotation!=this.maxRotation){c.body.angularVelocity=this.game.rnd.integerInRange(this.minRotation,this.maxRotation)}else{c.body.angularVelocity=this.minRotation}if(this.minParticleScale!==1||this.maxParticleScale!==1){var b=this.game.rnd.realInRange(this.minParticleScale,this.maxParticleScale);c.scale.setTo(b,b)}c.body.drag.x=this.particleDrag.x;c.body.drag.y=this.particleDrag.y};Phaser.Particles.Arcade.Emitter.prototype.setSize=function(c,b){this.width=c;this.height=b};Phaser.Particles.Arcade.Emitter.prototype.setXSpeed=function(c,b){c=c||0;b=b||0;this.minParticleSpeed.x=c;this.maxParticleSpeed.x=b};Phaser.Particles.Arcade.Emitter.prototype.setYSpeed=function(c,b){c=c||0;b=b||0;this.minParticleSpeed.y=c;this.maxParticleSpeed.y=b};Phaser.Particles.Arcade.Emitter.prototype.setRotation=function(c,b){c=c||0;b=b||0;this.minRotation=c;this.maxRotation=b};Phaser.Particles.Arcade.Emitter.prototype.at=function(b){this.emitX=b.center.x;this.emitY=b.center.y};Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"alpha",{get:function(){return this._container.alpha},set:function(b){this._container.alpha=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"visible",{get:function(){return this._container.visible},set:function(b){this._container.visible=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(b){this.emitX=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(b){this.emitY=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-(this.width/2))}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+(this.width/2))}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-(this.height/2))}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+(this.height/2))}});Phaser.Tilemap=function(d,e,b,i,g,h,c){if(typeof g==="undefined"){g=true}if(typeof h==="undefined"){h=0}if(typeof c==="undefined"){c=0}this.game=d;this.group=null;this.name="";this.key=e;this.renderOrderID=0;this.collisionCallback=null;this.exists=true;this.visible=true;this.tiles=[];this.layers=[];var f=this.game.cache.getTilemap(e);PIXI.DisplayObjectContainer.call(this);this.position.x=b;this.position.y=i;this.type=Phaser.TILEMAP;this.renderer=new Phaser.TilemapRenderer(this.game);this.mapFormat=f.format;switch(this.mapFormat){case Phaser.Tilemap.CSV:this.parseCSV(f.mapData,e,h,c);break;case Phaser.Tilemap.JSON:this.parseTiledJSON(f.mapData,e);break}if(this.currentLayer&&g){this.game.world.setSize(this.currentLayer.widthInPixels,this.currentLayer.heightInPixels,true)}};Phaser.Tilemap.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);Phaser.Tilemap.prototype.constructor=Phaser.Tilemap;Phaser.Tilemap.CSV=0;Phaser.Tilemap.JSON=1;Phaser.Tilemap.prototype.parseCSV=function(d,j,h,g){var f=new Phaser.TilemapLayer(this,0,j,Phaser.Tilemap.CSV,"TileLayerCSV"+this.layers.length.toString(),h,g);d=d.trim();var k=d.split("\n");for(var e=0;e0){f.addColumn(c)}}f.updateBounds();f.createCanvas();var b=f.parseTileOffsets();this.currentLayer=f;this.collisionLayer=f;this.layers.push(f);this.generateTiles(b)};Phaser.Tilemap.prototype.parseTiledJSON=function(g,f){for(var e=0;e0){this.collisionCallback.call(this.collisionCallbackContext,b,this._tempCollisionData)}return true}else{return false}};Phaser.Tilemap.prototype.putTile=function(b,e,c,d){if(typeof d==="undefined"){d=this.currentLayer.ID}this.layers[d].putTile(b,e,c)};Phaser.Tilemap.prototype.update=function(){this.renderer.render(this)};Phaser.Tilemap.prototype.destroy=function(){this.tiles.length=0;this.layers.length=0};Object.defineProperty(Phaser.Tilemap.prototype,"widthInPixels",{get:function(){return this.currentLayer.widthInPixels}});Object.defineProperty(Phaser.Tilemap.prototype,"heightInPixels",{get:function(){return this.currentLayer.heightInPixels}});Phaser.TilemapLayer=function(f,i,e,d,c,h,b){this.exists=true;this.visible=true;this.widthInTiles=0;this.heightInTiles=0;this.widthInPixels=0;this.heightInPixels=0;this.tileMargin=0;this.tileSpacing=0;this.parent=f;this.game=f.game;this.ID=i;this.name=c;this.key=e;this.type=Phaser.TILEMAPLAYER;this.mapFormat=d;this.tileWidth=h;this.tileHeight=b;this.boundsInTiles=new Phaser.Rectangle();var g=this.game.cache.getTilemap(e);this.tileset=g.data;this._alpha=1;this.canvas=null;this.context=null;this.baseTexture=null;this.texture=null;this.sprite=null;this.mapData=[];this._tempTileBlock=[];this._tempBlockResults=[]};Phaser.TilemapLayer.prototype={putTileWorldXY:function(b,d,c){b=this.game.math.snapToFloor(b,this.tileWidth)/this.tileWidth;d=this.game.math.snapToFloor(d,this.tileHeight)/this.tileHeight;if(d>=0&&d=0&&b=0&&d=0&&bthis.widthInPixels||b.body.y<0||b.body.bottom>this.heightInPixels){return this._tempBlockResults}this._tempTileX=this.game.math.snapToFloor(b.body.x,this.tileWidth)/this.tileWidth;this._tempTileY=this.game.math.snapToFloor(b.body.y,this.tileHeight)/this.tileHeight;this._tempTileW=(this.game.math.snapToCeil(b.body.width,this.tileWidth)+this.tileWidth)/this.tileWidth;this._tempTileH=(this.game.math.snapToCeil(b.body.height,this.tileHeight)+this.tileHeight)/this.tileHeight;this.getTempBlock(this._tempTileX,this._tempTileY,this._tempTileW,this._tempTileH,true);for(var c=0;cthis.widthInTiles){g=this.widthInTiles}if(c>this.heightInTiles){c=this.heightInTiles}this._tempTileBlock=[];for(var b=h;b=0&&c=0&&bb.widthInTiles){this._maxX=b.widthInTiles}if(this._maxY>b.heightInTiles){this._maxY=b.heightInTiles}if(this._startX+this._maxX>b.widthInTiles){this._startX=b.widthInTiles-this._maxX}if(this._startY+this._maxY>b.heightInTiles){this._startY=b.heightInTiles-this._maxY}this._dx=-(this.game.camera.x-(this._startX*b.tileWidth));this._dy=-(this.game.camera.y-(this._startY*b.tileHeight));this._tx=this._dx;this._ty=this._dy;if(b.alpha!==1){this._ga=b.context.globalAlpha;b.context.globalAlpha=b.alpha}b.context.clearRect(0,0,b.canvas.width,b.canvas.height);for(var f=this._startY;f-1){b.context.globalAlpha=this._ga}if(this.game.renderType==Phaser.WEBGL){PIXI.texturesToUpdate.push(b.baseTexture)}}return true}}; \ No newline at end of file diff --git a/Docs/Phaser Logo/Pixel Art/phaser logo sprite.gif b/Docs/Phaser Logo/Pixel Art/phaser logo sprite.gif deleted file mode 100644 index c66b810c..00000000 Binary files a/Docs/Phaser Logo/Pixel Art/phaser logo sprite.gif and /dev/null differ diff --git a/Docs/Phaser Logo/concepts/PHASER logotype vector 02.fla b/Docs/Phaser Logo/concepts/PHASER logotype vector 02.fla deleted file mode 100644 index 19b1e7a3..00000000 Binary files a/Docs/Phaser Logo/concepts/PHASER logotype vector 02.fla and /dev/null differ diff --git a/Docs/Phaser Logo/concepts/phaser vector final.png b/Docs/Phaser Logo/concepts/phaser vector final.png deleted file mode 100644 index 11668258..00000000 Binary files a/Docs/Phaser Logo/concepts/phaser vector final.png and /dev/null differ diff --git a/Docs/Phaser Logo/concepts/phaserWIP4.png b/Docs/Phaser Logo/concepts/phaserWIP4.png deleted file mode 100644 index aa2af7fd..00000000 Binary files a/Docs/Phaser Logo/concepts/phaserWIP4.png and /dev/null differ diff --git a/Docs/docs_build.bat b/Docs/docs_build.bat deleted file mode 100644 index 95cc9ce7..00000000 --- a/Docs/docs_build.bat +++ /dev/null @@ -1 +0,0 @@ -yuidoc -c ../Phaser/yuidoc.json -o API/ -t yuidoc-theme-dana -e .ts ../Phaser/time \ No newline at end of file diff --git a/Docs/docs_server.bat b/Docs/docs_server.bat deleted file mode 100644 index 05d5d3d6..00000000 --- a/Docs/docs_server.bat +++ /dev/null @@ -1 +0,0 @@ -yuidoc -n -e .ts --server 3000 ../Phaser/time \ No newline at end of file diff --git a/Docs/tags.txt b/Docs/tags.txt deleted file mode 100644 index 3a300098..00000000 --- a/Docs/tags.txt +++ /dev/null @@ -1,47 +0,0 @@ -/** -* @author Richard Davey -* @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser -*/ - -/** -* The class constructor -* -* @class Name -* @constructor -* @param {Phaser.Game} game A reference to the currently running game. -*/ - -/** -* A reference to the currently running Game. -* @property game -* @type {Phaser.Game} -*/ -public game: Phaser.Game; - -/** -* My method description. Like other pieces of your comment blocks, -* this can span multiple lines. -* -* @method methodName -* @param {String} foo Argument 1 -* @param {Object} config A config object -* @param {String} config.name The name on the config object -* @param {Function} config.callback A callback function on the config object -* @param {Boolean} [extra=false] Do extra, optional work -* @return {Boolean} Returns true on success -*/ - -/** -* Property description. -* -* @property propertyName -* @public @private -* @type {Object} -* @default "foo" -*/ - -@param {Type} Name Description -Object, Array, String, Boolean, Number, Mixed, MyType - diff --git a/Docs/yuidoc-theme-dana b/Docs/yuidoc-theme-dana deleted file mode 160000 index f4dea8f2..00000000 --- a/Docs/yuidoc-theme-dana +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f4dea8f2cc6cfac28244dd35b62d9f3cffe0291c diff --git a/GruntFile.js b/GruntFile.js deleted file mode 100644 index e83f27d1..00000000 --- a/GruntFile.js +++ /dev/null @@ -1,80 +0,0 @@ -module.exports = function (grunt) { - grunt.loadNpmTasks('grunt-typescript'); - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-contrib-copy'); - - var wrapPhaserInUmd = function(content, isAddon) { - var replacement = [ - '(function (root, factory) {', - ' if (typeof exports === \'object\') {', - ' module.exports = factory();', - ' } else if (typeof define === \'function\' && define.amd) {', - ' define(factory);', - ' } else {', - ' root.Phaser = factory();', - ' }', - '}(this, function () {', - content, - 'return Phaser;', - '}));' - ]; - return replacement.join('\n'); - }; - - var wrapAddonInUmd = function(content) { - var replacement = [ - '(function (root, factory) {', - ' if (typeof exports === \'object\') {', - ' module.exports = factory(require(\'phaser\'));', - ' } else if (typeof define === \'function\' && define.amd) {', - ' define([\'phaser\'], factory);', - ' } else {', - ' factory(root.Phaser);', - ' }', - '}(this, function (Phaser) {', - content, - 'return Phaser;', - '}));' - ]; - return replacement.join('\n'); - }; - - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - typescript: { - base: { - src: ['Phaser/**/*.ts'], - dest: 'build/phaser.js', - options: { - target: 'ES5', - declaration: true, - comments: true - } - }, - }, - copy: { - main: { - files: [{ - src: 'build/phaser.js', - dest: 'Tests/phaser.js' - }] - }, - mainAmd: { - files: [{ - src: 'build/phaser.js', - dest: 'build/phaser.amd.js' - }], - options: { - processContent: wrapPhaserInUmd - } - }, - }, - watch: { - files: '**/*.ts', - tasks: ['typescript', 'copy'] - } - }); - - grunt.registerTask('default', ['typescript', 'copy', 'watch']); - -} diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 00000000..0e12c14b --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,168 @@ +module.exports = function (grunt) { + + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-connect'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadTasks('./tasks'); + + grunt.initConfig({ + compile_dir: 'dist', + src: { + phaser: [ + 'src/Intro.js', + 'src/pixi/Pixi.js', + 'src/Phaser.js', + 'src/utils/Utils.js', + 'src/pixi/core/Matrix.js', + 'src/pixi/core/Point.js', + 'src/pixi/core/Rectangle.js', + 'src/pixi/display/DisplayObject.js', + 'src/pixi/display/DisplayObjectContainer.js', + 'src/pixi/display/Sprite.js', + 'src/pixi/display/Stage.js', + 'src/pixi/extras/CustomRenderable.js', + 'src/pixi/extras/Strip.js', + 'src/pixi/extras/Rope.js', + 'src/pixi/extras/TilingSprite.js', + 'src/pixi/filters/FilterBlock.js', + 'src/pixi/filters/MaskFilter.js', + 'src/pixi/primitives/Graphics.js', + 'src/pixi/renderers/canvas/CanvasGraphics.js', + 'src/pixi/renderers/canvas/CanvasRenderer.js', + 'src/pixi/renderers/webgl/WebGLBatch.js', + 'src/pixi/renderers/webgl/WebGLGraphics.js', + 'src/pixi/renderers/webgl/WebGLRenderer.js', + 'src/pixi/renderers/webgl/WebGLRenderGroup.js', + 'src/pixi/renderers/webgl/WebGLShaders.js', + 'src/pixi/text/BitmapText.js', + 'src/pixi/text/Text.js', + 'src/pixi/textures/BaseTexture.js', + 'src/pixi/textures/Texture.js', + 'src/pixi/textures/RenderTexture.js', + 'src/pixi/utils/EventTarget.js', + 'src/pixi/utils/Polyk.js', + 'src/core/Camera.js', + 'src/core/State.js', + 'src/core/StateManager.js', + 'src/core/LinkedList.js', + 'src/core/Signal.js', + 'src/core/SignalBinding.js', + 'src/core/Plugin.js', + 'src/core/PluginManager.js', + 'src/core/Stage.js', + 'src/core/Group.js', + 'src/core/World.js', + 'src/core/Game.js', + 'src/input/Input.js', + 'src/input/Key.js', + 'src/input/Keyboard.js', + 'src/input/Mouse.js', + 'src/input/MSPointer.js', + 'src/input/Pointer.js', + 'src/input/Touch.js', + 'src/input/InputHandler.js', + 'src/gameobjects/Events.js', + 'src/gameobjects/GameObjectFactory.js', + 'src/gameobjects/Sprite.js', + 'src/gameobjects/TileSprite.js', + 'src/gameobjects/Text.js', + 'src/gameobjects/BitmapText.js', + 'src/gameobjects/Button.js', + 'src/gameobjects/Graphics.js', + 'src/gameobjects/RenderTexture.js', + 'src/system/Canvas.js', + 'src/system/StageScaleMode.js', + 'src/system/Device.js', + 'src/system/RequestAnimationFrame.js', + 'src/math/RandomDataGenerator.js', + 'src/math/Math.js', + 'src/math/QuadTree.js', + 'src/geom/Circle.js', + 'src/geom/Point.js', + 'src/geom/Rectangle.js', + 'src/net/Net.js', + 'src/tween/TweenManager.js', + 'src/tween/Tween.js', + 'src/tween/Easing.js', + 'src/time/Time.js', + 'src/animation/AnimationManager.js', + 'src/animation/Animation.js', + 'src/animation/Frame.js', + 'src/animation/FrameData.js', + 'src/animation/AnimationParser.js', + 'src/loader/Cache.js', + 'src/loader/Loader.js', + 'src/loader/LoaderParser.js', + 'src/sound/Sound.js', + 'src/sound/SoundManager.js', + 'src/utils/Debug.js', + 'src/utils/Color.js', + 'src/physics/arcade/ArcadePhysics.js', + 'src/physics/arcade/Body.js', + 'src/particles/Particles.js', + 'src/particles/arcade/ArcadeParticles.js', + 'src/particles/arcade/Emitter.js', + 'src/tilemap/Tile.js', + 'src/tilemap/Tilemap.js', + 'src/tilemap/TilemapLayer.js', + 'src/tilemap/TilemapParser.js', + 'src/tilemap/Tileset.js', + 'src/PixiPatch.js' + ] + }, + pkg: grunt.file.readJSON('package.json'), + clean: ['<%= compile_dir %>'], + concat: { + phaser: { + options: { + process: { + data: { + version: '<%= pkg.version %>', + buildDate: '<%= grunt.template.today() %>' + } + } + }, + src: ['<%= src.phaser %>'], + dest: '<%= compile_dir %>/phaser.js' + } + }, + umd: { + phaser: { + src: '<%= concat.phaser.dest %>', + dest: '<%= umd.phaser.src %>' + } + }, + uglify: { + phaser: { + options: { + banner: '/*! Phaser v<%= pkg.version %> | (c) 2013 Photon Storm Ltd. */\n' + }, + src: ['<%= umd.phaser.dest %>'], + dest: '<%= compile_dir %>/phaser.min.js' + } + }, + examples: { + all: { + options: { + base: 'examples', + excludes: ['_site', 'assets', 'states', 'wip'] + }, + src: ['examples/**/*.js'], + dest: 'examples/_site/examples.json' + } + }, + connect: { + root: { + options: { + keepalive: true + } + } + } + }); + + grunt.registerTask('default', ['build', 'examples']); + grunt.registerTask('build', ['clean', 'concat', 'umd', 'uglify']); + +}; diff --git a/README.md b/README.md index c98942d0..8622c0ea 100644 --- a/README.md +++ b/README.md @@ -1,138 +1,194 @@ ![Phaser Logo](http://www.photonstorm.com/wp-content/uploads/2013/09/phaser_10_release.jpg) -Phaser 1.0 +Phaser 1.1 ========== Phaser is a fast, free and fun open source game framework for making desktop and mobile browser HTML5 games. It uses [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) internally for fast 2D Canvas and WebGL rendering. -Version: 1.0.6a - Released: September 26th 2013 +Version: 1.1 - Released: October 25th 2013 By Richard Davey, [Photon Storm](http://www.photonstorm.com) View the [Official Website](http://phaser.io)
    Follow on [Twitter](https://twitter.com/photonstorm)
    Read the [Development Blog](http://www.photonstorm.com)
    -Join the [Forum](http://www.html5gamedevs.com/forum/14-phaser/) -Try out the [Phaser Test Suite](http://gametest.mobi/phaser/) +Join the [Forum](http://www.html5gamedevs.com/forum/14-phaser/)
    +Try out 150+ [Phaser Examples](http://gametest.mobi/phaser/examples/) + +[Un-official Getting Started with Phaser](http://www.antonoffplus.com/coding-an-html5-game-for-30-minutes-or-an-introduction-to-the-phaser-framework) "Being negative is not how we make progress" - Larry Page, Google Welcome to Phaser ----------------- -We're very pleased to have finally shipped the 1.0 release of Phaser. This version represents many months of hard work, feedback and refactoring based on the previous 0.5 through to 0.97 releases. You can see the full gory details in our change log. +It's staggering to think just how much has been achieved in the short time Phaser has been alive. We've implemented literally hundreds of bug fixes and updates, thanks to the effort the community puts in to reporting issues they find. Exciting new features have been merged into the core and we revisited old ones and pimped them out. We also completely overhauled the Examples Suite, removed the requirement for PHP, rebuilt it and filled it with over 150 examples to dig in and learn from. And more importantly we've got our first pass at the API docs ready too. -Sorry but the jsdocs aren't yet finished, but it is now our priority (along with bug fixing). If you run into problems, or just want to chat about how to best use Phaser then please do join our forums. It's an active and inspiring community. +There is still more to be done of course. The API docs, while a good start, are lacking in places and still need to be backed up with a proper comprehensive manual. And we desperately need to write some 'best practises' and 'getting started' tutorials too. But we hope you appreciate the amount of effort that has been put in by the team so far. -Now 1.0 is released we'll focus on getting the docs and more examples completed. Both of these will be pushed to the master repo on a regular basis. We will tag new releases of Phaser, but changes to the examples or docs won't be release tagged. +There are many exciting new features and tweaks in this build that we felt it warranted a proper point release, hence the shift to version 1.1. Because of several core changes games that were in development in a 1.0.x version of Phaser may need refactoring for 1.1, but we feel those changes have helped the framework grow and mature as a whole. -Thank you to everyone who has encouraged us along the way. To those of you who worked with Phaser during its various incarnations, and who released full games with it despite there being zero API documentation available: you are our heroes. It's your kind words and enthusiasm, as well as our commercial need for Phaser that has kept us going. Now we're at 1.0 we will continue releasing rapidly and jumping on patches and bug reports quickly. +As before we offer a heart-felt "Thank you!" to everyone who has encouraged us along the way. To those of you who worked with Phaser during its various incarnations, and who released full games with it despite there being zero API documentation available: you are our heroes. It's your kind words and enthusiasm that has kept us going. -Phaser is everything we ever wanted from an HTML5 game framework. It will power all our client work going forward and we look forward to you joining us on this journey. +Phaser is everything we ever wanted from an HTML5 game framework. It powers all of our client work in build today and remains our single most important product, and we've only just scratched the surface of what we have planned for it. -![Blasteroids](http://www.photonstorm.com/wp-content/uploads/2013/04/phaser_blaster.png) +![MiniCybernoid](http://www.photonstorm.com/wp-content/uploads/2013/10/phaser-cybernoid-640x480.png) Change Log ---------- -Version 1.0.7 (in progress in the dev branch) +Version 1.1 + +What's New: + +* JSDoc is go! We've added jsdoc3 blocks to every property and function, in every file and published the API docs to the docs folder. +* Brand new Example system (no more php!) and over 150 examples to learn from too. +* New TypeScript definitions file generated (in the build folder - thanks to TomTom1229 for manually enhancing this). +* New Grunt based build system added (thanks to Florent Cailhol) +* New: Phaser.Animation.generateFrameNames - really useful when creating animation data from texture atlases using file names, not indexes. +* Added Sprite.play as a handy short-cut to play an animation already loaded onto a Sprite. +* Added Canvas.setUserSelect() to disable touchCallouts and user selections within the canvas. +* Added Keyboard.addKey() which creates a new Phaser.Key object that can be polled for updates, pressed states, etc. See the 2 new examples showing use. +* Added Button.freezeFrames boolean. Stops the frames being set on mouse events if true. +* Extended the Loader 404 error to display the url of the file that didn't load as well as the key. +* New: Direction constants have been added to Sprites and adjust based on body motion. +* Brand new Sprite.update loop handler. Combined with the transform cache fix and further optimisations this is now much quicker to execute. +* Added Keyboard.createCursorKeys() which creates an object with 4 Key objects inside it mapped to up, down, left and right. See the new example in the input folder. +* Added Body.skipQuadTree boolean for more fine-grained control over when a body is added to the World QuadTree. +* Re-implemented Angular Velocity and Angular Acceleration on the Sprite.body and created 2 new examples to show use. +* Added Sprite.fixedToCamera boolean. A Sprite that is fixed to the camera doesn't move with the world, but has its x/y coordinates relative to the top-left of the camera. +* Added Group.createMultiple - useful when you need to create a Group of identical sprites for pooling, such as bullets. +* Added Group.total. Same as Group.length, but more in line with the rest of the Group naming. +* Added Sprite.outOfBoundsKill boolean flag. Will automatically kill a sprite that leaves the game World bounds (off by default). +* Lots of changes and fixes in ArcadePhysics, including: +* Functions with "mouse" in the title have been updated to "pointer" to more accurately reflect what they do. +* New velocity functions: moveToObject, moveToPointer, moveToXY +* New acceleration functions: accelerateToObject, accelerateToPointer, accelerateToXY +* New distance functions: distanceBetween, distanceToXY, distanceToPointer +* New angle functions: angleBetween, angleToXY, angleToPointer +* velocityFromAngle and velocityFromRotation added with examples created. +* Added killOnComplete parameter to Animation.play. Really useful in situations where you want a Sprite to animate once then kill itself on complete, like an explosion effect. +* Added Sprite.loadTexture(key, frame) which allows you to load a new texture set into an existing sprite rather than having to create a new sprite. +* Added Sprite.destroy back in again and made it a lot more robust at cleaning up child objects. +* Added 'return this' to all the core Loader functions so you can chain load calls if you so wish. +* Added Text.destroy() and BitmapText.destroy(), also updated Group.remove to make it more bullet-proof when an element doesn't have any events. +* Added Phaser.Utils.shuffle to shuffle an array. +* Added Graphics.destroy, x, y and updated angle functions. +* Added AnimationManager.refreshFrame - will reset the texture being used for a Sprite (useful after a crop rect clear) +* Added Physics.overlap(sprite1, sprite2) for quick body vs. body overlap tests with no separation performed. +* On a busy page it's possible for the game to boot with an incorrect stage offset x/y which can cause input events to be calculated wrong. A new property has been added to Stage to combat this issue: Stage.checkOffsetInterval. By default it will check the canvas offset every 2500ms and adjust it accordingly. You can set the value to 'false' to disable the check entirely, or set a higher or lower value. We recommend that you get the value quite low during your games preloader, but once the game has fully loaded hopefully the containing page will have settled down, so it's probably safe to disable the check entirely. +* Added Rectangle.floorAll to floor all values in a Rectangle (x, y, width and height). + +What's changed: + +* Renamed Phaser.Text.text to Phaser.Text.content to avoid conflict and overwrite from Pixi local var. +* Renamed Phaser.Text.style to Phaser.Text.font to avoid conflict and overwrite from Pixi local var. +* Phaser.Button now sets useHandCursor to true by default. +* Change: When you start a new State all active tweens are now purged. +* When the game boots it will now by default disable user-select and touch action events on the game canvas. +* Moved LinkedList.dump to Debug.dumpLinkedList(list) +* Phaser.Animation.Frame is now Phaser.Frame +* Phaser.Animation.FrameData is now Phaser.FrameData +* Phaser.Animation.Parser is now Phaser.AnimationParser (also the file has renamed from Parser.js to AnimationParser.js) +* Phaser.Loader.Parser is now Phaser.LoaderParser (also the file has renamed from Parser.js to LoaderParser.js) +* Change: We've removed the scrollFactor property from all Game Objects. Sorry, but the new Camera system doesn't work with it and it caused all kinds of issues anyway. We will sort out a replacement for it at a later date. +* Change: World now extends Phaser.Group. As a result we've updated GameObjectFactory and other classes that linked to it. If you have anywhere in your code that used to reference world.group you can just remove 'group' from that. So before, world.group.add() is now just world.add(). +* Change: The Camera has been completely revamped. Rather than adjusting the position of all display objects (bad) it now just shifts the position of the single world container (good!), this is much quicker and also stops the game objects positions from self-adjusting all the time, allowing for them to be properly nested with other containers. +* Made Sprite.body optional and added in checks, so you can safely null the Sprite body object if using your own physics system and not impact rendering. +* Moved the Camera update checks to World.postUpdate, so all the sprites get the correct adjusted camera position. +* The default Game.antialias value is now 'true', so graphics will be smoothed automatically in canvas. Disable it via the Game constructor or Canvas utils. +* Phaser.Group now automatically calls updateTransform on any child added to it (avoids temp. frame glitches when new objects are rendered on their first frame). + +What has been updated: -* Added World.postUpdate - all sprite position changes, as a result of physics, happen here before the render. * Complete overhaul of Physics.Arcade.Body - now significantly more stable and faster too. * Updated ArcadePhysics.separateX/Y to use new body system - much better results now. -* QuadTree bug found in 1.0.5 now fixed. The QuadTree is updated properly now using worldTransform values. -* Added Zwoptex Phaser Template created by Bruno Assarisse - it's in the docs folder if you need it. Thanks Bruno! +* Added World.postUpdate - all sprite position changes, as a result of physics, happen here before the render. +* Added Animation.paused - can be set to true/false. +* Added support for Body.maxVelocity (thanks cocoademon) +* InputHandler now creates the _pointerData array on creation and populates with one empty set of values, so pointerOver etc all work before a start call. +* Removed the callbackContext parameter from Group.callAll because it's no longer needed. +* Updated Group.forEach, forEachAlive and forEachDead so you can now pass as many parameters as you want, which will all be given to the callback after the child. +* Updated build script so it can be run from the command-line and includes UMD wrappers (thanks iaincarsberg) +* World.randomX/Y now returns values anywhere in the world.bounds range (if set, otherwise 0), including negative values. +* Updated InputHandler to use Math.round rather than Math.floor when snapping an object during drag. +* If you didn't provide the useNumericIndex parameter then AnimationManager.add will set the value by looking at the datatype of the first element in the frames array. +* Group.create now sets the visible and alive properties of the Sprite to the same value as the 'exists' parameter. +* World.randomX/Y now works with negative World.bounds values. +* Tweens .to will now always return the parent (thanks powerfear) +* You can now pass a PIXI.Texture to Sprite (you also need to pass a Phaser.Frame as the frame parameter) but this is useful for Sprites sharing joint canvases. +* Group.alpha is now exposed publically and changes the Group container object (not the children directly, who can still have their own alpha values) +* Device.webGL uses new inspection code to accurately catch more webGL capable devices. +* Debug.renderSpriteBody updated to use a the new Sprite.Body.screenX/Y properties. +* Additional checks added to AnimationManager.frame/frameName on the given values. +* You can now null a Sprite.crop and it will clear down the crop rect area correctly. +* Phaser.Time physicsElapsed delta timer clamp added. Stops rogue iOS / slow mobile timer errors causing crazy high deltas. +* Animation.generateFrameNames can now work in reverse, so the start/stop values can create frames that increment or decrement respectively. +* Loader updated to use xhr.responseText when loading json, csv or text files. xhr.response is still used for Web Audio binary files (thanks bubba) +* Input.onDown and onUp events now dispatch the original event that triggered them (i.e. a MouseEvent or TouchEvent) as the 2nd parameter, after the Pointer (thanks rezoner) +* Updated Sprite.crop significantly. Values are now cached, stopping constant Texture frame updates and you can do sprite.crop.width++ for example (thanks haden) +* Change: Sprite.crop needs to be enabled with sprite.cropEnabled = true. +* Sprite.loadTexture now works correctly with static images, RenderTextures and Animations. +* Lots of fixes within Sprite.bounds. The bounds is now correct regardless of rotation, anchor or scale of the Sprite or any of its parent objects. -* TODO: addMarker hh:mm:ss:ms -* TODO: Direction constants +What has been fixed: -Version 1.0.6a (September 26th 2013) +* QuadTree bug found in 1.0.5 now fixed. The QuadTree is updated properly now using localTransform values. +* Fixed the Bounce.In and Bounce.InOut tweens (thanks XekeDeath) +* Fixed an issue in Animation.update where if the game was paused it would get an insane delta timer throwing a uuid error. +* Added PixiPatch.js to patch in a few essential features until Pixi is updated. +* Fixed issue in Animation.play where the given frameRate and loop values wouldn't overwrite those set on construction. +* Fixed small bug stopping Tween.pause / resume from resuming correctly when called directly. +* Fixed an issue where Tweens.removeAll wasn't clearing tweens in the addition queue. +* Fixed Particle Emitters when using Emitter width/height (thanks XekeDeath) +* Made animation looping more robust when skipping frames (thanks XekeDeath) +* Fix for incorrect new particle positioning (issue #73) (thanks cottonflop) +* Fixed issue in Sound.play where if you gave a missing marker it would play the whole sound sprite instead. +* Button.setFrames will set the current frame based on the button state immediately. +* Loaded.setPreloadSprite now rounds the width/height values and starts from 1. This fixes canvas draw errors in IE9/10 and Firefox. +* Fixed issue causing Keyboard.justPressed to always fire (thanks stemkoski) +* Fixed bug in LinkedList#remove that could cause first to point to a dead node (thanks onedayitwillmake) +* Fixed Cache.addDefaultImage so the default image works in Canvas as well as WebGL. Updated to a new image (32x32 black square with green outline) +* Fixed a bug in the Sprite transform cache check that caused the skew/scale cache to get constantly invalidated - now only updates as needed, significant performance increase! +* Fixed typo in StageScaleMode so it's not pageAlignVeritcally any longer, but pageAlignVertically. +* Fixed issue in Group.countLiving / countDead where the value was off by one (thanks mjablonski) +* Fixed issue with a jittery Camera if you moved a Sprite via velocity instead of x/y placement. +* Fixed the RandomDataGenerator.sow method so if you give in the same seed you'll now get the same results (thanks Hsaka) +* Fixed Issue #101 (Mouse Button 0 is not recognised, thanks rezoner) +* Fixed an issue where creating an animation with just one frame with an index of zero would cause a UUID error (thanks SYNYST3R1) +* Fixed Rectangle.union (thanks andron77) +* Fixed Sound.resume so it now correctly resumes playback from the point it was paused (fixes issue 51, thanks Yora). +* Fixed issue 105 where a dragged object that was destroyed would cause an Input error (thanks onedayitwillmake) +* Fixed Issue 111 - calling Kill on a Phaser.Graphics instance causes error on undefined events. +* Game.destroy will now stop the raf from running as well as close down all input related event listeners (issue 92, thanks astrism) +* Pixel Perfect click detection now works even if the Sprite is part of a texture atlas. -Sorry there was an error in the StateManager that stopped states from switching correctly that we forgot to merge with the 1.0.6 -release. This has now been resolved, so please update to 1.0.6a. +![Tanks](http://www.photonstorm.com/wp-content/uploads/2013/10/phaser_tanks-640x480.png) -Version 1.0.6 (September 24th 2013) +Outstanding Tasks +----------------- -* Added check into Pointer.move to always consider a Sprite that has pixelPerfect enabled, regardless of render ID. -* BUG: The pixel perfect click check doesn't work if the sprite is part of a texture atlas yet. -* Fixed issue with anti-alias in the Game constructor not being set correctly (thanks luizbills) -* Added support for the Graphics game object back in and two examples (thanks earok for spotting) -* New: Tweens can now be chained via multiple to() calls + example created (thanks to powerfear for adding) -* Fixed Math.wrap (thanks TheJare) -* New: When loading a Sprite Sheet you can now pass negative values for the frame sizes which specifies the number of rows/columns to load instead (thanks TheJare) -* New: BitmapText now supports anchor and has fixed box dimensions (thanks TheJare) -* Fixed bug where if a State contains an empty Preloader the Update will not be called (thanks TheJare) -* Several new examples added (cameras, tweens, etc) -* Added in extra checks to halt collision if it involves an empty Group (thanks cang) -* Added time smoothing to Animation update to help frames hopefully not get too out of sync during long animations with high frame rates. -* Added frame skip to Animation.update. If it gets too far behind it will now skip frames to try and catch up. +* TODY: Loader conflict if 2 keys are the same even if they are in different packages (i.e. you can't use "title" for both and image and sound file). +* TODO: d-pad example (http://www.html5gamedevs.com/topic/1574-gameinputondown-question/) +* TODO: more touch input examples (http://www.html5gamedevs.com/topic/1556-mobile-touch-event/) +* TODO: Sound.addMarker hh:mm:ss:ms +* TODO: swap state (non-destructive shift) +* TODO: rotation offset +* TODO: Look at HiDPI Canvas settings -Version 1.0.5 (September 20th 2013) +How to Build +------------ -* Fixed issue in FrameData.getFrameIndexes where the input array was being ignored. -* Added Math.numberArray - Returns an Array containing the numbers from min to max (inclusive), useful for animation frame construction. -* Fixed a horrendously sneaky bug: If a new tween was created in the onComplete callback of a tween about to be deleted, it would get automatically spliced. -* Added a pendingDelete property to Tween to stop tweens that were removed during a callback from causing update errors during the TweenManager loop. -* Added Group.length property. -* Added explicit x/y attributes to Phaser.Text to make it work with the camera system (thanks cocoademon). -* Fixed issue stopping multiple animations from playing, only the most recent would play (frames array was being overwritten, thanks Legrandk) -* Updated Debug.renderSpriteBounds() so it doesn't use the deprecated Sprite.worldView any more (thanks MikeMnD) -* Added 2 new properties to the Text object: Text.text and Text.style, both are getter/setters and don't flag dirty unless changed, so safe for core loop use. -* Removed the exists check from Group.callAll, it now runs on all children (as the name implies) -* Added Group.callAllExists - you can now call a function on all children who have exists = the provided boolean. -* Finished off the Breakout example game - now fully playable, proper rebound, scoring, lives, etc. -* Removed Group.sort dummy entry until it's working. -* Removed ArcadePhysics.postUpdate. -* Updated Sprite.update to set renderable to false when the object goes out of Camera, not 'visible' false, otherwise it stops the transform being updated by Pixi. -* BUG: There is a known issue where the wrong rect coordinates are given to the QuadTree if the Sprite is a child of a Group or another Sprite which has an x/y offset. - -Version 1.0.4 (September 18th 2013) - -* Small fix to Phaser.Canvas to stop it from setting overflow hidden if the parent DOM element doesn't exist. -* Added Loader.setPreloadSprite(sprite, direction) - this will automatically apply a crop rect to the Sprite which is updated in line with the load progress. -* A lot of changes inside the StateManager. State functions are now passed through link() which automatically creates the key Game properties (load, input, etc) -* Fixed a bug in getFrameByName that wouldn't return the first frame in the array. -* Updated Phaser.Rectangle.intersects to use x and y instead of left and top so it can be used to check Physics bodies overlapping. -* Fixed issue in Cache where the Frame index wasn't being set correctly (thanks Cameron) -* Fixed issue in Sprite where boundsY wasn't set (thanks Cameron) -* For some reason there were 2 copies of the Canvas class in the build file - fixed, a few KB saved :) - -Version 1.0.3 (September 17th 2013) - -* FrameData.getFrameIndexes and getFrameIndexesByName refactored into a more versatile getFrames function. -* Various fixes to looping parameters in the Sound system. -* Documentation started across most classes. Keep track of progress in the Docs folder. -* Optimised AnimationManager.add so it will only get the required frames rather than all of them and is now faster at parsing the frame data. -* Fixed Phaser.Text and Phaser.BitmapText so they now render correctly and added several Text examples. - -Version 1.0.2 (September 16th 2013) - -* Added optional parameter to Animation.stop: resetFrame. If true the animation will be stopped and then the current frame reset to the first frame in the animation. -* Fixed an issue causing 'explode' particle bursts to ignore the quantity parameter. -* Added 'collideWorldBounds' to Emitter.makeParticles function. -* Added Emitter.angularDrag -* Changed Emitter.bounce from a number to a Point, so now set its x/y properties to control different amounts of bounce per axis. -* Fixed a bug in the AnimationManager where useNumericIndex was always set to true -* Added in lots of Particle examples -* Added in the start of a Breakout game -* Added in the start of a Platformer game - -Version 1.0.1 (September 15th 2013) - -* Added checks into every Group function to ensure that the Group has children before running them. -* Added optional flag to Group.create which allows you to set the default exists state of the Sprites. -* Sprite.animation.stop no longer needs an animation name parameter, will default to stopping the current animation. -* Fixed the license in package.json -* Fixed a logic bug in the separateTileX function that would sometimes cause tunneling of big sprites through small tiles. +A Grunt script has been provided that will build Phaser from source as well as the examples. Run `grunt` in the phaser folder for a list of command-line options. Requirements ------------ Games created with Phaser require a modern web browser that supports the canvas tag. This includes Internet Explorer 9+, Firefox, Chrome, Safari and Opera. It also works on mobile web browsers including stock Android 2.x browser and above and iOS5 Mobile Safari and above. -For developing with Phaser you can use either a plain-vanilla JavaScript approach or [TypeScript](https://typescript.codeplex.com/). We made no assumptions about how you like to code your games, and were careful not to impose any form of class/inheritance/structure upon you. +For developing with Phaser you can use either a plain-vanilla JavaScript approach or [TypeScript](https://typescript.codeplex.com/) using the provided TypeScript definitions file. We made no assumptions about how you like to code your games, and were careful not to impose any form of class/inheritance/structure upon you. -Phaser is 275 KB minified and 62 KB gzipped. +Phaser is 281 KB minified and 66 KB gzipped. Features -------- @@ -202,47 +258,40 @@ We use Phaser every day on our many client projects. As a result it's constantly Although Phaser 1.0 is a brand new release it is born from years of experience building some of the biggest HTML5 games out there. We're not saying it is 100% bug free, but we use it for our client work every day, so issues get resolved fast and we stay on-top of the changing browser landscape. -![Phaser Particles](http://www.photonstorm.com/wp-content/uploads/2013/04/phaser_particles.png) +![FruitParty](http://www.photonstorm.com/wp-content/uploads/2013/10/phaser_fruit_particles-640x480.png) -Known Issues ------------- +Road Map +-------- -* The TypeScript definition file isn't yet complete. -* The JSDOCS are not yet complete. +The 1.1 release was a massive under-taking, but we're really happy with how Phaser is progressing. It's becoming more solid and versatile with each iteration. Here is what's on our road map for future versions: -Future Plans ------------- +* Integration with an advanced physics system. We've been experimenting with p2.js but have yet to conclude our research. +* A more advanced Particle system, one that can render to a single canvas (rather than spawn hundreds of Sprites), more advanced effects, etc. +* Massively enhance the audio side of Phaser. Although it does what it does well, it could do with taking more advantage of Web Audio - echo effects, positional sound, etc. +* Comprehensive testing across Firefox OS devices, CocoonJS and Ejecta. +* Integration with third party services like Google Play Game Services and Amazon JS SDK. +* Ability to control DOM elements from the core game and layer them into the game. +* Touch Gestures. +* Virtual d-pad support and also support for the Joypad API. +* Test out packaging with Node-webkit. +* Flash CC HTML5 export integration. +* Game parameters stored in Google Docs. +* More advanced tile map features. Better support for advanced Tiled features and also I want to add full support for DAME tilemaps. -The following list is not exhaustive and is subject to change: +Learn By Example +---------------- -* Integrate Advanced Physics system. -* Integrate Advanced Particle system. -* Better sound controls and audio effects. -* Google Play Game Services. -* Ability to layer another DOM object and have it controlled by the game. -* More GUI components: checkbox, radio button, window, etc. -* Tilemap: more advanced Tiled support and support for DAME tilemaps. -* Joypad support. -* Gestures input class. -* Flash CC html output support. -* Game parameters read from Google Docs. +Phaser comes with an ever growing suite of Examples. Personally I feel that we learn better by looking at small refined code examples, so we created over 150 of them and create new ones to test every new feature added. Inside the `examples` folder you'll find the current set. If you write a particularly good example then please send it to us. -Right now however our main focus is on documentation and examples, we won't be touching any of the above features until the docs are finished. +The examples need running through a local web server (to avoid file access permission errors from your browser). -Test Suite ----------- +Browse to the examples folder via your web server. -Phaser comes with an ever growing Test Suite. Personally we learn better by looking at small refined code examples, so we create lots of them to test each new feature we add. Inside the Tests folder you'll find the current set. If you write a particularly good test then please send it to us. + examples/index.html -The tests need running through a local web server (to avoid file access permission errors from your browser). +There is a new 'Side View' example viewer as well. This loads all the examples into a left-hand frame for faster navigation. -Make sure you can browse to the Tests folder via your web server. If you've got php installed then launch: - - examples/index.php - -Right now the Test Suite requires PHP, but we will remove this requirement soon. - -You can also browse the [Phaser Test Suite](http://gametest.mobi/phaser/) online. +You can also browse all [Phaser Examples](http://gametest.mobi/phaser/) online. Contributing ------------ diff --git a/build/build.php b/build/build.php index 8379975d..e5a4e48f 100644 --- a/build/build.php +++ b/build/build.php @@ -1,15 +1,14 @@ -Minify it
    - - \ No newline at end of file diff --git a/examples/js.php b/build/config.php similarity index 94% rename from examples/js.php rename to build/config.php index 3c6650cf..e41fb353 100644 --- a/examples/js.php +++ b/build/config.php @@ -52,6 +52,7 @@ + @@ -94,11 +95,11 @@ - + - + @@ -113,8 +114,10 @@ + - - + + + diff --git a/build/phaser.d.ts b/build/phaser.d.ts new file mode 100644 index 00000000..249e9d2a --- /dev/null +++ b/build/phaser.d.ts @@ -0,0 +1,1817 @@ +declare class Phaser { + static VERSION: string; + static GAMES: Array; + static AUTO: number; + static CANVAS: number; + static WEBGL: number; + static SPRITE: number; + static BUTTON: number; + static BULLET: number; + static GRAPHICS: number; + static TEXT: number; + static TILESPRITE: number; + static BITMAPTEXT: number; + static GROUP: number; + static RENDERTEXTURE: number; + static TILEMAP: number; + static TILEMAPLAYER: number; + static EMITTER: number; +} + +declare module Phaser { + class Camera { + constructor(game: Phaser.Game, id: number, x: number, y: number, width: number, height: number); + game: Phaser.Game; + world: Phaser.World; + id: number; + x: number; + y: number; + width: number; + height: number; + view: Phaser.Rectangle; + screenView: Phaser.Rectangle; + deadzone: Phaser.Rectangle; + visible: boolean; + atLimit: { x: boolean; y: boolean; }; + target: Phaser.Sprite; + _edge: number; + static FOLLOW_LOCKON: number; + static FOLLOW_PLATFORMER: number; + static FOLLOW_TOPDOWN: number; + static FOLLOW_TOPDOWN_TIGHT: number; + follow(target: Phaser.Sprite, style?: number): void; + focusOnXY(x: number, y: number): void; + update(): void; + checkWorldBounds(): void; + setPosition(x: number, y: number): void; + setSize(width: number, height: number): void; + } + + class State { + game: Phaser.Game; + add: Phaser.GameObjectFactory; + camera: Phaser.Camera; + cache: Phaser.Cache; + input: Phaser.Input; + stage: Phaser.Stage; + math: Phaser.Math; + sound: Phaser.SoundManager; + time: Phaser.Time; + tweens: Phaser.TweenManager; + world: Phaser.World; + particles: Phaser.Particles; + physics: Phaser.Physics.Arcade; + load(); + preload(); + create(); + render(); + update(); + paused(); + destroy(); + } + + class StateManager { + constructor(game: Phaser.Game, pendingState: Phaser.State); + game: Phaser.Game; + states: Object; + current: Phaser.State; + onInitCallback(): void; + onPreloadCallback(): void; + onCreateCallback(): void; + onUpdateCallback(): void; + onRenderCallback(): void; + onPreRenderCallback(): void; + onLoadUpdateCallback(): void; + onLoadRenderCallback(): void; + onPausedCallback(): void; + onShutDownCallback(): void; + boot(): void; + add(key: string, state: Phaser.State, autoStart: boolean): void; + remove(key: string): void; + start(key: string, clearWorld: boolean, clearCache: boolean): void; + dummy(): void; + checkState(key: string): boolean; + link(key: string): void; + setCurrentState(key: string): void; + loadComplete(): void; + update(): void; + preRender(): void; + render(): void; + destroy(): void; + } + + class LinkedListItem { + next: LinkedListItem; + prev: LinkedListItem; + first: LinkedListItem; + last: LinkedListItem; + } + + class LinkedList extends LinkedListItem { + total: number; + add(child: LinkedListItem): LinkedListItem; + remove(child: LinkedListItem): void; + callAll(callback: string): void; + dump(): void; + } + + class Signal { + memorize: boolean; + active: boolean; + validateListener(listener: Function, fnName: string): void; + has(listener: Function, context?: Object): boolean; + add(listener: Function, listenerContext?: Object, priority?: number): Phaser.SignalBinding; + addOnce(listener: Function, listenerContext?: Object, priority?: number): Phaser.SignalBinding; + remove(listener: Function, context?: Object): Function; + removeAll(): void; + getNumListeners(): number; + halt(): void; + dispatch(...params: any[]): void; + forget(): void; + dispose(): void; + toString(): string; + } + + class SignalBinding { + constructor(signal: Phaser.Signal, listener: Function, isOnce: boolean, listenerContext: Object, priority?: number); + context: Object; + active: boolean; + params: Array; + execute(paramsArr?: Array): void; + detach(): Function; + isBound(): boolean; + isOnce(): boolean; + getListener(): Function; + getSignal(): Phaser.Signal; + toString(): string; + } + + class StateCycle { + preUpdate(): void; + update(): void; + render(): void; + postRender(): void; + destroy(): void; + } + + class Plugin extends StateCycle { + constructor(game: Phaser.Game, parent: any); + game: Phaser.Game; + parent: any; + active: boolean; + visible: boolean; + hasPreUpdate: boolean; + hasUpdate: boolean; + hasRender: boolean; + hasPostRender: boolean; + } + + class PluginManager extends StateCycle { + constructor(game: Phaser.Game, parent: any); + game: Phaser.Game; + private _parent: any; + plugins: Phaser.Plugin[]; + add(plugin: Phaser.Plugin): Phaser.Plugin; + remove(plugin: Phaser.Plugin): void; + } + + class Stage { + constructor(game: Phaser.Game, width: number, height: number); + game: Phaser.Game; + offset: Phaser.Point; + canvas: HTMLCanvasElement; + scaleMode: number; + scale: Phaser.StageScaleMode; + aspectRatio: number; + backgroundColor: string; + boot(): void; + visibilityChange(event: Event): void; + } + + class Group { + constructor(game: Phaser.Game, parent: any, name: string, useStage: boolean); + game: Phaser.Game; + name: string; + type: number; + exists: boolean; + sortIndex: string; + length: number; + x: number; + y: number; + angle: number; + rotation: number; + visible: boolean; + add(child: any): any; + addAt(child: any, index: number): any; + getAt(index: number): any; + create(x: number, y: number, key: string, frame: string, exists: boolean): any; + swap(child1: any, child2: any): boolean; + bringToTop(child: any): any; + getIndex(child: any): number; + replace(oldChild: any, newChild: any): void; + setProperty(child: any, key: string[], value: string, operation: number): void; + setAll(key: string, value: number, checkAlive: boolean, checkVisible: boolean, operation: number): void; + subAll(key: string, value: number, checkAlive: boolean, checkVisible: boolean, operation: number): void; + multiplyAll(key: string, value: number, checkAlive: boolean, checkVisible: boolean, operation: number): void; + divideAll(key: string, value: number, checkAlive: boolean, checkVisible: boolean, operation: number): void; + callAllExists(callback: Function, callbackContext: Object, existsValue: boolean): void; + callAll(callback: Function, callbackContext: Object): void; + forEach(callback: Function, callbackContext: Object, checkExists: boolean): void; + forEachAlive(callback: Function, callbackContext: Object): void; + forEachDead(callback: Function, callbackContext: Object): void; + getFirstExists(state: boolean): any; + getFirstAlive(): any; + getFirstDead(): any; + countLiving(): number; + countDead(): number; + getRandom(startIndex: number, length: number): any; + remove(child: any): void; + removeAll(): void; + removeBetween(startIndex: number, endIndex: number): void; + destroy(): void; + dump(full: boolean): void; + } + + class World { + constructor(game: Phaser.Game); + game: Phaser.Game; + bounds: Phaser.Rectangle; + camera: Phaser.Camera; + currentRenderOrderID: number; + group: Phaser.Group; + width: number; + height: number; + centerX: number; + centerY: number; + randomX: number; + randomY: number; + boot(): void; + update(): void; + setSize(width: number, height: number): void; + destroy(): void; + } + + class Game { + constructor(width: number, height: number, renderer: number, parent: string, state: Phaser.StateManager, transparent: boolean, antialias: boolean); + id: number; + width: number; + height: number; + renderer: number; + transparent: boolean; + antialias: boolean; + parent: string; + state: Phaser.StateManager; + renderType: number; + isBooted: boolean; + raf: Phaser.RequestAnimationFrame; + add: Phaser.GameObjectFactory; + cache: Phaser.Cache; + input: Phaser.Input; + load: Phaser.Loader; + math: Phaser.Math; + sound: Phaser.SoundManager; + stage: Phaser.Stage; + time: Phaser.Time; + tweens: Phaser.TweenManager; + world: Phaser.World; + physics: Phaser.Physics.Arcade; + rnd: Phaser.RandomDataGenerator; + device: Phaser.Device; + camera: Phaser.Camera; + canvas: HTMLCanvasElement; + context: Object; + debug: Phaser.Utils.Debug; + particles: Phaser.Particles; + _paused: boolean; + paused: boolean; + boot(): void; + setUpRenderer(): void; + loadComplete(): void; + update(): void; + destroy(): void; + } + + class Input { + constructor(game: Phaser.Game); + static MOUSE_OVERRIDES_TOUCH: number; + static TOUCH_OVERRIDES_MOUSE: number; + static MOUSE_TOUCH_COMBINE: number; + id: number; + active: boolean; + game: Phaser.Game; + hitCanvas: any; + hitContext: any; + pollRate: number; + disabled: boolean; + multiInputOverride: number; + position: Phaser.Point; + speed: Phaser.Point; + circle: Phaser.Circle; + scale: Phaser.Point; + maxPointers: number; + currentPointers: number; + tapRate: number; + doubleTapRate: number; + holdRate: number; + justPressedRate: number; + justReleasedRate: number; + recordPointerHistory: boolean; + recordRate: number; + recordLimit: number; + x: number; + y: number; + totalInactivePointers: number; + totalActivePointers: number; + worldX: number; + worldY: number; + pollLocked: boolean; + pointer1: Phaser.Pointer; + pointer2: Phaser.Pointer; + pointer3: Phaser.Pointer; + pointer4: Phaser.Pointer; + pointer5: Phaser.Pointer; + pointer6: Phaser.Pointer; + pointer7: Phaser.Pointer; + pointer8: Phaser.Pointer; + pointer9: Phaser.Pointer; + pointer10: Phaser.Pointer; + activePointer: Phaser.Pointer; + mousePointer: Phaser.Pointer; + mouse: Phaser.Mouse; + keyboard: Phaser.Keyboard; + touch: Phaser.Touch; + mspointer: Phaser.MSPointer; + interactiveItems: Phaser.LinkedList; + onDown(): void; + onUp(): void; + onTap(): void; + onHold(): void; + boot(): void; + update(): void; + reset(hard?: boolean); + resetSpeed(x: number, y: number); + startPointer(event: Event): Phaser.Pointer; + updatePointer(event: Event): Phaser.Pointer; + stopPointer(event: Event): Phaser.Pointer; + getPointer(state: boolean): Phaser.Pointer; + getPointerFromIdentifier(identifier: number): Phaser.Pointer; + addPointer(): Phaser.Pointer; + } + + class Keyboard { + constructor(game: Phaser.Game); + game: Phaser.Game; + disabled: boolean; + static A: number; + static B: number; + static C: number; + static D: number; + static E: number; + static F: number; + static G: number; + static H: number; + static I: number; + static J: number; + static K: number; + static L: number; + static M: number; + static N: number; + static O: number; + static P: number; + static Q: number; + static R: number; + static S: number; + static T: number; + static U: number; + static V: number; + static W: number; + static X: number; + static Y: number; + static Z: number; + static ZERO: number; + static ONE: number; + static TWO: number; + static THREE: number; + static FOUR: number; + static FIVE: number; + static SIX: number; + static SEVEN: number; + static EIGHT: number; + static NINE: number; + static NUMPAD_0: number; + static NUMPAD_1: number; + static NUMPAD_2: number; + static NUMPAD_3: number; + static NUMPAD_4: number; + static NUMPAD_5: number; + static NUMPAD_6: number; + static NUMPAD_7: number; + static NUMPAD_8: number; + static NUMPAD_9: number; + static NUMPAD_MULTIPLY: number; + static NUMPAD_ADD: number; + static NUMPAD_ENTER: number; + static NUMPAD_SUBTRACT: number; + static NUMPAD_DECIMAL: number; + static NUMPAD_DIVIDE: number; + static F1: number; + static F2: number; + static F3: number; + static F4: number; + static F5: number; + static F6: number; + static F7: number; + static F8: number; + static F9: number; + static F10: number; + static F11: number; + static F12: number; + static F13: number; + static F14: number; + static F15: number; + static COLON: number; + static EQUALS: number; + static UNDERSCORE: number; + static QUESTION_MARK: number; + static TILDE: number; + static OPEN_BRACKET: number; + static BACKWARD_SLASH: number; + static CLOSED_BRACKET: number; + static QUOTES: number; + static BACKSPACE: number; + static TAB: number; + static CLEAR: number; + static ENTER: number; + static SHIFT: number; + static CONTROL: number; + static ALT: number; + static CAPS_LOCK: number; + static ESC: number; + static SPACEBAR: number; + static PAGE_UP: number; + static PAGE_DOWN: number; + static END: number; + static HOME: number; + static LEFT: number; + static UP: number; + static RIGHT: number; + static DOWN: number; + static INSERT: number; + static DELETE: number; + static HELP: number; + static NUM_LOCK: number; + start(): void; + stop(): void; + addKeyCapture(keycode: any): void; + removeKeyCapture(keycode: number): void; + clearCaptures(): void; + onKeyDown(event: any): void; + onKeyUp(event: any): void; + reset(): void; + justPressed(keycode: number, duration?: number): boolean; + justReleased(keycode: number, duration?: number): boolean; + isDown(keycode: number): boolean; + } + + class Mouse { + constructor(game: Phaser.Game) + game: Phaser.Game; + callbackContext: Object; + disabled: boolean; + locked: boolean; + static LEFT_BUTTON: number; + static MIDDLE_BUTTON: number; + static RIGHT_BUTTON: number; + mouseDownCallback(): void; + mouseMoveCallback(): void; + mouseUpCallback(): void; + start(): void; + onMouseDown(): void; + onMouseUp(): void; + onMouseMove(): void; + requestPointerLock(): void; + pointerLockChange(): void; + releasePointerLock(): void; + stop(); + } + + class MSPointer { + constructor(game: Phaser.Game); + game: Phaser.Game; + callbackContext: Object; + disabled: boolean; + mouseDownCallback(): void; + mouseMoveCallback(): void; + mouseUpCallback(): void; + start(): void; + onPointerDown(): void; + onPointerUp(): void; + onPointerMove(): void; + stop(): void; + } + + class Pointer { + constructor(game: Phaser.Game, id: number); + game: Phaser.Game; + id: number; + active: boolean; + positionDown: Phaser.Point; + position: Phaser.Point; + circle: Phaser.Circle; + withinGame: boolean; + clientX: number; + clientY: number; + pageX: number; + pageY: number; + screenX: number; + screenY: number; + duation: number; + worldX: number; + worldY: number; + x: number; + y: number; + isMouse: boolean; + isDown: boolean; + isUp: boolean; + timeDown: number; + timeUp: number; + previousTapTime: number; + totalTouches: number; + msSinceLastClick: number; + targetObject: any; + start(event: any): Phaser.Pointer; + update(): void; + move(event: any): void; + leave(event: any): void; + stop(event: any): void; + justPressed(duration?: number): boolean; + justReleased(duration?: number): boolean; + reset(): void; + toString(): string; + } + + class Touch { + constructor(game: Phaser.Game); + game: Phaser.Game; + callbackContext: any; + touchStartCallback: Function; + touchMoveCallback: Function; + touchEndCallback: Function; + touchEnterCallback: Function; + touchLeaveCallback: Function; + touchCancelCallback: Function; + preventDefault: boolean; + disabled: boolean; + start(): void; + consumeDocumentTouches(): void; + onTouchStart(event: any): void; + onTouchCancel(event: any): void; + onTouchEnter(event: any): void; + onTouchLeave(event: any): void; + onTouchMove(event: any): void; + onTouchEnd(event: any): void; + stop(): void; + } + + class InputHandler extends LinkedListItem { + constructor(sprite: Phaser.Sprite); + game: Phaser.Game; + sprite: Phaser.Sprite; + enabled: boolean; + priorityID: number; + useHandCursor: boolean; + isDragged: boolean; + allowHorizontalDrag: boolean; + allowVerticalDrag: boolean; + bringToTop: boolean; + snapOffset: number; + snapOnDrag: boolean; + snapOnRelease: boolean; + snapX: number; + snapY: number; + pixelPerfect: boolean; + pixelPerfectAlpha: number; + draggable: boolean; + boundsSprite: Phaser.Sprite; + consumePointerEvent: boolean; + start(priority: number, useHandCursor: boolean): void; + reset(): void; + stop(): void; + destroy(): void; + pointerX(pointer: number): number; + pointerY(pointer: number): number; + pointerDown(pointer: number): boolean; + pointerUp(pointer: number): boolean; + pointerTimeDown(pointer: number): number; + pointerTimeUp(pointer: number): number; + pointerOver(pointer: number): boolean; + pointerOut(pointer: number): boolean; + pointerTimeOver(pointer: number): number; + pointerTimeOut(pointer: number): number; + pointerDragged(pointer: number): boolean; + checkPointerOver(pointer: number): boolean; + checkPixel(x: number, y: number): boolean; + update(pointer: number): void; + updateDrag(pointer: number): boolean; + justOver(pointer: number, delay: number): boolean; + justOut(pointer: number, delay: number): boolean; + justPressed(pointer: number, delay: number): boolean; + justReleased(pointer: number, delay: number): boolean; + overDuration(pointer: number): number; + downDuration(pointer: number): number; + enableDrag(lockCenter: boolean, bringToTop: boolean, pixelPerfect: boolean, alphaThreshold?: number, boundsRect?: Phaser.Rectangle, boundsSprite?: Phaser.Rectangle): void; + disableDrag(): void; + startDrag(): void; + stopDrag(): void; + setDragLock(allowHorizontal: boolean, allowVertical: boolean): void; + enableSnap(snapX: number, snapY: number, onDrag?: boolean, onRelease?: boolean): void; + disableSnap(): void; + checkBoundsRect(): void; + checkBoundsSprite(): void; + } + + class Event { + constructor(sprite: Phaser.Sprite); + parent: Phaser.Sprite; + onAddedToGroup: Phaser.Signal; + onRemovedFromGroup: Phaser.Signal; + onKilled: Phaser.Signal; + onRevived: Phaser.Signal; + onOutOfBounds: Phaser.Signal; + onInputOver: Phaser.Signal; + onInputOut: Phaser.Signal; + onInputDown: Phaser.Signal; + onInputUp: Phaser.Signal; + onDragStart: Phaser.Signal; + onDragStop: Phaser.Signal; + onAnimationStart: Phaser.Signal; + onAnimationComplete: Phaser.Signal; + onAnimationLoop: Phaser.Signal; + } + + class GameObjectFactory { + constructor(game: Phaser.Game); + game: Phaser.Game; + world: Phaser.World; + existing(object: any): boolean; + sprite(x: number, y: number, key?: string, frame?: number): Phaser.Sprite; + child(parent: any, x: number, y: number, key?: string, frame?: number): Phaser.Sprite; + tween(obj: Object): Phaser.Tween; + group(parent: any, name: string): Phaser.Group; + audio(key: string, volume: number, loop: boolean): Phaser.Sound; + tileSprite(x: number, y: number, width: number, height: number, key?: string, frame?: number): Phaser.TileSprite; + text(x: number, y: number, text: string, style: string): Phaser.Text; + button(x: number, y: number, key: string, callback: Function, callbackContext: Object, overFrame?: number, outFrame?: number, downFrame?: number): Phaser.Button; + graphics(x: number, y: number): Phaser.Graphics; + emitter(x: number, y: number, maxParticles: number): Phaser.Particles.Arcade.Emitter; + bitmapText(x: number, y: number, text: string, style: string): Phaser.BitmapText; + tilemap(x: number, y: number, key: string, resizeWorld: boolean, tileWidth: number, tileHeight: number): Phaser.Tilemap; + renderTexture(key: string, width: number, height: number): Phaser.RenderTexture; + } + + class Sprite { + constructor(game: Phaser.Game, x: number, y: number, key: string, frame: number); + game: Phaser.Game; + exists: boolean; + alive: boolean; + group: Phaser.Group; + name: string; + type: number; + renderOrderID: number; + lifespan: number; + events: Phaser.Event[]; + animations: Phaser.AnimationManager; + input: Phaser.InputHandler; + key: string; + currentFrame: number; + anchor: Phaser.Point; + x: number; + y: number; + position: Phaser.Point; + autoCull: boolean; + scale: Phaser.Point; + scrollFactor: Phaser.Point; + offset: Phaser.Point; + center: Phaser.Point; + topLeft: Phaser.Point; + topRight: Phaser.Point; + bottomRight: Phaser.Point; + bottomLeft: Phaser.Point; + bounds: Phaser.Rectangle; + body: Phaser.Physics.Arcade.Body; + velocity: number; + acceleration: number; + inWorld: boolean; + inWorldThreshold: number; + angle: number; + frame: number; + frameName: string; + inCamera: boolean; + crop: boolean; + inputEnabled: boolean; + preUpdate(): void; + postUpdate(): void; + centerOn(x: number, y: number): void; + revive(): void; + kill(): void; + reset(x: number, y: number): void; + updateBounds(): void; + getLocalPosition(p: Phaser.Point, x: number, y: number): Phaser.Point; + getLocalUnmodifiedPosition(p: Phaser.Point, x: number, y: number): Phaser.Point; + bringToTop(): void; + getBounds(rect: Phaser.Rectangle): Phaser.Rectangle; + } + + class TileSprite { + constructor(game: Phaser.Game, x: number, y: number, width: number, height: number, key?: string, frame?: number); + texture: Phaser.RenderTexture; + type: number; + tileScale: Phaser.Point; + tilePosition: Phaser.Point; + } + + class Text { + constructor(game: Phaser.Game, x: number, y: number, text: string, style: string); + exists: boolean; + alive: boolean; + group: Phaser.Group; + name: string; + game: Phaser.Game; + type: number; + text: string; + angle: number; + style: string; + position: Phaser.Point; + anchor: Phaser.Point; + scale: Phaser.Point; + scrollFactor: Phaser.Point; + renderable: boolean; + update(): void; + } + + class BitmapText extends Phaser.Text { + } + + class Button { + constructor(game: Phaser.Game, x: number, y: number, key: string, callback: Function, overFrame: number, outFrame: number, downFrame: number); + input: Phaser.InputHandler; + onInputUp: Phaser.Signal; + onInputDown: Phaser.Signal; + onInputOut: Phaser.Signal; + onInputOver: Phaser.Signal; + events: Phaser.Event[]; + setFrames(overFrame?: number, outFrame?: number, downFrame?: number): void; + onInputOverHandler(pointer: Phaser.Pointer): void; + onInputUpHandler(pointer: Phaser.Pointer): void; + onInputDownHandler(pointer: Phaser.Pointer): void; + onInputOutHandler(pointer: Phaser.Pointer): void; + } + + class Graphics extends Phaser.Sprite { + constructor(game: Phaser.Game, x: number, y: number); + angle: number; + } + + class RenderTexture { + constructor(game: Phaser.Game, key: string, width: number, height: number); + name: string; + type: number; + } + + class Canvas { + create(width: number, height: number): HTMLCanvasElement; + getOffset(element: HTMLElement, point?: Phaser.Point): Phaser.Point; + getAspectRatio(canvas: HTMLCanvasElement): number; + setBackgroundColor(canvas: HTMLCanvasElement, color: string): HTMLCanvasElement; + setTouchAction(canvas: HTMLCanvasElement, value: string): HTMLCanvasElement; + addToDOM(canvas: HTMLCanvasElement, parent: string, overflowHidden: boolean): HTMLCanvasElement; + setTransform(context: CanvasRenderingContext2D, translateX: number, translateY: number, scaleX: number, scaleY: number, skewX: number, skewY: number): CanvasRenderingContext2D; + setSmoothingEnabled(context: CanvasRenderingContext2D, value: boolean): CanvasRenderingContext2D; + setImageRenderingCrisp(canvas: HTMLCanvasElement): HTMLCanvasElement; + setImageRenderingBicubic(canvas: HTMLCanvasElement): HTMLCanvasElement; + } + + class StageScaleMode { + constructor(game: Phaser.Game, width: number, height: number); + static EXACT_FIT: number; + static NO_SCALE: number; + static SHOW_ALL: number; + forceLandscape: boolean; + forcePortrait: boolean; + incorrectOrientation: boolean; + pageAlignHorizontally: boolean; + pageAlignVeritcally: boolean; + minWidth: number; + maxWidth: number; + width: number; + height: number; + maxIterations: number; + game: Phaser.Game; + enterLandscape: Phaser.Signal; + enterPortrait: Phaser.Signal; + orientation: number; + scaleFactor: Phaser.Point; + aspectRatio: number; + isFullScreen: boolean; + isPortrait: boolean; + isLandscape: boolean; + startFullScreen(): void; + stopFullScreen(): void; + checkOrientationState(): void; + checkOrientation(): void; + checkResize(event: any): void; + refresh(): void; + setScreenSize(force: boolean): void; + setSize(): void; + setMaximum(): void; + setShowAll(): void; + setExactFit(): void; + } + + class Device { + patchAndroidClearRect: boolean; + desktop: boolean; + iOS: boolean; + android: boolean; + chromeOS: boolean; + linux: boolean; + macOS: boolean; + windows: boolean; + canvas: boolean; + file: boolean; + fileSystem: boolean; + localStorage: boolean; + webGL: boolean; + worker: boolean; + touch: boolean; + mspointer: boolean; + css3D: boolean; + pointerLock: boolean; + arora: boolean; + chrome: boolean; + epiphany: boolean; + firefox: boolean; + ie: boolean; + ieVersion: number; + mobileSafari: boolean; + midori: boolean; + opera: boolean; + safari: boolean; + webApp: boolean; + audioData: boolean; + webAudio: boolean; + ogg: boolean; + opus: boolean; + mp3: boolean; + wav: boolean; + m4a: boolean; + webm: boolean; + iPhone: boolean; + iPhone4: boolean; + iPad: boolean; + pixelRatio: number; + canPlayAudio(type: string): boolean; + isConsoleOpen(): boolean; + } + + class RequestAnimationFrame { + constructor(game: Phaser.Game); + game: Phaser.Game; + isRunning: boolean; + start(): boolean; + updateRAF(time: number): void; + updateSetTimeout(): void; + stop(): void; + isSetTimeOut(): boolean; + isRAF(): boolean; + } + + class RandomDataGenerator { + constructor(seeds: Array); + c: number; + s0: number; + s1: number; + s2: number; + rnd(): number; + sow(seeds: Array): void; + hash(data: any): number; + integer(): number; + frac(): number; + real(): number; + integerInRange(min: number, max: number): number; + realInRange(min: number, max: number): number; + normal(): number; + uuid(): number; + pick(ary: number[]): number; + weightedPick(ary: number[]): number; + timestamp(a?: number, b?: number): number; + angle(): number; + } + + class Math { + static PI2: number; + static fuzzyEqual(a: number, b: number, epsilon?: number): boolean; + static fuzzyLessThan(a: number, b: number, epsilon?: number): boolean; + static fuzzyGreaterThan(a: number, b: number, epsilon?: number): boolean; + static fuzzyCeil(a: number, b: number, epsilon?: number): boolean; + static fuzzyFloor(a: number, b: number, epsilon?: number): boolean; + static average(...numbers: number[]): number; + static truncate(n: number): number; + static shear(n: number): number; + static snapTo(input: number, gap: number, start?: number): number; + static snapToFloor(input: number, gap: number, start?: number): number; + static snapToCeil(input: number, gap: number, start?: number): number; + static snapToInArray(input: number, arr: number[], sort?: boolean): number; + static roundTo(value: number, place?: number, base?: number): number; + static floorTo(value: number, place?: number, base?: number): number; + static ceilTo(value: number, place?: number, base?: number): number; + static interpolateFloat(a: number, b: number, weight: number): number; + static angleBetween(x1: number, y1: number, x2: number, y2: number): number; + static normalizeAngle(angle: number, radians?: boolean): number; + static nearestAngleBetween(a1: number, a2: number, radians?: boolean): number; + static interpolateAngles(a1: number, a2: number, weight: number, radians?: boolean, ease?: any): number; + static chanceRoll(chance?: number): boolean; + static numberArray(min: number, max: number): number[]; + static maxAdd(value: number, amount: number, max: number): number; + static minSub(value: number, amount: number, min: number): number; + static wrap(value: number, min: number, max: number): number; + static wrapValue(value: number, amount: number, max: number): number; + static randomSign(): number; + static isOdd(n: number): boolean; + static isEven(n: number): boolean; + static max(...numbers: number[]): number; + static min(...numbers: number[]): number; + static wrapAngle(angle: number): number; + static angleLimit(angle: number, min: number, max: number): number; + static linearInterpolation(v: number[], k: number): number; + static bezierInterpolation(v: number[], k: number): number; + static catmullRomInterpolation(v: number[], k: number): number; + static linear(p0: number, p1: number, t: number): number; + static bernstein(n: number, i: number): number; + static catmullRom(p0: number, p1: number, p2: number, p3: number, t: number): number; + static difference(a: number, b: number): number; + static getRandom(objects: Object[], startIndex?: number, length?: number): Object; + static floor(value: number): number; + static ceil(value: number): number; + static sinCosGenerator(length: number, sinAmplitude?: number, cosAmplitude?: number, frequency?: number): { sin: number[]; cos: number[]; }; + static shift(stack: Array): any; + static shuffleArray(array: Array): Array; + static distance(x1: number, y1: number, x2: number, y2: number): number; + static distanceRounded(x1: number, y1: number, x2: number, y2: number): number; + static clamp(x: number, a: number, b: number): number; + static clampBottom(x: number, a: number): number; + static mapLinear(x: number, a1: number, a2: number, b1: number, b2: number): number; + static smoothstep(x: number, min: number, max: number): number; + static smootherstep(x: number, min: number, max: number): number; + static sign(x: number): number; + static degToRad(degrees: number): number; + static radToDeg(radians: number): number; + } + + class QuadTree { + constructor(physicsManager: Phaser.Physics.Arcade, x: number, y: number, width: number, height: number, maxObject?: number, maxLevels?: number, level?: number); + physicsManager: Phaser.Physics.Arcade; + ID: number; + maxObjects: number; + maxLevels: number; + level: number; + bounds: { + x: number; + y: number; + width: number; + height: number; + subWidth: number; + subHeight: number; + right: number; + bottom: number; + }; + objects: Array; + nodes: Array; + split(): void; + insert(body: Object): void; + getIndex(rect: Object): number; + retrieve(sprite: Object): Array; + clear(): void; + } + + class Circle { + constructor(x?: number, y?: number, diameter?: number); + x: number; + y: number; + diameter: number; + radius: number; + left: number; + right: number; + top: number; + bottom: number; + area: number; + empty: boolean; + circumference(): number; + setTo(x: number, y: number, diameter: number): Circle; + copyFrom(source: any): Circle; + copyTo(dest: Object): Object; + distance(dest: Object, round: boolean): number; + clone(out: Phaser.Circle): Phaser.Circle; + contains(x: number, y: number): Phaser.Circle; + circumferencePoint(angle: number, asDegrees: number, output?: Phaser.Point): Phaser.Point; + offset(dx: number, dy: number): Phaser.Circle; + offsetPoint(point: Phaser.Point): Phaser.Circle; + toString(): string; + static contains(a: Phaser.Circle, x: number, y: number): boolean; + static equals(a: Phaser.Circle, b: Phaser.Circle): boolean; + static intersects(a: Phaser.Circle, b: Phaser.Circle): boolean; + static circumferencePoint(a: Phaser.Circle, angle: number, asDegrees: boolean, output?: Phaser.Point): Phaser.Point; + static intersectsRectangle(c: Phaser.Circle, r: Phaser.Rectangle): boolean; + } + + class Point { + constructor(x: number, y: number); + x: number; + y: number; + copyFrom(source: any): Phaser.Point; + invert(): Phaser.Point; + setTo(x: number, y: number): Phaser.Point; + add(x: number, y: number): Phaser.Point; + subtract(x: number, y: number): Phaser.Point; + multiply(x: number, y: number): Phaser.Point; + divide(x: number, y: number): Phaser.Point; + clampX(min: number, max: number): Phaser.Point; + clampY(min: number, max: number): Phaser.Point; + clamp(min: number, max: number): Phaser.Point; + clone(output: Phaser.Point): Phaser.Point; + copyTo(dest: any): Object; + distance(dest: Object, round?: boolean): number; + equals(a: Phaser.Point): boolean; + rotate(x: number, y: number, angle: number, asDegrees: boolean, distance: number): Phaser.Point; + toString(): string; + static add(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point; + static subtract(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point; + static multiply(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point; + static divide(a: Phaser.Point, b: Phaser.Point, out?: Phaser.Point): Phaser.Point; + static equals(a: Phaser.Point, b: Phaser.Point): boolean; + static distance(a: Phaser.Point, b: Phaser.Point, round: boolean): number; + static rotate(a: Phaser.Point, x: number, y: number, angle: number, asDegrees: boolean, distance: boolean): Phaser.Point; + } + + class Rectangle { + constructor(x: number, y: number, width: number, height: number); + x: number; + y: number; + width: number; + height: number; + halfWidth: number; + halfHeight: number; + bottom: number; + bottomRight: Phaser.Point; + left: number; + right: number; + volume: number; + perimeter: number; + centerX: number; + centerY: number; + top: number; + topLeft: Phaser.Point; + empty: boolean; + offset(dx: number, dy: number): Phaser.Rectangle; + offsetPoint(point: Phaser.Point): Phaser.Rectangle; + setTo(x: number, y: number, width: number, height: number): Phaser.Rectangle; + floor(): void; + copyFrom(source: any): Phaser.Rectangle; + copyTo(dest: any): Object; + inflate(dx: number, dy: number): Phaser.Rectangle; + size(output: Phaser.Point): Phaser.Point; + clone(output: Phaser.Rectangle): Phaser.Rectangle; + contains(x: number, y: number): boolean; + containsRect(b: Phaser.Rectangle): boolean; + equals(b: Phaser.Rectangle): boolean; + intersection(b: Phaser.Rectangle, out: Phaser.Rectangle): Phaser.Rectangle; + intersects(b: Phaser.Rectangle, tolerance: number): boolean; + intersectsRaw(left: number, right: number, top: number, bottom: number, tolerance: number): boolean; + union(b: Phaser.Rectangle, out: Phaser.Rectangle): Phaser.Rectangle; + toString(): string; + static inflate(a: Phaser.Rectangle, dx: number, dy: number): Phaser.Rectangle; + static inflatePoint(a: Phaser.Rectangle, point: Phaser.Point): Phaser.Rectangle; + static size(a: Phaser.Rectangle, output: Phaser.Point): Phaser.Point; + static clone(a: Phaser.Rectangle, output: Phaser.Rectangle): Phaser.Rectangle; + static contains(a: Phaser.Rectangle, x: number, y: number): boolean; + static containsPoint(a: Phaser.Rectangle, point: Phaser.Point): boolean; + static containsRect(a: Phaser.Rectangle, b: Phaser.Rectangle): boolean; + static equals(a: Phaser.Rectangle, b: Phaser.Rectangle): boolean; + static intersection(a: Phaser.Rectangle, b: Phaser.Rectangle, out: Phaser.Rectangle): Phaser.Rectangle; + static intersects(a: Phaser.Rectangle, b: Phaser.Rectangle, tolerance: number): boolean; + static intersectsRaw(a: Phaser.Rectangle, left: number, right: number, top: number, bottom: number, tolerance: number): boolean; + static union(a: Phaser.Rectangle, b: Phaser.Rectangle, out: Phaser.Rectangle): Phaser.Rectangle; + } + + class Net { + constructor(game: Phaser.Game); + game: Phaser.Game; + getHostName(): string; + checkDomainName(domain: string): string; + updateQueryString(key: string, value: any, redirect?: boolean, url?: string): string; + getQueryString(parameter?: string): string; + decodeURI(value: string): string; + } + + class TweenManager { + constructor(game: Phaser.Game); + game: Phaser.Game; + REVISION: string; + getAll(): Phaser.Tween[]; + removeAll(): void; + add(tween: Phaser.Tween): Phaser.Tween; + create(object: Object): Phaser.Tween; + remove(tween: Phaser.Tween): void; + update(): boolean; + pauseAll(): void; + resumeAll(): void; + } + + class Tween { + constructor(object: Object, game: Phaser.Game); + game: Phaser.Game; + pending: boolean; + pendingDelete: boolean; + onStart: Phaser.Signal; + onComplete: Phaser.Signal; + isRunning: boolean; + to(properties: Object, duration?: number, ease?: any, autoStart?: boolean, delay?: number, loop?: boolean): Phaser.Tween; + start(time: number): Phaser.Tween; + stop(): Phaser.Tween; + delay(amount: number): Phaser.Tween; + repeat(times: number): Phaser.Tween; + yoyo(yoyo: boolean): Phaser.Tween; + easing(easing: any): Phaser.Tween; + interpolation(interpolation: Function): Phaser.Tween; + chain(...tweens: Phaser.Tween[]): Phaser.Tween; + loop(): Phaser.Tween; + onStartCallback(callback: Function): Phaser.Tween; + onUpdateCallback(callback: Function): Phaser.Tween; + onCompleteCallback(callback: Function): Phaser.Tween; + pause(): void; + resume(): void; + update(time: number): boolean; + } + + class Easing { + Linear: { + None: (k: number) => number; + }; + Quadratic: { + In: (k: number) => number; + Out: (k: number) => number; + InOut: (k: number) => number; + }; + Cubic: { + In: (k: number) => number; + Out: (k: number) => number; + InOut: (k: number) => number; + }; + Quartic: { + In: (k: number) => number; + Out: (k: number) => number; + InOut: (k: number) => number; + }; + Quintic: { + In: (k: number) => number; + Out: (k: number) => number; + InOut: (k: number) => number; + }; + Sinusoidal: { + In: (k: number) => number; + Out: (k: number) => number; + InOut: (k: number) => number; + }; + Exponential: { + In: (k: number) => number; + Out: (k: number) => number; + InOut: (k: number) => number; + }; + Circular: { + In: (k: number) => number; + Out: (k: number) => number; + InOut: (k: number) => number; + }; + Elastic: { + In: (k: number) => number; + Out: (k: number) => number; + InOut: (k: number) => number; + }; + Back: { + In: (k: number) => number; + Out: (k: number) => number; + InOut: (k: number) => number; + }; + Bounce: { + In: (k: number) => number; + Out: (k: number) => number; + InOut: (k: number) => number; + }; + } + + class Time { + constructor(game: Phaser.Game); + game: Phaser.Game; + physicsElapsed: number; + time: number; + pausedTime: number; + now: number; + elapsed: number; + fps: number; + fpsMin: number; + fpsMax: number; + msMin: number; + msMax: number; + frames: number; + pauseDuration: number; + timeToCall: number; + lastTime: number; + totalElapsedSeconds(): number; + update(time: number): number; + gamePaused(): void; + gameResumed(): void; + elapsedSince(since: number): number; + elapsedSecondsSince(since: number): number; + reset(): void; + } + + class AnimationManager { + constructor(sprite); + sprite: Phaser.Sprite; + game: Phaser.Game; + currentFrame: Phaser.Animation.Frame; + updateIfVisible: boolean; + frameData: Phaser.Animation.FrameData; + frameTotal: number; + frame: number; + frameName: string; + loadFrameData(frameData: Phaser.Animation.FrameData): void; + add(name: string, frames?: Array, frameRate?: number, loop?: boolean, useNumericIndex?: boolean): Phaser.Animation; + validateFrames(frames: Array, useNumericIndex?: boolean): boolean; + play(name: string, frameRate?: number, loop?: boolean): Phaser.Animation; + stop(name?: string, resetFrame?: boolean): void; + update(): boolean; + destroy(): void; + } + + class Animation { + constructor(game: Phaser.Game, parent: Phaser.Sprite, name: string, frameData: Phaser.Animation.FrameData, frames: any[], delay: number, looped: boolean); + game: Phaser.Game; + name: string; + delay: number; + looped: boolean; + isFinished: boolean; + isPlaying: boolean; + currentFrame: Phaser.Animation.Frame; + frameTotal: number; + frame: number; + play(frameRate?: number, loop?: boolean): Phaser.Animation; + restart(): void; + stop(resetFrame?: boolean): void; + update(): boolean; + destroy(): void; + onComplete(): void; + } + + module Animation { + class Frame { + constructor(index: number, x: number, y: number, width: number, height: number, name: string, uuid: string); + index: number; + x: number; + y: number; + width: number; + height: number; + centerX: number; + centerY: number; + distance: number; + name: string; + uuid: string; + rotated: boolean; + rotationDirection: string; + trimmed: boolean; + sourceSizeW: number; + sourceSizeH: number; + spriteSourceSizeX: number; + spriteSourceSizeY: number; + spriteSourceSizeW: number; + spriteSourcesizeH: number; + setTrim(trimmed: boolean, actualWidth: number, actualHeight: number, destX: number, destY: number, destWidth: number, destHeight: number): void; + } + + class FrameData { + addFrame(frame: Frame): Frame; + getFrame(index: number): Frame; + getFrameByName(name: string): Frame; + checkFrame(name: string): boolean; + getFrameRange(start: number, end: number, output: Array): Array; + getFrames(frames: Array, useNumericIndex?: boolean, output?: Array): Array; + getFrameIndexes(frames: Array, useNumericIndex?: boolean, output?: Array): Array; + total: number; + } + + class Parser { + spriteSheet(game: Phaser.Game, key: string, frameWidth: number, frameHeight: number, frameMax?: number): Phaser.Animation.FrameData; + JSONData(game: Phaser.Game, json: Object, cacheKey: string): Phaser.Animation.FrameData; + JSONDataHash(game: Phaser.Game, json: Object, cacheKey: string): Phaser.Animation.FrameData; + XMLData(game: Phaser.Game, xml: Object, cacheKey: string): Phaser.Animation.FrameData; + } + } + + class Cache { + constructor(game: Phaser.Game); + game: Phaser.Game; + onSoundUnlock: Phaser.Signal; + addCanvas(key: string, canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; + addRenderTexture(key: string, texture: RenderTexture): void; + addSpriteSheet(key: string, url: string, data: Object, frameWidth: number, frameHeight: number, frameMax: number): void; + addTilemap(key: string, url: string, data: Object, mapData: Object, atlasData: Object): void; + addTextureAtlas(key: string, url: string, data: Object, atlasData: Object): void; + addBitmapFont(key: string, url: string, data: Object, xmlData: Object): void; + addDefaultImage(): void; + addImage(key: string, url: string, data: Object): void; + addSound(key: string, url: string, data: Object): void; + reloadSound(key: string): void; + reloadSoundComplete(key: string): void; + updateSound(key: string, property: string, value: Phaser.Sound): void; + decodedSound(key: string, data: Object): void; + addText(key: string, url: string, data: Object): void; + getCanvas(key: string): Object; + checkImageKey(key: string): boolean; + getImage(key: string): Object; + getTilemap(key: string): Phaser.Tilemap; + getFrameData(key: string): Phaser.Animation.FrameData; + getFrameByIndex(key: string, frame: string): Phaser.Animation.Frame; + getFrameByName(key: string, frame: string): Phaser.Animation.Frame; + getFrame(key: string): Phaser.Animation.Frame; + getTextureFrame(key: string): Phaser.Animation.Frame; + getTexture(key: string): Phaser.RenderTexture; + getSound(key: string): Phaser.Sound; + getSoundData(key: string): Object; + isSoundDecoded(key: string): boolean; + isSoundReady(key: string): boolean; + isSpriteSheet(key: string): boolean; + getText(key: string): Object; + getKeys(array: Array): Array; + getImageKeys(): string[]; + getSoundKeys(): string[]; + getTextKeys(): string[]; + removeCanvas(key: string): void; + removeImage(key: string): void; + removeSound(key: string): void; + removeText(key: string): void; + destroy(): void; + } + + class Loader { + static TEXTURE_ATLAS_JSON_ARRAY: number; + static TEXTURE_ATLAS_JSON_HASH: number; + static TEXTURE_ATLAS_XML_STARLING: number; + constructor(game: Phaser.Game); + game: Phaser.Game; + queueSize: number; + isLoading: boolean; + hasLoaded: boolean; + progress: number; + preloadSprite: Phaser.Sprite; + crossOrigin: string; + baseURL: string; + onFileComplete: Phaser.Signal; + onFileError: Phaser.Signal; + onLoadStart: Phaser.Signal; + onLoadComplete: Phaser.Signal; + setPreloadSprite(sprite: Phaser.Sprite, direction: number): void; + checkKeyExists(key: string): boolean; + reset(): void; + addToFileList(type: string, key: string, url: string, properties: Array): void; + image(key: string, url: string, overwrite?: boolean): void; + text(key: string, url: string, overwrite?: boolean): void; + spritesheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax: number): void; + audio(key: string, urls: string[], autoDecode?: boolean): void; + tilemap(key: string, tilesetURL: string, mapDataURL?: string, mapData?: Object, format?: string): void; + bitmapFont(key: string, textureURL: string, xmlURL?: string, xmlData?: Object): void; + atlasJSONArray(key: string, textureURL: string, atlasURL: string, atlasData: Object): void; + atlasJSONHash(key: string, textureURL: string, atlasURL: string, atlasData: Object): void; + atlasXML(key: string, textureURL: string, atlasURL: string, atlasData: Object): void; + atlas(key: string, textureURL: string, atlasURL?: string, atlasData?: Object, format?: number): void; + removeFile(key: string): void; + removeAll(): void; + start(): void; + loadFile(): void; + getAudioURL(urls: string[]): string; + fileError(key: string): void; + fileComplete(key: string): void; + jsonLoadComplete(key: string): void; + csvLoadComplete(key: string): void; + dataLoadError(key: string): void; + xmlLoadComplete(key: string): void; + nextFile(previousKey: string, success: boolean): void; + } + + module Loader { + class Parser { + bitmapFont(game: Phaser.Game, xml: Object, cacheKey: Phaser.Animation.FrameData): void; + } + } + + class Sound { + constructor(game: Phaser.Game, key: string, volume?: number, loop?: boolean); + game: Phaser.Game; + name: string; + key: string; + loop: boolean; + markers: Object; + context: any; + autoplay: boolean; + totalDuration: number; + startTime: number; + currentTime: number; + duration: number; + stopTime: number; + paused: boolean; + isPlaying: boolean; + currentMarker: string; + pendingPlayback: boolean; + override: boolean; + usingWebAudio: boolean; + usingAudioTag: boolean; + onDecoded: Phaser.Signal; + onPlay: Phaser.Signal; + onPause: Phaser.Signal; + onResume: Phaser.Signal; + onLoop: Phaser.Signal; + onStop: Phaser.Signal; + onMute: Phaser.Signal; + isDecoded: boolean; + isDecoding: boolean; + mute: boolean; + volume: number; + onMarkerComplete: Phaser.Signal; + soundHasUnlocked(key: string): void; + addMarker(name: string, start: number, stop: number, volume?: number, loop?: boolean): void; + removeMarker(name: string): void; + update(): void; + play(marker: string, position: number, volume?: number, loop?: boolean): Phaser.Sound; + restart(marker: string, position: number, volume?: number, loop?: boolean): void; + pause(): void; + resume(): void; + stop(): void; + } + + class SoundManager { + constructor(game: Phaser.Game); + game: Phaser.Game; + onSoundDecode: Phaser.Signal; + context: any; + usingWebAudio: boolean; + usingAudioTag: boolean; + noAudio: boolean; + touchLocked: boolean; + channels: number; + mute: boolean; + volume: number; + boot(): void; + unlock(): void; + stopAll(): void; + pauseAll(): void; + resumeAll(): void; + decode(key: string, sound?: Phaser.Sound): void; + update(): void; + add(key: string, volume: number, loop: boolean): Phaser.Sound; + } + + module Utils { + class Debug { + constructor(game: Phaser.Game); + game: Phaser.Game; + font: string; + lineHeight: number; + renderShadow: boolean; + currentX: number; + currentY: number; + currentAlpha: number; + start(x?: number, y?: number, color?: string): void; + stop(): void; + line(text: string, x: number, y: number): void; + renderQuadTree(quadtree: Phaser.QuadTree, color?: string): void; + renderSpriteCorners(sprite: Phaser.Sprite, showText?: boolean, showBounds?: boolean, color?: string): void; + renderSoundInfo(sound: Phaser.Sound, x: number, y: number, color?: string): void; + renderCameraInfo(camera: Phaser.Camera, x: number, y: number, color?: string): void; + renderPointer(pointer: Phaser.Pointer, hideIfUp?: boolean, downColor?: string, upColor?: string, color?: string): void; + renderSpriteInputInfo(sprite: Phaser.Sprite, x: number, y: number, color?: string): void; + renderSpriteCollision(sprite: Phaser.Sprite, x: number, y: number, color?: string): void; + renderInputInfo(x: number, y: number, color?: string): void; + renderSpriteInfo(sprite: Phaser.Sprite, x: number, y: number, color?: string): void; + renderWorldTransformInfo(sprite: Phaser.Sprite, x: number, y: number, color?: string): void; + renderLocalTransformInfo(sprite: Phaser.Sprite, x: number, y: number, color?: string): void; + renderPointInfo(point: Phaser.Point, x: number, y: number, color?: string): void; + renderSpriteBody(sprite: Phaser.Sprite, color?: string): void; + renderSpriteBounds(sprite: Phaser.Sprite, color?: string, fill?: boolean): void; + renderPixel(x: number, y: number, fillStyle?: string): void; + renderPoint(point: Phaser.Point, fillStyle?: string): void; + renderRectangle(rect: Phaser.Rectangle, fillStyle?: string): void; + renderCircle(circle: Phaser.Circle, fillStyle?: string): void; + renderText(text: string, x: number, y: number, color?: string, font?: string): void; + } + } + + class Color { + getColor32(alpha: number, red: number, green: number, blue: number): number; + getColor(red: number, green: number, blue: number): number; + hexToRGB(h: string): number; + getColorInfo(color: number): string; + RGBtoHexstring(color: number): string; + RGBtoWebstring(color: number): string; + colorToHexstring(color: number): string; + interpolateColor(color1: number, color2: number, steps: number, currentStep: number, alpha: number): number; + interpolateColorWithRGB(color: number, r: number, g: number, b: number, steps: number, currentStep: number): number; + interpolateRGB(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, steps: number, currentStep: number): number; + getRandomColor(min?: number, max?: number, alpha?: number): number; + getRGB(color: number): Object; + getWebRGB(color: number): string; + getAlpha(color: number): number; + getAlphaFloat(color: number): number; + getRed(color: number): number; + getGreen(color: number): number; + getBlue(color: number): number; + } + + module Physics { + class Arcade { + constructor(game: Phaser.Game) + game: Phaser.Game; + gravity: Phaser.Point; + bounds: Phaser.Rectangle; + maxObjects: number; + maxLevels: number; + OVERLAP_BIAS: number; + TILE_OVERLAP: number; + quadTree: Phaser.QuadTree; + quadTreeID: number; + updateMotion(body: Phaser.Physics.Arcade.Body); + computeVelocity(axis: number, body: Phaser.Physics.Arcade.Body, velocity: number, acceleration: number, drag: number, max: number): void; + preUpdate(): void; + postUpdate(): void; + collide(object1: any, object2: any, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean; + collideSpriteVsSprite(sprite1: Phaser.Sprite, sprite2: Phaser.Sprite, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean; + collideSpriteVsTilemap(sprite1: Phaser.Sprite, tilemap: Phaser.Tilemap, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean; + collideSpriteVsGroup(sprite1: Phaser.Sprite, group: Phaser.Group, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean; + collideGroupVsTilemap(group: Phaser.Group, tilemap: Phaser.Tilemap, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean; + collideGroupVsGroup(group: Phaser.Group, group2: Phaser.Group, collideCallback?: Function, processCallback?: Function, callbackContext?: any): boolean; + separate(body: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body): void; + separateX(body: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body): void; + separateY(body: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body): void; + separateTile(object: Object, x: number, y: number, width: number, height: number, mass: number, collideLeft: boolean, collideRight: boolean, collideUp: boolean, collideDown: boolean, separateX: boolean, separateY: boolean): boolean; + separateTileX(object: Object, x: number, y: number, width: number, height: number, mass: number, collideLeft: boolean, collideRight: boolean, collideUp: boolean, collideDown: boolean, separateX: boolean, separateY: boolean): boolean; + separateTileY(object: Object, x: number, y: number, width: number, height: number, mass: number, collideLeft: boolean, collideRight: boolean, collideUp: boolean, collideDown: boolean, separateX: boolean, separateY: boolean): boolean; + velocityFromAngle(angle: number, speed?: number, point?: Phaser.Point): Phaser.Point; + moveTowardsObject(source: Phaser.Sprite, dest: Phaser.Sprite, speed?: number, maxTime?: number): void; + accelerateTowardsObject(source: Phaser.Sprite, dest: Phaser.Sprite, speed?: number, xSpeedMax?: number, ySpeedMax?: number): void; + moveTowardsMouse(source: Phaser.Sprite, speed?: number, maxTime?: number): void; + accelerateTowardsMouse(source: Phaser.Sprite, speed: number, xSpeedMax?: number, ySpeedMax?: number): void; + moveTowardsPoint(source: Phaser.Sprite, target: Phaser.Point, speed?: number, maxTime?: number): void; + accelerateTowardsPoint(source: Phaser.Sprite, target: Phaser.Point, speed: number, xSpeedMax?: number, ySpeedMax?: number): void; + distanceBetween(a: Phaser.Sprite, b: Phaser.Sprite): number; + distanceToPoint(a: Phaser.Sprite, target: Phaser.Point): number; + distanceToMouse(a: Phaser.Sprite): number; + angleBetweenPoint(a: Phaser.Sprite, target: Phaser.Point, asDegrees?: boolean): number; + angleBetween(a: Phaser.Sprite, b: Phaser.Sprite, asDegrees?: boolean): number; + velocityFromFacing(parent: Phaser.Sprite, speed: number): Phaser.Point; + angleBetweenMouse(a: Phaser.Sprite, asDegress?: boolean): number; + } + + module Arcade { + class BorderChoices { + none: boolean; + any: boolean; + up: boolean; + down: boolean; + left: boolean; + right: boolean; + } + + class Body { + constructor(sprite: Phaser.Sprite); + sprite: Phaser.Sprite; + game: Phaser.Game; + offset: Phaser.Point; + x: number; + y: number; + lastX: number; + lastY: number; + sourceWidth: number; + sourceHeight: number; + width: number; + height: number; + halfWidth: number; + helfHeight: number; + velocity: Phaser.Point; + acceleration: Phaser.Point; + drag: Phaser.Point; + gravity: Phaser.Point; + bounce: Phaser.Point; + maxVelocity: Phaser.Point; + angularVelocity: number; + angularAcceleration: number; + angularDrag: number; + maxAngular: number; + mass: number; + quadTreeIDs: string[]; + quadTreeIndex: number; + allowCollision: BorderChoices; + touching: BorderChoices; + wasTouching: BorderChoices; + immovable: boolean; + moves: boolean; + rotation: number; + allowRotation: boolean; + allowGravity: boolean; + customSeparateX: boolean; + customSeparateY: boolean; + overlapX: number; + overlapY: number; + collideWorldBounds: boolean; + bottom: number; + right: number; + updateBounds(centerX: number, centerY: number, scaleX: number, scaleY: number): void; + update(): void; + postUpdate(): void; + checkWorldBounds(): void; + setSize(width: number, height: number, offsetX: number, offsetY: number): void; + reset(): void; + deltaAbsX(): number; + deltaAbsY(): number; + deltaX(): number; + deltaY(): number; + } + } + } + + class Particles { + constructor(game: Phaser.Game); + emitters: Object; + ID: number; + add(emitter: Phaser.Particles.Arcade.Emitter): Phaser.Particles.Arcade.Emitter; + remove(emitter: Phaser.Particles.Arcade.Emitter): void; + update(): void; + } + + module Particles { + module Arcade { + class Emitter { + constructor(game: Phaser.Game, x: number, y: number, maxParticles?: number); + name: string; + type: number; + x: number; + y: number; + width: number; + height: number; + minParticleSpeed: Phaser.Point; + maxParticleSpeed: Phaser.Point; + minParticleScale: number; + maxParticleScale: number; + minRotation: number; + maxRotation: number; + gravity: number; + particleClass: string; + particleDrag: Phaser.Point; + angularDrag: number; + frequency: number; + maxParticles: number; + lifespan: number; + bounce: Phaser.Point; + on: boolean; + exists: boolean; + emitX: number; + emitY: number; + alpha: number; + visible: boolean; + left: number; + top: number; + bottom: number; + right: number; + update(): void; + makeParticles(keys: string[], frames: string[], quantity: number, collide: boolean, collideWorldBounds: boolean): Phaser.Particles.Arcade.Emitter; + kill(): void; + revive(): void; + start(explode: boolean, lifespan: number, frequency: number, quantity: number): void; + emitParticle(): void; + setSize(width: number, height: number): void; + setXSpeed(min: number, max: number): void; + setYSpeed(min: number, max: number): void; + setRotation(min: number, max: number): void; + at(object: Object): void; + + } + } + } + + class Tilemap { + constructor(game: Phaser.Game, key: string, x: number, y: number, resizeWorld?: boolean, tileWidth?: number, tileHeight?: number); + game: Phaser.Game; + group: Phaser.Group; + name: string; + key: string; + renderOrderID: number; + collisionCallback: Function; + exists: boolean; + visible: boolean; + tiles: Array; + layers: Array; + position: Phaser.Point; + type: number; + renderer: Phaser.TilemapRenderer; + mapFormat: string; + widthInPixels: number; + heightInPixels: number; + static CSV: number; + static JSON: number; + parseCSV(data: string, key: string, tileWidth: number, tileHeight: number): void; + parseTiledJSON(json: string, key: string): void; + generateTiles(quantity: number): void; + setCollisionCallback(context: Object, callback: Function): void; + setCollisionRange(start: number, end: number, collision: number, resetCollisions?: boolean, separateX?: boolean, separateY?: boolean): void; + setCollisionByIndex(value: number[], collision: number, resetCollisions?: boolean, separateX?: boolean, separateY?: boolean): void; + getTileByIndex(value: number): Tile; + getTile(x: number, y: number, layer?: number): Tile; + getTileFromWorldXY(x: number, y: number, layer?: number): Tile; + getTileFromInputXY(layer?: number): Tile; + getTileOverlaps(object: Object): Array; + collide(objectOrGroup: any, callback: Function, context: Object): boolean; + collideGameObject(object: Object): boolean; + putTile(x: number, y: number, index: number, layer?: number): void; + update(): void; + destroy(): void; + } + + class TilemapLayer { + constructor(parent: Tilemap, id: number, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number); + exists: boolean; + visible: boolean; + widthInTiles: number; + heightInTiles: number; + widthInPixels: number; + heightInPixels: number; + tileMargin: number; + tileSpacing: number; + parent: Tilemap; + game: Phaser.Game; + ID: number; + name: string; + key: string; + type: number; + mapFormat: number; + tileWidth: number; + tileHeight: number; + boundsInTiles: Phaser.Rectangle; + tileset: Object; + canvas: any; + context: any; + baseTexture: any; + texture: any; + sprite: Phaser.Sprite; + mapData: Array; + alpha: number; + putTileWorldXY(x: number, y: number, index: number): void; + putTile(x: number, y: number, index: number): void; + swapTile(tileA: number, tileB: number, x?: number, y?: number, width?: number, height?: number): void; + fillTile(index: number, x?: number, y?: number, width?: number, height?: number): void; + randomiseTiles(tiles: number[], x?: number, y?: number, width?: number, height?: number): void; + replaceTile(tileA: number, tileB: number, x?: number, y?: number, width?: number, height?: number): void; + getTileBlock(x: number, y: number, width: number, height: number): Array; + getTileFromWorldXY(x: number, y: number): Tile; + getTileOverlaps(object: Object): Array; + getTempBlock(x: number, y: number, width: number, height: number, collisionOnly?: boolean): void; + getTileIndex(x: number, y: number): number; + addColumn(column: string[]): void; + createCanvas(): void; + updateBounds(): void; + parseTileOffsets(): number; + } + + class Tile { + constructor(game: Phaser.Game, tilemap: Tilemap, index: number, width: number, height: number); + mass: number; + collideNone: boolean; + collideLeft: boolean; + collideRight: boolean; + collideUp: boolean; + collideDown: boolean; + separateX: boolean; + separateY: boolean; + game: Phaser.Game; + tilemap: Tilemap; + index: number; + width: number; + height: number; + destroy(): void; + setCollision(left: boolean, right: boolean, up: boolean, down: boolean, reset: boolean, seperateX: boolean, seperateY: boolean): void; + resetCollsion(): void; + toString(): string; + } + + class TilemapRenderer { + constructor(game: Phaser.Game); + game: Phaser.Game; + render(tilemap: Tilemap): void; + } +} \ No newline at end of file diff --git a/build/phaser.js b/build/phaser.js index 5ffb83d7..64dbcf4d 100644 --- a/build/phaser.js +++ b/build/phaser.js @@ -1,9 +1,26 @@ +!function(root, factory) { + if (typeof define === "function" && define.amd) { + define(factory); + } else if (typeof exports === "object") { + module.exports = factory(); + } else { + root.Phaser = factory(); + } +}(this, function() { /** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* @overview +* * Phaser - http://www.phaser.io * -* v1.0.6 - Built at: Thu, 26 Sep 2013 10:48:10 +0000 +* v1.1.0 - Built at: Fri Oct 25 2013 18:25:28 * -* @author Richard Davey http://www.photonstorm.com @photonstorm +* By Richard Davey http://www.photonstorm.com @photonstorm * * A feature-packed 2D HTML5 game framework born from the smouldering pits of Flixel and * constructed via plenty of blood, sweat, tears and coffee by Richard Davey (@photonstorm). @@ -30,12 +47,18 @@ var PIXI = PIXI || {}; /** - * @module Phaser - */ -var Phaser = Phaser || { +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ - VERSION: '1.0.6a', - GAMES: [], +/** +* @namespace Phaser +*/ +var Phaser = Phaser || { + + VERSION: '1.1.0', + GAMES: [], AUTO: 0, CANVAS: 1, WEBGL: 2, @@ -51,7 +74,13 @@ var Phaser = Phaser || { RENDERTEXTURE: 8, TILEMAP: 9, TILEMAPLAYER: 10, - EMITTER: 11 + EMITTER: 11, + + NONE: 0, + LEFT: 1, + RIGHT: 2, + UP: 3, + DOWN: 4 }; @@ -59,31 +88,44 @@ PIXI.InteractionManager = function (dummy) { // We don't need this in Pixi, so we've removed it to save space // however the Stage object expects a reference to it, so here is a dummy entry. }; + /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Utils +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** -* -* @class Utils +* @class Phaser.Utils * @static */ Phaser.Utils = { + shuffle: function (array) { + + for (var i = array.length - 1; i > 0; i--) + { + var j = Math.floor(Math.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + + return array; + + }, + /** - * Javascript string pad - * http://www.webtoolkit.info/ - * pad = the string to pad it out with (defaults to a space) + * Javascript string pad http://www.webtoolkit.info/. + * pad = the string to pad it out with (defaults to a space)
    * dir = 1 (left), 2 (right), 3 (both) - * @method pad - * @param {string} str the target string - * @param {number} pad the string to pad it out with (defaults to a space) - * @param {number} len - * @param {number} [dir=3] the direction dir = 1 (left), 2 (right), 3 (both) - **/ + * @method Phaser.Utils.pad + * @param {string} str - The target string. + * @param {number} len - Description. + * @param {number} pad - the string to pad it out with (defaults to a space). + * @param {number} [dir=3] the direction dir = 1 (left), 2 (right), 3 (both). + * @return {string} + */ pad: function (str, len, pad, dir) { if (typeof(len) == "undefined") { var len = 0; } @@ -114,10 +156,11 @@ Phaser.Utils = { }, - /** - * This is a slightly modified version of jQuery.isPlainObject - * @method isPlainObject - * @param {object} obj + /** + * This is a slightly modified version of jQuery.isPlainObject. A plain object is an object whose internal class property is [object Object]. + * @method Phaser.Utils.isPlainObject + * @param {object} obj - The object to inspect. + * @return {boolean} - true if the object is plain, otherwise false. */ isPlainObject: function (obj) { @@ -148,12 +191,19 @@ Phaser.Utils = { return true; }, - /** - * This is a slightly modified version of jQuery.extend (http://api.jquery.com/jQuery.extend/) - * @method extend - * @param {bool} [deep] If true, the merge becomes recursive (aka. deep copy). - * @param {object} target The object to add to - * @param {object} objets Objects to recurse and copy from + + // deep, target, objects to copy to the target object + // This is a slightly modified version of {@link http://api.jquery.com/jQuery.extend/|jQuery.extend} + // deep (boolean) + // target (object to add to) + // objects ... (objects to recurse and copy from) + + /** + * This is a slightly modified version of http://api.jquery.com/jQuery.extend/ + * @method Phaser.Utils.extend + * @param {boolean} deep - Perform a deep copy? + * @param {object} target - The target object to copy to. + * @return {object} The extended object. */ extend: function () { @@ -233,8 +283,7 @@ Phaser.Utils = { /** * Converts a hex color number to an [R, G, B] array * - * @method HEXtoRGB - * @param {Number} hex + * @param {number} hex * @return {array} */ function HEXtoRGB(hex) { @@ -243,8 +292,6 @@ function HEXtoRGB(hex) { /** * A polyfill for Function.prototype.bind - * - * @method bind */ if (typeof Function.prototype.bind != 'function') { Function.prototype.bind = (function () { @@ -573,8 +620,8 @@ PIXI.mat4.multiply = function (mat, mat2, dest) * * @class Point * @constructor - * @param x {Number} position of the point - * @param y {Number} position of the point + * @param x {number} position of the point + * @param y {number} position of the point */ PIXI.Point = function(x, y) { @@ -617,10 +664,10 @@ PIXI.Point.prototype.constructor = PIXI.Point; * * @class Rectangle * @constructor - * @param x {Number} The X coord of the upper-left corner of the rectangle - * @param y {Number} The Y coord of the upper-left corner of the rectangle - * @param width {Number} The overall wisth of this rectangle - * @param height {Number} The overall height of this rectangle + * @param x {number} The X coord of the upper-left corner of the rectangle + * @param y {number} The Y coord of the upper-left corner of the rectangle + * @param width {number} The overall wisth of this rectangle + * @param height {number} The overall height of this rectangle */ PIXI.Rectangle = function(x, y, width, height) { @@ -668,8 +715,8 @@ PIXI.Rectangle.prototype.clone = function() * Checks if the x, and y coords passed to this function are contained within this Rectangle * * @method contains - * @param x {Number} The X coord of the point to test - * @param y {Number} The Y coord of the point to test + * @param x {number} The X coord of the point to test + * @param y {number} The Y coord of the point to test * @return {Boolean} if the x/y coords are within this Rectangle */ PIXI.Rectangle.prototype.contains = function(x, y) @@ -1344,7 +1391,7 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child) * * @method addChildAt * @param child {DisplayObject} The child to add - * @param index {Number} The index to place the child in + * @param index {number} The index to place the child in */ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index) { @@ -1479,7 +1526,7 @@ PIXI.DisplayObjectContainer.prototype.swapChildren = function(child, child2) * Returns the Child at the specified index * * @method getChildAt - * @param index {Number} The index to get the child from + * @param index {number} The index to get the child from */ PIXI.DisplayObjectContainer.prototype.getChildAt = function(index) { @@ -1785,7 +1832,7 @@ PIXI.Sprite.fromImage = function(imageId) * @class Stage * @extends DisplayObjectContainer * @constructor - * @param backgroundColor {Number} the background color of the stage, easiest way to pass this in is in hex format + * @param backgroundColor {number} the background color of the stage, easiest way to pass this in is in hex format * like: 0xFFFFFF for white * @param interactive {Boolean} enable / disable interaction (default is false) */ @@ -1876,7 +1923,7 @@ PIXI.Stage.prototype.updateTransform = function() * Sets the background color for the stage * * @method setBackgroundColor - * @param backgroundColor {Number} the color of the background, easiest way to pass this in is in hex format + * @param backgroundColor {number} the color of the background, easiest way to pass this in is in hex format * like: 0xFFFFFF for white */ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor) @@ -2233,8 +2280,8 @@ PIXI.Rope.prototype.setTexture = function(texture) * @extends DisplayObjectContainer * @constructor * @param texture {Texture} the texture of the tiling sprite - * @param width {Number} the width of the tiling sprite - * @param height {Number} the height of the tiling sprite + * @param width {number} the width of the tiling sprite + * @param height {number} the height of the tiling sprite */ PIXI.TilingSprite = function(texture, width, height) { @@ -2416,9 +2463,9 @@ PIXI.Graphics.prototype.constructor = PIXI.Graphics; * Specifies a line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method. * * @method lineStyle - * @param lineWidth {Number} width of the line to draw, will update the object's stored style - * @param color {Number} color of the line to draw, will update the object's stored style - * @param alpha {Number} alpha of the line to draw, will update the object's stored style + * @param lineWidth {number} width of the line to draw, will update the object's stored style + * @param color {number} color of the line to draw, will update the object's stored style + * @param alpha {number} alpha of the line to draw, will update the object's stored style */ PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha) { @@ -2438,8 +2485,8 @@ PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha) * Moves the current drawing position to (x, y). * * @method moveTo - * @param x {Number} the X coord to move to - * @param y {Number} the Y coord to move to + * @param x {number} the X coord to move to + * @param y {number} the Y coord to move to */ PIXI.Graphics.prototype.moveTo = function(x, y) { @@ -2458,8 +2505,8 @@ PIXI.Graphics.prototype.moveTo = function(x, y) * the current drawing position is then set to (x, y). * * @method lineTo - * @param x {Number} the X coord to draw to - * @param y {Number} the Y coord to draw to + * @param x {number} the X coord to draw to + * @param y {number} the Y coord to draw to */ PIXI.Graphics.prototype.lineTo = function(x, y) { @@ -2473,7 +2520,7 @@ PIXI.Graphics.prototype.lineTo = function(x, y) * * @method beginFill * @param color {uint} the color of the fill - * @param alpha {Number} the alpha + * @param alpha {number} the alpha */ PIXI.Graphics.prototype.beginFill = function(color, alpha) { @@ -2497,10 +2544,10 @@ PIXI.Graphics.prototype.endFill = function() /** * @method drawRect * - * @param x {Number} The X coord of the top-left of the rectangle - * @param y {Number} The Y coord of the top-left of the rectangle - * @param width {Number} The width of the rectangle - * @param height {Number} The height of the rectangle + * @param x {number} The X coord of the top-left of the rectangle + * @param y {number} The Y coord of the top-left of the rectangle + * @param width {number} The width of the rectangle + * @param height {number} The height of the rectangle */ PIXI.Graphics.prototype.drawRect = function( x, y, width, height ) { @@ -2518,9 +2565,9 @@ PIXI.Graphics.prototype.drawRect = function( x, y, width, height ) * Draws a circle. * * @method drawCircle - * @param x {Number} The X coord of the center of the circle - * @param y {Number} The Y coord of the center of the circle - * @param radius {Number} The radius of the circle + * @param x {number} The X coord of the center of the circle + * @param y {number} The Y coord of the center of the circle + * @param radius {number} The radius of the circle */ PIXI.Graphics.prototype.drawCircle = function( x, y, radius) { @@ -2538,10 +2585,10 @@ PIXI.Graphics.prototype.drawCircle = function( x, y, radius) * Draws an elipse. * * @method drawElipse - * @param x {Number} - * @param y {Number} - * @param width {Number} - * @param height {Number} + * @param x {number} + * @param y {number} + * @param width {number} + * @param height {number} */ PIXI.Graphics.prototype.drawElipse = function( x, y, width, height) { @@ -2827,8 +2874,8 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context) * * @class CanvasRenderer * @constructor - * @param width=0 {Number} the width of the canvas view - * @param height=0 {Number} the height of the canvas view + * @param width=0 {number} the width of the canvas view + * @param height=0 {number} the height of the canvas view * @param view {Canvas} the canvas to use as a view, optional * @param transparent=false {Boolean} the transparency of the render view, default false */ @@ -2932,8 +2979,8 @@ PIXI.CanvasRenderer.prototype.render = function(stage) * resizes the canvas view to the specified width and height * * @method resize - * @param width {Number} the new width of the canvas view - * @param height {Number} the new height of the canvas view + * @param width {number} the new width of the canvas view + * @param height {number} the new height of the canvas view */ PIXI.CanvasRenderer.prototype.resize = function(width, height) { @@ -4299,8 +4346,8 @@ PIXI.gl; * * @class WebGLRenderer * @constructor - * @param width=0 {Number} the width of the canvas view - * @param height=0 {Number} the height of the canvas view + * @param width=0 {number} the width of the canvas view + * @param height=0 {number} the height of the canvas view * @param view {Canvas} the canvas to use as a view, optional * @param transparent=false {Boolean} the transparency of the render view, default false * @param antialias=false {Boolean} sets antialias (only applicable in chrome at the moment) @@ -4560,8 +4607,8 @@ PIXI.WebGLRenderer.destroyTexture = function(texture) * resizes the webGL view to the specified width and height * * @method resize - * @param width {Number} the new width of the webGL view - * @param height {Number} the new height of the webGL view + * @param width {number} the new width of the webGL view + * @param height {number} the new height of the webGL view */ PIXI.WebGLRenderer.prototype.resize = function(width, height) { @@ -6064,9 +6111,9 @@ PIXI.BitmapText.fonts = {}; * @param [style.fill="black"] {Object} A canvas fillstyle that will be used on the text eg "red", "#00FF00" * @param [style.align="left"] {String} An alignment of the multiline text ("left", "center" or "right") * @param [style.stroke] {String} A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00" - * @param [style.strokeThickness=0] {Number} A number that represents the thickness of the stroke. Default is 0 (no stroke) + * @param [style.strokeThickness=0] {number} A number that represents the thickness of the stroke. Default is 0 (no stroke) * @param [style.wordWrap=false] {Boolean} Indicates if word wrap should be used - * @param [style.wordWrapWidth=100] {Number} The width at which text will wrap + * @param [style.wordWrapWidth=100] {number} The width at which text will wrap */ PIXI.Text = function(text, style) { @@ -6094,9 +6141,9 @@ PIXI.Text.prototype.constructor = PIXI.Text; * @param [style.fill="black"] {Object} A canvas fillstyle that will be used on the text eg "red", "#00FF00" * @param [style.align="left"] {String} An alignment of the multiline text ("left", "center" or "right") * @param [style.stroke="black"] {String} A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00" - * @param [style.strokeThickness=0] {Number} A number that represents the thickness of the stroke. Default is 0 (no stroke) + * @param [style.strokeThickness=0] {number} A number that represents the thickness of the stroke. Default is 0 (no stroke) * @param [style.wordWrap=false] {Boolean} Indicates if word wrap should be used - * @param [style.wordWrapWidth=100] {Number} The width at which text will wrap + * @param [style.wordWrapWidth=100] {number} The width at which text will wrap */ PIXI.Text.prototype.setStyle = function(style) { @@ -6718,8 +6765,8 @@ PIXI.Texture.frameUpdates = []; @class RenderTexture @extends Texture @constructor - @param width {Number} The width of the render texture - @param height {Number} The height of the render texture + @param width {number} The width of the render texture + @param height {number} The height of the render texture */ PIXI.RenderTexture = function(width, height) { @@ -7156,123 +7203,125 @@ PIXI.PolyK._convex = function(ax, ay, bx, by, cx, cy, sign) /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Camera +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** -* * A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view. * The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y * -* @class Camera +* @class Phaser.Camera * @constructor -* @param {Phaser.Game} game game reference to the currently running game. -* @param {number} id not being used at the moment, will be when Phaser supports multiple camera -* @param {number} x position of the camera on the X axis -* @param {number} y position of the camera on the Y axis -* @param {number} width the width of the view rectangle -* @param {number} height the height of the view rectangle +* @param {Phaser.Game} game - Game reference to the currently running game. +* @param {number} id - Not being used at the moment, will be when Phaser supports multiple camera +* @param {number} x - Position of the camera on the X axis +* @param {number} y - Position of the camera on the Y axis +* @param {number} width - The width of the view rectangle +* @param {number} height - The height of the view rectangle */ - Phaser.Camera = function (game, id, x, y, width, height) { - - /** - * A reference to the currently running Game. - * @property game - * @public - * @type {Phaser.Game} - */ + + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; - /** - * A reference to the game world - * @property world - * @public - * @type {Phaser.World} - */ + /** + * @property {Phaser.World} world - A reference to the game world. + */ this.world = game.world; - /** - * reserved for future multiple camera set-ups - * @property id - * @public - * @type {number} - */ + /** + * @property {number} id - Reserved for future multiple camera set-ups. + * @default + */ this.id = 0; - /** - * Camera view. - * The view into the world we wish to render (by default the game dimensions) - * The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render - * Objects outside of this view are not rendered (unless set to ignore the Camera, i.e. UI?) - * @property view - * @public - * @type {Phaser.Rectangle} - */ + /** + * Camera view. + * The view into the world we wish to render (by default the game dimensions). + * The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render. + * Objects outside of this view are not rendered (unless set to ignore the Camera, i.e. UI?). + * @property {Phaser.Rectangle} view + */ this.view = new Phaser.Rectangle(x, y, width, height); /** - * Used by Sprites to work out Camera culling. - * @property screenView - * @public - * @type {Phaser.Rectangle} - */ + * @property {Phaser.Rectangle} screenView - Used by Sprites to work out Camera culling. + */ this.screenView = new Phaser.Rectangle(x, y, width, height); /** - * Sprite moving inside this Rectangle will not cause camera moving. - * @property deadzone - * @type {Phaser.Rectangle} + * The Camera is bound to this Rectangle and cannot move outside of it. By default it is enabled and set to the size of the World. + * The Rectangle can be located anywhere in the world and updated as often as you like. If you don't wish the Camera to be bound + * at all then set this to null. The values can be anything and are in World coordinates, with 0,0 being the center of the world. + * @property {Phaser.Rectangle} bounds - The Rectangle in which the Camera is bounded. Set to null to allow for movement anywhere. */ + this.bounds = new Phaser.Rectangle(x, y, width, height); + + /** + * @property {Phaser.Rectangle} deadzone - Moving inside this Rectangle will not cause camera moving. + */ this.deadzone = null; - /** - * Whether this camera is visible or not. (default is true) - * @property visible - * @public - * @default true - * @type {bool} - */ + /** + * @property {boolean} visible - Whether this camera is visible or not. + * @default + */ this.visible = true; - /** - * Whether this camera is flush with the World Bounds or not. - * @property atLimit - * @type {bool} + /** + * @property {boolean} atLimit - Whether this camera is flush with the World Bounds or not. */ this.atLimit = { x: false, y: false }; - /** - * If the camera is tracking a Sprite, this is a reference to it, otherwise null - * @property target - * @public - * @type {Phaser.Sprite} + /** + * @property {Phaser.Sprite} target - If the camera is tracking a Sprite, this is a reference to it, otherwise null. + * @default */ this.target = null; - /** - * Edge property - * @property edge + /** + * @property {number} edge - Edge property. * @private - * @type {number} + * @default */ this._edge = 0; + + this.displayObject = null; }; -// Consts +/** +* @constant +* @type {number} +*/ Phaser.Camera.FOLLOW_LOCKON = 0; + +/** +* @constant +* @type {number} +*/ Phaser.Camera.FOLLOW_PLATFORMER = 1; + +/** +* @constant +* @type {number} +*/ Phaser.Camera.FOLLOW_TOPDOWN = 2; + +/** +* @constant +* @type {number} +*/ Phaser.Camera.FOLLOW_TOPDOWN_TIGHT = 3; Phaser.Camera.prototype = { /** * Tells this camera which sprite to follow. - * @method follow - * @param {Phaser.Sprite} target The object you want the camera to track. Set to null to not follow anything. + * @method Phaser.Camera#follow + * @param {Phaser.Sprite} target - The object you want the camera to track. Set to null to not follow anything. * @param {number} [style] Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow(). */ follow: function (target, style) { @@ -7307,103 +7356,136 @@ Phaser.Camera.prototype = { break; } + }, + + /** + * Move the camera focus on a display object instantly. + * @method Phaser.Camera#focusOn + * @param {any} displayObject - The display object to focus the camera on. Must have visible x/y properties. + */ + focusOn: function (displayObject) { + + this.setPosition(Math.round(displayObject.x - this.view.halfWidth), Math.round(displayObject.y - this.view.halfHeight)); + }, /** - * Move the camera focus to a location instantly. - * @method focusOnXY - * @param {number} x X position. - * @param {number} y Y position. + * Move the camera focus on a location instantly. + * @method Phaser.Camera#focusOnXY + * @param {number} x - X position. + * @param {number} y - Y position. */ focusOnXY: function (x, y) { - this.view.x = Math.round(x - this.view.halfWidth); - this.view.y = Math.round(y - this.view.halfHeight); + this.setPosition(Math.round(x - this.view.halfWidth), Math.round(y - this.view.halfHeight)); }, /** * Update focusing and scrolling. - * @method update + * @method Phaser.Camera#update */ update: function () { - // Add dirty flag - - if (this.target !== null) + if (this.target) { - if (this.deadzone) - { - this._edge = this.target.x - this.deadzone.x; - - if (this.view.x > this._edge) - { - this.view.x = this._edge; - } - - this._edge = this.target.x + this.target.width - this.deadzone.x - this.deadzone.width; - - if (this.view.x < this._edge) - { - this.view.x = this._edge; - } - - this._edge = this.target.y - this.deadzone.y; - - if (this.view.y > this._edge) - { - this.view.y = this._edge; - } - - this._edge = this.target.y + this.target.height - this.deadzone.y - this.deadzone.height; - - if (this.view.y < this._edge) - { - this.view.y = this._edge; - } - } - else - { - this.focusOnXY(this.target.x, this.target.y); - } + this.updateTarget(); } - this.checkWorldBounds(); + if (this.bounds) + { + this.checkBounds(); + } + + if (this.view.x !== -this.displayObject.position.x) + { + this.displayObject.position.x = -this.view.x; + } + + if (this.view.y !== -this.displayObject.position.y) + { + this.displayObject.position.y = -this.view.y; + } + + }, + + updateTarget: function () { + + if (this.deadzone) + { + this._edge = this.target.x - this.deadzone.x; + + if (this.view.x > this._edge) + { + this.view.x = this._edge; + } + + this._edge = this.target.x + this.target.width - this.deadzone.x - this.deadzone.width; + + if (this.view.x < this._edge) + { + this.view.x = this._edge; + } + + this._edge = this.target.y - this.deadzone.y; + + if (this.view.y > this._edge) + { + this.view.y = this._edge; + } + + this._edge = this.target.y + this.target.height - this.deadzone.y - this.deadzone.height; + + if (this.view.y < this._edge) + { + this.view.y = this._edge; + } + } + else + { + this.focusOnXY(this.target.x, this.target.y); + } + + }, + + setBoundsToWorld: function () { + + this.bounds.setTo(this.game.world.x, this.game.world.y, this.game.world.width, this.game.world.height); }, /** - * Method called to ensure the camera doesn't venture outside of the game world - * @method checkWorldBounds + * Method called to ensure the camera doesn't venture outside of the game world. + * @method Phaser.Camera#checkWorldBounds */ - checkWorldBounds: function () { + checkBounds: function () { this.atLimit.x = false; this.atLimit.y = false; - // Make sure we didn't go outside the cameras worldBounds - if (this.view.x < this.world.bounds.left) + // Make sure we didn't go outside the cameras bounds + if (this.view.x < this.bounds.x) { this.atLimit.x = true; - this.view.x = this.world.bounds.left; + this.view.x = this.bounds.x; } - if (this.view.x > this.world.bounds.right - this.width) + if (this.view.x > this.bounds.right - this.width) { this.atLimit.x = true; - this.view.x = (this.world.bounds.right - this.width) + 1; + this.view.x = (this.bounds.right - this.width) + 1; } - if (this.view.y < this.world.bounds.top) + if (this.view.y < this.bounds.top) { this.atLimit.y = true; - this.view.y = this.world.bounds.top; + this.view.y = this.bounds.top; } - if (this.view.y > this.world.bounds.bottom - this.height) + if (this.view.y > this.bounds.bottom - this.height) { this.atLimit.y = true; - this.view.y = (this.world.bounds.bottom - this.height) + 1; + this.view.y = (this.bounds.bottom - this.height) + 1; } this.view.floor(); @@ -7412,26 +7494,30 @@ Phaser.Camera.prototype = { /** * A helper function to set both the X and Y properties of the camera at once - * without having to use game.camera.x and game.camera.y + * without having to use game.camera.x and game.camera.y. * - * @method setPosition - * @param {number} x X position. - * @param {number} y Y position. + * @method Phaser.Camera#setPosition + * @param {number} x - X position. + * @param {number} y - Y position. */ setPosition: function (x, y) { this.view.x = x; this.view.y = y; - this.checkWorldBounds(); + + if (this.bounds) + { + this.checkBounds(); + } }, /** - * Sets the size of the view rectangle given the width and height in parameters + * Sets the size of the view rectangle given the width and height in parameters. * - * @method setSize - * @param {number} width The desired width. - * @param {number} height The desired height. + * @method Phaser.Camera#setSize + * @param {number} width - The desired width. + * @param {number} height - The desired height. */ setSize: function (width, height) { @@ -7442,81 +7528,80 @@ Phaser.Camera.prototype = { }; +/** +* The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds. +* @name Phaser.Camera#x +* @property {number} x - Gets or sets the cameras x position. +*/ Object.defineProperty(Phaser.Camera.prototype, "x", { - /** - * @method x - * @return {Number} The x position - */ get: function () { return this.view.x; }, - /** - * @method x - * @return {Number} Sets the camera's x position and clamp it if it's outside the world bounds - */ + set: function (value) { + this.view.x = value; - this.checkWorldBounds(); + + if (this.bounds) + { + this.checkBounds(); + } } }); +/** +* The Cameras y coordinate. This value is automatically clamped if it falls outside of the World bounds. +* @name Phaser.Camera#y +* @property {number} y - Gets or sets the cameras y position. +*/ Object.defineProperty(Phaser.Camera.prototype, "y", { - - /** - * @method y - * @return {Number} The y position - */ + get: function () { return this.view.y; }, - /** - * @method y - * @return {Number} Sets the camera's y position and clamp it if it's outside the world bounds - */ set: function (value) { + this.view.y = value; - this.checkWorldBounds(); + + if (this.bounds) + { + this.checkBounds(); + } } }); +/** +* The Cameras width. By default this is the same as the Game size and should not be adjusted for now. +* @name Phaser.Camera#width +* @property {number} width - Gets or sets the cameras width. +*/ Object.defineProperty(Phaser.Camera.prototype, "width", { - /** - * @method width - * @return {Number} The width of the view rectangle, in pixels - */ get: function () { return this.view.width; }, - /** - * @method width - * @return {Number} Sets the width of the view rectangle - */ set: function (value) { this.view.width = value; } }); +/** +* The Cameras height. By default this is the same as the Game size and should not be adjusted for now. +* @name Phaser.Camera#height +* @property {number} height - Gets or sets the cameras height. +*/ Object.defineProperty(Phaser.Camera.prototype, "height", { - /** - * @method height - * @return {Number} The height of the view rectangle, in pixels - */ get: function () { return this.view.height; }, - /** - * @method height - * @return {Number} Sets the height of the view rectangle - */ set: function (value) { this.view.height = value; } @@ -7524,32 +7609,102 @@ Object.defineProperty(Phaser.Camera.prototype, "height", { }); /** -* State -* +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** * This is a base State class which can be extended if you are creating your own game. * It provides quick access to common functions such as the camera, cache, input, match, sound and more. * -* @package Phaser.State -* @author Richard Davey -* @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License +* @class Phaser.State +* @constructor */ Phaser.State = function () { + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = null; + + /** + * @property {Phaser.GameObjectFactory} add - Reference to the GameObjectFactory. + * @default + */ this.add = null; + + /** + * @property {Phaser.Physics.PhysicsManager} camera - A handy reference to world.camera. + * @default + */ this.camera = null; + + /** + * @property {Phaser.Cache} cache - Reference to the assets cache. + * @default + */ this.cache = null; + + /** + * @property {Phaser.Input} input - Reference to the input manager + * @default + */ this.input = null; + + /** + * @property {Phaser.Loader} load - Reference to the assets loader. + * @default + */ this.load = null; + + /** + * @property {Phaser.GameMath} math - Reference to the math helper. + * @default + */ this.math = null; + + /** + * @property {Phaser.SoundManager} sound - Reference to the sound manager. + * @default + */ this.sound = null; + + /** + * @property {Phaser.Stage} stage - Reference to the stage. + * @default + */ this.stage = null; + + /** + * @property {Phaser.TimeManager} time - Reference to game clock. + * @default + */ this.time = null; + + /** + * @property {Phaser.TweenManager} tweens - Reference to the tween manager. + * @default + */ this.tweens = null; + + /** + * @property {Phaser.World} world - Reference to the world. + * @default + */ this.world = null; + + /** + * @property {Description} add - Description. + * @default + */ this.particles = null; + + /** + * @property {Phaser.Physics.PhysicsManager} physics - Reference to the physics manager. + * @default + */ this.physics = null; }; @@ -7559,47 +7714,96 @@ Phaser.State.prototype = { /** * Override this method to add some load operations. * If you need to use the loader, you may need to use them here. + * + * @method Phaser.State#preload */ preload: function () { }, + /** + * Put update logic here. + * + * @method Phaser.State#loadUpdate + */ + loadUpdate: function () { + }, + + /** + * Put render operations here. + * + * @method Phaser.State#loadRender + */ + loadRender: function () { + }, + /** * This method is called after the game engine successfully switches states. - * Feel free to add any setup code here.(Do not load anything here, override preload() instead) + * Feel free to add any setup code here (do not load anything here, override preload() instead). + * + * @method Phaser.State#create */ create: function () { }, /** * Put update logic here. + * + * @method Phaser.State#update */ update: function () { }, /** * Put render operations here. + * + * @method Phaser.State#render */ render: function () { }, /** * This method will be called when game paused. + * + * @method Phaser.State#paused */ paused: function () { }, /** - * This method will be called when the state is destroyed + * This method will be called when the state is destroyed. + * @method Phaser.State#destroy */ destroy: function () { } }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* The State Manager is responsible for loading, setting up and switching game states. +* +* @class Phaser.StateManager +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {Phaser.State|Object} [pendingState=null] - A State object to seed the manager with. +*/ Phaser.StateManager = function (game, pendingState) { + /** + * A reference to the currently running game. + * @property {Phaser.Game} game. + */ this.game = game; + /** + * Description. + * @property {Description} states. + */ this.states = {}; if (pendingState !== null) @@ -7612,94 +7816,102 @@ Phaser.StateManager = function (game, pendingState) { Phaser.StateManager.prototype = { /** - * @type {Phaser.Game} + * A reference to the currently running game. + * @property {Phaser.Game} game. */ game: null, /** * The state to be switched to in the next frame. - * @type {State} + * @property {State} _pendingState + * @private */ _pendingState: null, /** * Flag that sets if the State has been created or not. - * @type {Boolean} + * @property {boolean}_created + * @private */ _created: false, /** * The state to be switched to in the next frame. - * @type {Object} + * @property {Description} states */ states: {}, /** - * The current active State object (defaults to null) - * @type {String} + * The current active State object (defaults to null). + * @property {string} current */ current: '', /** - * This will be called when the state is started (i.e. set as the current active state) - * @type {function} + * This will be called when the state is started (i.e. set as the current active state). + * @property {function} onInitCallback */ onInitCallback: null, /** - * This will be called when init states. (loading assets...) - * @type {function} + * This will be called when init states (loading assets...). + * @property {function} onPreloadCallback */ onPreloadCallback: null, /** - * This will be called when create states. (setup states...) - * @type {function} + * This will be called when create states (setup states...). + * @property {function} onCreateCallback */ onCreateCallback: null, /** - * This will be called when State is updated, this doesn't happen during load (see onLoadUpdateCallback) - * @type {function} + * This will be called when State is updated, this doesn't happen during load (@see onLoadUpdateCallback). + * @property {function} onUpdateCallback */ onUpdateCallback: null, /** - * This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback) - * @type {function} + * This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback). + * @property {function} onRenderCallback */ onRenderCallback: null, /** - * This will be called before the State is rendered and before the stage is cleared - * @type {function} + * This will be called before the State is rendered and before the stage is cleared. + * @property {function} onPreRenderCallback */ onPreRenderCallback: null, /** - * This will be called when the State is updated but only during the load process - * @type {function} + * This will be called when the State is updated but only during the load process. + * @property {function} onLoadUpdateCallback */ onLoadUpdateCallback: null, /** - * This will be called when the State is rendered but only during the load process - * @type {function} + * This will be called when the State is rendered but only during the load process. + * @property {function} onLoadRenderCallback */ onLoadRenderCallback: null, /** * This will be called when states paused. - * @type {function} + * @property {function} onPausedCallback */ onPausedCallback: null, /** - * This will be called when the state is shut down (i.e. swapped to another state) - * @type {function} + * This will be called when the state is shut down (i.e. swapped to another state). + * @property {function} onShutDownCallback */ onShutDownCallback: null, + /** + * Description. + * @method Phaser.StateManager#boot + * @private + */ boot: function () { // console.log('Phaser.StateManager.boot'); @@ -7725,9 +7937,10 @@ Phaser.StateManager.prototype = { /** * Add a new State. - * @param key {String} A unique key you use to reference this state, i.e. "MainMenu", "Level1". - * @param state {State} The state you want to switch to. - * @param autoStart {Boolean} Start the state immediately after creating it? (default true) + * @method Phaser.StateManager#add + * @param key {string} - A unique key you use to reference this state, i.e. "MainMenu", "Level1". + * @param state {State} - The state you want to switch to. + * @param autoStart {boolean} - Start the state immediately after creating it? (default true) */ add: function (key, state, autoStart) { @@ -7776,6 +7989,11 @@ Phaser.StateManager.prototype = { }, + /** + * Delete the given state. + * @method Phaser.StateManager#remove + * @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1". + */ remove: function (key) { if (this.current == key) @@ -7801,9 +8019,10 @@ Phaser.StateManager.prototype = { /** * Start the given state - * @param key {String} The key of the state you want to start. - * @param [clearWorld] {bool} clear everything in the world? (Default to true) - * @param [clearCache] {bool} clear asset cache? (Default to false and ONLY available when clearWorld=true) + * @method Phaser.StateManager#start + * @param {string} key - The key of the state you want to start. + * @param {boolean} [clearWorld] - clear everything in the world? (Default to true) + * @param {boolean} [clearCache] - clear asset cache? (Default to false and ONLY available when clearWorld=true) */ start: function (key, clearWorld, clearCache) { @@ -7833,7 +8052,9 @@ Phaser.StateManager.prototype = { this.onShutDownCallback.call(this.callbackContext); } - if (clearWorld) { + if (clearWorld) + { + this.game.tweens.removeAll(); this.game.world.destroy(); @@ -7873,11 +8094,21 @@ Phaser.StateManager.prototype = { } }, - - // Used by onInit and onShutdown when those functions don't exist on the state + + /** + * Used by onInit and onShutdown when those functions don't exist on the state + * @method Phaser.StateManager#dummy + * @private + */ dummy: function () { }, + /** + * Description. + * @method Phaser.StateManager#checkState + * @param {string} key - The key of the state you want to check. + * @return {boolean} Description. + */ checkState: function (key) { if (this.states[key]) @@ -7910,6 +8141,12 @@ Phaser.StateManager.prototype = { }, + /** + * Links game properties to the State given by the key. + * @method Phaser.StateManager#link + * @param {string} key - State key. + * @protected + */ link: function (key) { // console.log('linked'); @@ -7931,6 +8168,12 @@ Phaser.StateManager.prototype = { }, + /** + * Sets the current State. Should not be called directly (use StateManager.start) + * @method Phaser.StateManager#setCurrentState + * @param {string} key - State key. + * @protected + */ setCurrentState: function (key) { this.callbackContext = this.states[key]; @@ -7959,6 +8202,10 @@ Phaser.StateManager.prototype = { }, + /** + * @method Phaser.StateManager#loadComplete + * @protected + */ loadComplete: function () { // console.log('Phaser.StateManager.loadComplete'); @@ -7976,6 +8223,10 @@ Phaser.StateManager.prototype = { }, + /** + * @method Phaser.StateManager#update + * @protected + */ update: function () { if (this._created && this.onUpdateCallback) @@ -7992,6 +8243,10 @@ Phaser.StateManager.prototype = { }, + /** + * @method Phaser.StateManager#preRender + * @protected + */ preRender: function () { if (this.onPreRenderCallback) @@ -8001,6 +8256,10 @@ Phaser.StateManager.prototype = { }, + /** + * @method Phaser.StateManager#render + * @protected + */ render: function () { if (this._created && this.onRenderCallback) @@ -8019,6 +8278,7 @@ Phaser.StateManager.prototype = { /** * Nuke the entire game from orbit + * @method Phaser.StateManager#destroy */ destroy: function () { @@ -8044,19 +8304,61 @@ Phaser.StateManager.prototype = { }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* A basic linked list data structure. +* +* @class Phaser.LinkedList +* @constructor +*/ Phaser.LinkedList = function () { + /** + * @property {object} next - Next element in the list. + * @default + */ this.next = null; + + /** + * @property {object} prev - Previous element in the list. + * @default + */ this.prev = null; + + /** + * @property {object} first - First element in the list. + * @default + */ this.first = null; + + /** + * @property {object} last - Last element in the list. + * @default + */ this.last = null; + + /** + * @property {object} game - Number of elements in the list. + * @default + */ this.total = 0; }; Phaser.LinkedList.prototype = { - + /** + * Adds a new element to this linked list. + * + * @method Phaser.LinkedList#add + * @param {object} child - The element to add to this list. Can be a Phaser.Sprite or any other object you need to quickly iterate through. + * @return {object} The child that was added. + */ add: function (child) { // If the list is empty @@ -8067,7 +8369,7 @@ Phaser.LinkedList.prototype = { this.next = child; child.prev = this; this.total++; - return; + return child; } // Get gets appended to the end of the list, regardless of anything, and it won't have any children of its own (non-nested list) @@ -8083,40 +8385,55 @@ Phaser.LinkedList.prototype = { }, + /** + * Removes the given element from this linked list if it exists. + * + * @method Phaser.LinkedList#remove + * @param {object} child - The child to be removed from the list. + */ remove: function (child) { - // If the list is empty - if (this.first == null && this.last == null) + if (child == this.first) { - return; - } + // It was 'first', make 'first' point to first.next + this.first = this.first.next; + } + else if (child == this.last) + { + // It was 'last', make 'last' point to last.prev + this.last = this.last.prev; + } + + if (child.prev) + { + // make child.prev.next point to childs.next instead of child + child.prev.next = child.next; + } + + if (child.next) + { + // make child.next.prev point to child.prev instead of child + child.next.prev = child.prev; + } + + child.next = child.prev = null; + + if (this.first == null ) + { + this.last = null; + } this.total--; - // The only node? - if (this.first == child && this.last == child) - { - this.first = null; - this.last = null; - this.next = null; - child.next = null; - child.prev = null; - return; - } - - var childPrev = child.prev; - - // Tail node? - if (child.next) - { - // Has another node after it? - child.next.prev = child.prev; - } - - childPrev.next = child.next; - }, + /** + * Calls a function on all members of this list, using the member as the context for the callback. + * The function must exist on the member. + * + * @method Phaser.LinkedList#callAll + * @param {function} callback - The function to call. + */ callAll: function (callback) { if (!this.first || !this.last) @@ -8138,102 +8455,41 @@ Phaser.LinkedList.prototype = { } while(entity != this.last.next) - }, - - dump: function () { - - var spacing = 20; - - var output = "\n" + Phaser.Utils.pad('Node', spacing) + "|" + Phaser.Utils.pad('Next', spacing) + "|" + Phaser.Utils.pad('Previous', spacing) + "|" + Phaser.Utils.pad('First', spacing) + "|" + Phaser.Utils.pad('Last', spacing); - console.log(output); - - var output = Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing); - console.log(output); - - var entity = this; - - var testObject = entity.last.next; - entity = entity.first; - - do - { - var name = entity.sprite.name || '*'; - var nameNext = '-'; - var namePrev = '-'; - var nameFirst = '-'; - var nameLast = '-'; - - if (entity.next) - { - nameNext = entity.next.sprite.name; - } - - if (entity.prev) - { - namePrev = entity.prev.sprite.name; - } - - if (entity.first) - { - nameFirst = entity.first.sprite.name; - } - - if (entity.last) - { - nameLast = entity.last.sprite.name; - } - - if (typeof nameNext === 'undefined') - { - nameNext = '-'; - } - - if (typeof namePrev === 'undefined') - { - namePrev = '-'; - } - - if (typeof nameFirst === 'undefined') - { - nameFirst = '-'; - } - - if (typeof nameLast === 'undefined') - { - nameLast = '-'; - } - - var output = Phaser.Utils.pad(name, spacing) + "|" + Phaser.Utils.pad(nameNext, spacing) + "|" + Phaser.Utils.pad(namePrev, spacing) + "|" + Phaser.Utils.pad(nameFirst, spacing) + "|" + Phaser.Utils.pad(nameLast, spacing); - console.log(output); - - entity = entity.next; - - } - while(entity != testObject) - - } + } }; /** -* Phaser.Signal -* -* A Signal is used for object communication via a custom broadcaster instead of Events. -* +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* @class Phaser.Signal +* @classdesc A Signal is used for object communication via a custom broadcaster instead of Events. * @author Miller Medeiros http://millermedeiros.github.com/js-signals/ * @constructor */ Phaser.Signal = function () { /** - * @type Array. - * @private - */ + * @property {Array.} _bindings - Description. + * @private + */ this._bindings = []; + + /** + * @property {Description} _prevParams - Description. + * @private + */ this._prevParams = null; // enforce dispatch to aways work on same context (#47) var self = this; + /** + * @property {Description} dispatch - Description. + */ this.dispatch = function(){ Phaser.Signal.prototype.dispatch.apply(self, arguments); }; @@ -8243,26 +8499,33 @@ Phaser.Signal = function () { Phaser.Signal.prototype = { /** - * If Signal should keep record of previously dispatched parameters and - * automatically execute listener during `add()`/`addOnce()` if Signal was - * already dispatched before. - * @type boolean - */ + * If Signal should keep record of previously dispatched parameters and + * automatically execute listener during `add()`/`addOnce()` if Signal was + * already dispatched before. + * @property {boolean} memorize + */ memorize: false, /** - * @type boolean - * @private - */ + * @property {boolean} _shouldPropagate + * @private + */ _shouldPropagate: true, /** - * If Signal is active and should broadcast events. - *

    IMPORTANT: Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.

    - * @type boolean - */ + * If Signal is active and should broadcast events. + *

    IMPORTANT: Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.

    + * @property {boolean} active + * @default + */ active: true, + /** + * @method Phaser.Signal#validateListener + * @param {function} listener - Signal handler function. + * @param {Description} fnName - Description. + * @private + */ validateListener: function (listener, fnName) { if (typeof listener !== 'function') { throw new Error( 'listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName) ); @@ -8270,11 +8533,12 @@ Phaser.Signal.prototype = { }, /** - * @param {Function} listener - * @param {boolean} isOnce - * @param {Object} [listenerContext] - * @param {Number} [priority] - * @return {Phaser.SignalBinding} + * @method Phaser.Signal#_registerListener + * @param {function} listener - Signal handler function. + * @param {boolean} isOnce - Description. + * @param {object} [listenerContext] - Description. + * @param {number} [priority] - The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0). + * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener. * @private */ _registerListener: function (listener, isOnce, listenerContext, priority) { @@ -8300,7 +8564,8 @@ Phaser.Signal.prototype = { }, /** - * @param {Phaser.SignalBinding} binding + * @method Phaser.Signal#_addBinding + * @param {Phaser.SignalBinding} binding - An Object representing the binding between the Signal and listener. * @private */ _addBinding: function (binding) { @@ -8311,8 +8576,9 @@ Phaser.Signal.prototype = { }, /** - * @param {Function} listener - * @return {number} + * @method Phaser.Signal#_indexOfListener + * @param {function} listener - Signal handler function. + * @return {number} Description. * @private */ _indexOfListener: function (listener, context) { @@ -8329,9 +8595,11 @@ Phaser.Signal.prototype = { /** * Check if listener was attached to Signal. - * @param {Function} listener - * @param {Object} [context] - * @return {boolean} if Signal has the specified listener. + * + * @method Phaser.Signal#has + * @param {Function} listener - Signal handler function. + * @param {Object} [context] - Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @return {boolean} If Signal has the specified listener. */ has: function (listener, context) { return this._indexOfListener(listener, context) !== -1; @@ -8339,9 +8607,11 @@ Phaser.Signal.prototype = { /** * Add a listener to the signal. - * @param {Function} listener Signal handler function. - * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) + * + * @method Phaser.Signal#add + * @param {function} listener - Signal handler function. + * @param {object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @param {number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0). * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener. */ add: function (listener, listenerContext, priority) { @@ -8350,37 +8620,48 @@ Phaser.Signal.prototype = { }, /** - * Add listener to the signal that should be removed after first execution (will be executed only once). - * @param {Function} listener Signal handler function. - * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) - * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener. - */ + * Add listener to the signal that should be removed after first execution (will be executed only once). + * + * @method Phaser.Signal#addOnce + * @param {function} listener Signal handler function. + * @param {object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @param {number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) + * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener. + */ addOnce: function (listener, listenerContext, priority) { this.validateListener(listener, 'addOnce'); return this._registerListener(listener, true, listenerContext, priority); }, /** - * Remove a single listener from the dispatch queue. - * @param {Function} listener Handler function that should be removed. - * @param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context). - * @return {Function} Listener handler function. - */ + * Remove a single listener from the dispatch queue. + * + * @method Phaser.Signal#remove + * @param {function} listener Handler function that should be removed. + * @param {object} [context] Execution context (since you can add the same handler multiple times if executing in a different context). + * @return {function} Listener handler function. + */ remove: function (listener, context) { + this.validateListener(listener, 'remove'); var i = this._indexOfListener(listener, context); - if (i !== -1) { + + if (i !== -1) + { this._bindings[i]._destroy(); //no reason to a Phaser.SignalBinding exist if it isn't attached to a signal this._bindings.splice(i, 1); } + return listener; + }, /** - * Remove all listeners from the Signal. - */ + * Remove all listeners from the Signal. + * + * @method Phaser.Signal#removeAll + */ removeAll: function () { var n = this._bindings.length; while (n--) { @@ -8390,25 +8671,32 @@ Phaser.Signal.prototype = { }, /** - * @return {number} Number of listeners attached to the Signal. - */ + * Gets the total number of listeneres attached to ths Signal. + * + * @method Phaser.Signal#getNumListeners + * @return {number} Number of listeners attached to the Signal. + */ getNumListeners: function () { return this._bindings.length; }, /** - * Stop propagation of the event, blocking the dispatch to next listeners on the queue. - *

    IMPORTANT: should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.

    - * @see Signal.prototype.disable - */ + * Stop propagation of the event, blocking the dispatch to next listeners on the queue. + *

    IMPORTANT: should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.

    + * @see Signal.prototype.disable + * + * @method Phaser.Signal#halt + */ halt: function () { this._shouldPropagate = false; }, /** - * Dispatch/Broadcast Signal to all listeners added to the queue. - * @param {...*} [params] Parameters that should be passed to each handler. - */ + * Dispatch/Broadcast Signal to all listeners added to the queue. + * + * @method Phaser.Signal#dispatch + * @param {any} [params] - Parameters that should be passed to each handler. + */ dispatch: function (params) { if (! this.active) { return; @@ -8436,17 +8724,21 @@ Phaser.Signal.prototype = { }, /** - * Forget memorized arguments. - * @see Signal.memorize - */ + * Forget memorized arguments. + * @see Signal.memorize + * + * @method Phaser.Signal#forget + */ forget: function(){ this._prevParams = null; }, /** - * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object). - *

    IMPORTANT: calling any method on the signal instance after calling dispose will throw errors.

    - */ + * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object). + *

    IMPORTANT: calling any method on the signal instance after calling dispose will throw errors.

    + * + * @method Phaser.Signal#dispose + */ dispose: function () { this.removeAll(); delete this._bindings; @@ -8454,14 +8746,22 @@ Phaser.Signal.prototype = { }, /** - * @return {string} String representation of the object. - */ + * + * @method Phaser.Signal#toString + * @return {string} String representation of the object. + */ toString: function () { return '[Phaser.Signal active:'+ this.active +' numListeners:'+ this.getNumListeners() +']'; } }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + /** * Phaser.SignalBinding * @@ -8469,52 +8769,47 @@ Phaser.Signal.prototype = { *
    - This is an internal constructor and shouldn't be called by regular users. *
    - inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes. * +* @class Phaser.SignalBinding +* @name SignalBinding * @author Miller Medeiros http://millermedeiros.github.com/js-signals/ * @constructor -* @internal -* @name SignalBinding -* @param {Signal} signal Reference to Signal object that listener is currently bound to. -* @param {Function} listener Handler function bound to the signal. -* @param {boolean} isOnce If binding should be executed just once. -* @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). -* @param {Number} [priority] The priority level of the event listener. (default = 0). +* @inner +* @param {Signal} signal - Reference to Signal object that listener is currently bound to. +* @param {function} listener - Handler function bound to the signal. +* @param {boolean} isOnce - If binding should be executed just once. +* @param {object} [listenerContext] - Context on which listener will be executed (object that should represent the `this` variable inside listener function). +* @param {number} [priority] - The priority level of the event listener. (default = 0). */ Phaser.SignalBinding = function (signal, listener, isOnce, listenerContext, priority) { /** - * Handler function bound to the signal. - * @type Function - * @private - */ + * @property {Phaser.Game} _listener - Handler function bound to the signal. + * @private + */ this._listener = listener; /** - * If binding should be executed just once. - * @type boolean - * @private - */ + * @property {boolean} _isOnce - If binding should be executed just once. + * @private + */ this._isOnce = isOnce; /** - * Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @memberOf SignalBinding.prototype - * @name context - * @type Object|undefined|null - */ + * @property {object|undefined|null} context - Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @memberof SignalBinding.prototype + */ this.context = listenerContext; /** - * Reference to Signal object that listener is currently bound to. - * @type Signal - * @private - */ + * @property {Signal} _signal - Reference to Signal object that listener is currently bound to. + * @private + */ this._signal = signal; /** - * Listener priority - * @type Number - * @private - */ + * @property {number} _priority - Listener priority. + * @private + */ this._priority = priority || 0; }; @@ -8522,23 +8817,26 @@ Phaser.SignalBinding = function (signal, listener, isOnce, listenerContext, prio Phaser.SignalBinding.prototype = { /** - * If binding is active and should be executed. - * @type boolean - */ + * If binding is active and should be executed. + * @property {boolean} active + * @default + */ active: true, /** - * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters) - * @type Array|null - */ + * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute` (curried parameters). + * @property {array|null} params + * @default + */ params: null, /** - * Call listener passing arbitrary parameters. - *

    If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.

    - * @param {Array} [paramsArr] Array of parameters that should be passed to the listener - * @return {*} Value returned by the listener. - */ + * Call listener passing arbitrary parameters. + *

    If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.

    + * @method Phaser.SignalBinding#execute + * @param {array} [paramsArr] - Array of parameters that should be passed to the listener. + * @return {Description} Value returned by the listener. + */ execute: function (paramsArr) { var handlerReturn, params; @@ -8559,46 +8857,52 @@ Phaser.SignalBinding.prototype = { }, /** - * Detach binding from signal. - * - alias to: mySignal.remove(myBinding.getListener()); - * @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached. - */ + * Detach binding from signal. + *

    alias to: @see mySignal.remove(myBinding.getListener()); + * @method Phaser.SignalBinding#detach + * @return {function|null} Handler function bound to the signal or `null` if binding was previously detached. + */ detach: function () { return this.isBound() ? this._signal.remove(this._listener, this.context) : null; }, /** - * @return {Boolean} `true` if binding is still bound to the signal and have a listener. - */ + * @method Phaser.SignalBinding#isBound + * @return {boolean} True if binding is still bound to the signal and has a listener. + */ isBound: function () { return (!!this._signal && !!this._listener); }, /** - * @return {boolean} If SignalBinding will only be executed once. - */ + * @method Phaser.SignalBinding#isOnce + * @return {boolean} If SignalBinding will only be executed once. + */ isOnce: function () { return this._isOnce; }, /** - * @return {Function} Handler function bound to the signal. - */ + * @method Phaser.SignalBinding#getListener + * @return {Function} Handler function bound to the signal. + */ getListener: function () { return this._listener; }, /** - * @return {Signal} Signal that listener is currently bound to. - */ + * @method Phaser.SignalBinding#getSignal + * @return {Signal} Signal that listener is currently bound to. + */ getSignal: function () { return this._signal; }, /** - * Delete instance properties - * @private - */ + * @method Phaser.SignalBinding#_destroy + * Delete instance properties + * @private + */ _destroy: function () { delete this._signal; delete this._listener; @@ -8606,8 +8910,9 @@ Phaser.SignalBinding.prototype = { }, /** - * @return {string} String representation of the object. - */ + * @method Phaser.SignalBinding#toString + * @return {string} String representation of the object. + */ toString: function () { return '[Phaser.SignalBinding isOnce:' + this._isOnce +', isBound:'+ this.isBound() +', active:' + this.active + ']'; } @@ -8615,21 +8920,68 @@ Phaser.SignalBinding.prototype = { }; /** -* Phaser - Plugin -* -* This is a base Plugin template to use for any Phaser plugin development +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* This is a base Plugin template to use for any Phaser plugin development. +* +* @class Phaser.Plugin +* @classdesc Phaser - Plugin +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {Any} parent - The object that owns this plugin, usually Phaser.PluginManager. */ Phaser.Plugin = function (game, parent) { + if (typeof parent === 'undefined') { parent = null; } + + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; + + /** + * @property {Any} parent - The parent of this plugin. If added to the PluginManager the parent will be set to that, otherwise it will be null. + */ this.parent = parent; + /** + * @property {boolean} active - A Plugin with active=true has its preUpdate and update methods called by the parent, otherwise they are skipped. + * @default + */ this.active = false; + + /** + * @property {boolean} visible - A Plugin with visible=true has its render and postRender methods called by the parent, otherwise they are skipped. + * @default + */ this.visible = false; + /** + * @property {boolean} hasPreUpdate - A flag to indicate if this plugin has a preUpdate method. + * @default + */ this.hasPreUpdate = false; + + /** + * @property {boolean} hasUpdate - A flag to indicate if this plugin has an update method. + * @default + */ this.hasUpdate = false; + + /** + * @property {boolean} hasRender - A flag to indicate if this plugin has a render method. + * @default + */ this.hasRender = false; + + /** + * @property {boolean} hasPostRender - A flag to indicate if this plugin has a postRender method. + * @default + */ this.hasPostRender = false; }; @@ -8637,8 +8989,9 @@ Phaser.Plugin = function (game, parent) { Phaser.Plugin.prototype = { /** - * Pre-update is called at the start of the update cycle, before any other updates have taken place (including Physics). + * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). * It is only called if active is set to true. + * @method Phaser.Plugin#preUpdate */ preUpdate: function () { }, @@ -8646,6 +8999,7 @@ Phaser.Plugin.prototype = { /** * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. * It is only called if active is set to true. + * @method Phaser.Plugin#update */ update: function () { }, @@ -8653,6 +9007,7 @@ Phaser.Plugin.prototype = { /** * Render is called right after the Game Renderer completes, but before the State.render. * It is only called if visible is set to true. + * @method Phaser.Plugin#render */ render: function () { }, @@ -8660,12 +9015,14 @@ Phaser.Plugin.prototype = { /** * Post-render is called after the Game Renderer and State.render have run. * It is only called if visible is set to true. + * @method Phaser.Plugin#postRender */ postRender: function () { }, /** * Clear down this Plugin and null out references + * @method Phaser.Plugin#destroy */ destroy: function () { @@ -8679,16 +9036,43 @@ Phaser.Plugin.prototype = { }; /** -* Phaser - PluginManager -* -* TODO: We can optimise this a lot by using separate hashes per function (update, render, etc) +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +/** +* Description. +* +* @class Phaser.PluginManager +* @classdesc Phaser - PluginManager +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {Description} parent - Description. +*/ Phaser.PluginManager = function(game, parent) { + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; + + /** + * @property {Description} _parent - Description. + * @private + */ this._parent = parent; + + /** + * @property {array} plugins - Description. + */ this.plugins = []; + + /** + * @property {array} _pluginsLength - Description. + * @private + * @default + */ this._pluginsLength = 0; }; @@ -8697,8 +9081,10 @@ Phaser.PluginManager.prototype = { /** * Add a new Plugin to the PluginManager. - * The plugins game and parent reference are set to this game and pluginmanager parent. - * @type {Phaser.Plugin} + * The plugin's game and parent reference are set to this game and pluginmanager parent. + * @method Phaser.PluginManager#add + * @param {Phaser.Plugin} plugin - Description. + * @return {Phaser.Plugin} Description. */ add: function (plugin) { @@ -8762,6 +9148,11 @@ Phaser.PluginManager.prototype = { } }, + /** + * Remove a Plugin from the PluginManager. + * @method Phaser.PluginManager#remove + * @param {Phaser.Plugin} plugin - The plugin to be removed. + */ remove: function (plugin) { // TODO @@ -8769,6 +9160,12 @@ Phaser.PluginManager.prototype = { }, + /** + * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). + * It only calls plugins who have active=true. + * + * @method Phaser.PluginManager#preUpdate + */ preUpdate: function () { if (this._pluginsLength == 0) @@ -8786,6 +9183,12 @@ Phaser.PluginManager.prototype = { }, + /** + * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. + * It only calls plugins who have active=true. + * + * @method Phaser.PluginManager#update + */ update: function () { if (this._pluginsLength == 0) @@ -8803,6 +9206,12 @@ Phaser.PluginManager.prototype = { }, + /** + * Render is called right after the Game Renderer completes, but before the State.render. + * It only calls plugins who have visible=true. + * + * @method Phaser.PluginManager#render + */ render: function () { if (this._pluginsLength == 0) @@ -8820,6 +9229,12 @@ Phaser.PluginManager.prototype = { }, + /** + * Post-render is called after the Game Renderer and State.render have run. + * It only calls plugins who have visible=true. + * + * @method Phaser.PluginManager#postRender + */ postRender: function () { if (this._pluginsLength == 0) @@ -8837,6 +9252,11 @@ Phaser.PluginManager.prototype = { }, + /** + * Clear down this PluginManager and null out references + * + * @method Phaser.PluginManager#destroy + */ destroy: function () { this.plugins.length = 0; @@ -8851,96 +9271,86 @@ Phaser.PluginManager.prototype = { /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Stage +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** -* * The Stage controls the canvas on which everything is displayed. It handles display within the browser, * focus handling, game resizing, scaling and the pause, boot and orientation screens. * -* @class Stage +* @class Phaser.Stage * @constructor -* @param {Phaser.Game} game Game reference to the currently running game. -* @param {number} width Width of the canvas element -* @param {number} height Height of the canvas element +* @param {Phaser.Game} game - Game reference to the currently running game. +* @param {number} width - Width of the canvas element. +* @param {number} height - Height of the canvas element. */ Phaser.Stage = function (game, width, height) { - /** - * A reference to the currently running Game. - * @property game - * @public - * @type {Phaser.Game} - */ + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; /** - * Background color of the stage (defaults to black). Set via the public backgroundColor property. - * @property _backgroundColor - * @private - * @type {string} - */ + * @property {string} game - Background color of the stage (defaults to black). Set via the public backgroundColor property. + * @private + * @default 'rgb(0,0,0)' + */ this._backgroundColor = 'rgb(0,0,0)'; /** - * Get the offset values (for input and other things) - * @property offset - * @public - * @type {Phaser.Point} - */ + * @property {Phaser.Point} offset - Get the offset values (for input and other things). + */ this.offset = new Phaser.Point; /** - * reference to the newly created element - * @property canvas - * @public - * @type {HTMLCanvasElement} + * @property {HTMLCanvasElement} canvas - Reference to the newly created <canvas> element. */ - this.canvas = Phaser.Canvas.create(width, height); + this.canvas = Phaser.Canvas.create(width, height); this.canvas.style['-webkit-full-screen'] = 'width: 100%; height: 100%'; /** - * The Pixi Stage which is hooked to the renderer - * @property _stage + * @property {PIXI.Stage} _stage - The Pixi Stage which is hooked to the renderer. * @private - * @type {PIXI.Stage} */ this._stage = new PIXI.Stage(0x000000, false); this._stage.name = '_stage_root'; /** - * The current scaleMode - * @property scaleMode - * @public - * @type {number} - */ + * @property {number} scaleMode - The current scaleMode. + */ this.scaleMode = Phaser.StageScaleMode.NO_SCALE; /** - * The scale of the current running game - * @property scale - * @public - * @type {Phaser.StageScaleMode} + * @property {Phaser.StageScaleMode} scale - The scale of the current running game. */ this.scale = new Phaser.StageScaleMode(this.game, width, height); /** - * aspect ratio - * @property aspectRatio - * @public - * @type {number} - */ + * @property {number} aspectRatio - Aspect ratio. + */ this.aspectRatio = width / height; + /** + * @property {number} _nextOffsetCheck - The time to run the next offset check. + * @private + */ + this._nextOffsetCheck = 0; + + /** + * @property {number|false} checkOffsetInterval - The time (in ms) between which the stage should check to see if it has moved. + * @default + */ + this.checkOffsetInterval = 2500; + }; Phaser.Stage.prototype = { /** - * Initialises the stage and adds the event listeners - * @method boot + * Initialises the stage and adds the event listeners. + * @method Phaser.Stage#boot + * @private */ boot: function () { @@ -8954,6 +9364,9 @@ Phaser.Stage.prototype = { return _this.visibilityChange(event); } + Phaser.Canvas.setUserSelect(this.canvas, 'none'); + Phaser.Canvas.setTouchAction(this.canvas, 'none'); + document.addEventListener('visibilitychange', this._onChange, false); document.addEventListener('webkitvisibilitychange', this._onChange, false); document.addEventListener('pagehide', this._onChange, false); @@ -8962,12 +9375,30 @@ Phaser.Stage.prototype = { window.onblur = this._onChange; window.onfocus = this._onChange; + }, + + /** + * Runs Stage processes that need periodic updates, such as the offset checks. + * @method Phaser.Stage#update + */ + update: function () { + + if (this.checkOffsetInterval !== false) + { + if (this.game.time.now > this._nextOffsetCheck) + { + Phaser.Canvas.getOffset(this.canvas, this.offset); + this._nextOffsetCheck = this.game.time.now + this.checkOffsetInterval; + } + + } + }, /** * This method is called when the document visibility is changed. - * @method visibilityChange - * @param {Event} event Its type will be used to decide whether the game should be paused or not + * @method Phaser.Stage#visibilityChange + * @param {Event} event - Its type will be used to decide whether the game should be paused or not. */ visibilityChange: function (event) { @@ -8978,12 +9409,10 @@ Phaser.Stage.prototype = { if (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] == true || document['webkitHidden'] == true) { - // console.log('visibilityChange - hidden', event); this.game.paused = true; } else { - // console.log('visibilityChange - shown', event); this.game.paused = false; } @@ -8991,21 +9420,16 @@ Phaser.Stage.prototype = { }; +/** +* @name Phaser.Stage#backgroundColor +* @property {number|string} paused - Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000' +*/ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", { - /** - * @method backgroundColor - * @return {string} returns the background color of the stage - */ get: function () { return this._backgroundColor; }, - /** - * @method backgroundColor - * @param {string} the background color you want the stage to have - * @return {string} returns the background color of the stage - */ set: function (color) { this._backgroundColor = color; @@ -9021,16 +9445,42 @@ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", { }); +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser Group constructor. +* @class Phaser.Group +* @classdesc A Group is a container for display objects that allows for fast pooling, recycling and collision checks. +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {*} parent - The parent Group or DisplayObjectContainer that will hold this group, if any. +* @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging. +* @param {boolean} [useStage=false] - Should the DisplayObjectContainer this Group creates be added to the World (default, false) or direct to the Stage (true). +*/ Phaser.Group = function (game, parent, name, useStage) { - parent = parent || null; + if (typeof parent === 'undefined') + { + parent = game.world; + } - if (typeof useStage == 'undefined') + if (typeof useStage === 'undefined') { useStage = false; } + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; + + /** + * @property {string} name - A name for this Group. Not used internally but useful for debugging. + */ this.name = name || 'group'; if (useStage) @@ -9047,31 +9497,53 @@ Phaser.Group = function (game, parent, name, useStage) { if (parent instanceof Phaser.Group) { parent._container.addChild(this._container); + parent._container.updateTransform(); } else { parent.addChild(this._container); + parent.updateTransform(); } } else { this.game.stage._stage.addChild(this._container); + this.game.stage._stage.updateTransform(); } } + /** + * @property {number} type - Internal Phaser Type value. + * @protected + */ this.type = Phaser.GROUP; + /** + * @property {boolean} exists - If exists is true the the Group is updated, otherwise it is skipped. + * @default + */ this.exists = true; /** - * Helper for sort. - */ - this._sortIndex = 'y'; - + * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one. + */ + this.scale = new Phaser.Point(1, 1); + }; Phaser.Group.prototype = { + /** + * Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object. + * The child is automatically added to the top of the Group, so renders on-top of everything else within the Group. If you need to control + * that then see the addAt method. + * + * @see Phaser.Group#create + * @see Phaser.Group#addAt + * @method Phaser.Group#add + * @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object.. + * @return {*} The child that was added to the Group. + */ add: function (child) { if (child.group !== this) @@ -9084,12 +9556,23 @@ Phaser.Group.prototype = { } this._container.addChild(child); + + child.updateTransform(); } return child; }, + /** + * Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object. + * The child is added to the Group at the location specified by the index value, this allows you to control child ordering. + * + * @method Phaser.Group#addAt + * @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object.. + * @param {number} index - The index within the Group to insert the child to. + * @return {*} The child that was added to the Group. + */ addAt: function (child, index) { if (child.group !== this) @@ -9102,18 +9585,40 @@ Phaser.Group.prototype = { } this._container.addChildAt(child, index); + + child.updateTransform(); } return child; }, + /** + * Returns the child found at the given index within this Group. + * + * @method Phaser.Group#getAt + * @memberof Phaser.Group + * @param {number} index - The index to return the child from. + * @return {*} The child that was found at the given index. + */ getAt: function (index) { return this._container.getChildAt(index); }, + /** + * Automatically creates a new Phaser.Sprite object and adds it to the top of this Group. + * Useful if you don't need to create the Sprite instances before-hand. + * + * @method Phaser.Group#create + * @param {number} x - The x coordinate to display the newly created Sprite at. The value is in relation to the Group.x point. + * @param {number} y - The y coordinate to display the newly created Sprite at. The value is in relation to the Group.y point. + * @param {string} key - The Game.cache key of the image that this Sprite will use. + * @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here. + * @param {boolean} [exists=true] - The default exists state of the Sprite. + * @return {Phaser.Sprite} The child that was created. + */ create: function (x, y, key, frame, exists) { if (typeof exists == 'undefined') { exists = true; } @@ -9122,6 +9627,8 @@ Phaser.Group.prototype = { child.group = this; child.exists = exists; + child.visible = exists; + child.alive = exists; if (child.events) { @@ -9129,11 +9636,57 @@ Phaser.Group.prototype = { } this._container.addChild(child); + + child.updateTransform(); return child; }, + /** + * Automatically creates multiple Phaser.Sprite objects and adds them to the top of this Group. + * Useful if you need to quickly generate a pool of identical sprites, such as bullets. By default the sprites will be set to not exist + * and will be positioned at 0, 0 (relative to the Group.x/y) + * + * @method Phaser.Group#createMultiple + * @param {number} quantity - The number of Sprites to create. + * @param {string} key - The Game.cache key of the image that this Sprite will use. + * @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here. + * @param {boolean} [exists=false] - The default exists state of the Sprite. + */ + createMultiple: function (quantity, key, frame, exists) { + + if (typeof exists == 'undefined') { exists = false; } + + for (var i = 0; i < quantity; i++) + { + var child = new Phaser.Sprite(this.game, 0, 0, key, frame); + + child.group = this; + child.exists = exists; + child.visible = exists; + child.alive = exists; + + if (child.events) + { + child.events.onAddedToGroup.dispatch(child, this); + } + + this._container.addChild(child); + child.updateTransform(); + + } + + }, + + /** + * Swaps the position of two children in this Group. + * + * @method Phaser.Group#swap + * @param {*} child1 - The first child to swap. + * @param {*} child2 - The second child to swap. + * @return {boolean} True if the swap was successful, otherwise false. + */ swap: function (child1, child2) { if (child1 === child2 || !child1.parent || !child2.parent) @@ -9254,6 +9807,13 @@ Phaser.Group.prototype = { }, + /** + * Brings the given child to the top of this Group so it renders above all other children. + * + * @method Phaser.Group#bringToTop + * @param {*} child - The child to bring to the top of this Group. + * @return {*} The child that was moved. + */ bringToTop: function (child) { if (child.group === this) @@ -9266,12 +9826,26 @@ Phaser.Group.prototype = { }, + /** + * Get the index position of the given child in this Group. + * + * @method Phaser.Group#getIndex + * @param {*} child - The child to get the index for. + * @return {number} The index of the child or -1 if it's not a member of this Group. + */ getIndex: function (child) { return this._container.children.indexOf(child); }, + /** + * Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group. + * + * @method Phaser.Group#replace + * @param {*} oldChild - The child in this Group that will be replaced. + * @param {*} newChild - The child to be inserted into this group. + */ replace: function (oldChild, newChild) { if (!this._container.first._iNext) @@ -9292,11 +9866,20 @@ Phaser.Group.prototype = { this._container.removeChild(oldChild); this._container.addChildAt(newChild, index); newChild.events.onAddedToGroup.dispatch(newChild, this); + newChild.updateTransform(); } }, - // key is an ARRAY of values. + /** + * Sets the given property to the given value on the child. The operation controls the assignment of the value. + * + * @method Phaser.Group#setProperty + * @param {*} child - The child to set the property value on. + * @param {array} key - An array of strings that make up the property that will be set. + * @param {*} value - The value that will be set. + * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. + */ setProperty: function (child, key, value, operation) { operation = operation || 0; @@ -9350,11 +9933,24 @@ Phaser.Group.prototype = { }, + /** + * This function allows you to quickly set the same property across all children of this Group to a new value. + * The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication. + * + * @method Phaser.Group#setAll + * @param {string} key - The property, as a string, to be set. For example: 'body.velocity.x' + * @param {*} value - The value that will be set. + * @param {boolean} [checkAlive=false] - If set then only children with alive=true will be updated. + * @param {boolean} [checkVisible=false] - If set then only children with visible=true will be updated. + * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. + */ setAll: function (key, value, checkAlive, checkVisible, operation) { key = key.split('.'); - checkAlive = checkAlive || false; - checkVisible = checkVisible || false; + + if (typeof checkAlive === 'undefined') { checkAlive = false; } + if (typeof checkVisible === 'undefined') { checkVisible = false; } + operation = operation || 0; if (this._container.children.length > 0 && this._container.first._iNext) @@ -9375,33 +9971,82 @@ Phaser.Group.prototype = { }, - addAll: function (key, value, checkAlive, checkVisible) { + /** + * Adds the amount to the given property on all children in this Group. + * Group.addAll('x', 10) will add 10 to the child.x value. + * + * @method Phaser.Group#addAll + * @param {string} property - The property to increment, for example 'body.velocity.x' or 'angle'. + * @param {number} amount - The amount to increment the property by. If child.x = 10 then addAll('x', 40) would make child.x = 50. + * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. + * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. + */ + addAll: function (property, amount, checkAlive, checkVisible) { - this.setAll(key, value, checkAlive, checkVisible, 1); + this.setAll(property, amount, checkAlive, checkVisible, 1); }, - subAll: function (key, value, checkAlive, checkVisible) { + /** + * Subtracts the amount from the given property on all children in this Group. + * Group.subAll('x', 10) will minus 10 from the child.x value. + * + * @method Phaser.Group#subAll + * @param {string} property - The property to decrement, for example 'body.velocity.x' or 'angle'. + * @param {number} amount - The amount to subtract from the property. If child.x = 50 then subAll('x', 40) would make child.x = 10. + * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. + * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. + */ + subAll: function (property, amount, checkAlive, checkVisible) { - this.setAll(key, value, checkAlive, checkVisible, 2); + this.setAll(property, amount, checkAlive, checkVisible, 2); }, - multiplyAll: function (key, value, checkAlive, checkVisible) { + /** + * Multiplies the given property by the amount on all children in this Group. + * Group.multiplyAll('x', 2) will x2 the child.x value. + * + * @method Phaser.Group#multiplyAll + * @param {string} property - The property to multiply, for example 'body.velocity.x' or 'angle'. + * @param {number} amount - The amount to multiply the property by. If child.x = 10 then multiplyAll('x', 2) would make child.x = 20. + * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. + * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. + */ + multiplyAll: function (property, amount, checkAlive, checkVisible) { - this.setAll(key, value, checkAlive, checkVisible, 3); + this.setAll(property, amount, checkAlive, checkVisible, 3); }, - divideAll: function (key, value, checkAlive, checkVisible) { + /** + * Divides the given property by the amount on all children in this Group. + * Group.divideAll('x', 2) will half the child.x value. + * + * @method Phaser.Group#divideAll + * @param {string} property - The property to divide, for example 'body.velocity.x' or 'angle'. + * @param {number} amount - The amount to divide the property by. If child.x = 100 then divideAll('x', 2) would make child.x = 50. + * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. + * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. + */ + divideAll: function (property, amount, checkAlive, checkVisible) { - this.setAll(key, value, checkAlive, checkVisible, 4); + this.setAll(property, amount, checkAlive, checkVisible, 4); }, - callAllExists: function (callback, callbackContext, existsValue) { + /** + * Calls a function on all of the children that have exists=true in this Group. + * After the existsValue parameter you can add as many parameters as you like, which will all be passed to the child callback. + * + * @method Phaser.Group#callAllExists + * @param {function} callback - The function that exists on the children that will be called. + * @param {boolean} existsValue - Only children with exists=existsValue will be called. + * @param {...*} parameter - Additional parameters that will be passed to the callback. + */ + callAllExists: function (callback, existsValue) { - var args = Array.prototype.splice.call(arguments, 3); + var args = Array.prototype.splice.call(arguments, 2); if (this._container.children.length > 0 && this._container.first._iNext) { @@ -9424,12 +10069,15 @@ Phaser.Group.prototype = { /** * Calls a function on all of the children regardless if they are dead or alive (see callAllExists if you need control over that) - * You must pass the context in which the callback is applied. - * After the context you can add as many parameters as you like, which will all be passed to the child. + * After the callback parameter you can add as many extra parameters as you like, which will all be passed to the child. + * + * @method Phaser.Group#callAll + * @param {function} callback - The function that exists on the children that will be called. + * @param {...*} parameter - Additional parameters that will be passed to the callback. */ - callAll: function (callback, callbackContext) { + callAll: function (callback) { - var args = Array.prototype.splice.call(arguments, 2); + var args = Array.prototype.splice.call(arguments, 1); if (this._container.children.length > 0 && this._container.first._iNext) { @@ -9450,9 +10098,25 @@ Phaser.Group.prototype = { }, + /** + * Allows you to call your own function on each member of this Group. You must pass the callback and context in which it will run. + * After the checkExists parameter you can add as many parameters as you like, which will all be passed to the callback along with the child. + * For example: Group.forEach(awardBonusGold, this, true, 100, 500) + * + * @method Phaser.Group#forEach + * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter. + * @param {Object} callbackContext - The context in which the function should be called (usually 'this'). + * @param {boolean} checkExists - If set only children with exists=true will be passed to the callback, otherwise all children will be passed. + */ forEach: function (callback, callbackContext, checkExists) { - if (typeof checkExists == 'undefined') { checkExists = false; } + if (typeof checkExists === 'undefined') + { + checkExists = false; + } + + var args = Array.prototype.splice.call(arguments, 3); + args.unshift(null); if (this._container.children.length > 0 && this._container.first._iNext) { @@ -9462,7 +10126,8 @@ Phaser.Group.prototype = { { if (checkExists == false || (checkExists && currentNode.exists)) { - callback.call(callbackContext, currentNode); + args[0] = currentNode; + callback.apply(callbackContext, args); } currentNode = currentNode._iNext; @@ -9473,8 +10138,20 @@ Phaser.Group.prototype = { }, + /** + * Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run. + * You can add as many parameters as you like, which will all be passed to the callback along with the child. + * For example: Group.forEachAlive(causeDamage, this, 500) + * + * @method Phaser.Group#forEachAlive + * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter. + * @param {Object} callbackContext - The context in which the function should be called (usually 'this'). + */ forEachAlive: function (callback, callbackContext) { + var args = Array.prototype.splice.call(arguments, 2); + args.unshift(null); + if (this._container.children.length > 0 && this._container.first._iNext) { var currentNode = this._container.first._iNext; @@ -9483,7 +10160,8 @@ Phaser.Group.prototype = { { if (currentNode.alive) { - callback.call(callbackContext, currentNode); + args[0] = currentNode; + callback.apply(callbackContext, args); } currentNode = currentNode._iNext; @@ -9494,8 +10172,20 @@ Phaser.Group.prototype = { }, + /** + * Allows you to call your own function on each dead member of this Group (where alive=false). You must pass the callback and context in which it will run. + * You can add as many parameters as you like, which will all be passed to the callback along with the child. + * For example: Group.forEachDead(bringToLife, this) + * + * @method Phaser.Group#forEachDead + * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter. + * @param {Object} callbackContext - The context in which the function should be called (usually 'this'). + */ forEachDead: function (callback, callbackContext) { + var args = Array.prototype.splice.call(arguments, 2); + args.unshift(null); + if (this._container.children.length > 0 && this._container.first._iNext) { var currentNode = this._container.first._iNext; @@ -9504,7 +10194,8 @@ Phaser.Group.prototype = { { if (currentNode.alive == false) { - callback.call(callbackContext, currentNode); + args[0] = currentNode; + callback.apply(callbackContext, args); } currentNode = currentNode._iNext; @@ -9515,8 +10206,10 @@ Phaser.Group.prototype = { }, /** - * Call this function to retrieve the first object with exists == (the given state) in the group. + * Call this function to retrieve the first object with exists == (the given state) in the Group. * + * @method Phaser.Group#getFirstExists + * @param {boolean} state - True or false. * @return {Any} The first child, or null if none found. */ getFirstExists: function (state) { @@ -9548,8 +10241,9 @@ Phaser.Group.prototype = { /** * Call this function to retrieve the first object with alive == true in the group. - * This is handy for checking if everything's wiped out, or choosing a squad leader, etc. + * This is handy for checking if everything has been wiped out, or choosing a squad leader, etc. * + * @method Phaser.Group#getFirstAlive * @return {Any} The first alive child, or null if none found. */ getFirstAlive: function () { @@ -9576,8 +10270,9 @@ Phaser.Group.prototype = { /** * Call this function to retrieve the first object with alive == false in the group. - * This is handy for checking if everything's wiped out, or choosing a squad leader, etc. + * This is handy for checking if everything has been wiped out, or choosing a squad leader, etc. * + * @method Phaser.Group#getFirstDead * @return {Any} The first dead child, or null if none found. */ getFirstDead: function () { @@ -9605,11 +10300,12 @@ Phaser.Group.prototype = { /** * Call this function to find out how many members of the group are alive. * + * @method Phaser.Group#countLiving * @return {number} The number of children flagged as alive. Returns -1 if Group is empty. */ countLiving: function () { - var total = -1; + var total = 0; if (this._container.children.length > 0 && this._container.first._iNext) { @@ -9626,6 +10322,10 @@ Phaser.Group.prototype = { } while (currentNode != this._container.last._iNext); } + else + { + total = -1; + } return total; @@ -9634,11 +10334,12 @@ Phaser.Group.prototype = { /** * Call this function to find out how many members of the group are dead. * + * @method Phaser.Group#countDead * @return {number} The number of children flagged as dead. Returns -1 if Group is empty. */ countDead: function () { - var total = -1; + var total = 0; if (this._container.children.length > 0 && this._container.first._iNext) { @@ -9655,6 +10356,10 @@ Phaser.Group.prototype = { } while (currentNode != this._container.last._iNext); } + else + { + total = -1; + } return total; @@ -9663,9 +10368,9 @@ Phaser.Group.prototype = { /** * Returns a member at random from the group. * - * @param {number} startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array. - * @param {number} length Optional restriction on the number of values you want to randomly select from. - * + * @method Phaser.Group#getRandom + * @param {number} startIndex - Optional offset off the front of the array. Default value is 0, or the beginning of the array. + * @param {number} length - Optional restriction on the number of values you want to randomly select from. * @return {Any} A random child of this Group. */ getRandom: function (startIndex, length) { @@ -9682,14 +10387,31 @@ Phaser.Group.prototype = { }, + /** + * Removes the given child from this Group and sets its group property to null. + * + * @method Phaser.Group#remove + * @param {Any} child - The child to remove. + */ remove: function (child) { - child.events.onRemovedFromGroup.dispatch(child, this); + if (child.events) + { + child.events.onRemovedFromGroup.dispatch(child, this); + } + this._container.removeChild(child); + child.group = null; }, + /** + * Removes all children from this Group, setting all group properties to null. + * The Group container remains on the display list. + * + * @method Phaser.Group#removeAll + */ removeAll: function () { if (this._container.children.length == 0) @@ -9709,6 +10431,13 @@ Phaser.Group.prototype = { }, + /** + * Removes all children from this Group whos index falls beteen the given startIndex and endIndex values. + * + * @method Phaser.Group#removeBetween + * @param {number} startIndex - The index to start removing children from. + * @param {number} endIndex - The index to stop removing children from. Must be higher than startIndex and less than the length of the Group. + */ removeBetween: function (startIndex, endIndex) { if (this._container.children.length == 0) @@ -9730,6 +10459,11 @@ Phaser.Group.prototype = { }, + /** + * Destroys this Group. Removes all children, then removes the container from the display list and nulls references. + * + * @method Phaser.Group#destroy + */ destroy: function () { this.removeAll(); @@ -9744,6 +10478,12 @@ Phaser.Group.prototype = { }, + /** + * Dumps out a list of Group children and their index positions to the browser console. Useful for group debugging. + * + * @method Phaser.Group#dump + * @param {boolean} [full=false] - If full the dump will include the entire display list, start from the Stage. Otherwise it will only include this container. + */ dump: function (full) { if (typeof full == 'undefined') @@ -9830,6 +10570,24 @@ Phaser.Group.prototype = { }; +/** +* @name Phaser.Group#total +* @property {number} total - The total number of children in this Group, regardless of their alive state. +* @readonly +*/ +Object.defineProperty(Phaser.Group.prototype, "total", { + + get: function () { + return this._container.children.length; + } + +}); + +/** +* @name Phaser.Group#length +* @property {number} length - The number of children in this Group. +* @readonly +*/ Object.defineProperty(Phaser.Group.prototype, "length", { get: function () { @@ -9838,6 +10596,12 @@ Object.defineProperty(Phaser.Group.prototype, "length", { }); +/** +* The x coordinate of the Group container. You can adjust the Group container itself by modifying its coordinates. +* This will have no impact on the x/y coordinates of its children, but it will update their worldTransform and on-screen position. +* @name Phaser.Group#x +* @property {number} x - The x coordinate of the Group container. +*/ Object.defineProperty(Phaser.Group.prototype, "x", { get: function () { @@ -9850,6 +10614,12 @@ Object.defineProperty(Phaser.Group.prototype, "x", { }); +/** +* The y coordinate of the Group container. You can adjust the Group container itself by modifying its coordinates. +* This will have no impact on the x/y coordinates of its children, but it will update their worldTransform and on-screen position. +* @name Phaser.Group#y +* @property {number} y - The y coordinate of the Group container. +*/ Object.defineProperty(Phaser.Group.prototype, "y", { get: function () { @@ -9862,6 +10632,12 @@ Object.defineProperty(Phaser.Group.prototype, "y", { }); +/** +* The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation. +* This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position. +* @name Phaser.Group#angle +* @property {number} angle - The angle of rotation given in degrees, where 0 degrees = to the right. +*/ Object.defineProperty(Phaser.Group.prototype, "angle", { get: function() { @@ -9874,6 +10650,12 @@ Object.defineProperty(Phaser.Group.prototype, "angle", { }); +/** +* The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation. +* This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position. +* @name Phaser.Group#rotation +* @property {number} rotation - The angle of rotation given in radians. +*/ Object.defineProperty(Phaser.Group.prototype, "rotation", { get: function () { @@ -9886,6 +10668,10 @@ Object.defineProperty(Phaser.Group.prototype, "rotation", { }); +/** +* @name Phaser.Group#visible +* @property {boolean} visible - The visible state of the Group. Non-visible Groups and all of their children are not rendered. +*/ Object.defineProperty(Phaser.Group.prototype, "visible", { get: function () { @@ -9898,272 +10684,306 @@ Object.defineProperty(Phaser.Group.prototype, "visible", { }); +/** +* @name Phaser.Group#alpha +* @property {number} alpha - The alpha value of the Group container. +*/ +Object.defineProperty(Phaser.Group.prototype, "alpha", { + + get: function () { + return this._container.alpha; + }, + + set: function (value) { + this._container.alpha = value; + } + +}); + /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.World +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** - * - * "This world is but a canvas to our imagination." - Henry David Thoreau - * - * A game has only one world. The world is an abstract place in which all game objects live. It is not bound - * by stage limits and can be any size. You look into the world via cameras. All game objects live within - * the world at world-based coordinates. By default a world is created the same size as your Stage. - * - * @class World - * @constructor - * @param {Phaser.Game} game Reference to the current game instance. - */ +* "This world is but a canvas to our imagination." - Henry David Thoreau +* +* A game has only one world. The world is an abstract place in which all game objects live. It is not bound +* by stage limits and can be any size. You look into the world via cameras. All game objects live within +* the world at world-based coordinates. By default a world is created the same size as your Stage. +* +* @class Phaser.World +* @constructor +* @param {Phaser.Game} game - Reference to the current game instance. +*/ Phaser.World = function (game) { - /** - * A reference to the currently running Game. - * @property game - * @public - * @type {Phaser.Game} - */ - this.game = game; + Phaser.Group.call(this, game, null, '__world', false); /** - * Bound of this world that objects can not escape from. - * @property bounds - * @public - * @type {Phaser.Rectangle} - */ + * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one. + */ + this.scale = new Phaser.Point(1, 1); + + /** + * The World has no fixed size, but it does have a bounds outside of which objects are no longer considered as being "in world" and you should use this to clean-up the display list and purge dead objects. + * By default we set the Bounds to be from 0,0 to Game.width,Game.height. I.e. it will match the size given to the game constructor with 0,0 representing the top-left of the display. + * However 0,0 is actually the center of the world, and if you rotate or scale the world all of that will happen from 0,0. + * So if you want to make a game in which the world itself will rotate you should adjust the bounds so that 0,0 is the center point, i.e. set them to -1000,-1000,2000,2000 for a 2000x2000 sized world centered around 0,0. + * @property {Phaser.Rectangle} bounds - Bound of this world that objects can not escape from. + */ this.bounds = new Phaser.Rectangle(0, 0, game.width, game.height); /** - * Camera instance. - * @property camera - * @public - * @type {Phaser.Camera} - */ + * @property {Phaser.Camera} camera - Camera instance. + */ this.camera = null; /** - * Reset each frame, keeps a count of the total number of objects updated. - * @property currentRenderOrderID - * @public - * @type {Number} - */ + * @property {number} currentRenderOrderID - Reset each frame, keeps a count of the total number of objects updated. + */ + this.currentRenderOrderID = 0; + +}; + +Phaser.World.prototype = Object.create(Phaser.Group.prototype); +Phaser.World.prototype.constructor = Phaser.World; + +/** +* Initialises the game world. +* +* @method Phaser.World#boot +* @protected +*/ +Phaser.World.prototype.boot = function () { + + this.camera = new Phaser.Camera(this.game, 0, 0, 0, this.game.width, this.game.height); + + this.camera.displayObject = this._container; + + this.game.camera = this.camera; + +} + +/** +* This is called automatically every frame, and is where main logic happens. +* +* @method Phaser.World#update +*/ +Phaser.World.prototype.update = function () { + this.currentRenderOrderID = 0; - /** - * Object container stores every object created with `create*` methods. - * @property group - * @public - * @type {Phaser.Group} - */ - this.group = null; - -}; - -Phaser.World.prototype = { - - - /** - * Initialises the game world - * - * @method boot - */ - boot: function () { - - this.camera = new Phaser.Camera(this.game, 0, 0, 0, this.game.width, this.game.height); - - this.game.camera = this.camera; - - this.group = new Phaser.Group(this.game, null, '__world', true); - - }, - - /** - * This is called automatically every frame, and is where main logic happens. - * @method update - */ - update: function () { - - this.camera.update(); - - this.currentRenderOrderID = 0; - - if (this.game.stage._stage.first._iNext) + if (this.game.stage._stage.first._iNext) + { + var currentNode = this.game.stage._stage.first._iNext; + + do { - var currentNode = this.game.stage._stage.first._iNext; - - do + if (currentNode['preUpdate']) { - if (currentNode['preUpdate']) - { - currentNode.preUpdate(); - } - - if (currentNode['update']) - { - currentNode.update(); - } - - currentNode = currentNode._iNext; + currentNode.preUpdate(); } - while (currentNode != this.game.stage._stage.last._iNext) + + if (currentNode['update']) + { + currentNode.update(); + } + + currentNode = currentNode._iNext; } + while (currentNode != this.game.stage._stage.last._iNext) + } - }, +} - /** - * Updates the size of this world. - * @method setSize - * @param {number} width New width of the world. - * @param {number} height New height of the world. - */ - setSize: function (width, height) { +/** +* This is called automatically every frame, and is where main logic happens. +* @method Phaser.World#postUpdate +*/ +Phaser.World.prototype.postUpdate = function () { - if (width >= this.game.width) + this.camera.update(); + + if (this.game.stage._stage.first._iNext) + { + var currentNode = this.game.stage._stage.first._iNext; + + do { - this.bounds.width = width; + if (currentNode['postUpdate']) + { + currentNode.postUpdate(); + } + + currentNode = currentNode._iNext; } - - if (height >= this.game.height) - { - this.bounds.height = height; - } - - }, - - /** - * Destroyer of worlds. - * @method destroy - */ - destroy: function () { - - this.camera.x = 0; - this.camera.y = 0; - - this.game.input.reset(true); - - this.group.removeAll(); - + while (currentNode != this.game.stage._stage.last._iNext) } - -}; -// Getters / Setters +} +/** +* Updates the size of this world. Note that this doesn't modify the world x/y coordinates, just the width and height. +* If you need to adjust the bounds of the world +* @method Phaser.World#setBounds +* @param {number} x - Top left most corner of the world. +* @param {number} y - Top left most corner of the world. +* @param {number} width - New width of the world. +* @param {number} height - New height of the world. +*/ +Phaser.World.prototype.setBounds = function (x, y, width, height) { + + this.bounds.setTo(x, y, width, height); + + if (this.camera.bounds) + { + this.camera.bounds.setTo(x, y, width, height); + } + +} + +/** +* Destroyer of worlds. +* @method Phaser.World#destroy +*/ +Phaser.World.prototype.destroy = function () { + + this.camera.x = 0; + this.camera.y = 0; + + this.game.input.reset(true); + + this.removeAll(); + +} + +/** +* @name Phaser.World#width +* @property {number} width - Gets or sets the current width of the game world. +*/ Object.defineProperty(Phaser.World.prototype, "width", { - /** - * @method width - * @return {Number} The current width of the game world - */ get: function () { return this.bounds.width; }, - /** - * @method width - * @return {Number} Sets the width of the game world - */ set: function (value) { this.bounds.width = value; } }); +/** +* @name Phaser.World#height +* @property {number} height - Gets or sets the current height of the game world. +*/ Object.defineProperty(Phaser.World.prototype, "height", { - /** - * @method height - * @return {Number} The current height of the game world - */ get: function () { return this.bounds.height; }, - /** - * @method height - * @return {Number} Sets the width of the game world - */ set: function (value) { this.bounds.height = value; } }); +/** +* @name Phaser.World#centerX +* @property {number} centerX - Gets the X position corresponding to the center point of the world. +* @readonly +*/ Object.defineProperty(Phaser.World.prototype, "centerX", { - /** - * @method centerX - * @return {Number} return the X position of the center point of the world - */ get: function () { return this.bounds.halfWidth; } }); +/** +* @name Phaser.World#centerY +* @property {number} centerY - Gets the Y position corresponding to the center point of the world. +* @readonly +*/ Object.defineProperty(Phaser.World.prototype, "centerY", { - /** - * @method centerY - * @return {Number} return the Y position of the center point of the world - */ get: function () { return this.bounds.halfHeight; } }); +/** +* @name Phaser.World#randomX +* @property {number} randomX - Gets a random integer which is lesser than or equal to the current width of the game world. +* @readonly +*/ Object.defineProperty(Phaser.World.prototype, "randomX", { - /** - * @method randomX - * @return {Number} a random integer which is lesser or equal to the current width of the game world - */ get: function () { - return Math.round(Math.random() * this.bounds.width); - } -}); + if (this.bounds.x < 0) + { + return this.game.rnd.integerInRange(this.bounds.x, (this.bounds.width - Math.abs(this.bounds.x))); + } + else + { + return this.game.rnd.integerInRange(this.bounds.x, this.bounds.width); + } -Object.defineProperty(Phaser.World.prototype, "randomY", { - - /** - * @method randomY - * @return {Number} a random integer which is lesser or equal to the current height of the game world - */ - get: function () { - return Math.round(Math.random() * this.bounds.height); } }); /** -* Phaser.Game -* -* This is where the magic happens. The Game object is the heart of your game, -* providing quick access to common functions and handling the boot process. -* -* "Hell, there are no rules here - we're trying to accomplish something." -* Thomas A. Edison -* -* @package Phaser.Game -* @author Richard Davey -* @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License +* @name Phaser.World#randomY +* @property {number} randomY - Gets a random integer which is lesser than or equal to the current height of the game world. +* @readonly +*/ +Object.defineProperty(Phaser.World.prototype, "randomY", { + + get: function () { + + if (this.bounds.y < 0) + { + return this.game.rnd.integerInRange(this.bounds.y, (this.bounds.height - Math.abs(this.bounds.y))); + } + else + { + return this.game.rnd.integerInRange(this.bounds.y, this.bounds.height); + } + + } + +}); + +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** * Game constructor * * Instantiate a new Phaser.Game object. -* +* @class Phaser.Game +* @classdesc This is where the magic happens. The Game object is the heart of your game, +* providing quick access to common functions and handling the boot process. +*

    "Hell, there are no rules here - we're trying to accomplish something."


    +* Thomas A. Edison * @constructor -* @param width {number} The width of your game in game pixels. -* @param height {number} The height of your game in game pixels. -* @param renderer {number} Which renderer to use (canvas or webgl) -* @param parent {string} ID of its parent DOM element. +* @param {number} width - The width of your game in game pixels. +* @param {number} height - The height of your game in game pixels. +* @param {number} renderer -Which renderer to use (canvas or webgl) +* @param {HTMLElement} parent -The Games DOM parent. +* @param {Description} state - Description. +* @param {boolean} transparent - Use a transparent canvas background or not. +* @param {boolean} antialias - Anti-alias graphics. */ Phaser.Game = function (width, height, renderer, parent, state, transparent, antialias) { @@ -10172,206 +10992,201 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant renderer = renderer || Phaser.AUTO; parent = parent || ''; state = state || null; - transparent = transparent || false; - antialias = typeof antialias === 'undefined' ? true : antialias; + + if (typeof transparent == 'undefined') { transparent = false; } + if (typeof antialias == 'undefined') { antialias = true; } /** - * Phaser Game ID (for when Pixi supports multiple instances) - * @type {number} + * @property {number} id - Phaser Game ID (for when Pixi supports multiple instances). */ this.id = Phaser.GAMES.push(this) - 1; /** - * The Games DOM parent. - * @type {HTMLElement} + * @property {HTMLElement} parent - The Games DOM parent. */ this.parent = parent; // Do some more intelligent size parsing here, so they can set "100%" for example, maybe pass the scale mode in here too? /** - * The Game width (in pixels). - * @type {number} + * @property {number} width - The Game width (in pixels). */ this.width = width; /** - * The Game height (in pixels). - * @type {number} + * @property {number} height - The Game height (in pixels). */ this.height = height; /** - * Use a transparent canvas background or not. - * @type {boolean} + * @property {boolean} transparent - Use a transparent canvas background or not. */ this.transparent = transparent; /** - * Anti-alias graphics (in WebGL this helps with edges, in Canvas2D it retains pixel-art quality) - * @type {boolean} + * @property {boolean} antialias - Anti-alias graphics (in WebGL this helps with edges, in Canvas2D it retains pixel-art quality). */ this.antialias = antialias; /** - * The Pixi Renderer - * @type {number} + * @property {number} renderer - The Pixi Renderer + * @default */ this.renderer = null; - /** - * The StateManager. - * @type {Phaser.StateManager} - */ + /** + * @property {number} state - The StateManager. + */ this.state = new Phaser.StateManager(this, state); /** - * Is game paused? - * @type {bool} + * @property {boolean} _paused - Is game paused? + * @private + * @default */ this._paused = false; /** - * The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL - * @type {number} + * @property {number} renderType - The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL. */ this.renderType = renderer; /** - * Whether load complete loading or not. - * @type {bool} + * @property {boolean} _loadComplete - Whether load complete loading or not. + * @private + * @default */ this._loadComplete = false; /** - * Whether the game engine is booted, aka available. - * @type {bool} + * @property {boolean} isBooted - Whether the game engine is booted, aka available. + * @default */ this.isBooted = false; /** - * Is game running or paused? - * @type {bool} + * @property {boolean} id -Is game running or paused? + * @default */ this.isRunning = false; /** - * Automatically handles the core game loop via requestAnimationFrame or setTimeout - * @type {Phaser.RequestAnimationFrame} + * @property {Phaser.RequestAnimationFrame} raf - Automatically handles the core game loop via requestAnimationFrame or setTimeout + * @default */ this.raf = null; - /** - * Reference to the GameObject Factory. - * @type {Phaser.GameObjectFactory} - */ + /** + * @property {Phaser.GameObjectFactory} add - Reference to the GameObject Factory. + * @default + */ this.add = null; /** - * Reference to the assets cache. - * @type {Phaser.Cache} - */ + * @property {Phaser.Cache} cache - Reference to the assets cache. + * @default + */ this.cache = null; /** - * Reference to the input manager - * @type {Phaser.Input} - */ + * @property {Phaser.Input} input - Reference to the input manager + * @default + */ this.input = null; /** - * Reference to the assets loader. - * @type {Phaser.Loader} - */ + * @property {Phaser.Loader} load - Reference to the assets loader. + * @default + */ this.load = null; /** - * Reference to the math helper. - * @type {Phaser.GameMath} - */ + * @property {Phaser.GameMath} math - Reference to the math helper. + * @default + */ this.math = null; /** - * Reference to the network class. - * @type {Phaser.Net} - */ + * @property {Phaser.Net} net - Reference to the network class. + * @default + */ this.net = null; /** - * Reference to the sound manager. - * @type {Phaser.SoundManager} - */ + * @property {Phaser.SoundManager} sound - Reference to the sound manager. + * @default + */ this.sound = null; /** - * Reference to the stage. - * @type {Phaser.Stage} - */ + * @property {Phaser.Stage} stage - Reference to the stage. + * @default + */ this.stage = null; /** - * Reference to game clock. - * @type {Phaser.TimeManager} - */ + * @property {Phaser.TimeManager} time - Reference to game clock. + * @default + */ this.time = null; /** - * Reference to the tween manager. - * @type {Phaser.TweenManager} - */ + * @property {Phaser.TweenManager} tweens - Reference to the tween manager. + * @default + */ this.tweens = null; /** - * Reference to the world. - * @type {Phaser.World} - */ + * @property {Phaser.World} world - Reference to the world. + * @default + */ this.world = null; /** - * Reference to the physics manager. - * @type {Phaser.Physics.PhysicsManager} - */ + * @property {Phaser.Physics.PhysicsManager} physics - Reference to the physics manager. + * @default + */ this.physics = null; /** - * Instance of repeatable random data generator helper. - * @type {Phaser.RandomDataGenerator} - */ + * @property {Phaser.RandomDataGenerator} rnd - Instance of repeatable random data generator helper. + * @default + */ this.rnd = null; /** - * Contains device information and capabilities. - * @type {Phaser.Device} - */ + * @property {Phaser.Device} device - Contains device information and capabilities. + * @default + */ this.device = null; - /** - * A handy reference to world.camera - * @type {Phaser.Camera} + /** + * @property {Phaser.Physics.PhysicsManager} camera - A handy reference to world.camera. + * @default */ this.camera = null; - /** - * A handy reference to renderer.view - * @type {HTMLCanvasElement} + /** + * @property {HTMLCanvasElement} canvas - A handy reference to renderer.view. + * @default */ this.canvas = null; /** - * A handy reference to renderer.context (only set for CANVAS games) - * @type {Context} + * @property {Context} context - A handy reference to renderer.context (only set for CANVAS games) + * @default */ this.context = null; - /** - * A set of useful debug utilities - * @type {Phaser.Utils.Debug} + /** + * @property {Phaser.Utils.Debug} debug - A set of useful debug utilitie. + * @default */ this.debug = null; /** - * The Particle Manager - * @type {Phaser.Particles} + * @property {Phaser.Particles} particles - The Particle Manager. + * @default */ this.particles = null; @@ -10399,9 +11214,9 @@ Phaser.Game.prototype = { /** * Initialize engine sub modules and start the game. - * @param parent {string} ID of parent Dom element. - * @param width {number} Width of the game screen. - * @param height {number} Height of the game screen. + * + * @method Phaser.Game#boot + * @protected */ boot: function () { @@ -10446,14 +11261,14 @@ Phaser.Game.prototype = { this.net = new Phaser.Net(this); this.debug = new Phaser.Utils.Debug(this); - this.load.onLoadComplete.add(this.loadComplete, this); - this.stage.boot(); this.world.boot(); this.input.boot(); this.sound.boot(); this.state.boot(); + this.load.onLoadComplete.add(this.loadComplete, this); + if (this.renderType == Phaser.CANVAS) { console.log('%cPhaser ' + Phaser.VERSION + ' initialized. Rendering to Canvas', 'color: #ffff33; background: #000000'); @@ -10463,6 +11278,14 @@ Phaser.Game.prototype = { console.log('%cPhaser ' + Phaser.VERSION + ' initialized. Rendering to WebGL', 'color: #ffff33; background: #000000'); } + var pos = Phaser.VERSION.indexOf('-'); + var versionQualifier = (pos >= 0) ? Phaser.VERSION.substr(pos + 1) : null; + if (versionQualifier) + { + var article = ['a', 'e', 'i', 'o', 'u', 'y'].indexOf(versionQualifier.charAt(0)) >= 0 ? 'an' : 'a'; + console.warn('You are using %s %s version of Phaser. Some things may not work.', article, versionQualifier); + } + this.isRunning = true; this._loadComplete = false; @@ -10473,6 +11296,12 @@ Phaser.Game.prototype = { }, + /** + * Checks if the device is capable of using the requested renderer and sets it up or an alternative if not. + * + * @method Phaser.Game#setUpRenderer + * @protected + */ setUpRenderer: function () { if (this.renderType === Phaser.CANVAS || (this.renderType === Phaser.AUTO && this.device.webGL == false)) @@ -10506,6 +11335,9 @@ Phaser.Game.prototype = { /** * Called when the load has finished, after preload was run. + * + * @method Phaser.Game#loadComplete + * @protected */ loadComplete: function () { @@ -10515,6 +11347,13 @@ Phaser.Game.prototype = { }, + /** + * The core game loop. + * + * @method Phaser.Game#update + * @protected + * @param {number} time - The current time as provided by RequestAnimationFrame. + */ update: function (time) { this.time.update(time); @@ -10524,6 +11363,7 @@ Phaser.Game.prototype = { this.plugins.preUpdate(); this.physics.preUpdate(); + this.stage.update(); this.input.update(); this.tweens.update(); this.sound.update(); @@ -10532,6 +11372,8 @@ Phaser.Game.prototype = { this.state.update(); this.plugins.update(); + this.world.postUpdate(); + this.renderer.render(this.stage._stage); this.plugins.render(); this.state.render(); @@ -10543,9 +11385,15 @@ Phaser.Game.prototype = { /** * Nuke the entire game from orbit + * + * @method Phaser.Game#destroy */ destroy: function () { + this.raf.stop(); + + this.input.destroy(); + this.state.destroy(); this.state = null; @@ -10562,6 +11410,12 @@ Phaser.Game.prototype = { }; +/** +* The paused state of the Game. A paused game doesn't update any of its subsystems. +* When a game is paused the onPause event is dispatched. When it is resumed the onResume event is dispatched. +* @name Phaser.Game#paused +* @property {boolean} paused - Gets and sets the paused state of the Game. +*/ Object.defineProperty(Phaser.Game.prototype, "paused", { get: function () { @@ -10591,269 +11445,370 @@ Object.defineProperty(Phaser.Game.prototype, "paused", { }); +/** +* "Deleted code is debugged code." - Jeff Sickel +*/ /** -* Phaser.Input -* -* A game specific Input manager that looks after the mouse, keyboard and touch objects. +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Constructor for Phaser Input. +* @class Phaser.Input +* @classdesc A game specific Input manager that looks after the mouse, keyboard and touch objects. * This is updated by the core game loop. +* @constructor +* @param {Phaser.Game} game - Current game instance. */ Phaser.Input = function (game) { + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; + /** + * @property {Description} hitCanvas - Description. + * @default + */ this.hitCanvas = null; + + /** + * @property {Description} hitContext - Description. + * @default + */ this.hitContext = null; }; +/** +* @constant +* @type {number} +*/ Phaser.Input.MOUSE_OVERRIDES_TOUCH = 0; + +/** +* @constant +* @type {number} +*/ Phaser.Input.TOUCH_OVERRIDES_MOUSE = 1; + +/** +* @constant +* @type {number} +*/ Phaser.Input.MOUSE_TOUCH_COMBINE = 2; Phaser.Input.prototype = { + /** + * @property {Phaser.Game} game + */ game: null, /** * How often should the input pointers be checked for updates? * A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on. - * @type {number} + * @property {number} pollRate + * @default */ pollRate: 0, + + /** + * @property {number} _pollCounter - Description. + * @private + * @default + */ _pollCounter: 0, /** * A vector object representing the previous position of the Pointer. - * @property vector - * @type {Vec2} - **/ + * @property {Vec2} vector + * @private + * @default + */ _oldPosition: null, /** * X coordinate of the most recent Pointer event - * @type {Number} + * @property {number} _x * @private + * @default */ _x: 0, /** - * X coordinate of the most recent Pointer event - * @type {Number} + * Y coordinate of the most recent Pointer event + * @property {number} _y * @private + * @default */ _y: 0, /** * You can disable all Input by setting Input.disabled: true. While set all new input related events will be ignored. * If you need to disable just one type of input, for example mouse, use Input.mouse.disabled: true instead - * @type {bool} + * @property {boolean} disabled + * @default */ disabled: false, /** - * Controls the expected behaviour when using a mouse and touch together on a multi-input device + * Controls the expected behaviour when using a mouse and touch together on a multi-input device. + * @property {Description} multiInputOverride */ multiInputOverride: Phaser.Input.MOUSE_TOUCH_COMBINE, /** * A vector object representing the current position of the Pointer. - * @property vector - * @type {Vec2} - **/ + * @property {Phaser.Point} position + * @default + */ position: null, /** * A vector object representing the speed of the Pointer. Only really useful in single Pointer games, * otherwise see the Pointer objects directly. - * @property vector - * @type {Vec2} - **/ + * @property {Phaser.Point} speed + * @default + */ speed: null, /** * A Circle object centered on the x/y screen coordinates of the Input. - * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything - * @property circle - * @type {Circle} - **/ + * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything. + * @property {Phaser.Circle} circle + * @default + */ circle: null, /** * The scale by which all input coordinates are multiplied, calculated by the StageScaleMode. * In an un-scaled game the values will be x: 1 and y: 1. - * @type {Vec2} + * @property {Phaser.Point} scale + * @default */ scale: null, /** * The maximum number of Pointers allowed to be active at any one time. - * For lots of games it's useful to set this to 1 - * @type {Number} + * For lots of games it's useful to set this to 1. + * @property {number} maxPointers + * @default */ maxPointers: 10, /** * The current number of active Pointers. - * @type {Number} + * @property {number} currentPointers + * @default */ currentPointers: 0, /** - * The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or click - * @property tapRate - * @type {Number} - **/ + * The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or clicke + * @property {number} tapRate + * @default + */ tapRate: 200, /** * The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click - * @property doubleTapRate - * @type {Number} - **/ + * @property {number} doubleTapRate + * @default + */ doubleTapRate: 300, /** * The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event - * @property holdRate - * @type {Number} - **/ + * @property {number} holdRate + * @default + */ holdRate: 2000, /** * The number of milliseconds below which the Pointer is considered justPressed - * @property justPressedRate - * @type {Number} - **/ + * @property {number} justPressedRate + * @default + */ justPressedRate: 200, /** - * The number of milliseconds below which the Pointer is considered justReleased - * @property justReleasedRate - * @type {Number} - **/ + * The number of milliseconds below which the Pointer is considered justReleased + * @property {number} justReleasedRate + * @default + */ justReleasedRate: 200, /** * Sets if the Pointer objects should record a history of x/y coordinates they have passed through. * The history is cleared each time the Pointer is pressed down. * The history is updated at the rate specified in Input.pollRate - * @property recordPointerHistory - * @type {bool} - **/ + * @property {boolean} recordPointerHistory + * @default + */ recordPointerHistory: false, /** * The rate in milliseconds at which the Pointer objects should update their tracking history - * @property recordRate - * @type {Number} + * @property {number} recordRate + * @default */ recordRate: 100, /** * The total number of entries that can be recorded into the Pointer objects tracking history. * If the Pointer is tracking one event every 100ms, then a trackLimit of 100 would store the last 10 seconds worth of history. - * @property recordLimit - * @type {Number} + * @property {number} recordLimit + * @default */ recordLimit: 100, /** * A Pointer object - * @property pointer1 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer1 + */ pointer1: null, /** * A Pointer object - * @property pointer2 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer2 + */ pointer2: null, /** - * A Pointer object - * @property pointer3 - * @type {Pointer} - **/ + * A Pointer object + * @property {Phaser.Pointer} pointer3 + */ pointer3: null, /** * A Pointer object - * @property pointer4 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer4 + */ pointer4: null, /** * A Pointer object - * @property pointer5 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer5 + */ pointer5: null, /** * A Pointer object - * @property pointer6 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer6 + */ pointer6: null, /** - * A Pointer object - * @property pointer7 - * @type {Pointer} - **/ + * A Pointer object + * @property {Phaser.Pointer} pointer7 + */ pointer7: null, /** * A Pointer object - * @property pointer8 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer8 + */ pointer8: null, /** * A Pointer object - * @property pointer9 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer9 + */ pointer9: null, /** - * A Pointer object - * @property pointer10 - * @type {Pointer} - **/ + * A Pointer object. + * @property {Phaser.Pointer} pointer10 + */ pointer10: null, /** * The most recently active Pointer object. * When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse. - * @property activePointer - * @type {Pointer} - **/ + * @property {Phaser.Pointer} activePointer + * @default + */ activePointer: null, + /** + * The mouse has its own unique Phaser.Pointer object which you can use if making a desktop specific game. + * @property {Pointer} mousePointer + * @default + */ mousePointer: null, + + /** + * The Mouse Input manager. + * @property {Phaser.Mouse} mouse - The Mouse Input manager. + * @default + */ mouse: null, + + /** + * The Keyboard Input manager. + * @property {Phaser.Keyboard} keyboard - The Keyboard Input manager. + * @default + */ keyboard: null, + + /** + * The Touch Input manager. + * @property {Phaser.Touch} touch - the Touch Input manager. + * @default + */ touch: null, + + /** + * The MSPointer Input manager. + * @property {Phaser.MSPointer} mspointer - The MSPointer Input manager. + * @default + */ mspointer: null, + /** + * A Signal that is dispatched each time a pointer is pressed down. + * @property {Phaser.Signal} onDown + * @default + */ onDown: null, + + /** + * A Signal that is dispatched each time a pointer is released. + * @property {Phaser.Signal} onUp + * @default + */ onUp: null, + + /** + * A Signal that is dispatched each time a pointer is tapped. + * @property {Phaser.Signal} onTap + * @default + */ onTap: null, + + /** + * A Signal that is dispatched each time a pointer is held down. + * @property {Phaser.Signal} onHold + * @default + */ onHold: null, - // A linked list of interactive objects, the InputHandler components (belong to Sprites) register themselves with this + /** + * A linked list of interactive objects, the InputHandler components (belonging to Sprites) register themselves with this. + * @property {Phaser.LinkedList} interactiveItems + */ interactiveItems: new Phaser.LinkedList(), /** - * Starts the Input Manager running - * @method start - **/ + * Starts the Input Manager running. + * @method Phaser.Input#boot + * @protected + */ boot: function () { this.mousePointer = new Phaser.Pointer(this.game, 0); @@ -10891,14 +11846,27 @@ Phaser.Input.prototype = { this.mspointer.start(); this.mousePointer.active = true; + }, + + /** + * Stops all of the Input Managers from running. + * @method Phaser.Input#destroy + */ + destroy: function () { + + this.mouse.stop(); + this.keyboard.stop(); + this.touch.stop(); + this.mspointer.stop(); + }, /** - * Add a new Pointer object to the Input Manager. By default Input creates 2 pointer objects for you. If you need more - * use this to create a new one, up to a maximum of 10. - * @method addPointer - * @return {Pointer} A reference to the new Pointer object - **/ + * Add a new Pointer object to the Input Manager. By default Input creates 3 pointer objects: mousePointer, pointer1 and pointer2. + * If you need more then use this to create a new one, up to a maximum of 10. + * @method Phaser.Input#addPointer + * @return {Phaser.Pointer} A reference to the new Pointer object that was created. + */ addPointer: function () { var next = 0; @@ -10926,8 +11894,9 @@ Phaser.Input.prototype = { /** * Updates the Input Manager. Called by the core Game loop. - * @method update - **/ + * @method Phaser.Input#update + * @protected + */ update: function () { if (this.pollRate > 0 && this._pollCounter < this.pollRate) @@ -10959,9 +11928,9 @@ Phaser.Input.prototype = { /** * Reset all of the Pointers and Input states - * @method reset - * @param hard {bool} A soft reset (hard = false) won't reset any signals that might be bound. A hard reset will. - **/ + * @method Phaser.Input#reset + * @param {boolean} hard - A soft reset (hard = false) won't reset any Signals that might be bound. A hard reset will. + */ reset: function (hard) { if (this.game.isBooted == false) @@ -11003,6 +11972,12 @@ Phaser.Input.prototype = { }, + /** + * Resets the speed and old position properties. + * @method Phaser.Input#resetSpeed + * @param {number} x - Sets the oldPosition.x value. + * @param {number} y - Sets the oldPosition.y value. + */ resetSpeed: function (x, y) { this._oldPosition.setTo(x, y); @@ -11011,11 +11986,11 @@ Phaser.Input.prototype = { }, /** - * Find the first free Pointer object and start it, passing in the event data. - * @method startPointer - * @param {Any} event The event data from the Touch event - * @return {Pointer} The Pointer object that was started or null if no Pointer object is available - **/ + * Find the first free Pointer object and start it, passing in the event data. This is called automatically by Phaser.Touch and Phaser.MSPointer. + * @method Phaser.Input#startPointer + * @param {Any} event - The event data from the Touch event. + * @return {Phaser.Pointer} The Pointer object that was started or null if no Pointer object is available. + */ startPointer: function (event) { if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers) @@ -11047,11 +12022,11 @@ Phaser.Input.prototype = { }, /** - * Updates the matching Pointer object, passing in the event data. - * @method updatePointer - * @param {Any} event The event data from the Touch event - * @return {Pointer} The Pointer object that was updated or null if no Pointer object is available - **/ + * Updates the matching Pointer object, passing in the event data. This is called automatically and should not normally need to be invoked. + * @method Phaser.Input#updatePointer + * @param {Any} event - The event data from the Touch event. + * @return {Phaser.Pointer} The Pointer object that was updated or null if no Pointer object is available. + */ updatePointer: function (event) { if (this.pointer1.active && this.pointer1.identifier == event.identifier) @@ -11079,10 +12054,10 @@ Phaser.Input.prototype = { /** * Stops the matching Pointer object, passing in the event data. - * @method stopPointer - * @param {Any} event The event data from the Touch event - * @return {Pointer} The Pointer object that was stopped or null if no Pointer object is available - **/ + * @method Phaser.Input#stopPointer + * @param {Any} event - The event data from the Touch event. + * @return {Phaser.Pointer} The Pointer object that was stopped or null if no Pointer object is available. + */ stopPointer: function (event) { if (this.pointer1.active && this.pointer1.identifier == event.identifier) @@ -11110,10 +12085,10 @@ Phaser.Input.prototype = { /** * Get the next Pointer object whos active property matches the given state - * @method getPointer - * @param {bool} state The state the Pointer should be in (false for inactive, true for active) - * @return {Pointer} A Pointer object or null if no Pointer object matches the requested state. - **/ + * @method Phaser.Input#getPointer + * @param {boolean} state - The state the Pointer should be in (false for inactive, true for active). + * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested state. + */ getPointer: function (state) { state = state || false; @@ -11142,11 +12117,11 @@ Phaser.Input.prototype = { }, /** - * Get the Pointer object whos identified property matches the given identifier value - * @method getPointerFromIdentifier - * @param {Number} identifier The Pointer.identifier value to search for - * @return {Pointer} A Pointer object or null if no Pointer object matches the requested identifier. - **/ + * Get the Pointer object whos identified property matches the given identifier value. + * @method Phaser.Input#getPointerFromIdentifier + * @param {number} identifier - The Pointer.identifier value to search for. + * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested identifier. + */ getPointerFromIdentifier: function (identifier) { if (this.pointer1.identifier == identifier) @@ -11170,40 +12145,17 @@ Phaser.Input.prototype = { return null; - }, - - /** - * Get the distance between two Pointer objects - * @method getDistance - * @param {Pointer} pointer1 - * @param {Pointer} pointer2 - **/ - getDistance: function (pointer1, pointer2) { - // return Phaser.Vec2Utils.distance(pointer1.position, pointer2.position); - }, - - /** - * Get the angle between two Pointer objects - * @method getAngle - * @param {Pointer} pointer1 - * @param {Pointer} pointer2 - **/ - getAngle: function (pointer1, pointer2) { - // return Phaser.Vec2Utils.angle(pointer1.position, pointer2.position); } }; -// Getters / Setters - +/** +* The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values. +* @name Phaser.Input#x +* @property {number} x - The X coordinate of the most recently active pointer. +*/ Object.defineProperty(Phaser.Input.prototype, "x", { - /** - * The X coordinate of the most recently active pointer. - * This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values. - * @property x - * @type {Number} - **/ get: function () { return this._x; }, @@ -11214,14 +12166,13 @@ Object.defineProperty(Phaser.Input.prototype, "x", { }); +/** +* The Y coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values. +* @name Phaser.Input#y +* @property {number} y - The Y coordinate of the most recently active pointer. +*/ Object.defineProperty(Phaser.Input.prototype, "y", { - /** - * The Y coordinate of the most recently active pointer. - * This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values. - * @property y - * @type {Number} - **/ get: function () { return this._y; }, @@ -11232,6 +12183,11 @@ Object.defineProperty(Phaser.Input.prototype, "y", { }); +/** +* @name Phaser.Input#pollLocked +* @property {boolean} pollLocked - True if the Input is currently poll rate locked. +* @readonly +*/ Object.defineProperty(Phaser.Input.prototype, "pollLocked", { get: function () { @@ -11240,26 +12196,28 @@ Object.defineProperty(Phaser.Input.prototype, "pollLocked", { }); +/** +* The total number of inactive Pointers +* @name Phaser.Input#totalInactivePointers +* @property {number} totalInactivePointers - The total number of inactive Pointers. +* @readonly +*/ Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", { - /** - * Get the total number of inactive Pointers - * @method totalInactivePointers - * @return {Number} The number of Pointers currently inactive - **/ get: function () { return 10 - this.currentPointers; } }); +/** +* The total number of active Pointers +* @name Phaser.Input#totalActivePointers +* @property {number} totalActivePointers - The total number of active Pointers. +* @readonly +*/ Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", { - /** - * Recalculates the total number of active Pointers - * @method totalActivePointers - * @return {Number} The number of Pointers currently active - **/ get: function () { this.currentPointers = 0; @@ -11278,6 +12236,11 @@ Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", { }); +/** +* The world X coordinate of the most recently active pointer. +* @name Phaser.Input#worldX +* @property {number} worldX - The world X coordinate of the most recently active pointer. +*/ Object.defineProperty(Phaser.Input.prototype, "worldX", { get: function () { @@ -11286,6 +12249,11 @@ Object.defineProperty(Phaser.Input.prototype, "worldX", { }); +/** +* The world Y coordinate of the most recently active pointer. +* @name Phaser.Input#worldY +* @property {number} worldY - The world Y coordinate of the most recently active pointer. +*/ Object.defineProperty(Phaser.Input.prototype, "worldY", { get: function () { @@ -11294,37 +12262,336 @@ Object.defineProperty(Phaser.Input.prototype, "worldY", { }); +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* @class Phaser.Key +* @classdesc If you need more fine-grained control over the handling of specific keys you can create and use Phaser.Key objects. +* @constructor +* @param {Phaser.Game} game - Current game instance. +* @param {number} keycode - The key code this Key is responsible for. +*/ +Phaser.Key = function (game, keycode) { + + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = game; + + /** + * @property {boolean} isDown - The "down" state of the key. + * @default + */ + this.isDown = false; + + /** + * @property {boolean} isUp - The "up" state of the key. + * @default + */ + this.isUp = false; + + /** + * @property {boolean} altKey - The down state of the ALT key, if pressed at the same time as this key. + * @default + */ + this.altKey = false; + + /** + * @property {boolean} ctrlKey - The down state of the CTRL key, if pressed at the same time as this key. + * @default + */ + this.ctrlKey = false; + + /** + * @property {boolean} shiftKey - The down state of the SHIFT key, if pressed at the same time as this key. + * @default + */ + this.shiftKey = false; + + /** + * @property {number} timeDown - The timestamp when the key was last pressed down. + * @default + */ + this.timeDown = 0; + + /** + * 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. + * @property {number} duration - The number of milliseconds this key has been held down for. + * @default + */ + this.duration = 0; + + /** + * @property {number} timeUp - The timestamp when the key was last released. + * @default + */ + this.timeUp = 0; + + /** + * @property {number} repeats - If a key is held down this holds down the number of times the key has 'repeated'. + * @default + */ + this.repeats = 0; + + /** + * @property {number} keyCode - The keycode of this key. + */ + this.keyCode = keycode; + + /** + * @property {Phaser.Signal} onDown - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again). + */ + this.onDown = new Phaser.Signal(); + + /** + * @property {Phaser.Signal} onUp - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again). + */ + this.onUp = new Phaser.Signal(); + +}; + +Phaser.Key.prototype = { + + /** + * Called automatically by Phaser.Keyboard. + * @method Phaser.Key#processKeyDown + * @param {KeyboardEvent} event. + * @protected + */ + processKeyDown: function (event) { + + this.altKey = event.altKey; + this.ctrlKey = event.ctrlKey; + this.shiftKey = event.shiftKey; + + if (this.isDown) + { + // Key was already held down, this must be a repeat rate based event + this.duration = event.timeStamp - this.timeDown; + this.repeats++; + } + else + { + this.isDown = true; + this.isUp = false; + this.timeDown = event.timeStamp; + this.duration = 0; + this.repeats = 0; + + this.onDown.dispatch(this); + } + + }, + + /** + * Called automatically by Phaser.Keyboard. + * @method Phaser.Key#processKeyUp + * @param {KeyboardEvent} event. + * @protected + */ + processKeyUp: function (event) { + + this.isDown = false; + this.isUp = true; + this.timeUp = event.timeStamp; + + this.onUp.dispatch(this); + + }, + + /** + * Returns the "just pressed" state of the Key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms) + * @method Phaser.Key#justPressed + * @param {number} [duration=250] - The duration below which the key is considered as being just pressed. + * @return {boolean} True if the key is just pressed otherwise false. + */ + justPressed: function (duration) { + + if (typeof duration === "undefined") { duration = 250; } + + return (this.isDown && this.duration < duration); + + }, + + /** + * Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms) + * @method Phaser.Key#justPressed + * @param {number} [duration=250] - The duration below which the key is considered as being just released. + * @return {boolean} True if the key is just released otherwise false. + */ + justReleased: function (duration) { + + if (typeof duration === "undefined") { duration = 250; } + + return (this.isDown == false && (this.game.time.now - this.timeUp < duration)); + + } + +}; + +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser - Keyboard constructor. +* +* @class Phaser.Keyboard +* @classdesc A Keyboard object Description. +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +*/ Phaser.Keyboard = function (game) { + /** + * @property {Phaser.Game} game - Local reference to game. + */ this.game = game; + + /** + * @property {Description} _keys - Description. + * @private + */ this._keys = {}; + + /** + * @property {Description} _hotkeys - Description. + * @private + */ + this._hotkeys = {}; + + /** + * @property {Description} _capture - Description. + * @private + */ this._capture = {}; + + /** + * You can disable all Keyboard Input by setting disabled to true. While true all new input related events will be ignored. + * @property {boolean} disabled - The disabled state of the Keyboard. + * @default + */ + this.disabled = false; + + /** + * @property {function} _onKeyDown + * @private + * @default + */ + this._onKeyDown = null; + + /** + * @property {function} _onKeyUp + * @private + * @default + */ + this._onKeyUp = null; + + /** + * @property {Object} callbackContext - The context under which the callbacks are run. + */ + this.callbackContext = this; + + /** + * @property {function} onDownCallback - This callback is invoked every time a key is pressed down. + */ + this.onDownCallback = null; + + /** + * @property {function} onUpCallback - This callback is invoked every time a key is released. + */ + this.onUpCallback = null; }; Phaser.Keyboard.prototype = { - game: null, + /** + * Add callbacks to the Keyboard handler so that each time a key is pressed down or releases the callbacks are activated. + * @method Phaser.Keyboard#addCallbacks + * @param {Object} context - The context under which the callbacks are run. + * @param {function} onDown - This callback is invoked every time a key is pressed down. + * @param {function} [onUp=null] - This callback is invoked every time a key is released. + */ + addCallbacks: function (context, onDown, onUp) { + + this.callbackContext = context; + this.onDownCallback = onDown; + + if (typeof onUp !== 'undefined') + { + this.onUpCallback = onUp; + } + + }, /** - * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. - * @type {bool} + * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method. + * The Key object can then be polled, have events attached to it, etc. + * + * @method Phaser.Keyboard#addKey + * @param {number} keycode - The keycode of the key, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + * @return {Phaser.Key} The Key object which you can store locally and reference directly. */ - disabled: false, + addKey: function (keycode) { - _onKeyDown: null, - _onKeyUp: null, + this._hotkeys[keycode] = new Phaser.Key(this.game, keycode); + return this._hotkeys[keycode]; + }, + + /** + * Removes a Key object from the Keyboard manager. + * + * @method Phaser.Keyboard#removeKey + * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + */ + removeKey: function (keycode) { + + delete (this._hotkeys[keycode]); + + }, + + /** + * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right. + * + * @method Phaser.Keyboard#createCursorKeys + * @return {object} An object containing properties: up, down, left and right. Which can be polled like any other Phaser.Key object. + */ + createCursorKeys: function () { + + return { + up: this.addKey(Phaser.Keyboard.UP), + down: this.addKey(Phaser.Keyboard.DOWN), + left: this.addKey(Phaser.Keyboard.LEFT), + right: this.addKey(Phaser.Keyboard.RIGHT) + } + + }, + + /** + * Starts the Keyboard event listeners running (keydown and keyup). They are attached to the document.body. + * This is called automatically by Phaser.Input and should not normally be invoked directly. + * + * @method Phaser.Keyboard#start + */ start: function () { var _this = this; this._onKeyDown = function (event) { - return _this.onKeyDown(event); + return _this.processKeyDown(event); }; this._onKeyUp = function (event) { - return _this.onKeyUp(event); + return _this.processKeyUp(event); }; document.body.addEventListener('keydown', this._onKeyDown, false); @@ -11332,6 +12599,11 @@ Phaser.Keyboard.prototype = { }, + /** + * Stops the Keyboard event listeners from running (keydown and keyup). They are removed from the document.body. + * + * @method Phaser.Keyboard#stop + */ stop: function () { document.body.removeEventListener('keydown', this._onKeyDown); @@ -11344,6 +12616,7 @@ Phaser.Keyboard.prototype = { * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. * You can use addKeyCapture to consume the keyboard event for specific keys so it doesn't bubble up to the the browser. * Pass in either a single keycode or an array/hash of keycodes. + * @method Phaser.Keyboard#addKeyCapture * @param {Any} keycode */ addKeyCapture: function (keycode) { @@ -11362,7 +12635,9 @@ Phaser.Keyboard.prototype = { }, /** - * @param {Number} keycode + * Removes an existing key capture. + * @method Phaser.Keyboard#removeKeyCapture + * @param {number} keycode */ removeKeyCapture: function (keycode) { @@ -11370,6 +12645,10 @@ Phaser.Keyboard.prototype = { }, + /** + * Clear all set key captures. + * @method Phaser.Keyboard#clearCaptures + */ clearCaptures: function () { this._capture = {}; @@ -11377,9 +12656,12 @@ Phaser.Keyboard.prototype = { }, /** + * Process the keydown event. + * @method Phaser.Keyboard#processKeyDown * @param {KeyboardEvent} event + * @protected */ - onKeyDown: function (event) { + processKeyDown: function (event) { if (this.game.input.disabled || this.disabled) { @@ -11391,26 +12673,51 @@ Phaser.Keyboard.prototype = { event.preventDefault(); } - if (!this._keys[event.keyCode]) + if (this.onDownCallback) { - this._keys[event.keyCode] = { - isDown: true, - timeDown: this.game.time.now, - timeUp: 0 - }; + this.onDownCallback.call(this.callbackContext, event); + } + + if (this._keys[event.keyCode] && this._keys[event.keyCode].isDown) + { + // Key already down and still down, so update + this._keys[event.keyCode].duration = this.game.time.now - this._keys[event.keyCode].timeDown; } else { - this._keys[event.keyCode].isDown = true; - this._keys[event.keyCode].timeDown = this.game.time.now; + if (!this._keys[event.keyCode]) + { + // Not used this key before, so register it + this._keys[event.keyCode] = { + isDown: true, + timeDown: this.game.time.now, + timeUp: 0, + duration: 0 + }; + } + else + { + // Key used before but freshly down + this._keys[event.keyCode].isDown = true; + this._keys[event.keyCode].timeDown = this.game.time.now; + this._keys[event.keyCode].duration = 0; + } + } + + if (this._hotkeys[event.keyCode]) + { + this._hotkeys[event.keyCode].processKeyDown(event); } }, /** + * Process the keyup event. + * @method Phaser.Keyboard#processKeyUp * @param {KeyboardEvent} event + * @protected */ - onKeyUp: function (event) { + processKeyUp: function (event) { if (this.game.input.disabled || this.disabled) { @@ -11422,22 +12729,38 @@ Phaser.Keyboard.prototype = { event.preventDefault(); } - if (!this._keys[event.keyCode]) + if (this.onUpCallback) { - this._keys[event.keyCode] = { - isDown: false, - timeDown: 0, - timeUp: this.game.time.now - }; + this.onUpCallback.call(this.callbackContext, event); } - else + + if (this._hotkeys[event.keyCode]) + { + this._hotkeys[event.keyCode].processKeyUp(event); + } + + if (this._keys[event.keyCode]) { this._keys[event.keyCode].isDown = false; this._keys[event.keyCode].timeUp = this.game.time.now; } + else + { + // Not used this key before, so register it + this._keys[event.keyCode] = { + isDown: false, + timeDown: this.game.time.now, + timeUp: this.game.time.now, + duration: 0 + }; + } }, + /** + * Reset the "isDown" state of all keys. + * @method Phaser.Keyboard#reset + */ reset: function () { for (var key in this._keys) @@ -11447,16 +12770,18 @@ Phaser.Keyboard.prototype = { }, - /** - * @param {Number} keycode - * @param {Number} [duration] - * @return {bool} + /** + * Returns the "just pressed" state of the key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms) + * @method Phaser.Keyboard#justPressed + * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + * @param {number} [duration=250] - The duration below which the key is considered as being just pressed. + * @return {boolean} True if the key is just pressed otherwise false. */ justPressed: function (keycode, duration) { if (typeof duration === "undefined") { duration = 250; } - if (this._keys[keycode] && this._keys[keycode].isDown === true && (this.game.time.now - this._keys[keycode].timeDown < duration)) + if (this._keys[keycode] && this._keys[keycode].isDown && this._keys[keycode].duration < duration) { return true; } @@ -11465,10 +12790,12 @@ Phaser.Keyboard.prototype = { }, - /** - * @param {Number} keycode - * @param {Number} [duration] - * @return {bool} + /** + * Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms) + * @method Phaser.Keyboard#justPressed + * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + * @param {number} [duration=250] - The duration below which the key is considered as being just released. + * @return {boolean} True if the key is just released otherwise false. */ justReleased: function (keycode, duration) { @@ -11483,9 +12810,11 @@ Phaser.Keyboard.prototype = { }, - /** - * @param {Number} keycode - * @return {bool} + /** + * Returns true of the key is currently pressed down. Note that it can only detect key presses on the web browser. + * @method Phaser.Keyboard#isDown + * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + * @return {boolean} True if the key is currently down. */ isDown: function (keycode) { @@ -11500,8 +12829,6 @@ Phaser.Keyboard.prototype = { }; -// Statics - Phaser.Keyboard.A = "A".charCodeAt(0); Phaser.Keyboard.B = "B".charCodeAt(0); Phaser.Keyboard.C = "C".charCodeAt(0); @@ -11601,40 +12928,89 @@ Phaser.Keyboard.DELETE = 46; Phaser.Keyboard.HELP = 47; Phaser.Keyboard.NUM_LOCK = 144; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser - Mouse constructor. +* +* @class Phaser.Mouse +* @classdesc The Mouse class +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +*/ Phaser.Mouse = function (game) { + /** + * @property {Phaser.Game} game - Local reference to game. + */ this.game = game; + + /** + * @property {Object} callbackContext - Description. + */ this.callbackContext = this.game; + /** + * @property {Description} mouseDownCallback - Description. + * @default + */ this.mouseDownCallback = null; + + /** + * @property {Description} mouseMoveCallback - Description. + * @default + */ this.mouseMoveCallback = null; + + /** + * @property {Description} mouseUpCallback - Description. + * @default + */ this.mouseUpCallback = null; + /** + * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. + * @property {boolean} disabled + * @default + */ + this.disabled = false; + + /** + * If the mouse has been Pointer Locked successfully this will be set to true. + * @property {boolean} locked + * @default + */ + this.locked = false; + }; +/** +* @constant +* @type {number} +*/ Phaser.Mouse.LEFT_BUTTON = 0; + +/** +* @constant +* @type {number} +*/ Phaser.Mouse.MIDDLE_BUTTON = 1; + +/** +* @constant +* @type {number} +*/ Phaser.Mouse.RIGHT_BUTTON = 2; Phaser.Mouse.prototype = { - game: null, - - /** - * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. - * @type {bool} - */ - disabled: false, - - /** - * If the mouse has been Pointer Locked successfully this will be set to true. - * @type {bool} - */ - locked: false, - /** - * Starts the event listeners running - * @method start + * Starts the event listeners running. + * @method Phaser.Mouse#start */ start: function () { @@ -11665,6 +13041,8 @@ Phaser.Mouse.prototype = { }, /** + * Description. + * @method Phaser.Mouse#onMouseDown * @param {MouseEvent} event */ onMouseDown: function (event) { @@ -11686,6 +13064,8 @@ Phaser.Mouse.prototype = { }, /** + * Description + * @method Phaser.Mouse#onMouseMove * @param {MouseEvent} event */ onMouseMove: function (event) { @@ -11707,6 +13087,8 @@ Phaser.Mouse.prototype = { }, /** + * Description. + * @method Phaser.Mouse#onMouseUp * @param {MouseEvent} event */ onMouseUp: function (event) { @@ -11727,6 +13109,10 @@ Phaser.Mouse.prototype = { }, + /** + * Description. + * @method Phaser.Mouse#requestPointerLock + */ requestPointerLock: function () { if (this.game.device.pointerLock) @@ -11750,6 +13136,11 @@ Phaser.Mouse.prototype = { }, + /** + * Description. + * @method Phaser.Mouse#pointerLockChange + * @param {MouseEvent} event + */ pointerLockChange: function (event) { var element = this.game.stage.canvas; @@ -11767,6 +13158,10 @@ Phaser.Mouse.prototype = { }, + /** + * Description. + * @method Phaser.Mouse#releasePointerLock + */ releasePointerLock: function () { document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock; @@ -11780,8 +13175,8 @@ Phaser.Mouse.prototype = { }, /** - * Stop the event listeners - * @method stop + * Stop the event listeners. + * @method Phaser.Mouse#stop */ stop: function () { @@ -11793,40 +13188,88 @@ Phaser.Mouse.prototype = { }; /** -* Phaser.MSPointer +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser - MSPointer constructor. * -* The MSPointer class handles touch interactions with the game and the resulting Pointer objects. +* @class Phaser.MSPointer +* @classdesc The MSPointer class handles touch interactions with the game and the resulting Pointer objects. * It will work only in Internet Explorer 10 and Windows Store or Windows Phone 8 apps using JavaScript. * http://msdn.microsoft.com/en-us/library/ie/hh673557(v=vs.85).aspx +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.MSPointer = function (game) { + /** + * @property {Phaser.Game} game - Local reference to game. + */ this.game = game; + + /** + * @property {Phaser.Game} callbackContext - Description. + */ this.callbackContext = this.game; + /** + * @property {Description} mouseDownCallback - Description. + * @default + */ this.mouseDownCallback = null; + + /** + * @property {Description} mouseMoveCallback - Description. + * @default + */ this.mouseMoveCallback = null; + + /** + * @property {Description} mouseUpCallback - Description. + * @default + */ this.mouseUpCallback = null; + /** + * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. + * @property {boolean} disabled + */ + this.disabled = false; + + /** + * Description. + * @property {Description} _onMSPointerDown + * @private + * @default + */ + this._onMSPointerDown = null; + + /** + * Description. + * @property {Description} _onMSPointerMove + * @private + * @default + */ + this._onMSPointerMove = null; + + /** + * Description. + * @property {Description} _onMSPointerUp + * @private + * @default + */ + this._onMSPointerUp = null; + }; Phaser.MSPointer.prototype = { - game: null, - - /** - * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. - * @type {bool} - */ - disabled: false, - - _onMSPointerDown: null, - _onMSPointerMove: null, - _onMSPointerUp: null, - /** - * Starts the event listeners running - * @method start + * Starts the event listeners running. + * @method Phaser.MSPointer#start */ start: function () { @@ -11858,7 +13301,8 @@ Phaser.MSPointer.prototype = { }, /** - * @method onPointerDown + * Description. + * @method Phaser.MSPointer#onPointerDown * @param {Any} event **/ onPointerDown: function (event) { @@ -11876,7 +13320,8 @@ Phaser.MSPointer.prototype = { }, /** - * @method onPointerMove + * Description. + * @method Phaser.MSPointer#onPointerMove * @param {Any} event **/ onPointerMove: function (event) { @@ -11894,7 +13339,8 @@ Phaser.MSPointer.prototype = { }, /** - * @method onPointerUp + * Description. + * @method Phaser.MSPointer#onPointerUp * @param {Any} event **/ onPointerUp: function (event) { @@ -11912,8 +13358,8 @@ Phaser.MSPointer.prototype = { }, /** - * Stop the event listeners - * @method stop + * Stop the event listeners. + * @method Phaser.MSPointer#stop */ stop: function () { @@ -11925,195 +13371,233 @@ Phaser.MSPointer.prototype = { }; /** -* Phaser - Pointer +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser - Pointer constructor. * -* A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen. +* @class Phaser.Pointer +* @classdesc A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen. +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {Description} id - Description. */ Phaser.Pointer = function (game, id) { /** - * Local private variable to store the status of dispatching a hold event - * @property _holdSent - * @type {bool} + * @property {Phaser.Game} game - Local reference to game. + */ + this.game = game; + + /** + * @property {Description} id - Description. + */ + this.id = id; + + /** + * Local private variable to store the status of dispatching a hold event. + * @property {boolean} _holdSent * @private + * @default */ this._holdSent = false; /** - * Local private variable storing the short-term history of pointer movements - * @property _history - * @type {Array} + * Local private variable storing the short-term history of pointer movements. + * @property {array} _history * @private */ this._history = []; /** * Local private variable storing the time at which the next history drop should occur - * @property _lastDrop - * @type {Number} + * @property {number} _lastDrop * @private + * @default */ this._nextDrop = 0; - // Monitor events outside of a state reset loop + /** + * Monitor events outside of a state reset loop. + * @property {boolean} _stateReset + * @private + * @default + */ this._stateReset = false; /** * A Vector object containing the initial position when the Pointer was engaged with the screen. - * @property positionDown - * @type {Vec2} + * @property {Vec2} positionDown + * @default **/ this.positionDown = null; /** * A Vector object containing the current position of the Pointer on the screen. - * @property position - * @type {Vec2} + * @property {Vec2} position + * @default **/ this.position = null; /** * A Circle object centered on the x/y screen coordinates of the Pointer. - * Default size of 44px (Apple's recommended "finger tip" size) - * @property circle - * @type {Circle} + * Default size of 44px (Apple's recommended "finger tip" size). + * @property {Circle} circle + * @default **/ this.circle = null; /** - * - * @property withinGame - * @type {bool} + * Description. + * @property {boolean} withinGame */ this.withinGame = false; /** - * The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset - * @property clientX - * @type {Number} + * The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset. + * @property {number} clientX + * @default */ this.clientX = -1; /** - * The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset - * @property clientY - * @type {Number} + * The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset. + * @property {number} clientY + * @default */ this.clientY = -1; /** - * The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset - * @property pageX - * @type {Number} + * The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset. + * @property {number} pageX + * @default */ this.pageX = -1; /** - * The vertical coordinate of point relative to the viewport in pixels, including any scroll offset - * @property pageY - * @type {Number} + * The vertical coordinate of point relative to the viewport in pixels, including any scroll offset. + * @property {number} pageY + * @default */ this.pageY = -1; /** - * The horizontal coordinate of point relative to the screen in pixels - * @property screenX - * @type {Number} + * The horizontal coordinate of point relative to the screen in pixels. + * @property {number} screenX + * @default */ this.screenX = -1; /** - * The vertical coordinate of point relative to the screen in pixels - * @property screenY - * @type {Number} + * The vertical coordinate of point relative to the screen in pixels. + * @property {number} screenY + * @default */ this.screenY = -1; /** * The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size. - * @property x - * @type {Number} + * @property {number} x + * @default */ this.x = -1; /** * The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size. - * @property y - * @type {Number} + * @property {number} y + * @default */ this.y = -1; /** - * If the Pointer is a mouse this is true, otherwise false - * @property isMouse - * @type {bool} - **/ + * If the Pointer is a mouse this is true, otherwise false. + * @property {boolean} isMouse + * @type {boolean} + */ this.isMouse = false; /** - * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true - * @property isDown - * @type {bool} - **/ + * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true. + * @property {boolean} isDown + * @default + */ this.isDown = false; /** - * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true - * @property isUp - * @type {bool} - **/ + * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true. + * @property {boolean} isUp + * @default + */ this.isUp = true; /** * A timestamp representing when the Pointer first touched the touchscreen. - * @property timeDown - * @type {Number} - **/ + * @property {number} timeDown + * @default + */ this.timeDown = 0; /** * A timestamp representing when the Pointer left the touchscreen. - * @property timeUp - * @type {Number} - **/ + * @property {number} timeUp + * @default + */ this.timeUp = 0; /** - * A timestamp representing when the Pointer was last tapped or clicked - * @property previousTapTime - * @type {Number} - **/ + * A timestamp representing when the Pointer was last tapped or clicked. + * @property {number} previousTapTime + * @default + */ this.previousTapTime = 0; /** - * The total number of times this Pointer has been touched to the touchscreen - * @property totalTouches - * @type {Number} - **/ + * The total number of times this Pointer has been touched to the touchscreen. + * @property {number} totalTouches + * @default + */ this.totalTouches = 0; /** - * The number of miliseconds since the last click - * @property msSinceLastClick - * @type {Number} - **/ + * The number of miliseconds since the last click. + * @property {number} msSinceLastClick + * @default + */ this.msSinceLastClick = Number.MAX_VALUE; /** * The Game Object this Pointer is currently over / touching / dragging. - * @property targetObject - * @type {Any} - **/ + * @property {Any} targetObject + * @default + */ this.targetObject = null; - this.game = game; - this.id = id; - + /** + * Description. + * @property {boolean} isDown - Description. + * @default + */ this.active = false; + /** + * Description + * @property {Phaser.Point} position + */ this.position = new Phaser.Point(); + + /** + * Description + * @property {Phaser.Point} positionDown + */ this.positionDown = new Phaser.Point(); + /** + * Description + * @property {Phaser.Circle} circle + */ this.circle = new Phaser.Circle(0, 0, 44); if (id == 0) @@ -12126,8 +13610,8 @@ Phaser.Pointer = function (game, id) { Phaser.Pointer.prototype = { /** - * Called when the Pointer is pressed onto the touchscreen - * @method start + * Called when the Pointer is pressed onto the touchscreen. + * @method Phaser.Pointer#start * @param {Any} event */ start: function (event) { @@ -12135,7 +13619,7 @@ Phaser.Pointer.prototype = { this.identifier = event.identifier; this.target = event.target; - if (event.button) + if (typeof event.button !== 'undefined') { this.button = event.button; } @@ -12169,7 +13653,7 @@ Phaser.Pointer.prototype = { this.game.input.x = this.x * this.game.input.scale.x; this.game.input.y = this.y * this.game.input.scale.y; this.game.input.position.setTo(this.x, this.y); - this.game.input.onDown.dispatch(this); + this.game.input.onDown.dispatch(this, event); this.game.input.resetSpeed(this.x, this.y); } @@ -12190,6 +13674,10 @@ Phaser.Pointer.prototype = { }, + /** + * Description. + * @method Phaser.Pointer#update + */ update: function () { if (this.active) @@ -12225,7 +13713,7 @@ Phaser.Pointer.prototype = { /** * Called when the Pointer is moved - * @method move + * @method Phaser.Pointer#move * @param {Any} event */ move: function (event) { @@ -12235,7 +13723,7 @@ Phaser.Pointer.prototype = { return; } - if (event.button) + if (typeof event.button !== 'undefined') { this.button = event.button; } @@ -12314,8 +13802,6 @@ Phaser.Pointer.prototype = { if (this._highestRenderObject == null) { - // console.log("HRO null"); - // The pointer isn't currently over anything, check if we've got a lingering previous target if (this.targetObject) { @@ -12364,8 +13850,8 @@ Phaser.Pointer.prototype = { }, /** - * Called when the Pointer leaves the target area - * @method leave + * Called when the Pointer leaves the target area. + * @method Phaser.Pointer#leave * @param {Any} event */ leave: function (event) { @@ -12376,8 +13862,8 @@ Phaser.Pointer.prototype = { }, /** - * Called when the Pointer leaves the touchscreen - * @method stop + * Called when the Pointer leaves the touchscreen. + * @method Phaser.Pointer#stop * @param {Any} event */ stop: function (event) { @@ -12392,7 +13878,7 @@ Phaser.Pointer.prototype = { if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0)) { - this.game.input.onUp.dispatch(this); + this.game.input.onUp.dispatch(this, event); // Was it a tap? if (this.duration >= 0 && this.duration <= this.game.input.tapRate) @@ -12455,10 +13941,10 @@ Phaser.Pointer.prototype = { }, /** - * The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate - * @method justPressed - * @param {Number} [duration]. - * @return {bool} + * The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate. + * @method Phaser.Pointer#justPressed + * @param {number} [duration] + * @return {boolean} */ justPressed: function (duration) { @@ -12469,10 +13955,10 @@ Phaser.Pointer.prototype = { }, /** - * The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate - * @method justReleased - * @param {Number} [duration]. - * @return {bool} + * The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate. + * @method Phaser.Pointer#justReleased + * @param {number} [duration] + * @return {boolean} */ justReleased: function (duration) { @@ -12484,7 +13970,7 @@ Phaser.Pointer.prototype = { /** * Resets the Pointer properties. Called by InputManager.reset when you perform a State change. - * @method reset + * @method Phaser.Pointer#reset */ reset: function () { @@ -12512,8 +13998,8 @@ Phaser.Pointer.prototype = { /** * Returns a string representation of this object. - * @method toString - * @return {String} a string representation of the instance. + * @method Phaser.Pointer#toString + * @return {string} A string representation of the instance. **/ toString: function () { return "[{Pointer (id=" + this.id + " identifer=" + this.identifier + " active=" + this.active + " duration=" + this.duration + " withinGame=" + this.withinGame + " x=" + this.x + " y=" + this.y + " clientX=" + this.clientX + " clientY=" + this.clientY + " screenX=" + this.screenX + " screenY=" + this.screenY + " pageX=" + this.pageX + " pageY=" + this.pageY + ")}]"; @@ -12521,13 +14007,14 @@ Phaser.Pointer.prototype = { }; +/** +* How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1. +* @name Phaser.Pointer#duration +* @property {number} duration - How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1. +* @readonly +*/ Object.defineProperty(Phaser.Pointer.prototype, "duration", { - /** - * How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1. - * @property duration - * @type {Number} - **/ get: function () { if (this.isUp) @@ -12541,12 +14028,14 @@ Object.defineProperty(Phaser.Pointer.prototype, "duration", { }); +/** +* Gets the X value of this Pointer in world coordinates based on the world camera. +* @name Phaser.Pointer#worldX +* @property {number} duration - The X value of this Pointer in world coordinates based on the world camera. +* @readonly +*/ Object.defineProperty(Phaser.Pointer.prototype, "worldX", { - /** - * Gets the X value of this Pointer in world coordinates based on the given camera. - * @param {Camera} [camera] - */ get: function () { return this.game.world.camera.x + this.x; @@ -12555,12 +14044,14 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldX", { }); +/** +* Gets the Y value of this Pointer in world coordinates based on the world camera. +* @name Phaser.Pointer#worldY +* @property {number} duration - The Y value of this Pointer in world coordinates based on the world camera. +* @readonly +*/ Object.defineProperty(Phaser.Pointer.prototype, "worldY", { - /** - * Gets the Y value of this Pointer in world coordinates based on the given camera. - * @param {Camera} [camera] - */ get: function () { return this.game.world.camera.y + this.y; @@ -12570,51 +14061,95 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldY", { }); /** -* Phaser - Touch +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser.Touch handles touch events with your game. Note: Android 2.x only supports 1 touch event at once, no multi-touch. * -* The Touch class handles touch interactions with the game and the resulting Pointer objects. -* http://www.w3.org/TR/touch-events/ -* https://developer.mozilla.org/en-US/docs/DOM/TouchList -* http://www.html5rocks.com/en/mobile/touchandmouse/ -* Note: Android 2.x only supports 1 touch event at once, no multi-touch +* @class Phaser.Touch +* @classdesc The Touch class handles touch interactions with the game and the resulting Pointer objects. +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.Touch = function (game) { - this.game = game; + /** + * @property {Phaser.Game} game - Local reference to game. + */ + this.game = game; + + /** + * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. + * @method Phaser.Touch#disabled + * @return {boolean} + */ + this.disabled = false; + + /** + * @property {Phaser.Game} callbackContext - Description. + */ this.callbackContext = this.game; + /** + * @property {Phaser.Game} touchStartCallback - Description. + * @default + */ this.touchStartCallback = null; + + /** + * @property {Phaser.Game} touchMoveCallback - Description. + * @default + */ this.touchMoveCallback = null; + + /** + * @property {Phaser.Game} touchEndCallback - Description. + * @default + */ this.touchEndCallback = null; + + /** + * @property {Phaser.Game} touchEnterCallback - Description. + * @default + */ this.touchEnterCallback = null; + + /** + * @property {Phaser.Game} touchLeaveCallback - Description. + * @default + */ this.touchLeaveCallback = null; + + /** + * @property {Description} touchCancelCallback - Description. + * @default + */ this.touchCancelCallback = null; - + + /** + * @property {boolean} preventDefault - Description. + * @default + */ this.preventDefault = true; + this._onTouchStart = null; + this._onTouchMove = null; + this._onTouchEnd = null; + this._onTouchEnter = null; + this._onTouchLeave = null; + this._onTouchCancel = null; + this._onTouchMove = null; + }; Phaser.Touch.prototype = { - game: null, - /** - * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. - * @type {bool} - */ - disabled: false, - - _onTouchStart: null, - _onTouchMove: null, - _onTouchEnd: null, - _onTouchEnter: null, - _onTouchLeave: null, - _onTouchCancel: null, - _onTouchMove: null, - - /** - * Starts the event listeners running - * @method start + * Starts the event listeners running. + * @method Phaser.Touch#start */ start: function () { @@ -12657,10 +14192,9 @@ Phaser.Touch.prototype = { }, /** - * Consumes all touchmove events on the document (only enable this if you know you need it!) - * @method consumeTouchMove - * @param {Any} event - **/ + * Consumes all touchmove events on the document (only enable this if you know you need it!). + * @method Phaser.Touch#consumeTouchMove + */ consumeDocumentTouches: function () { this._documentTouchMove = function (event) { @@ -12671,11 +14205,11 @@ Phaser.Touch.prototype = { }, - /** - * - * @method onTouchStart + /** + * Description. + * @method Phaser.Touch#onTouchStart * @param {Any} event - **/ + */ onTouchStart: function (event) { if (this.touchStartCallback) @@ -12703,12 +14237,12 @@ Phaser.Touch.prototype = { }, - /** - * Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome) - * Occurs for example on iOS when you put down 4 fingers and the app selector UI appears - * @method onTouchCancel + /** + * Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome). + * Occurs for example on iOS when you put down 4 fingers and the app selector UI appears. + * @method Phaser.Touch#onTouchCancel * @param {Any} event - **/ + */ onTouchCancel: function (event) { if (this.touchCancelCallback) @@ -12735,12 +14269,12 @@ Phaser.Touch.prototype = { }, - /** - * For touch enter and leave its a list of the touch points that have entered or left the target - * Doesn't appear to be supported by most browsers on a canvas element yet - * @method onTouchEnter + /** + * For touch enter and leave its a list of the touch points that have entered or left the target. + * Doesn't appear to be supported by most browsers on a canvas element yet. + * @method Phaser.Touch#onTouchEnter * @param {Any} event - **/ + */ onTouchEnter: function (event) { if (this.touchEnterCallback) @@ -12765,12 +14299,12 @@ Phaser.Touch.prototype = { }, - /** - * For touch enter and leave its a list of the touch points that have entered or left the target - * Doesn't appear to be supported by most browsers on a canvas element yet - * @method onTouchLeave + /** + * For touch enter and leave its a list of the touch points that have entered or left the target. + * Doesn't appear to be supported by most browsers on a canvas element yet. + * @method Phaser.Touch#onTouchLeave * @param {Any} event - **/ + */ onTouchLeave: function (event) { if (this.touchLeaveCallback) @@ -12790,11 +14324,11 @@ Phaser.Touch.prototype = { }, - /** - * - * @method onTouchMove + /** + * Description. + * @method Phaser.Touch#onTouchMove * @param {Any} event - **/ + */ onTouchMove: function (event) { if (this.touchMoveCallback) @@ -12814,11 +14348,11 @@ Phaser.Touch.prototype = { }, - /** - * - * @method onTouchEnd + /** + * Description. + * @method Phaser.Touch#onTouchEnd * @param {Any} event - **/ + */ onTouchEnd: function (event) { if (this.touchEndCallback) @@ -12841,9 +14375,9 @@ Phaser.Touch.prototype = { }, - /** - * Stop the event listeners - * @method stop + /** + * Stop the event listeners. + * @method Phaser.Touch#stop */ stop: function () { @@ -12860,84 +14394,211 @@ Phaser.Touch.prototype = { } }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Constructor for Phaser InputHandler. +* @class Phaser.InputHandler +* @classdesc Description. +* @constructor +* @param {Phaser.Sprite} game - Description. +*/ Phaser.InputHandler = function (sprite) { - this.game = sprite.game; + /** + * @property {Phaser.Sprite} sprite - Description. + */ this.sprite = sprite; + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = sprite.game; + + /** + * @property {boolean} enabled - Description. + * @default + */ this.enabled = false; // Linked list references + /** + * @property {Description} parent - Description. + * @default + */ this.parent = null; + + /** + * @property {Description} next - Description. + * @default + */ this.next = null; + + /** + * @property {Description} prev - Description. + * @default + */ this.prev = null; + + /** + * @property {Description} last - Description. + * @default + */ this.last = this; + + /** + * @property {Description} first - Description. + * @default + */ this.first = this; - /** - * The PriorityID controls which Sprite receives an Input event first if they should overlap. - */ + /** + * @property {number} priorityID - The PriorityID controls which Sprite receives an Input event first if they should overlap. + * @default + */ this.priorityID = 0; + + /** + * @property {boolean} useHandCursor - Description. + * @default + */ this.useHandCursor = false; + /** + * @property {boolean} isDragged - Description. + * @default + */ this.isDragged = false; + + /** + * @property {boolean} allowHorizontalDrag - Description. + * @default + */ this.allowHorizontalDrag = true; + + /** + * @property {boolean} allowVerticalDrag - Description. + * @default + */ this.allowVerticalDrag = true; + + /** + * @property {boolean} bringToTop - Description. + * @default + */ this.bringToTop = false; + /** + * @property {Description} snapOffset - Description. + * @default + */ this.snapOffset = null; + + /** + * @property {boolean} snapOnDrag - Description. + * @default + */ this.snapOnDrag = false; + + /** + * @property {boolean} snapOnRelease - Description. + * @default + */ this.snapOnRelease = false; + + /** + * @property {number} snapX - Description. + * @default + */ this.snapX = 0; + + /** + * @property {number} snapY - Description. + * @default + */ this.snapY = 0; - /** - * Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it! - * @default false - */ + /** + * @property {number} pixelPerfect - Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it! + * @default + */ this.pixelPerfect = false; /** - * The alpha tolerance threshold. If the alpha value of the pixel matches or is above this value, it's considered a hit. - * @default 255 + * @property {number} pixelPerfectAlpha - The alpha tolerance threshold. If the alpha value of the pixel matches or is above this value, it's considered a hit. + * @default */ this.pixelPerfectAlpha = 255; /** - * Is this sprite allowed to be dragged by the mouse? true = yes, false = no - * @default false + * @property {boolean} draggable - Is this sprite allowed to be dragged by the mouse? true = yes, false = no + * @default */ this.draggable = false; /** - * A region of the game world within which the sprite is restricted during drag - * @default null + * @property {Description} boundsRect - A region of the game world within which the sprite is restricted during drag. + * @default */ this.boundsRect = null; /** - * An Sprite the bounds of which this sprite is restricted during drag - * @default null + * @property {Description} boundsSprite - A Sprite the bounds of which this sprite is restricted during drag. + * @default */ this.boundsSprite = null; /** * If this object is set to consume the pointer event then it will stop all propogation from this object on. * For example if you had a stack of 6 sprites with the same priority IDs and one consumed the event, none of the others would receive it. - * @type {bool} + * @property {boolean} consumePointerEvent + * @default */ this.consumePointerEvent = false; + /** + * @property {Phaser.Point} _tempPoint - Description. + * @private + */ this._tempPoint = new Phaser.Point; + this._pointerData = []; + + this._pointerData.push({ + id: 0, + x: 0, + y: 0, + isDown: false, + isUp: false, + isOver: false, + isOut: false, + timeOver: 0, + timeOut: 0, + timeDown: 0, + timeUp: 0, + downDuration: 0, + isDragged: false + }); + }; Phaser.InputHandler.prototype = { + /** + * Description. + * @method Phaser.InputHandler#start + * @param {number} priority - Description. + * @param {boolean} useHandCursor - Description. + * @return {Phaser.Sprite} Description. + */ start: function (priority, useHandCursor) { priority = priority || 0; - useHandCursor = useHandCursor || false; + if (typeof useHandCursor == 'undefined') { useHandCursor = false; } // Turning on if (this.enabled == false) @@ -12946,11 +14607,10 @@ Phaser.InputHandler.prototype = { this.game.input.interactiveItems.add(this); this.useHandCursor = useHandCursor; this.priorityID = priority; - this._pointerData = []; for (var i = 0; i < 10; i++) { - this._pointerData.push({ + this._pointerData[i] = { id: i, x: 0, y: 0, @@ -12964,7 +14624,7 @@ Phaser.InputHandler.prototype = { timeUp: 0, downDuration: 0, isDragged: false - }); + }; } this.snapOffset = new Phaser.Point; @@ -12986,6 +14646,10 @@ Phaser.InputHandler.prototype = { }, + /** + * Description. + * @method Phaser.InputHandler#reset + */ reset: function () { this.enabled = false; @@ -13010,6 +14674,10 @@ Phaser.InputHandler.prototype = { } }, + /** + * Description. + * @method Phaser.InputHandler#stop + */ stop: function () { // Turning off @@ -13027,23 +14695,29 @@ Phaser.InputHandler.prototype = { }, /** - * Clean up memory. - */ + * Clean up memory. + * @method Phaser.InputHandler#destroy + */ destroy: function () { if (this.enabled) { + this.enabled = false; + + this.game.input.interactiveItems.remove(this); + this.stop(); - // Null everything + this.sprite = null; - // etc } }, /** * The x coordinate of the Input pointer, relative to the top-left of the parent Sprite. * This value is only set when the pointer is over this Sprite. - * @type {number} + * @method Phaser.InputHandler#pointerX + * @param {Pointer} pointer + * @return {number} The x coordinate of the Input pointer. */ pointerX: function (pointer) { @@ -13056,7 +14730,9 @@ Phaser.InputHandler.prototype = { /** * The y coordinate of the Input pointer, relative to the top-left of the parent Sprite * This value is only set when the pointer is over this Sprite. - * @type {number} + * @method Phaser.InputHandler#pointerY + * @param {Pointer} pointer + * @return {number} The y coordinate of the Input pointer. */ pointerY: function (pointer) { @@ -13067,10 +14743,11 @@ Phaser.InputHandler.prototype = { }, /** - * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true - * @property isDown - * @type {bool} - **/ + * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true. + * @method Phaser.InputHandler#pointerDown + * @param {Pointer} pointer + * @return {boolean} + */ pointerDown: function (pointer) { pointer = pointer || 0; @@ -13081,9 +14758,10 @@ Phaser.InputHandler.prototype = { /** * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true - * @property isUp - * @type {bool} - **/ + * @method Phaser.InputHandler#pointerUp + * @param {Pointer} pointer + * @return {boolean} + */ pointerUp: function (pointer) { pointer = pointer || 0; @@ -13094,9 +14772,10 @@ Phaser.InputHandler.prototype = { /** * A timestamp representing when the Pointer first touched the touchscreen. - * @property timeDown - * @type {Number} - **/ + * @method Phaser.InputHandler#pointerTimeDown + * @param {Pointer} pointer + * @return {number} + */ pointerTimeDown: function (pointer) { pointer = pointer || 0; @@ -13107,9 +14786,10 @@ Phaser.InputHandler.prototype = { /** * A timestamp representing when the Pointer left the touchscreen. - * @property timeUp - * @type {Number} - **/ + * @method Phaser.InputHandler#pointerTimeUp + * @param {Pointer} pointer + * @return {number} + */ pointerTimeUp: function (pointer) { pointer = pointer || 0; @@ -13119,10 +14799,11 @@ Phaser.InputHandler.prototype = { }, /** - * Is the Pointer over this Sprite - * @property isOver - * @type {bool} - **/ + * Is the Pointer over this Sprite? + * @method Phaser.InputHandler#pointerOver + * @param {Pointer} pointer + * @return {bool + */ pointerOver: function (pointer) { pointer = pointer || 0; @@ -13132,10 +14813,11 @@ Phaser.InputHandler.prototype = { }, /** - * Is the Pointer outside of this Sprite - * @property isOut - * @type {bool} - **/ + * Is the Pointer outside of this Sprite? + * @method Phaser.InputHandler#pointerOut + * @param {Pointer} pointer + * @return {boolean} + */ pointerOut: function (pointer) { pointer = pointer || 0; @@ -13146,9 +14828,10 @@ Phaser.InputHandler.prototype = { /** * A timestamp representing when the Pointer first touched the touchscreen. - * @property timeDown - * @type {Number} - **/ + * @method Phaser.InputHandler#pointerTimeOver + * @param {Pointer} pointer + * @return {number} + */ pointerTimeOver: function (pointer) { pointer = pointer || 0; @@ -13159,9 +14842,10 @@ Phaser.InputHandler.prototype = { /** * A timestamp representing when the Pointer left the touchscreen. - * @property timeUp - * @type {Number} - **/ + * @method Phaser.InputHandler#pointerTimeOut + * @param {Pointer} pointer + * @return {number} + */ pointerTimeOut: function (pointer) { pointer = pointer || 0; @@ -13172,7 +14856,9 @@ Phaser.InputHandler.prototype = { /** * Is this sprite being dragged by the mouse or not? - * @default false + * @method Phaser.InputHandler#pointerTimeOut + * @param {Pointer} pointer + * @return {number} */ pointerDragged: function (pointer) { @@ -13184,6 +14870,9 @@ Phaser.InputHandler.prototype = { /** * Checks if the given pointer is over this Sprite. + * @method Phaser.InputHandler#checkPointerOver + * @param {Pointer} pointer + * @return {boolean} */ checkPointerOver: function (pointer) { @@ -13191,46 +14880,42 @@ Phaser.InputHandler.prototype = { { this.sprite.getLocalUnmodifiedPosition(this._tempPoint, pointer.x, pointer.y); - // Check against bounds first (move these to private vars) - var x1 = -(this.sprite.texture.frame.width) * this.sprite.anchor.x; - var y1; - - if (this._tempPoint.x > x1 && this._tempPoint.x < x1 + this.sprite.texture.frame.width) + if (this._tempPoint.x >= 0 && this._tempPoint.x <= this.sprite.currentFrame.width && this._tempPoint.y >= 0 && this._tempPoint.y <= this.sprite.currentFrame.height) { - y1 = -(this.sprite.texture.frame.height) * this.sprite.anchor.y; - - if (this._tempPoint.y > y1 && this._tempPoint.y < y1 + this.sprite.texture.frame.height) + if (this.pixelPerfect) { - if (this.pixelPerfect) - { - return this.checkPixel(this._tempPoint.x, this._tempPoint.y); - } - else - { - return true; - } + return this.checkPixel(this._tempPoint.x, this._tempPoint.y); + } + else + { + return true; } } } - else - { - return false; - } + + return false; }, + /** + * Description. + * @method Phaser.InputHandler#checkPixel + * @param {Description} x - Description. + * @param {Description} y - Description. + * @return {boolean} + */ checkPixel: function (x, y) { - x += (this.sprite.texture.frame.width * this.sprite.anchor.x); - y += (this.sprite.texture.frame.height * this.sprite.anchor.y); - // Grab a pixel from our image into the hitCanvas and then test it - if (this.sprite.texture.baseTexture.source) { this.game.input.hitContext.clearRect(0, 0, 1, 1); // This will fail if the image is part of a texture atlas - need to modify the x/y values here + + x += this.sprite.texture.frame.x; + y += this.sprite.texture.frame.y; + this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source, x, y, 1, 1, 0, 0, 1, 1); var rgb = this.game.input.hitContext.getImageData(0, 0, 1, 1); @@ -13246,11 +14931,13 @@ Phaser.InputHandler.prototype = { }, /** - * Update + * Update. + * @method Phaser.InputHandler#update + * @param {Pointer} pointer */ update: function (pointer) { - if (this.enabled == false || this.sprite.visible == false) + if (this.enabled == false || this.sprite.visible == false || (this.sprite.group && this.sprite.group.visible == false)) { this._pointerOutHandler(pointer); return false; @@ -13276,6 +14963,12 @@ Phaser.InputHandler.prototype = { } }, + /** + * Description. + * @method Phaser.InputHandler#_pointerOverHandler + * @private + * @param {Pointer} pointer + */ _pointerOverHandler: function (pointer) { if (this._pointerData[pointer.id].isOver == false) @@ -13295,6 +14988,12 @@ Phaser.InputHandler.prototype = { } }, + /** + * Description. + * @method Phaser.InputHandler#_pointerOutHandler + * @private + * @param {Pointer} pointer + */ _pointerOutHandler: function (pointer) { this._pointerData[pointer.id].isOver = false; @@ -13306,10 +15005,19 @@ Phaser.InputHandler.prototype = { this.game.stage.canvas.style.cursor = "default"; } - this.sprite.events.onInputOut.dispatch(this.sprite, pointer); + if (this.sprite && this.sprite.events) + { + this.sprite.events.onInputOut.dispatch(this.sprite, pointer); + } }, + /** + * Description. + * @method Phaser.InputHandler#_touchedHandler + * @private + * @param {Pointer} pointer + */ _touchedHandler: function (pointer) { if (this._pointerData[pointer.id].isDown == false && this._pointerData[pointer.id].isOver == true) @@ -13336,6 +15044,12 @@ Phaser.InputHandler.prototype = { }, + /** + * Description. + * @method Phaser.InputHandler#_releasedHandler + * @private + * @param {Pointer} pointer + */ _releasedHandler: function (pointer) { // If was previously touched by this Pointer, check if still is AND still over this item @@ -13372,6 +15086,9 @@ Phaser.InputHandler.prototype = { /** * Updates the Pointer drag on this Sprite. + * @method Phaser.InputHandler#updateDrag + * @param {Pointer} pointer + * @return {boolean} */ updateDrag: function (pointer) { @@ -13403,8 +15120,8 @@ Phaser.InputHandler.prototype = { if (this.snapOnDrag) { - this.sprite.x = Math.floor(this.sprite.x / this.snapX) * this.snapX; - this.sprite.y = Math.floor(this.sprite.y / this.snapY) * this.snapY; + this.sprite.x = Math.round(this.sprite.x / this.snapX) * this.snapX; + this.sprite.y = Math.round(this.sprite.y / this.snapY) * this.snapY; } return true; @@ -13413,8 +15130,10 @@ Phaser.InputHandler.prototype = { /** * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second) - * @param delay The time below which the pointer is considered as just over. - * @returns {bool} + * @method Phaser.InputHandler#justOver + * @param {Pointer} pointer + * @param {number} delay - The time below which the pointer is considered as just over. + * @return {boolean} */ justOver: function (pointer, delay) { @@ -13427,8 +15146,10 @@ Phaser.InputHandler.prototype = { /** * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second) - * @param delay The time below which the pointer is considered as just out. - * @returns {bool} + * @method Phaser.InputHandler#justOut + * @param {Pointer} pointer + * @param {number} delay - The time below which the pointer is considered as just out. + * @return {boolean} */ justOut: function (pointer, delay) { @@ -13441,8 +15162,10 @@ Phaser.InputHandler.prototype = { /** * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second) - * @param delay The time below which the pointer is considered as just over. - * @returns {bool} + * @method Phaser.InputHandler#justPressed + * @param {Pointer} pointer + * @param {number} delay - The time below which the pointer is considered as just over. + * @return {boolean} */ justPressed: function (pointer, delay) { @@ -13455,8 +15178,10 @@ Phaser.InputHandler.prototype = { /** * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second) - * @param delay The time below which the pointer is considered as just out. - * @returns {bool} + * @method Phaser.InputHandler#justReleased + * @param {Pointer} pointer + * @param {number} delay - The time below which the pointer is considered as just out. + * @return {boolean} */ justReleased: function (pointer, delay) { @@ -13469,7 +15194,9 @@ Phaser.InputHandler.prototype = { /** * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds. - * @returns {number} The number of milliseconds the pointer has been over the Sprite, or -1 if not over. + * @method Phaser.InputHandler#overDuration + * @param {Pointer} pointer + * @return {number} The number of milliseconds the pointer has been over the Sprite, or -1 if not over. */ overDuration: function (pointer) { @@ -13486,7 +15213,9 @@ Phaser.InputHandler.prototype = { /** * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds. - * @returns {number} The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over. + * @method Phaser.InputHandler#downDuration + * @param {Pointer} pointer + * @return {number} The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over. */ downDuration: function (pointer) { @@ -13503,7 +15232,7 @@ Phaser.InputHandler.prototype = { /** * Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback - * + * @method Phaser.InputHandler#enableDrag * @param lockCenter If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer. * @param bringToTop If true the Sprite will be bought to the top of the rendering list in its current Group. * @param pixelPerfect If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box. @@ -13544,6 +15273,7 @@ Phaser.InputHandler.prototype = { /** * Stops this sprite from being able to be dragged. If it is currently the target of an active drag it will be stopped immediately. Also disables any set callbacks. + * @method Phaser.InputHandler#disableDrag */ disableDrag: function () { @@ -13563,6 +15293,7 @@ Phaser.InputHandler.prototype = { /** * Called by Pointer when drag starts on this Sprite. Should not usually be called directly. + * @method Phaser.InputHandler#startDrag */ startDrag: function (pointer) { @@ -13593,6 +15324,7 @@ Phaser.InputHandler.prototype = { /** * Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly. + * @method Phaser.InputHandler#stopDrag */ stopDrag: function (pointer) { @@ -13602,8 +15334,8 @@ Phaser.InputHandler.prototype = { if (this.snapOnRelease) { - this.sprite.x = Math.floor(this.sprite.x / this.snapX) * this.snapX; - this.sprite.y = Math.floor(this.sprite.y / this.snapY) * this.snapY; + this.sprite.x = Math.round(this.sprite.x / this.snapX) * this.snapX; + this.sprite.y = Math.round(this.sprite.y / this.snapY) * this.snapY; } this.sprite.events.onDragStop.dispatch(this.sprite, pointer); @@ -13613,7 +15345,7 @@ Phaser.InputHandler.prototype = { /** * Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move! - * + * @method Phaser.InputHandler#setDragLock * @param allowHorizontal To enable the sprite to be dragged horizontally set to true, otherwise false * @param allowVertical To enable the sprite to be dragged vertically set to true, otherwise false */ @@ -13630,7 +15362,7 @@ Phaser.InputHandler.prototype = { /** * Make this Sprite snap to the given grid either during drag or when it's released. * For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels. - * + * @method Phaser.InputHandler#enableSnap * @param snapX The width of the grid cell in pixels * @param snapY The height of the grid cell in pixels * @param onDrag If true the sprite will snap to the grid while being dragged @@ -13650,6 +15382,7 @@ Phaser.InputHandler.prototype = { /** * Stops the sprite from snapping to a grid during drag or release. + * @method Phaser.InputHandler#disableSnap */ disableSnap: function () { @@ -13660,6 +15393,7 @@ Phaser.InputHandler.prototype = { /** * Bounds Rect check for the sprite drag + * @method Phaser.InputHandler#checkBoundsRect */ checkBoundsRect: function () { @@ -13684,7 +15418,8 @@ Phaser.InputHandler.prototype = { }, /** - * Parent Sprite Bounds check for the sprite drag + * Parent Sprite Bounds check for the sprite drag. + * @method Phaser.InputHandler#checkBoundsSprite */ checkBoundsSprite: function () { @@ -13709,9 +15444,20 @@ Phaser.InputHandler.prototype = { } }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + + /** * The Events component is a collection of events fired by the parent game object and its components. -* @param parent The game object using this Input component +* +* @class Phaser.Events +* @constructor +* +* @param {Phaser.Sprite} sprite - A reference to Description. */ Phaser.Events = function (sprite) { @@ -13734,61 +15480,118 @@ Phaser.Events = function (sprite) { this.onAnimationLoop = null; }; + +Phaser.Events.prototype = { + + destroy: function () { + + this.parent = null; + this.onAddedToGroup.dispose(); + this.onRemovedFromGroup.dispose(); + this.onKilled.dispose(); + this.onRevived.dispose(); + this.onOutOfBounds.dispose(); + + if (this.onInputOver) + { + this.onInputOver.dispose(); + this.onInputOut.dispose(); + this.onInputDown.dispose(); + this.onInputUp.dispose(); + this.onDragStart.dispose(); + this.onDragStop.dispose(); + } + + if (this.onAnimationStart) + { + this.onAnimationStart.dispose(); + this.onAnimationComplete.dispose(); + this.onAnimationLoop.dispose(); + } + + } + +}; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* The Game Object Factory is a quick way to create all of the different sorts of core objects that Phaser uses. +* +* @class Phaser.GameObjectFactory +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +*/ Phaser.GameObjectFactory = function (game) { + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; + + /** + * @property {Phaser.World} world - A reference to the game world. + */ this.world = this.game.world; }; Phaser.GameObjectFactory.prototype = { - game: null, - world: null, - + /** + * Adds an existing object to the game world. + * @method Phaser.GameObjectFactory#existing + * @param {*} object - An instance of Phaser.Sprite, Phaser.Button or any other display object.. + * @return {*} The child that was added to the Group. + */ existing: function (object) { - return this.world.group.add(object); + return this.world.add(object); }, /** * Create a new Sprite with specific position and sprite sheet key. * - * @param x {number} X position of the new sprite. - * @param y {number} Y position of the new sprite. - * @param [key] {string|RenderTexture} The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture - * @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. - * @returns {Sprite} The newly created sprite object. + * @method Phaser.GameObjectFactory#sprite + * @param {number} x - X position of the new sprite. + * @param {number} y - Y position of the new sprite. + * @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + * @param {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. + * @returns {Phaser.Sprite} the newly created sprite object. */ sprite: function (x, y, key, frame) { - return this.world.group.add(new Phaser.Sprite(this.game, x, y, key, frame)); + return this.world.create(x, y, key, frame); }, /** * Create a new Sprite with specific position and sprite sheet key that will automatically be added as a child of the given parent. * - * @param x {number} X position of the new sprite. - * @param y {number} Y position of the new sprite. - * @param [key] {string|RenderTexture} The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture - * @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. - * @returns {Sprite} The newly created sprite object. + * @method Phaser.GameObjectFactory#child + * @param {Phaser.Group} group - The Group to add this child to. + * @param {number} x - X position of the new sprite. + * @param {number} y - Y position of the new sprite. + * @param {string|RenderTexture} [key] - The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture. + * @param {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. + * @returns {Phaser.Sprite} the newly created sprite object. */ - child: function (parent, x, y, key, frame) { + child: function (group, x, y, key, frame) { - var child = this.world.group.add(new Phaser.Sprite(this.game, x, y, key, frame)); - parent.addChild(child); - return child; + return group.create(x, y, key, frame); }, /** * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. * - * @param obj {object} Object the tween will be run on. - * @return {Phaser.Tween} The newly created tween object. + * @method Phaser.GameObjectFactory#tween + * @param {object} obj - Object the tween will be run on. + * @return {Phaser.Tween} Description. */ tween: function (obj) { @@ -13796,60 +15599,187 @@ Phaser.GameObjectFactory.prototype = { }, + /** + * A Group is a container for display objects that allows for fast pooling, recycling and collision checks. + * + * @method Phaser.GameObjectFactory#group + * @param {*} parent - The parent Group or DisplayObjectContainer that will hold this group, if any. + * @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging. + * @return {Phaser.Group} The newly created group. + */ group: function (parent, name) { return new Phaser.Group(this.game, parent, name); }, + /** + * Creates a new instance of the Sound class. + * + * @method Phaser.GameObjectFactory#audio + * @param {string} key - The Game.cache key of the sound that this object will use. + * @param {number} volume - The volume at which the sound will be played. + * @param {boolean} loop - Whether or not the sound will loop. + * @return {Phaser.Sound} The newly created text object. + */ audio: function (key, volume, loop) { return this.game.sound.add(key, volume, loop); }, + /** + * Creates a new TileSprite. + * + * @method Phaser.GameObjectFactory#tileSprite + * @param {number} x - X position of the new tileSprite. + * @param {number} y - Y position of the new tileSprite. + * @param {number} width - the width of the tilesprite. + * @param {number} height - the height of the tilesprite. + * @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + * @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @return {Phaser.TileSprite} The newly created tileSprite object. + */ tileSprite: function (x, y, width, height, key, frame) { - return this.world.group.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame)); + return this.world.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame)); }, + /** + * Creates a new Text. + * + * @method Phaser.GameObjectFactory#text + * @param {number} x - X position of the new text object. + * @param {number} y - Y position of the new text object. + * @param {string} text - The actual text that will be written. + * @param {object} style - The style object containing style attributes like font, font size , etc. + * @return {Phaser.Text} The newly created text object. + */ text: function (x, y, text, style) { - return this.world.group.add(new Phaser.Text(this.game, x, y, text, style)); + return this.world.add(new Phaser.Text(this.game, x, y, text, style)); }, + /** + * Creates a new Button object. + * + * @method Phaser.GameObjectFactory#button + * @param {number} [x] X position of the new button object. + * @param {number} [y] Y position of the new button object. + * @param {string} [key] The image key as defined in the Game.Cache to use as the texture for this button. + * @param {function} [callback] The function to call when this button is pressed + * @param {object} [callbackContext] The context in which the callback will be called (usually 'this') + * @param {string|number} [overFrame] This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name. + * @param {string|number} [outFrame] This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name. + * @param {string|number} [downFrame] This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name. + * @return {Phaser.Button} The newly created button object. + */ button: function (x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) { - return this.world.group.add(new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame)); + return this.world.add(new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame)); }, + /** + * Creates a new Graphics object. + * + * @method Phaser.GameObjectFactory#graphics + * @param {number} x - X position of the new graphics object. + * @param {number} y - Y position of the new graphics object. + * @return {Phaser.Graphics} The newly created graphics object. + */ graphics: function (x, y) { - return this.world.group.add(new Phaser.Graphics(this.game, x, y)); + return this.world.add(new Phaser.Graphics(this.game, x, y)); }, + /** + * Emitter is a lightweight particle emitter. It can be used for one-time explosions or for + * continuous effects like rain and fire. All it really does is launch Particle objects out + * at set intervals, and fixes their positions and velocities accorindgly. + * + * @method Phaser.GameObjectFactory#emitter + * @param {number} [x=0] - The x coordinate within the Emitter that the particles are emitted from. + * @param {number} [y=0] - The y coordinate within the Emitter that the particles are emitted from. + * @param {number} [maxParticles=50] - The total number of particles in this emitter. + * @return {Phaser.Emitter} The newly created emitter object. + */ emitter: function (x, y, maxParticles) { return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game, x, y, maxParticles)); }, + /** + * * Create a new BitmapText. + * + * @method Phaser.GameObjectFactory#bitmapText + * @param {number} x - X position of the new bitmapText object. + * @param {number} y - Y position of the new bitmapText object. + * @param {string} text - The actual text that will be written. + * @param {object} style - The style object containing style attributes like font, font size , etc. + * @return {Phaser.BitmapText} The newly created bitmapText object. + */ bitmapText: function (x, y, text, style) { - return this.world.group.add(new Phaser.BitmapText(this.game, x, y, text, style)); + return this.world.add(new Phaser.BitmapText(this.game, x, y, text, style)); }, - tilemap: function (x, y, key, resizeWorld, tileWidth, tileHeight) { + /** + * Creates a new Tilemap object. + * + * @method Phaser.GameObjectFactory#tilemap + * @param {string} key - Asset key for the JSON file. + * @return {Phaser.Tilemap} The newly created tilemap object. + */ + tilemap: function (key) { - return this.world.group.add(new Phaser.Tilemap(this.game, key, x, y, resizeWorld, tileWidth, tileHeight)); + return new Phaser.Tilemap(this.game, key); }, + /** + * Creates a new Tileset object. + * + * @method Phaser.GameObjectFactory#tileset + * @param {string} key - The image key as defined in the Game.Cache to use as the tileset. + * @return {Phaser.Tileset} The newly created tileset object. + */ + tileset: function (key) { + + return this.game.cache.getTileset(key); + + }, + + /** + * Creates a new Tilemap Layer object. + * + * @method Phaser.GameObjectFactory#tilemapLayer + * @param {number} x - X position of the new tilemapLayer. + * @param {number} y - Y position of the new tilemapLayer. + * @param {number} width - the width of the tilemapLayer. + * @param {number} height - the height of the tilemapLayer. + * @return {Phaser.TilemapLayer} The newly created tilemaplayer object. + */ + tilemapLayer: function (x, y, width, height, tileset, tilemap, layer) { + + return this.world.add(new Phaser.TilemapLayer(this.game, x, y, width, height, tileset, tilemap, layer)); + + }, + + /** + * A dynamic initially blank canvas to which images can be drawn. + * + * @method Phaser.GameObjectFactory#renderTexture + * @param {string} key - Asset key for the render texture. + * @param {number} width - the width of the render texture. + * @param {number} height - the height of the render texture. + * @return {Phaser.RenderTexture} The newly created renderTexture object. + */ renderTexture: function (key, width, height) { var texture = new Phaser.RenderTexture(this.game, key, width, height); @@ -13858,67 +15788,127 @@ Phaser.GameObjectFactory.prototype = { return texture; - }, + } }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Create a new `Sprite` object. Sprites are the lifeblood of your game, used for nearly everything visual. +* At its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas. +* They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input), +* events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases. +* +* @class Phaser.Sprite +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {number} x - The x coordinate (in world space) to position the Sprite at. +* @param {number} y - The y coordinate (in world space) to position the Sprite at. +* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. +* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. +*/ Phaser.Sprite = function (game, x, y, key, frame) { x = x || 0; y = y || 0; key = key || null; frame = frame || null; - + + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; - - // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all + + /** + * @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all. + * @default + */ this.exists = true; - // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering + /** + * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering. + * @default + */ this.alive = true; + /** + * @property {Phaser.Group} group - The parent Group of this Sprite. This is usually set after Sprite instantiation by the parent. + */ this.group = null; + /** + * @property {string} name - The user defined name given to this Sprite. + * @default + */ this.name = ''; + /** + * @property {number} type - The const type of this object. + * @default + */ this.type = Phaser.SPRITE; + /** + * @property {number} renderOrderID - Used by the Renderer and Input Manager to control picking order. + * @default + */ this.renderOrderID = -1; - // If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc. - // The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called. + /** + * If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc. + * The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called. + * @property {number} lifespan - The lifespan of the Sprite (in ms) before it will be killed. + * @default + */ this.lifespan = 0; /** - * The Signals you can subscribe to that are dispatched when certain things happen on this Sprite or its components - * @type Events - */ + * @property {Events} events - The Events you can subscribe to that are dispatched when certain things happen on this Sprite or its components. + */ this.events = new Phaser.Events(this); /** - * This manages animations of the sprite. You can modify animations through it. (see AnimationManager) - * @type AnimationManager - */ + * @property {Phaser.AnimationManager} animations - This manages animations of the sprite. You can modify animations through it (see Phaser.AnimationManager) + */ this.animations = new Phaser.AnimationManager(this); /** - * The Input Handler Component - * @type InputHandler - */ + * @property {InputHandler} input - The Input Handler Component. + */ this.input = new Phaser.InputHandler(this); + /** + * @property {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + */ this.key = key; + /** + * @property {Phaser.Frame} currentFrame - A reference to the currently displayed frame. + */ + this.currentFrame = null; + if (key instanceof Phaser.RenderTexture) { PIXI.Sprite.call(this, key); this.currentFrame = this.game.cache.getTextureFrame(key.name); } + else if (key instanceof PIXI.Texture) + { + PIXI.Sprite.call(this, key); + + this.currentFrame = frame; + } else { if (key == null || this.game.cache.checkImageKey(key) == false) { key = '__default'; + this.key = key; } PIXI.Sprite.call(this, PIXI.TextureCache[key]); @@ -13946,98 +15936,184 @@ Phaser.Sprite = function (game, x, y, key, frame) { } /** - * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right - * - * @property anchor - * @type Point - */ + * The anchor sets the origin point of the texture. + * The default is 0,0 this means the textures origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centered + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * + * @property {Phaser.Point} anchor - The anchor around with Sprite rotation and scaling takes place. + */ this.anchor = new Phaser.Point(); - this._cropUUID = null; - this._cropRect = null; - + /** + * @property {number} x - The x coordinate (in world space) of this Sprite. + */ this.x = x; + + /** + * @property {number} y - The y coordinate (in world space) of this Sprite. + */ this.y = y; this.position.x = x; this.position.y = y; /** - * Should this Sprite be automatically culled if out of range of the camera? - * A culled sprite has its visible property set to 'false'. - * Note that this check doesn't look at this Sprites children, which may still be in camera range. - * So you should set autoCull to false if the Sprite will have children likely to still be in camera range. - * - * @property autoCull - * @type Boolean - */ + * Should this Sprite be automatically culled if out of range of the camera? + * A culled sprite has its renderable property set to 'false'. + * + * @property {boolean} autoCull - A flag indicating if the Sprite should be automatically camera culled or not. + * @default + */ this.autoCull = false; - // Replaces the PIXI.Point with a slightly more flexible one + /** + * @property {Phaser.Point} scale - The scale of the Sprite when rendered. By default it's set to 1 (no scale). You can modify it via scale.x or scale.y or scale.setTo(x, y). A value of 1 means no change to the scale, 0.5 means "half the size", 2 means "twice the size", etc. + */ this.scale = new Phaser.Point(1, 1); - // Influence of camera movement upon the position - this.scrollFactor = new Phaser.Point(1, 1); - - // A mini cache for storing all of the calculated values + /** + * @property {Phaser.Point} _cache - A mini cache for storing all of the calculated values. + * @private + */ this._cache = { dirty: false, // Transform cache - a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, + a00: -1, a01: -1, a02: -1, a10: -1, a11: -1, a12: -1, id: -1, // Input specific transform cache - i01: 0, i10: 0, idi: 1, + i01: -1, i10: -1, idi: -1, // Bounds check left: null, right: null, top: null, bottom: null, - // The previous calculated position inc. camera x/y and scrollFactor + // The previous calculated position x: -1, y: -1, // The actual scale values based on the worldTransform scaleX: 1, scaleY: 1, + // cache scale check + realScaleX: 1, realScaleY: 1, + // The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size width: this.currentFrame.sourceSizeW, height: this.currentFrame.sourceSizeH, // The actual width/height of the image if from a trimmed atlas, multiplied by the final calculated scale size halfWidth: Math.floor(this.currentFrame.sourceSizeW / 2), halfHeight: Math.floor(this.currentFrame.sourceSizeH / 2), + // The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size + calcWidth: -1, calcHeight: -1, + // The current frame details - frameID: this.currentFrame.uuid, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height, + // frameID: this.currentFrame.uuid, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height, + frameID: -1, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height, boundsX: 0, boundsY: 0, // If this sprite visible to the camera (regardless of being set to visible or not) - cameraVisible: true + cameraVisible: true, + + // Crop cache + cropX: 0, cropY: 0, cropWidth: this.currentFrame.sourceSizeW, cropHeight: this.currentFrame.sourceSizeH }; - - // Corner point defaults + + /** + * @property {Phaser.Point} offset - Corner point defaults. Should not typically be modified. + */ this.offset = new Phaser.Point; + + /** + * @property {Phaser.Point} center - A Point containing the center coordinate of the Sprite. Takes rotation and scale into account. + */ this.center = new Phaser.Point(x + Math.floor(this._cache.width / 2), y + Math.floor(this._cache.height / 2)); + + /** + * @property {Phaser.Point} topLeft - A Point containing the top left coordinate of the Sprite. Takes rotation and scale into account. + */ this.topLeft = new Phaser.Point(x, y); + + /** + * @property {Phaser.Point} topRight - A Point containing the top right coordinate of the Sprite. Takes rotation and scale into account. + */ this.topRight = new Phaser.Point(x + this._cache.width, y); + + /** + * @property {Phaser.Point} bottomRight - A Point containing the bottom right coordinate of the Sprite. Takes rotation and scale into account. + */ this.bottomRight = new Phaser.Point(x + this._cache.width, y + this._cache.height); + + /** + * @property {Phaser.Point} bottomLeft - A Point containing the bottom left coordinate of the Sprite. Takes rotation and scale into account. + */ this.bottomLeft = new Phaser.Point(x, y + this._cache.height); + + /** + * This Rectangle object fully encompasses the Sprite and is updated in real-time. + * The bounds is the full bounding area after rotation and scale have been taken into account. It should not be modified directly. + * It's used for Camera culling and physics body alignment. + * @property {Phaser.Rectangle} bounds + */ this.bounds = new Phaser.Rectangle(x, y, this._cache.width, this._cache.height); - - // Set-up the physics body + + /** + * @property {Phaser.Physics.Arcade.Body} body - By default Sprites have a Phaser.Physics Body attached to them. You can operate physics actions via this property, or null it to skip all physics updates. + */ this.body = new Phaser.Physics.Arcade.Body(this); - this.velocity = this.body.velocity; - this.acceleration = this.body.acceleration; + /** + * @property {number} health - Health value. Used in combination with damage() to allow for quick killing of Sprites. + */ + this.health = 1; - // World bounds check + /** + * @property {boolean} inWorld - This value is set to true if the Sprite is positioned within the World, otherwise false. + */ this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds); + + /** + * @property {number} inWorldThreshold - A threshold value applied to the inWorld check. If you don't want a Sprite to be considered "out of the world" until at least 100px away for example then set it to 100. + * @default + */ this.inWorldThreshold = 0; + + /** + * @property {boolean} outOfBoundsKill - If true the Sprite is killed as soon as Sprite.inWorld is false. + * @default + */ + this.outOfBoundsKill = false; + + /** + * @property {boolean} _outOfBoundsFired - Internal flag. + * @private + * @default + */ this._outOfBoundsFired = false; + /** + * A Sprite that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera. + * @property {boolean} fixedToCamera - Fixes this Sprite to the Camera. + * @default + */ + this.fixedToCamera = false; + + /** + * You can crop the Sprites texture by modifying the crop properties. For example crop.width = 50 would set the Sprite to only render 50px wide. + * The crop is only applied if you have set Sprite.cropEnabled to true. + * @property {Phaser.Rectangle} crop - The crop Rectangle applied to the Sprite texture before rendering. + * @default + */ + this.crop = new Phaser.Rectangle(0, 0, this._cache.width, this._cache.height); + + /** + * @property {boolean} cropEnabled - If true the Sprite.crop property is used to crop the texture before render. Set to false to disable. + * @default + */ + this.cropEnabled = false; + }; // Needed to keep the PIXI.Sprite constructor in the prototype chain (as the core pixi renderer uses an instanceof check sadly) @@ -14045,8 +16121,11 @@ Phaser.Sprite.prototype = Object.create(PIXI.Sprite.prototype); Phaser.Sprite.prototype.constructor = Phaser.Sprite; /** - * Automatically called by World.update. You can create your own update in Objects that extend Phaser.Sprite. - */ +* Automatically called by World.preUpdate. Handles cache updates, lifespan checks, animation updates and physics updates. +* +* @method Phaser.Sprite#preUpdate +* @memberof Phaser.Sprite +*/ Phaser.Sprite.prototype.preUpdate = function() { if (!this.exists) @@ -14073,46 +16152,77 @@ Phaser.Sprite.prototype.preUpdate = function() { this._cache.dirty = true; } - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); - - // If this sprite or the camera have moved then let's update everything - // Note: The actual position shouldn't be changed if this item is inside a Group? - if (this.position.x != this._cache.x || this.position.y != this._cache.y) - { - this.position.x = this._cache.x; - this.position.y = this._cache.y; - this._cache.dirty = true; - } - if (this.visible) { this.renderOrderID = this.game.world.currentRenderOrderID++; } + this.prevX = this.x; + this.prevY = this.y; + + this.updateCache(); + this.updateAnimation(); + + if (this.cropEnabled) + { + this.updateCrop(); + } + + // Re-run the camera visibility check + if (this._cache.dirty) + { + this.updateBounds(); + + this._cache.cameraVisible = Phaser.Rectangle.intersects(this.game.world.camera.screenView, this.bounds, 0); + + if (this.autoCull == true) + { + // Won't get rendered but will still get its transform updated + this.renderable = this._cache.cameraVisible; + } + + // Update our physics bounds + if (this.body) + { + this.body.updateBounds(this.center.x, this.center.y, this._cache.scaleX, this._cache.scaleY); + } + } + + if (this.body) + { + this.body.preUpdate(); + } + +} + +/** +* Internal function called by preUpdate. +* +* @method Phaser.Sprite#updateCache +* @memberof Phaser.Sprite +*/ +Phaser.Sprite.prototype.updateCache = function() { + // |a c tx| // |b d ty| // |0 0 1| - // Only update the values we need - if (this.worldTransform[0] != this._cache.a00 || this.worldTransform[1] != this._cache.a01) + if (this.worldTransform[1] != this._cache.i01 || this.worldTransform[3] != this._cache.i10) { this._cache.a00 = this.worldTransform[0]; // scaleX a this._cache.a01 = this.worldTransform[1]; // skewY c - this._cache.i01 = this.worldTransform[1]; // skewY c - this._cache.scaleX = Math.sqrt((this._cache.a00 * this._cache.a00) + (this._cache.a01 * this._cache.a01)); // round this off a bit? - this._cache.a01 *= -1; - this._cache.dirty = true; - } - - // Need to test, but probably highly unlikely that a scaleX would happen without effecting the Y skew - if (this.worldTransform[3] != this._cache.a10 || this.worldTransform[4] != this._cache.a11) - { this._cache.a10 = this.worldTransform[3]; // skewX b - this._cache.i10 = this.worldTransform[3]; // skewX b this._cache.a11 = this.worldTransform[4]; // scaleY d + + this._cache.i01 = this.worldTransform[1]; // skewY c (remains non-modified for input checks) + this._cache.i10 = this.worldTransform[3]; // skewX b (remains non-modified for input checks) + + this._cache.scaleX = Math.sqrt((this._cache.a00 * this._cache.a00) + (this._cache.a01 * this._cache.a01)); // round this off a bit? this._cache.scaleY = Math.sqrt((this._cache.a10 * this._cache.a10) + (this._cache.a11 * this._cache.a11)); // round this off a bit? + + this._cache.a01 *= -1; this._cache.a10 *= -1; + this._cache.dirty = true; } @@ -14123,8 +16233,17 @@ Phaser.Sprite.prototype.preUpdate = function() { this._cache.dirty = true; } - // Frame updated? - if (this.currentFrame.uuid != this._cache.frameID) +} + +/** +* Internal function called by preUpdate. +* +* @method Phaser.Sprite#updateAnimation +* @memberof Phaser.Sprite +*/ +Phaser.Sprite.prototype.updateAnimation = function() { + + if (this.currentFrame && this.currentFrame.uuid != this._cache.frameID) { this._cache.frameWidth = this.texture.frame.width; this._cache.frameHeight = this.texture.frame.height; @@ -14132,116 +16251,43 @@ Phaser.Sprite.prototype.preUpdate = function() { this._cache.dirty = true; } - if (this._cache.dirty) + if (this._cache.dirty && this.currentFrame) { - this._cache.width = Math.floor(this.currentFrame.sourceSizeW * this._cache.scaleX); - this._cache.height = Math.floor(this.currentFrame.sourceSizeH * this._cache.scaleY); + this._cache.width = this.currentFrame.width; + this._cache.height = this.currentFrame.height; this._cache.halfWidth = Math.floor(this._cache.width / 2); this._cache.halfHeight = Math.floor(this._cache.height / 2); this._cache.id = 1 / (this._cache.a00 * this._cache.a11 + this._cache.a01 * -this._cache.a10); this._cache.idi = 1 / (this._cache.a00 * this._cache.a11 + this._cache.i01 * -this._cache.i10); - - this.updateBounds(); - } - // } - // else - // { - // We still need to work out the bounds in case the camera has moved - // but we can't use the local or worldTransform to do it, as Pixi resets that if a Sprite is invisible. - // So we'll compare against the cached state + new position. - // if (this._cache.dirty && this.visible == false) - // { - // this.bounds.x -= this._cache.boundsX - this._cache.x; - // this._cache.boundsX = this._cache.x; - - // this.bounds.y -= this._cache.boundsY - this._cache.y; - // this._cache.boundsY = this._cache.y; - // } - // } - - // Re-run the camera visibility check - if (this._cache.dirty) - { - this._cache.cameraVisible = Phaser.Rectangle.intersects(this.game.world.camera.screenView, this.bounds, 0); - - if (this.autoCull == true) - { - // Won't get rendered but will still get its transform updated - this.renderable = this._cache.cameraVisible; - } - - // Update our physics bounds - this.body.updateBounds(this.center.x, this.center.y, this._cache.scaleX, this._cache.scaleY); - } - - this.body.update(); - -} - -Phaser.Sprite.prototype.postUpdate = function() { - - if (this.exists) - { - this.body.postUpdate(); } } /** - * Moves the sprite so its center is located on the given x and y coordinates. - * Doesn't change the origin of the sprite. - */ -Phaser.Sprite.prototype.centerOn = function(x, y) { - - this.x = x + (this.x - this.center.x); - this.y = y + (this.y - this.center.y); - -} - -Phaser.Sprite.prototype.revive = function() { - - this.alive = true; - this.exists = true; - this.visible = true; - this.events.onRevived.dispatch(this); - -} - -Phaser.Sprite.prototype.kill = function() { - - this.alive = false; - this.exists = false; - this.visible = false; - this.events.onKilled.dispatch(this); - -} - -Phaser.Sprite.prototype.reset = function(x, y) { - - this.x = x; - this.y = y; - this.position.x = x; - this.position.y = y; - this.alive = true; - this.exists = true; - this.visible = true; - this._outOfBoundsFired = false; - this.body.reset(); - -} - +* Internal function called by preUpdate. +* +* @method Phaser.Sprite#updateBounds +* @memberof Phaser.Sprite +*/ Phaser.Sprite.prototype.updateBounds = function() { - // Update the edge points + var sx = 1; + var sy = 1; - this.offset.setTo(this._cache.a02 - (this.anchor.x * this._cache.width), this._cache.a12 - (this.anchor.y * this._cache.height)); + if (this.worldTransform[3] !== 0 || this.worldTransform[1] !== 0) + { + sx = this.scale.x; + sy = this.scale.y; + } - this.getLocalPosition(this.center, this.offset.x + this._cache.halfWidth, this.offset.y + this._cache.halfHeight); - this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y); - this.getLocalPosition(this.topRight, this.offset.x + this._cache.width, this.offset.y); - this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this._cache.height); - this.getLocalPosition(this.bottomRight, this.offset.x + this._cache.width, this.offset.y + this._cache.height); + this.offset.setTo(this._cache.a02 - (this.anchor.x * this.width), this._cache.a12 - (this.anchor.y * this.height)); + + this.getLocalPosition(this.center, this.offset.x + (this.width / 2), this.offset.y + (this.height / 2), sx, sy); + this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y, sx, sy); + this.getLocalPosition(this.topRight, this.offset.x + this.width, this.offset.y, sx, sy); + this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this.height, sx, sy); + this.getLocalPosition(this.bottomRight, this.offset.x + this.width, this.offset.y + this.height, sx, sy); this._cache.left = Phaser.Math.min(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x); this._cache.right = Phaser.Math.max(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x); @@ -14253,6 +16299,8 @@ Phaser.Sprite.prototype.updateBounds = function() { // This is the coordinate the Sprite was at when the last bounds was created this._cache.boundsX = this._cache.x; this._cache.boundsY = this._cache.y; + + this.updateFrame = true; if (this.inWorld == false) { @@ -14274,29 +16322,419 @@ Phaser.Sprite.prototype.updateBounds = function() { { this.events.onOutOfBounds.dispatch(this); this._outOfBoundsFired = true; + + if (this.outOfBoundsKill) + { + this.kill(); + } } } } -Phaser.Sprite.prototype.getLocalPosition = function(p, x, y) { +/** +* Gets the local position of a coordinate relative to the Sprite, factoring in rotation and scale. +* Mostly only used internally. +* +* @method Phaser.Sprite#getLocalPosition +* @memberof Phaser.Sprite +* @param {Phaser.Point} p - The Point object to store the results in. +* @param {number} x - x coordinate within the Sprite to translate. +* @param {number} y - x coordinate within the Sprite to translate. +* @param {number} sx - Scale factor to be applied. +* @param {number} sy - Scale factor to be applied. +* @return {Phaser.Point} The translated point. +*/ +Phaser.Sprite.prototype.getLocalPosition = function(p, x, y, sx, sy) { - p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * this._cache.scaleX) + this._cache.a02; - p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * this._cache.scaleY) + this._cache.a12; + p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * sx) + this._cache.a02; + p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * sy) + this._cache.a12; return p; } -Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, x, y) { +/** +* Gets the local unmodified position of a coordinate relative to the Sprite, factoring in rotation and scale. +* Mostly only used internally by the Input Manager, but also useful for custom hit detection. +* +* @method Phaser.Sprite#getLocalUnmodifiedPosition +* @memberof Phaser.Sprite +* @param {Phaser.Point} p - The Point object to store the results in. +* @param {number} x - x coordinate within the Sprite to translate. +* @param {number} y - x coordinate within the Sprite to translate. +* @return {Phaser.Point} The translated point. +*/ +Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, gx, gy) { - p.x = this._cache.a11 * this._cache.idi * x + -this._cache.i01 * this._cache.idi * y + (this._cache.a12 * this._cache.i01 - this._cache.a02 * this._cache.a11) * this._cache.idi; - p.y = this._cache.a00 * this._cache.idi * y + -this._cache.i10 * this._cache.idi * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.i10) * this._cache.idi; + var a00 = this.worldTransform[0], a01 = this.worldTransform[1], a02 = this.worldTransform[2], + a10 = this.worldTransform[3], a11 = this.worldTransform[4], a12 = this.worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10), + x = a11 * id * gx + -a01 * id * gy + (a12 * a01 - a02 * a11) * id, + y = a00 * id * gy + -a10 * id * gx + (-a12 * a00 + a02 * a10) * id; + + p.x = x + (this.anchor.x * this._cache.width); + p.y = y + (this.anchor.y * this._cache.height); return p; } +/** +* Internal function called by preUpdate. +* +* @method Phaser.Sprite#updateCrop +* @memberof Phaser.Sprite +*/ +Phaser.Sprite.prototype.updateCrop = function() { + + // This only runs if crop is enabled + if (this.crop.width != this._cache.cropWidth || this.crop.height != this._cache.cropHeight || this.crop.x != this._cache.cropX || this.crop.y != this._cache.cropY) + { + this.crop.floorAll(); + + this._cache.cropX = this.crop.x; + this._cache.cropY = this.crop.y; + this._cache.cropWidth = this.crop.width; + this._cache.cropHeight = this.crop.height; + + this.texture.frame = this.crop; + this.texture.width = this.crop.width; + this.texture.height = this.crop.height; + + this.texture.updateFrame = true; + + PIXI.Texture.frameUpdates.push(this.texture); + } + +} + +/** +* Resets the Sprite.crop value back to the frame dimensions. +* +* @method Phaser.Sprite#resetCrop +* @memberof Phaser.Sprite +*/ +Phaser.Sprite.prototype.resetCrop = function() { + + this.crop = new Phaser.Rectangle(0, 0, this._cache.width, this._cache.height); + this.texture.setFrame(this.crop); + this.cropEnabled = false; + +} + +/** +* Internal function called by the World postUpdate cycle. +* +* @method Phaser.Sprite#postUpdate +* @memberof Phaser.Sprite +*/ +Phaser.Sprite.prototype.postUpdate = function() { + + if (this.exists) + { + // The sprite is positioned in this call, after taking into consideration motion updates and collision + if (this.body) + { + this.body.postUpdate(); + } + + if (this.fixedToCamera) + { + this._cache.x = this.game.camera.view.x + this.x; + this._cache.y = this.game.camera.view.y + this.y; + } + else + { + this._cache.x = this.x; + this._cache.y = this.y; + } + + if (this.position.x != this._cache.x || this.position.y != this._cache.y) + { + this.position.x = this._cache.x; + this.position.y = this._cache.y; + } + } + +} + +/** +* Changes the Texture the Sprite is using entirely. The old texture is removed and the new one is referenced or fetched from the Cache. +* This causes a WebGL texture update, so use sparingly or in low-intensity portions of your game. +* +* @method Phaser.Sprite#loadTexture +* @memberof Phaser.Sprite +* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. +* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. +*/ +Phaser.Sprite.prototype.loadTexture = function (key, frame) { + + this.key = key; + + if (key instanceof Phaser.RenderTexture) + { + this.currentFrame = this.game.cache.getTextureFrame(key.name); + } + else if (key instanceof PIXI.Texture) + { + this.currentFrame = frame; + } + else + { + if (typeof key === 'undefined' || this.game.cache.checkImageKey(key) === false) + { + key = '__default'; + this.key = key; + } + + if (this.game.cache.isSpriteSheet(key)) + { + this.animations.loadFrameData(this.game.cache.getFrameData(key)); + + if (typeof frame !== 'undefined') + { + if (typeof frame === 'string') + { + this.frameName = frame; + } + else + { + this.frame = frame; + } + } + } + else + { + this.currentFrame = this.game.cache.getFrame(key); + this.setTexture(PIXI.TextureCache[key]); + } + } + +} + +/** +* Returns the absolute delta x value. +* +* @method Phaser.Sprite#deltaAbsX +* @memberof Phaser.Sprite +* @return {number} The absolute delta value. +*/ +Phaser.Sprite.prototype.deltaAbsX = function () { + return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX()); +} + +/** +* Returns the absolute delta y value. +* +* @method Phaser.Sprite#deltaAbsY +* @memberof Phaser.Sprite +* @return {number} The absolute delta value. +*/ +Phaser.Sprite.prototype.deltaAbsY = function () { + return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY()); +} + +/** +* Returns the delta x value. +* +* @method Phaser.Sprite#deltaX +* @memberof Phaser.Sprite +* @return {number} The delta value. +*/ +Phaser.Sprite.prototype.deltaX = function () { + return this.x - this.prevX; +} + +/** +* Returns the delta y value. +* +* @method Phaser.Sprite#deltaY +* @memberof Phaser.Sprite +* @return {number} The delta value. +*/ +Phaser.Sprite.prototype.deltaY = function () { + return this.y - this.prevY; +} + +/** +* Moves the sprite so its center is located on the given x and y coordinates. +* Doesn't change the anchor point of the sprite. +* +* @method Phaser.Sprite#centerOn +* @memberof Phaser.Sprite +* @param {number} x - The x coordinate (in world space) to position the Sprite at. +* @param {number} y - The y coordinate (in world space) to position the Sprite at. +* @return (Phaser.Sprite) This instance. +*/ +Phaser.Sprite.prototype.centerOn = function(x, y) { + + this.x = x + (this.x - this.center.x); + this.y = y + (this.y - this.center.y); + return this; + +} + +/** +* Brings a 'dead' Sprite back to life, optionally giving it the health value specified. +* A resurrected Sprite has its alive, exists and visible properties all set to true. +* It will dispatch the onRevived event, you can listen to Sprite.events.onRevived for the signal. +* +* @method Phaser.Sprite#revive +* @memberof Phaser.Sprite +* @param {number} [health=1] - The health to give the Sprite. +* @return (Phaser.Sprite) This instance. +*/ +Phaser.Sprite.prototype.revive = function(health) { + + if (typeof health === 'undefined') { health = 1; } + + this.alive = true; + this.exists = true; + this.visible = true; + this.health = health; + + if (this.events) + { + this.events.onRevived.dispatch(this); + } + + return this; + +} + +/** +* Kills a Sprite. A killed Sprite has its alive, exists and visible properties all set to false. +* It will dispatch the onKilled event, you can listen to Sprite.events.onKilled for the signal. +* Note that killing a Sprite is a way for you to quickly recycle it in a Sprite pool, it doesn't free it up from memory. +* If you don't need this Sprite any more you should call Sprite.destroy instead. +* +* @method Phaser.Sprite#kill +* @memberof Phaser.Sprite +* @return (Phaser.Sprite) This instance. +*/ +Phaser.Sprite.prototype.kill = function() { + + this.alive = false; + this.exists = false; + this.visible = false; + + if (this.events) + { + this.events.onKilled.dispatch(this); + } + + return this; + +} + +/** +* Destroys the Sprite. This removes it from its parent group, destroys the input, event and animation handlers if present +* and nulls its reference to game, freeing it up for garbage collection. +* +* @method Phaser.Sprite#destroy +* @memberof Phaser.Sprite +*/ +Phaser.Sprite.prototype.destroy = function() { + + if (this.group) + { + this.group.remove(this); + } + + if (this.input) + { + this.input.destroy(); + } + + if (this.events) + { + this.events.destroy(); + } + + if (this.animations) + { + this.animations.destroy(); + } + + this.alive = false; + this.exists = false; + this.visible = false; + + this.game = null; + +} + +/** +* Damages the Sprite, this removes the given amount from the Sprites health property. +* If health is then taken below zero Sprite.kill is called. +* +* @method Phaser.Sprite#damage +* @memberof Phaser.Sprite +* @param {number} amount - The amount to subtract from the Sprite.health value. +* @return (Phaser.Sprite) This instance. +*/ +Phaser.Sprite.prototype.damage = function(amount) { + + if (this.alive) + { + this.health -= amount; + + if (this.health < 0) + { + this.kill(); + } + } + + return this; + +} + +/** +* Resets the Sprite. This places the Sprite at the given x/y world coordinates and then +* sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state and health values. +* If the Sprite has a physics body that too is reset. +* +* @method Phaser.Sprite#reset +* @memberof Phaser.Sprite +* @param {number} x - The x coordinate (in world space) to position the Sprite at. +* @param {number} y - The y coordinate (in world space) to position the Sprite at. +* @param {number} [health=1] - The health to give the Sprite. +* @return (Phaser.Sprite) This instance. +*/ +Phaser.Sprite.prototype.reset = function(x, y, health) { + + if (typeof health === 'undefined') { health = 1; } + + this.x = x; + this.y = y; + this.position.x = this.x; + this.position.y = this.y; + this.alive = true; + this.exists = true; + this.visible = true; + this.renderable = true; + this._outOfBoundsFired = false; + + this.health = health; + + if (this.body) + { + this.body.reset(); + } + + return this; + +} + +/** +* Brings the Sprite to the top of the display list it is a child of. Sprites that are members of a Phaser.Group are only +* bought to the top of that Group, not the entire display list. +* +* @method Phaser.Sprite#bringToTop +* @memberof Phaser.Sprite +* @return (Phaser.Sprite) This instance. +*/ Phaser.Sprite.prototype.bringToTop = function() { if (this.group) @@ -14308,141 +16746,156 @@ Phaser.Sprite.prototype.bringToTop = function() { this.game.world.bringToTop(this); } -} - -Phaser.Sprite.prototype.getBounds = function(rect) { - - rect = rect || new Phaser.Rectangle; - - var left = Phaser.Math.min(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x); - var right = Phaser.Math.max(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x); - var top = Phaser.Math.min(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y); - var bottom = Phaser.Math.max(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y); - - rect.x = left; - rect.y = top; - rect.width = right - left; - rect.height = bottom - top; - - return rect; + return this; } +/** +* Play an animation based on the given key. The animation should previously have been added via sprite.animations.add() +* If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself. +* +* @method Phaser.Sprite#play +* @memberof Phaser.Sprite +* @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump". +* @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. +* @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. +* @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. +* @return {Phaser.Animation} A reference to playing Animation instance. +*/ +Phaser.Sprite.prototype.play = function (name, frameRate, loop, killOnComplete) { + + if (this.animations) + { + return this.animations.play(name, frameRate, loop, killOnComplete); + } + +} + +/** +* Indicates the rotation of the Sprite, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. +* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90. +* If you wish to work in radians instead of degrees use the property Sprite.rotation instead. +* @name Phaser.Sprite#angle +* @property {number} angle - Gets or sets the Sprites angle of rotation in degrees. +*/ Object.defineProperty(Phaser.Sprite.prototype, 'angle', { get: function() { - return Phaser.Math.radToDeg(this.rotation); + return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation)); }, set: function(value) { - this.rotation = Phaser.Math.degToRad(value); + this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value)); } }); +/** +* @name Phaser.Sprite#frame +* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display. +*/ Object.defineProperty(Phaser.Sprite.prototype, "frame", { - /** - * Get the animation frame number. - */ get: function () { return this.animations.frame; }, - /** - * Set the animation frame by frame number. - */ set: function (value) { this.animations.frame = value; } }); +/** +* @name Phaser.Sprite#frameName +* @property {string} frameName - Gets or sets the current frame name and updates the Texture Cache for display. +*/ Object.defineProperty(Phaser.Sprite.prototype, "frameName", { - /** - * Get the animation frame name. - */ get: function () { return this.animations.frameName; }, - /** - * Set the animation frame by frame name. - */ set: function (value) { this.animations.frameName = value; } }); +/** +* @name Phaser.Sprite#inCamera +* @property {boolean} inCamera - Is this sprite visible to the camera or not? +* @readonly +*/ Object.defineProperty(Phaser.Sprite.prototype, "inCamera", { - /** - * Is this sprite visible to the camera or not? - */ get: function () { return this._cache.cameraVisible; } }); -Object.defineProperty(Phaser.Sprite.prototype, "crop", { - - /** - * Get the input enabled state of this Sprite. - */ - get: function () { - - return this._cropRect; +/** +* The width of the sprite in pixels, setting this will actually modify the scale to acheive the value desired. +* If you wish to crop the Sprite instead see the Sprite.crop value. +* +* @name Phaser.Sprite#width +* @property {number} width - The width of the Sprite in pixels. +*/ +Object.defineProperty(Phaser.Sprite.prototype, 'width', { + get: function() { + return this.scale.x * this.currentFrame.width; }, - /** - * Set the ability for this sprite to receive input events. - */ - set: function (value) { + set: function(value) { - if (value instanceof Phaser.Rectangle) - { - if (this._cropUUID == null) - { - this._cropUUID = this.game.rnd.uuid(); - - PIXI.TextureCache[this._cropUUID] = new PIXI.Texture(PIXI.BaseTextureCache[this.key], { - x: value.x, - y: value.y, - width: value.width, - height: value.height - }); - } - else - { - PIXI.TextureCache[this._cropUUID].frame = value; - } - - this._cropRect = value; - this.setTexture(PIXI.TextureCache[this._cropUUID]); - } + this.scale.x = value / this.currentFrame.width; + this._cache.scaleX = value / this.currentFrame.width; + this._width = value; } }); +/** +* The height of the sprite in pixels, setting this will actually modify the scale to acheive the value desired. +* If you wish to crop the Sprite instead see the Sprite.crop value. +* +* @name Phaser.Sprite#height +* @property {number} height - The height of the Sprite in pixels. +*/ +Object.defineProperty(Phaser.Sprite.prototype, 'height', { + + get: function() { + return this.scale.y * this.currentFrame.height; + }, + + set: function(value) { + + this.scale.y = value / this.currentFrame.height; + this._cache.scaleY = value / this.currentFrame.height; + this._height = value; + + } + +}); + +/** +* By default a Sprite won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is +* activated for this Sprite instance and it will then start to process click/touch events and more. +* +* @name Phaser.Sprite#inputEnabled +* @property {boolean} inputEnabled - Set to true to allow this Sprite to receive input events, otherwise false. +*/ Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", { - /** - * Get the input enabled state of this Sprite. - */ get: function () { return (this.input.enabled); }, - /** - * Set the ability for this sprite to receive input events. - */ set: function (value) { if (value) @@ -14464,6 +16917,24 @@ Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", { }); +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Create a new TileSprite. +* @class Phaser.Tilemap +* @constructor +* @param {Phaser.Game} game - Current game instance. +* @param {number} x - X position of the new tileSprite. +* @param {number} y - Y position of the new tileSprite. +* @param {number} width - the width of the tilesprite. +* @param {number} height - the height of the tilesprite. +* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. +* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. +*/ Phaser.TileSprite = function (game, x, y, width, height, key, frame) { x = x || 0; @@ -14475,26 +16946,26 @@ Phaser.TileSprite = function (game, x, y, width, height, key, frame) { Phaser.Sprite.call(this, game, x, y, key, frame); + /** + * @property {Description} texture - Description. + */ this.texture = PIXI.TextureCache[key]; PIXI.TilingSprite.call(this, this.texture, width, height); + /** + * @property {Description} type - Description. + */ this.type = Phaser.TILESPRITE; /** - * The scaling of the image that is being tiled - * - * @property tileScale - * @type Point - */ + * @property {Point} tileScale - The scaling of the image that is being tiled. + */ this.tileScale = new Phaser.Point(1, 1); /** - * The offset position of the image that is being tiled - * - * @property tilePosition - * @type Point - */ + * @property {Point} tilePosition - The offset position of the image that is being tiled. + */ this.tilePosition = new Phaser.Point(0, 0); }; @@ -14504,6 +16975,22 @@ Phaser.TileSprite.prototype.constructor = Phaser.TileSprite; // Add our own custom methods +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Create a new Text. +* @class Phaser.Text +* @constructor +* @param {Phaser.Game} game - Current game instance. +* @param {number} x - X position of the new text object. +* @param {number} y - Y position of the new text object. +* @param {string} text - The actual text that will be written. +* @param {object} style - The style object containing style attributes like font, font size , +*/ Phaser.Text = function (game, x, y, text, style) { x = x || 0; @@ -14512,15 +16999,34 @@ Phaser.Text = function (game, x, y, text, style) { style = style || ''; // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all + /** + * @property {boolean} exists - Description. + * @default + */ this.exists = true; // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering + /** + * @property {boolean} alive - Description. + * @default + */ this.alive = true; + /** + * @property {Description} group - Description. + * @default + */ this.group = null; + /** + * @property {string} name - Description. + * @default + */ this.name = ''; + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; this._text = text; @@ -14528,19 +17034,33 @@ Phaser.Text = function (game, x, y, text, style) { PIXI.Text.call(this, text, style); + /** + * @property {Description} type - Description. + */ this.type = Phaser.TEXT; + /** + * @property {Description} position - Description. + */ this.position.x = this.x = x; this.position.y = this.y = y; // Replaces the PIXI.Point with a slightly more flexible one + /** + * @property {Phaser.Point} anchor - Description. + */ this.anchor = new Phaser.Point(); + + /** + * @property {Phaser.Point} scale - Description. + */ this.scale = new Phaser.Point(1, 1); - // Influence of camera movement upon the position - this.scrollFactor = new Phaser.Point(1, 1); - // A mini cache for storing all of the calculated values + /** + * @property {Description} _cache - Description. + * @private + */ this._cache = { dirty: false, @@ -14548,7 +17068,7 @@ Phaser.Text = function (game, x, y, text, style) { // Transform cache a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, - // The previous calculated position inc. camera x/y and scrollFactor + // The previous calculated position x: -1, y: -1, // The actual scale values based on the worldTransform @@ -14556,9 +17076,12 @@ Phaser.Text = function (game, x, y, text, style) { }; - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + this._cache.x = this.x; + this._cache.y = this.y; + /** + * @property {boolean} renderable - Description. + */ this.renderable = true; }; @@ -14566,7 +17089,10 @@ Phaser.Text = function (game, x, y, text, style) { Phaser.Text.prototype = Object.create(PIXI.Text.prototype); Phaser.Text.prototype.constructor = Phaser.Text; -// Automatically called by World.update +/** +* Automatically called by World.update. +* @method Phaser.Text.prototype.update +*/ Phaser.Text.prototype.update = function() { if (!this.exists) @@ -14576,8 +17102,8 @@ Phaser.Text.prototype.update = function() { this._cache.dirty = false; - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + this._cache.x = this.x; + this._cache.y = this.y; if (this.position.x != this._cache.x || this.position.y != this._cache.y) { @@ -14588,6 +17114,39 @@ Phaser.Text.prototype.update = function() { } +/** +* @method Phaser.Text.prototype.destroy +*/ +Phaser.Text.prototype.destroy = function() { + + if (this.group) + { + this.group.remove(this); + } + + if (this.canvas.parentNode) + { + this.canvas.parentNode.removeChild(this.canvas); + } + else + { + this.canvas = null; + this.context = null; + } + + this.exists = false; + + this.group = null; + +} + +/** +* Get +* @returns {Description} +*//** +* Set +* @param {Description} value - Description +*/ Object.defineProperty(Phaser.Text.prototype, 'angle', { get: function() { @@ -14600,7 +17159,7 @@ Object.defineProperty(Phaser.Text.prototype, 'angle', { }); -Object.defineProperty(Phaser.Text.prototype, 'text', { +Object.defineProperty(Phaser.Text.prototype, 'content', { get: function() { return this._text; @@ -14612,14 +17171,14 @@ Object.defineProperty(Phaser.Text.prototype, 'text', { if (value !== this._text) { this._text = value; - this.dirty = true; + this.setText(value); } } }); -Object.defineProperty(Phaser.Text.prototype, 'style', { +Object.defineProperty(Phaser.Text.prototype, 'font', { get: function() { return this._style; @@ -14631,47 +17190,99 @@ Object.defineProperty(Phaser.Text.prototype, 'style', { if (value !== this._style) { this._style = value; - this.dirty = true; + this.setStyle(value); } } }); +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Creates a new BitmapText. +* @class Phaser.BitmapText +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {number} x - X position of the new bitmapText object. +* @param {number} y - Y position of the new bitmapText object. +* @param {string} text - The actual text that will be written. +* @param {object} style - The style object containing style attributes like font, font size , etc. +*/ Phaser.BitmapText = function (game, x, y, text, style) { x = x || 0; y = y || 0; + text = text || ''; style = style || ''; - // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all + /** + * @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all. + * @default + */ this.exists = true; - // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering + /** + * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering. + * @default + */ this.alive = true; + /** + * @property {Description} group - Description. + * @default + */ this.group = null; + /** + * @property {string} name - Description. + * @default + */ this.name = ''; + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; PIXI.BitmapText.call(this, text, style); + /** + * @property {Description} type - Description. + */ this.type = Phaser.BITMAPTEXT; + /** + * @property {number} position.x - Description. + */ this.position.x = x; + + /** + * @property {number} position.y - Description. + */ this.position.y = y; // Replaces the PIXI.Point with a slightly more flexible one + /** + * @property {Phaser.Point} anchor - Description. + */ this.anchor = new Phaser.Point(); + + /** + * @property {Phaser.Point} scale - Description. + */ this.scale = new Phaser.Point(1, 1); - // Influence of camera movement upon the position - this.scrollFactor = new Phaser.Point(1, 1); - // A mini cache for storing all of the calculated values + /** + * @property {function} _cache - Description. + * @private + */ this._cache = { dirty: false, @@ -14679,7 +17290,7 @@ Phaser.BitmapText = function (game, x, y, text, style) { // Transform cache a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, - // The previous calculated position inc. camera x/y and scrollFactor + // The previous calculated position x: -1, y: -1, // The actual scale values based on the worldTransform @@ -14687,9 +17298,13 @@ Phaser.BitmapText = function (game, x, y, text, style) { }; - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + this._cache.x = this.x; + this._cache.y = this.y; + /** + * @property {boolean} renderable - Description. + * @private + */ this.renderable = true; }; @@ -14699,8 +17314,9 @@ Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype); Phaser.BitmapText.prototype.constructor = Phaser.BitmapText; /** - * Automatically called by World.update - */ +* Automatically called by World.update +* @method Phaser.BitmapText.prototype.update +*/ Phaser.BitmapText.prototype.update = function() { if (!this.exists) @@ -14710,8 +17326,8 @@ Phaser.BitmapText.prototype.update = function() { this._cache.dirty = false; - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + this._cache.x = this.x; + this._cache.y = this.y; if (this.position.x != this._cache.x || this.position.y != this._cache.y) { @@ -14725,6 +17341,39 @@ Phaser.BitmapText.prototype.update = function() { } +/** +* @method Phaser.Text.prototype.destroy +*/ +Phaser.BitmapText.prototype.destroy = function() { + + if (this.group) + { + this.group.remove(this); + } + + if (this.canvas.parentNode) + { + this.canvas.parentNode.removeChild(this.canvas); + } + else + { + this.canvas = null; + this.context = null; + } + + this.exists = false; + + this.group = null; + +} + +/** +* Get +* @returns {Description} +*//** +* Set +* @param {Description} value - Description +*/ Object.defineProperty(Phaser.BitmapText.prototype, 'angle', { get: function() { @@ -14737,6 +17386,13 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'angle', { }); +/** +* Get +* @returns {Description} +*//** +* Set +* @param {Description} value - Description +*/ Object.defineProperty(Phaser.BitmapText.prototype, 'x', { get: function() { @@ -14749,6 +17405,13 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'x', { }); +/** +* Get +* @returns {Description} +*//** +* Set +* @param {Description} value - Description +*/ Object.defineProperty(Phaser.BitmapText.prototype, 'y', { get: function() { @@ -14764,13 +17427,13 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'y', { /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Button +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ + /** * Create a new Button object. -* @class Button +* @class Phaser.Button * @constructor * * @param {Phaser.Game} game Current game instance. @@ -14785,7 +17448,6 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'y', { */ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) { - x = x || 0; y = y || 0; key = key || null; @@ -14794,21 +17456,86 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, Phaser.Sprite.call(this, game, x, y, key, outFrame); + /** + * @property {Description} type - Description. + */ this.type = Phaser.BUTTON; + /** + * @property {Description} _onOverFrameName - Description. + * @private + * @default + */ this._onOverFrameName = null; + + /** + * @property {Description} _onOutFrameName - Description. + * @private + * @default + */ this._onOutFrameName = null; + + /** + * @property {Description} _onDownFrameName - Description. + * @private + * @default + */ this._onDownFrameName = null; + + /** + * @property {Description} _onUpFrameName - Description. + * @private + * @default + */ this._onUpFrameName = null; + + /** + * @property {Description} _onOverFrameID - Description. + * @private + * @default + */ this._onOverFrameID = null; + + /** + * @property {Description} _onOutFrameID - Description. + * @private + * @default + */ this._onOutFrameID = null; + + /** + * @property {Description} _onDownFrameID - Description. + * @private + * @default + */ this._onDownFrameID = null; + + /** + * @property {Description} _onUpFrameID - Description. + * @private + * @default + */ this._onUpFrameID = null; // These are the signals the game will subscribe to + /** + * @property {Phaser.Signal} onInputOver - Description. + */ this.onInputOver = new Phaser.Signal; + + /** + * @property {Phaser.Signal} onInputOut - Description. + */ this.onInputOut = new Phaser.Signal; + + /** + * @property {Phaser.Signal} onInputDown - Description. + */ this.onInputDown = new Phaser.Signal; + + /** + * @property {Phaser.Signal} onInputUp - Description. + */ this.onInputUp = new Phaser.Signal; this.setFrames(overFrame, outFrame, downFrame); @@ -14818,7 +17545,9 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, this.onInputUp.add(callback, callbackContext); } - this.input.start(0, false, true); + this.freezeFrames = false; + + this.input.start(0, true); // Redirect the input events to here so we can handle animation updates, etc this.events.onInputOver.add(this.onInputOverHandler, this); @@ -14833,12 +17562,12 @@ Phaser.Button.prototype.constructor = Phaser.Button; /** * Used to manually set the frames that will be used for the different states of the button -* exactly like setting them in the constructor +* exactly like setting them in the constructor. * -* @method setFrames -* @param {string|number} [overFrame] This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name. -* @param {string|number} [outFrame] This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name. -* @param {string|number} [downFrame] This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name. +* @method Phaser.Button.prototype.setFrames +* @param {string|number} [overFrame] - This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name. +* @param {string|number} [outFrame] - This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name. +* @param {string|number} [downFrame] - This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name. */ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { @@ -14847,10 +17576,20 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { if (typeof overFrame === 'string') { this._onOverFrameName = overFrame; + + if (this.input.pointerOver()) + { + this.frameName = overFrame; + } } else { this._onOverFrameID = overFrame; + + if (this.input.pointerOver()) + { + this.frame = overFrame; + } } } @@ -14860,11 +17599,21 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { { this._onOutFrameName = outFrame; this._onUpFrameName = outFrame; + + if (this.input.pointerOver() == false) + { + this.frameName = outFrame; + } } else { this._onOutFrameID = outFrame; this._onUpFrameID = outFrame; + + if (this.input.pointerOver() == false) + { + this.frame = outFrame; + } } } @@ -14873,24 +17622,43 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { if (typeof downFrame === 'string') { this._onDownFrameName = downFrame; + + if (this.input.pointerOver()) + { + this.frameName = downFrame; + } } else { this._onDownFrameID = downFrame; + + if (this.input.pointerOver()) + { + this.frame = downFrame; + } } } }; +/** +* Description. +* +* @method Phaser.Button.prototype.onInputOverHandler +* @param {Description} pointer - Description. +*/ Phaser.Button.prototype.onInputOverHandler = function (pointer) { - if (this._onOverFrameName != null) + if (this.freezeFrames == false) { - this.frameName = this._onOverFrameName; - } - else if (this._onOverFrameID != null) - { - this.frame = this._onOverFrameID; + if (this._onOverFrameName != null) + { + this.frameName = this._onOverFrameName; + } + else if (this._onOverFrameID != null) + { + this.frame = this._onOverFrameID; + } } if (this.onInputOver) @@ -14899,15 +17667,24 @@ Phaser.Button.prototype.onInputOverHandler = function (pointer) { } }; +/** +* Description. +* +* @method Phaser.Button.prototype.onInputOutHandler +* @param {Description} pointer - Description. +*/ Phaser.Button.prototype.onInputOutHandler = function (pointer) { - if (this._onOutFrameName != null) + if (this.freezeFrames == false) { - this.frameName = this._onOutFrameName; - } - else if (this._onOutFrameID != null) - { - this.frame = this._onOutFrameID; + if (this._onOutFrameName != null) + { + this.frameName = this._onOutFrameName; + } + else if (this._onOutFrameID != null) + { + this.frame = this._onOutFrameID; + } } if (this.onInputOut) @@ -14916,15 +17693,24 @@ Phaser.Button.prototype.onInputOutHandler = function (pointer) { } }; +/** +* Description. +* +* @method Phaser.Button.prototype.onInputDownHandler +* @param {Description} pointer - Description. +*/ Phaser.Button.prototype.onInputDownHandler = function (pointer) { - if (this._onDownFrameName != null) + if (this.freezeFrames == false) { - this.frameName = this._onDownFrameName; - } - else if (this._onDownFrameID != null) - { - this.frame = this._onDownFrameID; + if (this._onDownFrameName != null) + { + this.frameName = this._onDownFrameName; + } + else if (this._onDownFrameID != null) + { + this.frame = this._onDownFrameID; + } } if (this.onInputDown) @@ -14933,15 +17719,24 @@ Phaser.Button.prototype.onInputDownHandler = function (pointer) { } }; +/** +* Description. +* +* @method Phaser.Button.prototype.onInputUpHandler +* @param {Description} pointer - Description. +*/ Phaser.Button.prototype.onInputUpHandler = function (pointer) { - if (this._onUpFrameName != null) + if (this.freezeFrames == false) { - this.frameName = this._onUpFrameName; - } - else if (this._onUpFrameID != null) - { - this.frame = this._onUpFrameID; + if (this._onUpFrameName != null) + { + this.frameName = this._onUpFrameName; + } + else if (this._onUpFrameID != null) + { + this.frame = this._onUpFrameID; + } } if (this.onInputUp) @@ -14950,51 +17745,148 @@ Phaser.Button.prototype.onInputUpHandler = function (pointer) { } }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Creates a new Graphics object. +* +* @class Phaser.Graphics +* @constructor +* +* @param {Phaser.Game} game Current game instance. +* @param {number} x - X position of the new graphics object. +* @param {number} y - Y position of the new graphics object. +*/ Phaser.Graphics = function (game, x, y) { + this.game = game; + PIXI.Graphics.call(this); - Phaser.Sprite.call(this, game, x, y); - + /** + * @property {Description} type - Description. + */ this.type = Phaser.GRAPHICS; }; Phaser.Graphics.prototype = Object.create(PIXI.Graphics.prototype); Phaser.Graphics.prototype.constructor = Phaser.Graphics; -Phaser.Graphics.prototype = Phaser.Utils.extend(true, Phaser.Graphics.prototype, Phaser.Sprite.prototype); // Add our own custom methods +/** +* Description. +* +* @method Phaser.Sprite.prototype.destroy +*/ +Phaser.Graphics.prototype.destroy = function() { + + this.clear(); + + if (this.group) + { + this.group.remove(this); + } + + this.game = null; + +} + Object.defineProperty(Phaser.Graphics.prototype, 'angle', { get: function() { - return Phaser.Math.radToDeg(this.rotation); + return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation)); }, set: function(value) { - this.rotation = Phaser.Math.degToRad(value); + this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value)); } }); +Object.defineProperty(Phaser.Graphics.prototype, 'x', { + + get: function() { + return this.position.x; + }, + + set: function(value) { + this.position.x = value; + } + +}); + +Object.defineProperty(Phaser.Graphics.prototype, 'y', { + + get: function() { + return this.position.y; + }, + + set: function(value) { + this.position.y = value; + } + +}); + +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* A dynamic initially blank canvas to which images can be drawn +* @class Phaser.RenderTexture +* @constructor +* @param {Phaser.Game} game - Current game instance. +* @param {string} key - Asset key for the render texture. +* @param {number} width - the width of the render texture. +* @param {number} height - the height of the render texture. +*/ Phaser.RenderTexture = function (game, key, width, height) { + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; + /** + * @property {string} name - the name of the object. + */ this.name = key; PIXI.EventTarget.call( this ); + /** + * @property {number} width - the width. + */ this.width = width || 100; + + /** + * @property {number} height - the height. + */ this.height = height || 100; - // I know this has a typo in it, but it's because the PIXI.RenderTexture does and we need to pair-up with it - // once they update pixi to fix the typo, we'll fix it here too :) + /** + * I know this has a typo in it, but it's because the PIXI.RenderTexture does and we need to pair-up with it + * once they update pixi to fix the typo, we'll fix it here too :) + * @property {Description} indetityMatrix - Description. + */ this.indetityMatrix = PIXI.mat3.create(); + /** + * @property {Description} frame - Description. + */ this.frame = new PIXI.Rectangle(0, 0, this.width, this.height); + /** + * @property {Description} type - Description. + */ this.type = Phaser.RENDERTEXTURE; if (PIXI.gl) @@ -15014,25 +17906,24 @@ Phaser.RenderTexture.prototype.constructor = Phaser.RenderTexture; /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Canvas +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** -* The Canvas class handles everything related to the tag as a DOM Element, like styles, offset, aspect ratio +* The Canvas class handles everything related to the <canvas> tag as a DOM Element, like styles, offset, aspect ratio * -* @class Canvas +* @class Phaser.Canvas * @static */ - Phaser.Canvas = { + /** - * Creates the tag + * Creates the <canvas> tag * - * @method create - * @param {number} width The desired width - * @param {number} height The desired height - * @return {HTMLCanvasElement} the newly created tag + * @method Phaser.Canvas.create + * @param {number} width - The desired width. + * @param {number} height - The desired height. + * @return {HTMLCanvasElement} The newly created <canvas> tag. */ create: function (width, height) { @@ -15050,10 +17941,10 @@ Phaser.Canvas = { /** * Get the DOM offset values of any given element - * @method getOffset - * @param {HTMLElement} element The targeted element that we want to retrieve the offset - * @param {Phaser.Point} [point] The point we want to take the x/y values of the offset - * @return point {Phaser.Point} A point objet with the offsetX and Y as its properties + * @method Phaser.Canvas.getOffset + * @param {HTMLElement} element - The targeted element that we want to retrieve the offset. + * @param {Phaser.Point} [point] - The point we want to take the x/y values of the offset. + * @return {Phaser.Point} - A point objet with the offsetX and Y as its properties. */ getOffset: function (element, point) { @@ -15075,9 +17966,9 @@ Phaser.Canvas = { /** * Returns the aspect ratio of the given canvas. * - * @method getAspectRatio - * @param {HTMLCanvasElement} canvas The canvas to get the aspect ratio from. - * @return {Number} Returns true on success + * @method Phaser.Canvas.getAspectRatio + * @param {HTMLCanvasElement} canvas - The canvas to get the aspect ratio from. + * @return {number} The ratio between canvas' width and height. */ getAspectRatio: function (canvas) { return canvas.width / canvas.height; @@ -15086,9 +17977,9 @@ Phaser.Canvas = { /** * Sets the background color behind the canvas. This changes the canvas style property. * - * @method setBackgroundColor - * @param {HTMLCanvasElement} canvas The canvas to set the background color on. - * @param {String} color The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color. + * @method Phaser.Canvas.setBackgroundColor + * @param {HTMLCanvasElement} canvas - The canvas to set the background color on. + * @param {string} [color] - The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color. * @return {HTMLCanvasElement} Returns the source canvas. */ setBackgroundColor: function (canvas, color) { @@ -15104,10 +17995,10 @@ Phaser.Canvas = { /** * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions. * - * @method setTouchAction - * @param {HTMLCanvasElement} canvas The canvas to set the touch action on. - * @param {String} value The touch action to set. Defaults to 'none'. - * @return {HTMLCanvasElement} Returns the source canvas. + * @method Phaser.Canvas.setTouchAction + * @param {HTMLCanvasElement} canvas - The canvas to set the touch action on. + * @param {String} [value] - The touch action to set. Defaults to 'none'. + * @return {HTMLCanvasElement} The source canvas. */ setTouchAction: function (canvas, value) { @@ -15121,14 +18012,38 @@ Phaser.Canvas = { }, + /** + * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions. + * + * @method Phaser.Canvas.setUserSelect + * @param {HTMLCanvasElement} canvas - The canvas to set the touch action on. + * @param {String} [value] - The touch action to set. Defaults to 'none'. + * @return {HTMLCanvasElement} The source canvas. + */ + setUserSelect: function (canvas, value) { + + value = value || 'none'; + + canvas.style['-webkit-touch-callout'] = value; + canvas.style['-webkit-user-select'] = value; + canvas.style['-khtml-user-select'] = value; + canvas.style['-moz-user-select'] = value; + canvas.style['-ms-user-select'] = value; + canvas.style['user-select'] = value; + canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)'; + + return canvas; + + }, + /** * Adds the given canvas element to the DOM. The canvas will be added as a child of the given parent. * If no parent is given it will be added as a child of the document.body. * - * @method addToDOM - * @param {HTMLCanvasElement} canvas The canvas to set the touch action on. - * @param {String} parent The DOM element to add the canvas to. Defaults to ''. - * @param {bool} overflowHidden If set to true it will add the overflow='hidden' style to the parent DOM element. + * @method Phaser.Canvas.addToDOM + * @param {HTMLCanvasElement} canvas - The canvas to set the touch action on. + * @param {string} parent - The DOM element to add the canvas to. Defaults to ''. + * @param {boolean} overflowHidden - If set to true it will add the overflow='hidden' style to the parent DOM element. * @return {HTMLCanvasElement} Returns the source canvas. */ addToDOM: function (canvas, parent, overflowHidden) { @@ -15165,14 +18080,14 @@ Phaser.Canvas = { /** * Sets the transform of the given canvas to the matrix values provided. * - * @method setTransform - * @param {CanvasRenderingContext2D} context The context to set the transform on. - * @param {Number} translateX The value to translate horizontally by. - * @param {Number} translateY The value to translate vertically by. - * @param {Number} scaleX The value to scale horizontally by. - * @param {Number} scaleY The value to scale vertically by. - * @param {Number} skewX The value to skew horizontaly by. - * @param {Number} skewY The value to skew vertically by. + * @method Phaser.Canvas.setTransform + * @param {CanvasRenderingContext2D} context - The context to set the transform on. + * @param {number} translateX - The value to translate horizontally by. + * @param {number} translateY - The value to translate vertically by. + * @param {number} scaleX - The value to scale horizontally by. + * @param {number} scaleY - The value to scale vertically by. + * @param {number} skewX - The value to skew horizontaly by. + * @param {number} skewY - The value to skew vertically by. * @return {CanvasRenderingContext2D} Returns the source context. */ setTransform: function (context, translateX, translateY, scaleX, scaleY, skewX, skewY) { @@ -15190,9 +18105,9 @@ Phaser.Canvas = { * 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. * - * @method setSmoothingEnabled - * @param {CanvasRenderingContext2D} context The context to enable or disable the image smoothing on. - * @param {bool} value If set to true it will enable image smoothing, false will disable it. + * @method Phaser.Canvas.setSmoothingEnabled + * @param {CanvasRenderingContext2D} context - The context to enable or disable the image smoothing on. + * @param {boolean} value - If set to true it will enable image smoothing, false will disable it. * @return {CanvasRenderingContext2D} Returns the source context. */ setSmoothingEnabled: function (context, value) { @@ -15211,8 +18126,8 @@ Phaser.Canvas = { * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast on webkit'). * Note that if this doesn't given the desired result then see the setSmoothingEnabled. * - * @method setImageRenderingCrisp - * @param {HTMLCanvasElement} canvas The canvas to set image-rendering crisp on. + * @method Phaser.Canvas.setImageRenderingCrisp + * @param {HTMLCanvasElement} canvas - The canvas to set image-rendering crisp on. * @return {HTMLCanvasElement} Returns the source canvas. */ setImageRenderingCrisp: function (canvas) { @@ -15230,7 +18145,7 @@ Phaser.Canvas = { * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). * Note that if this doesn't given the desired result then see the CanvasUtils.setSmoothingEnabled method. * - * @method setImageRenderingBicubic + * @method Phaser.Canvas.setImageRenderingBicubic * @param {HTMLCanvasElement} canvas The canvas to set image-rendering bicubic on. * @return {HTMLCanvasElement} Returns the source canvas. */ @@ -15245,94 +18160,122 @@ Phaser.Canvas = { }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* An Animation instance contains a single animation and the controls to play it. +* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite. +* +* @class Phaser.StageScaleMode +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {number} width - Description. +* @param {number} height - Description. +*/ Phaser.StageScaleMode = function (game, width, height) { /** - * Stage height when start the game. - * @type {number} + * @property {number} _startHeight - Stage height when starting the game. + * @default + * @private */ this._startHeight = 0; /** - * If the game should be forced to use Landscape mode, this is set to true by Game.Stage - * @type {bool} + * @property {boolean} forceLandscape - If the game should be forced to use Landscape mode, this is set to true by Game.Stage + * @default */ this.forceLandscape = false; /** - * If the game should be forced to use Portrait mode, this is set to true by Game.Stage - * @type {bool} + * @property {boolean} forcePortrait - If the game should be forced to use Portrait mode, this is set to true by Game.Stage + * @default */ - this.forcePortrait = false; + this.forcePortrait = false; /** - * If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true. - * @type {bool} + * @property {boolean} incorrectOrientation - If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true. + * @default */ this.incorrectOrientation = false; /** - * If you wish to align your game in the middle of the page then you can set this value to true. - * It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. - * It doesn't care about any other DOM element that may be on the page, it literally just sets the margin. - * @type {bool} + * @property {boolean} pageAlignHorizontally - If you wish to align your game in the middle of the page then you can set this value to true. +
    • It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.
    • +
    • It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.
    + * @default */ this.pageAlignHorizontally = false; /** - * If you wish to align your game in the middle of the page then you can set this value to true. - * It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. - * It doesn't care about any other DOM element that may be on the page, it literally just sets the margin. - * @type {bool} + * @property {boolean} pageAlignVertically - If you wish to align your game in the middle of the page then you can set this value to true. +
    • It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. +
    • It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.
    + * @default */ - this.pageAlignVeritcally = false; + this.pageAlignVertically = false; /** - * Minimum width the canvas should be scaled to (in pixels) - * @type {number} + * @property {number} minWidth - Minimum width the canvas should be scaled to (in pixels). + * @default */ this.minWidth = null; /** - * Maximum width the canvas should be scaled to (in pixels). + * @property {number} maxWidth - Maximum width the canvas should be scaled to (in pixels). * If null it will scale to whatever width the browser can handle. - * @type {number} + * @default */ this.maxWidth = null; /** - * Minimum height the canvas should be scaled to (in pixels) - * @type {number} + * @property {number} minHeight - Minimum height the canvas should be scaled to (in pixels). + * @default */ this.minHeight = null; /** - * Maximum height the canvas should be scaled to (in pixels). + * @property {number} maxHeight - Maximum height the canvas should be scaled to (in pixels). * If null it will scale to whatever height the browser can handle. - * @type {number} + * @default */ this.maxHeight = null; /** - * Width of the stage after calculation. - * @type {number} + * @property {number} width - Width of the stage after calculation. + * @default */ this.width = 0; /** - * Height of the stage after calculation. - * @type {number} + * @property {number} height - Height of the stage after calculation. + * @default */ this.height = 0; /** - * The maximum number of times it will try to resize the canvas to fill the browser (default is 5) - * @type {number} + * @property {number} maxIterations - The maximum number of times it will try to resize the canvas to fill the browser. + * @default */ this.maxIterations = 5; + + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; + /** + * @property {Description} enterLandscape - Description. + */ this.enterLandscape = new Phaser.Signal(); + + /** + * @property {Description} enterPortrait - Description. + */ this.enterPortrait = new Phaser.Signal(); if (window['orientation']) @@ -15351,7 +18294,15 @@ Phaser.StageScaleMode = function (game, width, height) { } } + /** + * @property {Description} scaleFactor - Description. + */ this.scaleFactor = new Phaser.Point(1, 1); + + /** + * @property {number} aspectRatio - Aspect ratio. + * @default + */ this.aspectRatio = 0; var _this = this; @@ -15366,12 +18317,31 @@ Phaser.StageScaleMode = function (game, width, height) { }; +/** +* @constant +* @type {number} +*/ Phaser.StageScaleMode.EXACT_FIT = 0; + +/** +* @constant +* @type {number} +*/ Phaser.StageScaleMode.NO_SCALE = 1; + +/** +* @constant +* @type {number} +*/ Phaser.StageScaleMode.SHOW_ALL = 2; Phaser.StageScaleMode.prototype = { + /** + * Tries to enter the browser into full screen mode. + * Please note that this needs to be supported by the web browser and isn't the same thing as setting your game to fill the browser. + * @method Phaser.StageScaleMode#startFullScreen + */ startFullScreen: function () { if (this.isFullScreen) @@ -15399,6 +18369,10 @@ Phaser.StageScaleMode.prototype = { }, + /** + * Stops full screen mode if the browser is in it. + * @method Phaser.StageScaleMode#stopFullScreen + */ stopFullScreen: function () { if (document['cancelFullScreen']) @@ -15416,6 +18390,10 @@ Phaser.StageScaleMode.prototype = { }, + /** + * Checks if the browser is in the correct orientation for your game (if forceLandscape or forcePortrait have been set) + * @method Phaser.StageScaleMode#checkOrientationState + */ checkOrientationState: function () { // They are in the wrong orientation @@ -15441,8 +18419,10 @@ Phaser.StageScaleMode.prototype = { } }, - /** + /** * Handle window.orientationchange events + * @method Phaser.StageScaleMode#checkOrientation + * @param {Event} event - The orientationchange event data. */ checkOrientation: function (event) { @@ -15464,8 +18444,10 @@ Phaser.StageScaleMode.prototype = { }, - /** + /** * Handle window.resize events + * @method Phaser.StageScaleMode#checkResize + * @param {Event} event - The resize event data. */ checkResize: function (event) { @@ -15493,8 +18475,9 @@ Phaser.StageScaleMode.prototype = { } }, - /** + /** * Re-calculate scale mode and update screen size. + * @method Phaser.StageScaleMode#refresh */ refresh: function () { @@ -15527,8 +18510,9 @@ Phaser.StageScaleMode.prototype = { }, - /** + /** * Set screen size automatically based on the scaleMode. + * @param {Description} force - If force is true it will try to resize the game regardless of the document dimensions. */ setScreenSize: function (force) { @@ -15576,6 +18560,10 @@ Phaser.StageScaleMode.prototype = { }, + /** + * Sets the canvas style width and height values based on minWidth/Height and maxWidth/Height. + * @method Phaser.StageScaleMode#setSize + */ setSize: function () { if (this.incorrectOrientation == false) @@ -15618,7 +18606,7 @@ Phaser.StageScaleMode.prototype = { } } - if (this.pageAlignVeritcally) + if (this.pageAlignVertically) { if (this.height < window.innerHeight && this.incorrectOrientation == false) { @@ -15639,6 +18627,10 @@ Phaser.StageScaleMode.prototype = { }, + /** + * Sets this.width equal to window.innerWidth and this.height equal to window.innerHeight + * @method Phaser.StageScaleMode#setMaximum + */ setMaximum: function () { this.width = window.innerWidth; @@ -15646,6 +18638,10 @@ Phaser.StageScaleMode.prototype = { }, + /** + * Calculates the multiplier needed to scale the game proportionally. + * @method Phaser.StageScaleMode#setShowAll + */ setShowAll: function () { var multiplier = Math.min((window.innerHeight / this.game.height), (window.innerWidth / this.game.width)); @@ -15655,12 +18651,16 @@ Phaser.StageScaleMode.prototype = { }, + /** + * Sets the width and height values of the canvas, no larger than the maxWidth/Height. + * @method Phaser.StageScaleMode#setExactFit + */ setExactFit: function () { var availableWidth = window.innerWidth - 0; var availableHeight = window.innerHeight - 5; - console.log('available', availableWidth, availableHeight); + // console.log('available', availableWidth, availableHeight); if (this.maxWidth && availableWidth > this.maxWidth) { @@ -15686,6 +18686,11 @@ Phaser.StageScaleMode.prototype = { }; +/** +* @name Phaser.StageScaleMode#isFullScreen +* @property {boolean} isFullScreen - Returns true if the browser is in full screen mode, otherwise false. +* @readonly +*/ Object.defineProperty(Phaser.StageScaleMode.prototype, "isFullScreen", { get: function () { @@ -15701,6 +18706,11 @@ Object.defineProperty(Phaser.StageScaleMode.prototype, "isFullScreen", { }); +/** +* @name Phaser.StageScaleMode#isPortrait +* @property {boolean} isPortrait - Returns true if the browser dimensions match a portrait display. +* @readonly +*/ Object.defineProperty(Phaser.StageScaleMode.prototype, "isPortrait", { get: function () { @@ -15709,6 +18719,11 @@ Object.defineProperty(Phaser.StageScaleMode.prototype, "isPortrait", { }); +/** +* @name Phaser.StageScaleMode#isLandscape +* @property {boolean} isLandscape - Returns true if the browser dimensions match a landscape display. +* @readonly +*/ Object.defineProperty(Phaser.StageScaleMode.prototype, "isLandscape", { get: function () { @@ -15717,188 +18732,193 @@ Object.defineProperty(Phaser.StageScaleMode.prototype, "isLandscape", { }); +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ /** -* Phaser - Device -* * Detects device support capabilities. Using some elements from System.js by MrDoob and Modernizr -* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/audio.js +* +* @class Phaser.Device +* @constructor */ Phaser.Device = function () { /** - * An optional 'fix' for the horrendous Android stock browser bug - * https://code.google.com/p/android/issues/detail?id=39247 - * @type {boolean} + * An optional 'fix' for the horrendous Android stock browser bug https://code.google.com/p/android/issues/detail?id=39247 + * @property {boolean} patchAndroidClearRectBug - Description. + * @default */ this.patchAndroidClearRectBug = false; // Operating System /** - * Is running desktop? - * @type {boolean} + * @property {boolean} desktop - Is running desktop? + * @default */ this.desktop = false; /** - * Is running on iOS? - * @type {boolean} + * @property {boolean} iOS - Is running on iOS? + * @default */ this.iOS = false; /** - * Is running on android? - * @type {boolean} + * @property {boolean} android - Is running on android? + * @default */ this.android = false; /** - * Is running on chromeOS? - * @type {boolean} + * @property {boolean} chromeOS - Is running on chromeOS? + * @default */ this.chromeOS = false; /** - * Is running on linux? - * @type {boolean} + * @property {boolean} linux - Is running on linux? + * @default */ this.linux = false; /** - * Is running on maxOS? - * @type {boolean} + * @property {boolean} macOS - Is running on macOS? + * @default */ this.macOS = false; /** - * Is running on windows? - * @type {boolean} + * @property {boolean} windows - Is running on windows? + * @default */ this.windows = false; // Features /** - * Is canvas available? - * @type {boolean} + * @property {boolean} canvas - Is canvas available? + * @default */ this.canvas = false; /** - * Is file available? - * @type {boolean} + * @property {boolean} file - Is file available? + * @default */ this.file = false; /** - * Is fileSystem available? - * @type {boolean} + * @property {boolean} fileSystem - Is fileSystem available? + * @default */ this.fileSystem = false; /** - * Is localStorage available? - * @type {boolean} + * @property {boolean} localStorage - Is localStorage available? + * @default */ this.localStorage = false; /** - * Is webGL available? - * @type {boolean} + * @property {boolean} webGL - Is webGL available? + * @default */ this.webGL = false; /** - * Is worker available? - * @type {boolean} + * @property {boolean} worker - Is worker available? + * @default */ this.worker = false; /** - * Is touch available? - * @type {boolean} + * @property {boolean} touch - Is touch available? + * @default */ this.touch = false; /** - * Is mspointer available? - * @type {boolean} + * @property {boolean} mspointer - Is mspointer available? + * @default */ this.mspointer = false; /** - * Is css3D available? - * @type {boolean} + * @property {boolean} css3D - Is css3D available? + * @default */ this.css3D = false; - /** - * Is Pointer Lock available? - * @type {boolean} + /** + * @property {boolean} pointerLock - Is Pointer Lock available? + * @default */ this.pointerLock = false; // Browser /** - * Is running in arora? - * @type {boolean} + * @property {boolean} arora - Is running in arora? + * @default */ this.arora = false; /** - * Is running in chrome? - * @type {boolean} + * @property {boolean} chrome - Is running in chrome? + * @default */ this.chrome = false; /** - * Is running in epiphany? - * @type {boolean} + * @property {boolean} epiphany - Is running in epiphany? + * @default */ this.epiphany = false; /** - * Is running in firefox? - * @type {boolean} + * @property {boolean} firefox - Is running in firefox? + * @default */ this.firefox = false; /** - * Is running in ie? - * @type {boolean} + * @property {boolean} ie - Is running in ie? + * @default */ this.ie = false; /** - * Version of ie? - * @type Number + * @property {number} ieVersion - Version of ie? + * @default */ this.ieVersion = 0; /** - * Is running in mobileSafari? - * @type {boolean} + * @property {boolean} mobileSafari - Is running in mobileSafari? + * @default */ this.mobileSafari = false; /** - * Is running in midori? - * @type {boolean} + * @property {boolean} midori - Is running in midori? + * @default */ this.midori = false; /** - * Is running in opera? - * @type {boolean} + * @property {boolean} opera - Is running in opera? + * @default */ this.opera = false; /** - * Is running in safari? - * @type {boolean} + * @property {boolean} safari - Is running in safari? + * @default */ this.safari = false; this.webApp = false; @@ -15906,75 +18926,76 @@ Phaser.Device = function () { // Audio /** - * Are Audio tags available? - * @type {boolean} + * @property {boolean} audioData - Are Audio tags available? + * @default */ this.audioData = false; /** - * Is the WebAudio API available? - * @type {boolean} + * @property {boolean} webAudio - Is the WebAudio API available? + * @default */ this.webAudio = false; /** - * Can this device play ogg files? - * @type {boolean} + * @property {boolean} ogg - Can this device play ogg files? + * @default */ this.ogg = false; /** - * Can this device play opus files? - * @type {boolean} + * @property {boolean} opus - Can this device play opus files? + * @default */ this.opus = false; /** - * Can this device play mp3 files? - * @type {boolean} + * @property {boolean} mp3 - Can this device play mp3 files? + * @default */ this.mp3 = false; /** - * Can this device play wav files? - * @type {boolean} + * @property {boolean} wav - Can this device play wav files? + * @default */ this.wav = false; /** * Can this device play m4a files? - * @type {boolean} + * @property {boolean} m4a - True if this device can play m4a files. + * @default */ this.m4a = false; /** - * Can this device play webm files? - * @type {boolean} + * @property {boolean} webm - Can this device play webm files? + * @default */ this.webm = false; // Device /** - * Is running on iPhone? - * @type {boolean} + * @property {boolean} iPhone - Is running on iPhone? + * @default */ this.iPhone = false; /** - * Is running on iPhone4? - * @type {boolean} + * @property {boolean} iPhone4 - Is running on iPhone4? + * @default */ this.iPhone4 = false; - /** - * Is running on iPad? - * @type {boolean} + /** + * @property {boolean} iPad - Is running on iPad? + * @default */ this.iPad = false; /** - * PixelRatio of the host device? - * @type Number + * @property {number} pixelRatio - PixelRatio of the host device? + * @default */ this.pixelRatio = 0; @@ -15992,6 +19013,7 @@ Phaser.Device.prototype = { /** * Check which OS is game running on. + * @method Phaser.Device#_checkOS * @private */ _checkOS: function () { @@ -16020,6 +19042,7 @@ Phaser.Device.prototype = { /** * Check HTML5 features of the host environment. + * @method Phaser.Device#_checkFeatures * @private */ _checkFeatures: function () { @@ -16034,8 +19057,17 @@ Phaser.Device.prototype = { this.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob']; this.fileSystem = !!window['requestFileSystem']; - this.webGL = ( function () { try { return !! window.WebGLRenderingContext && !! document.createElement( 'canvas' ).getContext( 'experimental-webgl' ); } catch( e ) { return false; } } )(); - // this.webGL = !!window['WebGLRenderingContext']; + this.webGL = ( function () { try { var canvas = document.createElement( 'canvas' ); return !! window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ); } catch( e ) { return false; } } )(); + + if (this.webGL === null) + { + this.webGL = false; + } + else + { + this.webGL = true; + } + this.worker = !!window['Worker']; if ('ontouchstart' in document.documentElement || window.navigator.msPointerEnabled) { @@ -16052,6 +19084,7 @@ Phaser.Device.prototype = { /** * Check what browser is game running in. + * @method Phaser.Device#_checkBrowser * @private */ _checkBrowser: function () { @@ -16088,6 +19121,7 @@ Phaser.Device.prototype = { /** * Check audio support. + * @method Phaser.Device#_checkAudio * @private */ _checkAudio: function () { @@ -16134,6 +19168,7 @@ Phaser.Device.prototype = { /** * Check PixelRatio of devices. + * @method Phaser.Device#_checkDevice * @private */ _checkDevice: function () { @@ -16147,9 +19182,11 @@ Phaser.Device.prototype = { /** * Check whether the host environment support 3D CSS. + * @method Phaser.Device#_checkCSS3D * @private */ _checkCSS3D: function () { + var el = document.createElement('p'); var has3d; var transforms = { @@ -16159,6 +19196,7 @@ Phaser.Device.prototype = { 'MozTransform': '-moz-transform', 'transform': 'transform' }; + // Add it to the body to get the computed style. document.body.insertBefore(el, null); @@ -16168,22 +19206,38 @@ Phaser.Device.prototype = { has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]); } } + document.body.removeChild(el); this.css3D = (has3d !== undefined && has3d.length > 0 && has3d !== "none"); }, + /** + * Check whether the host environment can play audio. + * @method Phaser.Device#canPlayAudio + * @param {string} type - One of 'mp3, 'ogg', 'm4a', 'wav', 'webm'. + * @return {boolean} True if the given file type is supported by the browser, otherwise false. + */ canPlayAudio: function (type) { - if (type == 'mp3' && this.mp3) { + if (type == 'mp3' && this.mp3) + { return true; - } else if (type == 'ogg' && (this.ogg || this.opus)) { + } + else if (type == 'ogg' && (this.ogg || this.opus)) + { return true; - } else if (type == 'm4a' && this.m4a) { + } + else if (type == 'm4a' && this.m4a) + { return true; - } else if (type == 'wav' && this.wav) { + } + else if (type == 'wav' && this.wav) + { return true; - } else if (type == 'webm' && this.webm) { + } + else if (type == 'webm' && this.webm) + { return true; } @@ -16191,17 +19245,25 @@ Phaser.Device.prototype = { }, + /** + * Check whether the console is open. + * @method Phaser.Device#isConsoleOpen + * @return {boolean} True if the browser dev console is open. + */ isConsoleOpen: function () { - if (window.console && window.console['firebug']) { + if (window.console && window.console['firebug']) + { return true; } - if (window.console) { + if (window.console) + { console.profile(); console.profileEnd(); - if (console.clear) { + if (console.clear) + { console.clear(); } @@ -16215,15 +19277,35 @@ Phaser.Device.prototype = { }; /** -* Phaser - RequestAnimationFrame -* +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** * Abstracts away the use of RAF or setTimeOut for the core game update loop. +* +* @class Phaser.RequestAnimationFrame +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.RequestAnimationFrame = function(game) { + /** + * @property {Phaser.Game} game - The currently running game. + */ this.game = game; + /** + * @property {boolean} _isSetTimeOut - Description. + * @private + */ this._isSetTimeOut = false; + + /** + * @property {boolean} isRunning - Description. + * @default + */ this.isRunning = false; var vendors = [ @@ -16233,25 +19315,28 @@ Phaser.RequestAnimationFrame = function(game) { 'o' ]; - for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++) { + for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++) + { window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame']; window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame']; } + /** + * The function called by the update + * @property _onLoop + * @private + */ + this._onLoop = null; + }; Phaser.RequestAnimationFrame.prototype = { - /** - * The function called by the update - * @private - **/ - _onLoop: null, /** * Starts the requestAnimatioFrame running or setTimeout if unavailable in browser - * @method start - **/ + * @method Phaser.RequestAnimationFrame#start + */ start: function () { this.isRunning = true; @@ -16283,8 +19368,9 @@ Phaser.RequestAnimationFrame.prototype = { /** * The update method for the requestAnimationFrame - * @method RAFUpdate - **/ + * @method Phaser.RequestAnimationFrame#updateRAF + * @param {number} time - A timestamp, either from RAF or setTimeOut + */ updateRAF: function (time) { this.game.update(time); @@ -16294,9 +19380,9 @@ Phaser.RequestAnimationFrame.prototype = { }, /** - * The update method for the setTimeout - * @method SetTimeoutUpdate - **/ + * The update method for the setTimeout. + * @method Phaser.RequestAnimationFrame#updateSetTimeout + */ updateSetTimeout: function () { this.game.update(Date.now()); @@ -16306,9 +19392,9 @@ Phaser.RequestAnimationFrame.prototype = { }, /** - * Stops the requestAnimationFrame from running - * @method stop - **/ + * Stops the requestAnimationFrame from running. + * @method Phaser.RequestAnimationFrame#stop + */ stop: function () { if (this._isSetTimeOut) @@ -16326,29 +19412,39 @@ Phaser.RequestAnimationFrame.prototype = { /** * Is the browser using setTimeout? - * @method isSetTimeOut - * @return bool - **/ + * @method Phaser.RequestAnimationFrame#isSetTimeOut + * @return {boolean} + */ isSetTimeOut: function () { return this._isSetTimeOut; }, /** * Is the browser using requestAnimationFrame? - * @method isRAF - * @return bool - **/ + * @method Phaser.RequestAnimationFrame#isRAF + * @return {boolean} + */ isRAF: function () { return (this._isSetTimeOut === false); } }; /** -* Phaser.RandomDataGenerator -* -* An extremely useful repeatable random data generator. Access it via Phaser.Game.rnd -* Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser.RandomDataGenerator constructor. +* +* @class Phaser.RandomDataGenerator +* @classdesc An extremely useful repeatable random data generator. Access it via Phaser.Game.rnd +* Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense. * Random number generator from http://baagoe.org/en/wiki/Better_random_numbers_for_javascript +* +* @constructor +* @param {array} seeds */ Phaser.RandomDataGenerator = function (seeds) { @@ -16361,37 +19457,34 @@ Phaser.RandomDataGenerator = function (seeds) { Phaser.RandomDataGenerator.prototype = { /** - * @property c - * @type Number + * @property {number} c * @private */ c: 1, /** - * @property s0 - * @type Number + * @property {number} s0 * @private */ s0: 0, /** - * @property s1 - * @type Number + * @property {number} s1 * @private */ s1: 0, /** - * @property s2 - * @type Number + * @property {number} s2 * @private */ s2: 0, /** - * Private random helper - * @method rnd + * Private random helper. + * @method Phaser.RandomDataGenerator#rnd * @private + * @return {number} Description. */ rnd: function () { @@ -16406,9 +19499,10 @@ Phaser.RandomDataGenerator.prototype = { }, /** - * Reset the seed of the random data generator - * @method sow - * @param {Array} seeds + * Reset the seed of the random data generator. + * + * @method Phaser.RandomDataGenerator#sow + * @param {array} seeds */ sow: function (seeds) { @@ -16417,10 +19511,12 @@ Phaser.RandomDataGenerator.prototype = { this.s0 = this.hash(' '); this.s1 = this.hash(this.s0); this.s2 = this.hash(this.s1); + this.c = 1; var seed; - for (var i = 0; seed = seeds[i++]; ) { + for (var i = 0; seed = seeds[i++]; ) + { this.s0 -= this.hash(seed); this.s0 += ~~(this.s0 < 0); this.s1 -= this.hash(seed); @@ -16432,9 +19528,11 @@ Phaser.RandomDataGenerator.prototype = { }, /** - * @method hash + * Description. + * @method Phaser.RandomDataGenerator#hash * @param {Any} data * @private + * @return {number} Description. */ hash: function (data) { @@ -16458,72 +19556,69 @@ Phaser.RandomDataGenerator.prototype = { }, /** - * Returns a random integer between 0 and 2^32 - * @method integer - * @return {Number} + * Returns a random integer between 0 and 2^32. + * @method Phaser.RandomDataGenerator#integer + * @return {number} */ integer: function() { return this.rnd.apply(this) * 0x100000000;// 2^32 }, /** - * Returns a random real number between 0 and 1 - * @method frac - * @return {Number} + * Returns a random real number between 0 and 1. + * @method Phaser.RandomDataGenerator#frac + * @return {number} */ frac: function() { return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16;// 2^-53 }, /** - * Returns a random real number between 0 and 2^32 - * @method real - * @return {Number} + * Returns a random real number between 0 and 2^32. + * @method Phaser.RandomDataGenerator#real + * @return {number} */ real: function() { return this.integer() + this.frac(); }, /** - * Returns a random integer between min and max - * @method integerInRange - * @param {Number} min - * @param {Number} max - * @return {Number} + * Returns a random integer between min and max. + * @method Phaser.RandomDataGenerator#integerInRange + * @param {number} min + * @param {number} max + * @return {number} */ integerInRange: function (min, max) { return Math.floor(this.realInRange(min, max)); }, /** - * Returns a random real number between min and max - * @method realInRange - * @param {Number} min - * @param {Number} max - * @return {Number} + * Returns a random real number between min and max. + * @method Phaser.RandomDataGenerator#realInRange + * @param {number} min + * @param {number} max + * @return {number} */ realInRange: function (min, max) { - min = min || 0; - max = max || 0; - return this.frac() * (max - min) + min; }, /** - * Returns a random real number between -1 and 1 - * @method normal - * @return {Number} + * Returns a random real number between -1 and 1. + * @method Phaser.RandomDataGenerator#normal + * @return {number} */ normal: function () { return 1 - 2 * this.frac(); }, /** - * Returns a valid RFC4122 version4 ID hex string (from https://gist.github.com/1308368) - * @method uuid - * @return {String} + * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 + * @method Phaser.RandomDataGenerator#uuid + * @return {string} */ uuid: function () { @@ -16540,36 +19635,40 @@ Phaser.RandomDataGenerator.prototype = { }, /** - * Returns a random member of `array` - * @method pick - * @param {Any} array + * Returns a random member of `array`. + * @method Phaser.RandomDataGenerator#pick + * @param {Any} ary + * @return {number} */ pick: function (ary) { return ary[this.integerInRange(0, ary.length)]; }, /** - * Returns a random member of `array`, favoring the earlier entries - * @method weightedPick - * @param {Any} array + * Returns a random member of `array`, favoring the earlier entries. + * @method Phaser.RandomDataGenerator#weightedPick + * @param {Any} ary + * @return {number} */ weightedPick: function (ary) { return ary[~~(Math.pow(this.frac(), 2) * ary.length)]; }, /** - * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified - * @method timestamp - * @param {Number} min - * @param {Number} max + * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. + * @method Phaser.RandomDataGenerator#timestamp + * @param {number} min + * @param {number} max + * @return {number} */ timestamp: function (a, b) { return this.realInRange(a || 946684800000, b || 1577862000000); }, /** - * Returns a random angle between -180 and 180 - * @method angle + * Returns a random angle between -180 and 180. + * @method Phaser.RandomDataGenerator#angle + * @return {number} */ angle: function() { return this.integerInRange(-180, 180); @@ -16577,35 +19676,91 @@ Phaser.RandomDataGenerator.prototype = { }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* A collection of mathematical methods. +* +* @class Phaser.Math +*/ Phaser.Math = { + /** + * = 2 π + * @method Phaser.Math#PI2 + */ PI2: Math.PI * 2, + /** + * Two number are fuzzyEqual if their difference is less than ε. + * @method Phaser.Math#fuzzyEqual + * @param {number} a + * @param {number} b + * @param {number} epsilon + * @return {boolean} True if |a-b|<ε + */ fuzzyEqual: function (a, b, epsilon) { if (typeof epsilon === "undefined") { epsilon = 0.0001; } return Math.abs(a - b) < epsilon; }, + /** + * a is fuzzyLessThan b if it is less than b + ε. + * @method Phaser.Math#fuzzyEqual + * @param {number} a + * @param {number} b + * @param {number} epsilon + * @return {boolean} True if ab+ε + */ fuzzyGreaterThan: function (a, b, epsilon) { if (typeof epsilon === "undefined") { epsilon = 0.0001; } return a > b - epsilon; }, + /** + * @method Phaser.Math#fuzzyCeil + * @param {number} val + * @param {number} epsilon + * @return {boolean} ceiling(val-ε) + */ fuzzyCeil: function (val, epsilon) { if (typeof epsilon === "undefined") { epsilon = 0.0001; } return Math.ceil(val - epsilon); }, + /** + * @method Phaser.Math#fuzzyFloor + * @param {number} val + * @param {number} epsilon + * @return {boolean} floor(val-ε) + */ fuzzyFloor: function (val, epsilon) { if (typeof epsilon === "undefined") { epsilon = 0.0001; } return Math.floor(val + epsilon); }, + /** + * Averages all values passed to the function and returns the result. You can pass as many parameters as you like. + * @method Phaser.Math#average + * @return {number} The average of all given values. + */ average: function () { var args = []; @@ -16624,10 +19779,20 @@ Phaser.Math = { }, + /** + * @method Phaser.Math#truncate + * @param {number} n + * @return {number} + */ truncate: function (n) { return (n > 0) ? Math.floor(n) : Math.ceil(n); }, + /** + * @method Phaser.Math#shear + * @param {number} n + * @return {number} n mod 1 + */ shear: function (n) { return n % 1; }, @@ -16635,11 +19800,13 @@ Phaser.Math = { /** * Snap a value to nearest grid slice, using rounding. * - * example if you have an interval gap of 5 and a position of 12... you will snap to 10. Where as 14 will snap to 15 + * Example: if you have an interval gap of 5 and a position of 12... you will snap to 10 whereas 14 will snap to 15. * - * @param input - the value to snap - * @param gap - the interval gap of the grid - * @param [start] - optional starting offset for gap + * @method Phaser.Math#snapTo + * @param {number} input - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start] - Optional starting offset for gap. + * @return {number} */ snapTo: function (input, gap, start) { @@ -16659,11 +19826,13 @@ Phaser.Math = { /** * Snap a value to nearest grid slice, using floor. * - * example if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15 + * Example: if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15 * - * @param input - the value to snap - * @param gap - the interval gap of the grid - * @param [start] - optional starting offset for gap + * @method Phaser.Math#snapToFloor + * @param {number} input - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start] - Optional starting offset for gap. + * @return {number} */ snapToFloor: function (input, gap, start) { @@ -16683,11 +19852,13 @@ Phaser.Math = { /** * Snap a value to nearest grid slice, using ceil. * - * example if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20 + * Example: if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20. * - * @param input - the value to snap - * @param gap - the interval gap of the grid - * @param [start] - optional starting offset for gap + * @method Phaser.Math#snapToCeil + * @param {number} input - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start] - Optional starting offset for gap. + * @return {number} */ snapToCeil: function (input, gap, start) { @@ -16707,6 +19878,11 @@ Phaser.Math = { /** * Snaps a value to the nearest value in an array. + * @method Phaser.Math#snapToInArray + * @param {number} input + * @param {array} arr + * @param {boolean} sort - True if the array needs to be sorted. + * @return {number} */ snapToInArray: function (input, arr, sort) { @@ -16734,16 +19910,10 @@ Phaser.Math = { }, /** - * roundTo some place comparative to a 'base', default is 10 for decimal place + * Round to some place comparative to a 'base', default is 10 for decimal place. * * 'place' is represented by the power applied to 'base' to get that place - * - * @param value - the value to round - * @param place - the place to round to - * @param base - the base to round in... default is 10 for decimal - * * e.g. - * * 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011 * * roundTo(2000/7,3) == 0 @@ -16766,8 +19936,14 @@ Phaser.Math = { * roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011 * roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111 * - * note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed + * Note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed * because we are rounding 100011.1011011011011011 which rounds up. + * + * @method Phaser.Math#roundTo + * @param {number} value - The value to round. + * @param {number} place - The place to round to. + * @param {number} base - The base to round in... default is 10 for decimal. + * @return {number} */ roundTo: function (value, place, base) { @@ -16780,6 +19956,13 @@ Phaser.Math = { }, + /** + * @method Phaser.Math#floorTo + * @param {number} value - The value to round. + * @param {number} place - The place to round to. + * @param {number} base - The base to round in... default is 10 for decimal. + * @return {number} + */ floorTo: function (value, place, base) { if (typeof place === "undefined") { place = 0; } @@ -16791,6 +19974,13 @@ Phaser.Math = { }, + /** + * @method Phaser.Math#ceilTo + * @param {number} value - The value to round. + * @param {number} place - The place to round to. + * @param {number} base - The base to round in... default is 10 for decimal. + * @return {number} + */ ceilTo: function (value, place, base) { if (typeof place === "undefined") { place = 0; } @@ -16803,34 +19993,54 @@ Phaser.Math = { }, /** - * a one dimensional linear interpolation of a value. + * A one dimensional linear interpolation of a value. + * @method Phaser.Math#interpolateFloat + * @param {number} a + * @param {number} b + * @param {number} weight + * @return {number} */ interpolateFloat: function (a, b, weight) { return (b - a) * weight + a; }, /** - * Find the angle of a segment from (x1, y1) -> (x2, y2 ) + * Find the angle of a segment from (x1, y1) -> (x2, y2 ). + * @method Phaser.Math#angleBetween + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @return {number} */ angleBetween: function (x1, y1, x2, y2) { return Math.atan2(y2 - y1, x2 - x1); }, /** - * set an angle within the bounds of -PI to PI + * Set an angle within the bounds of -π toπ. + * @method Phaser.Math#normalizeAngle + * @param {number} angle + * @param {boolean} radians - True if angle size is expressed in radians. + * @return {number} */ normalizeAngle: function (angle, radians) { if (typeof radians === "undefined") { radians = true; } - var rd = (radians) ? Math.PI : 180; - return this.wrap(angle, -rd, rd); + var rd = (radians) ? GameMath.PI : 180; + return this.wrap(angle, rd, -rd); }, /** - * closest angle between two angles from a1 to a2 + * Closest angle between two angles from a1 to a2 * absolute value the return for exact angle + * @method Phaser.Math#nearestAngleBetween + * @param {number} a1 + * @param {number} a2 + * @param {boolean} radians - True if angle sizes are expressed in radians. + * @return {number} */ nearestAngleBetween: function (a1, a2, radians) { @@ -16855,7 +20065,14 @@ Phaser.Math = { }, /** - * interpolate across the shortest arc between two angles + * Interpolate across the shortest arc between two angles. + * @method Phaser.Math#interpolateAngles + * @param {number} a1 - Description. + * @param {number} a2 - Description. + * @param {number} weight - Description. + * @param {boolean} radians - True if angle sizes are expressed in radians. + * @param {Description} ease - Description. + * @return {number} */ interpolateAngles: function (a1, a2, weight, radians, ease) { @@ -16870,13 +20087,14 @@ Phaser.Math = { }, /** - * Generate a random bool result based on the chance value + * Generate a random bool result based on the chance value. *

    * Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance * of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed. *

    - * @param chance The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%) - * @return true if the roll passed, or false + * @method Phaser.Math#chanceRoll + * @param {number} chance - The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%). + * @return {boolean} True if the roll passed, or false otherwise. */ chanceRoll: function (chance) { @@ -16905,11 +20123,12 @@ Phaser.Math = { }, /** - * Returns an Array containing the numbers from min to max (inclusive) + * Returns an Array containing the numbers from min to max (inclusive). * - * @param min The minimum value the array starts with - * @param max The maximum value the array contains - * @return The array of number values + * @method Phaser.Math#numberArray + * @param {number} min - The minimum value the array starts with. + * @param {number} max - The maximum value the array contains. + * @return {array} The array of number values. */ numberArray: function (min, max) { @@ -16925,12 +20144,13 @@ Phaser.Math = { }, /** - * Adds the given amount to the value, but never lets the value go over the specified maximum + * Adds the given amount to the value, but never lets the value go over the specified maximum. * - * @param value The value to add the amount to - * @param amount The amount to add to the value - * @param max The maximum the value is allowed to be - * @return The new value + * @method Phaser.Math#maxAdd + * @param {number} value - The value to add the amount to. + * @param {number} amount - The amount to add to the value. + * @param {number} max- The maximum the value is allowed to be. + * @return {number} */ maxAdd: function (value, amount, max) { @@ -16946,12 +20166,13 @@ Phaser.Math = { }, /** - * Subtracts the given amount from the value, but never lets the value go below the specified minimum + * Subtracts the given amount from the value, but never lets the value go below the specified minimum. * - * @param value The base value - * @param amount The amount to subtract from the base value - * @param min The minimum the value is allowed to be - * @return The new value + * @method Phaser.Math#minSub + * @param {number} value - The base value. + * @param {number} amount - The amount to subtract from the base value. + * @param {number} min - The minimum the value is allowed to be. + * @return {number} The new value. */ minSub: function (value, amount, min) { @@ -16970,34 +20191,41 @@ Phaser.Math = { * Ensures that the value always stays between min and max, by wrapping the value around. *

    max should be larger than min, or the function will return 0

    * + * @method Phaser.Math#wrap * @param value The value to wrap * @param min The minimum the value is allowed to be * @param max The maximum the value is allowed to be - * @return The wrapped value + * @return {number} The wrapped value */ wrap: function (value, min, max) { var range = max - min; + if (range <= 0) { return 0; } + var result = (value - min) % range; + if (result < 0) { result += range; } + return result + min; + }, /** * Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around. *

    Values must be positive integers, and are passed through Math.abs

    * - * @param value The value to add the amount to - * @param amount The amount to add to the value - * @param max The maximum the value is allowed to be - * @return The wrapped value + * @method Phaser.Math#wrapValue + * @param {number} value - The value to add the amount to. + * @param {number} amount - The amount to add to the value. + * @param {number} max - The maximum the value is allowed to be. + * @return {number} The wrapped value. */ wrapValue: function (value, amount, max) { @@ -17012,9 +20240,10 @@ Phaser.Math = { }, /** - * Randomly returns either a 1 or -1 + * Randomly returns either a 1 or -1. * - * @return 1 or -1 + * @method Phaser.Math#randomSign + * @return {number} 1 or -1 */ randomSign: function () { return (Math.random() > 0.5) ? 1 : -1; @@ -17023,9 +20252,9 @@ Phaser.Math = { /** * Returns true if the number given is odd. * - * @param n The number to check - * - * @return True if the given number is odd. False if the given number is even. + * @method Phaser.Math#isOdd + * @param {number} n - The number to check. + * @return {boolean} True if the given number is odd. False if the given number is even. */ isOdd: function (n) { @@ -17036,9 +20265,9 @@ Phaser.Math = { /** * Returns true if the number given is even. * - * @param n The number to check - * - * @return True if the given number is even. False if the given number is odd. + * @method Phaser.Math#isEven + * @param {number} n - The number to check. + * @return {boolean} True if the given number is even. False if the given number is odd. */ isEven: function (n) { @@ -17057,7 +20286,8 @@ Phaser.Math = { * Significantly faster version of Math.max * See http://jsperf.com/math-s-min-max-vs-homemade/5 * - * @return The highest value from those given. + * @method Phaser.Math#max + * @return {number} The highest value from those given. */ max: function () { @@ -17077,7 +20307,8 @@ Phaser.Math = { * Significantly faster version of Math.min * See http://jsperf.com/math-s-min-max-vs-homemade/5 * - * @return The lowest value from those given. + * @method Phaser.Math#min + * @return {number} The lowest value from those given. */ min: function () { @@ -17097,9 +20328,9 @@ Phaser.Math = { * Keeps an angle value between -180 and +180
    * Should be called whenever the angle is updated on the Sprite to stop it from going insane. * - * @param angle The angle value to check - * - * @return The new angle value, returns the same as the input angle if it was within bounds + * @method Phaser.Math#wrapAngle + * @param {number} angle - The angle value to check + * @return {number} The new angle value, returns the same as the input angle if it was within bounds. */ wrapAngle: function (angle) { @@ -17124,63 +20355,86 @@ Phaser.Math = { }, /** - * Keeps an angle value between the given min and max values + * Keeps an angle value between the given min and max values. * - * @param angle The angle value to check. Must be between -180 and +180 - * @param min The minimum angle that is allowed (must be -180 or greater) - * @param max The maximum angle that is allowed (must be 180 or less) + * @method Phaser.Math#angleLimit + * @param {number} angle - The angle value to check. Must be between -180 and +180. + * @param {number} min - The minimum angle that is allowed (must be -180 or greater). + * @param {number} max - The maximum angle that is allowed (must be 180 or less). * - * @return The new angle value, returns the same as the input angle if it was within bounds + * @return {number} The new angle value, returns the same as the input angle if it was within bounds */ angleLimit: function (angle, min, max) { + var result = angle; - if (angle > max) { + + if (angle > max) + { result = max; - } else if (angle < min) { + } + else if (angle < min) + { result = min; } + return result; + }, /** - * @method linearInterpolation - * @param {Any} v - * @param {Any} k - * @public + * Description. + * @method Phaser.Math#linearInterpolation + * @param {number} v + * @param {number} k + * @return {number} */ linearInterpolation: function (v, k) { + var m = v.length - 1; var f = m * k; var i = Math.floor(f); - if (k < 0) { + + if (k < 0) + { return this.linear(v[0], v[1], f); } - if (k > 1) { + + if (k > 1) + { return this.linear(v[m], v[m - 1], m - f); } + return this.linear(v[i], v[i + 1 > m ? m : i + 1], f - i); + }, /** - * @method bezierInterpolation - * @param {Any} v - * @param {Any} k - * @public + * Description. + * @method Phaser.Math#bezierInterpolation + * @param {number} v + * @param {number} k + * @return {number} */ bezierInterpolation: function (v, k) { + var b = 0; var n = v.length - 1; - for (var i = 0; i <= n; i++) { + + for (var i = 0; i <= n; i++) + { b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * this.bernstein(n, i); } + return b; + }, /** - * @method catmullRomInterpolation - * @param {Any} v - * @param {Any} k - * @public + * Description. + * @method Phaser.Math#catmullRomInterpolation + * @param {number} v + * @param {number} k + * @return {number} */ catmullRomInterpolation: function (v, k) { @@ -17188,57 +20442,79 @@ Phaser.Math = { var f = m * k; var i = Math.floor(f); - if (v[0] === v[m]) { - if (k < 0) { + if (v[0] === v[m]) + { + if (k < 0) + { i = Math.floor(f = m * (1 + k)); } + return this.catmullRom(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); - } else { - if (k < 0) { + + } + else + { + if (k < 0) + { return v[0] - (this.catmullRom(v[0], v[0], v[1], v[1], -f) - v[0]); } - if (k > 1) { + + if (k > 1) + { return v[m] - (this.catmullRom(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); } + return this.catmullRom(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); } + }, /** - * @method Linear - * @param {Any} p0 - * @param {Any} p1 - * @param {Any} t - * @public + * Description. + * @method Phaser.Math#Linear + * @param {number} p0 + * @param {number} p1 + * @param {number} t + * @return {number} */ linear: function (p0, p1, t) { return (p1 - p0) * t + p0; }, /** - * @method bernstein - * @param {Any} n - * @param {Any} i - * @public + * @method Phaser.Math#bernstein + * @param {number} n + * @param {number} i + * @return {number} */ bernstein: function (n, i) { return this.factorial(n) / this.factorial(i) / this.factorial(n - i); }, /** - * @method catmullRom - * @param {Any} p0 - * @param {Any} p1 - * @param {Any} p2 - * @param {Any} p3 - * @param {Any} t - * @public + * Description. + * @method Phaser.Math#catmullRom + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @return {number} */ catmullRom: function (p0, p1, p2, p3, t) { + var v0 = (p2 - p0) * 0.5, v1 = (p3 - p1) * 0.5, t2 = t * t, t3 = t * t2; + return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; + }, + /** + * @method Phaser.Math#difference + * @param {number} a + * @param {number} b + * @return {number} + */ difference: function (a, b) { return Math.abs(a - b); }, @@ -17247,11 +20523,11 @@ Phaser.Math = { * Fetch a random entry from the given array. * Will return null if random selection is missing, or array has no entries. * - * @param objects An array of objects. - * @param startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array. - * @param length Optional restriction on the number of values you want to randomly select from. - * - * @return The random object that was selected. + * @method Phaser.Math#getRandom + * @param {array} objects - An array of objects. + * @param {number} startIndex - Optional offset off the front of the array. Default value is 0, or the beginning of the array. + * @param {number} length - Optional restriction on the number of values you want to randomly select from. + * @return {object} The random object that was selected. */ getRandom: function (objects, startIndex, length) { @@ -17280,9 +20556,9 @@ Phaser.Math = { /** * Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2. * - * @param Value Any number. - * - * @return The rounded value of that number. + * @method Phaser.Math#floor + * @param {number} Value Any number. + * @return {number} The rounded value of that number. */ floor: function (value) { @@ -17295,9 +20571,9 @@ Phaser.Math = { /** * Round up to the next whole number. E.g. ceil(1.3) == 2, and ceil(-2.3) == -3. * - * @param Value Any number. - * - * @return The rounded value of that number. + * @method Phaser.Math#ceil + * @param {number} value - Any number. + * @return {number} The rounded value of that number. */ ceil: function (value) { var n = value | 0; @@ -17310,13 +20586,12 @@ Phaser.Math = { * The parameters allow you to specify the length, amplitude and frequency of the wave. Once you have called this function * you should get the results via getSinTable() and getCosTable(). This generator is fast enough to be used in real-time. *

    - * @param length The length of the wave - * @param sinAmplitude The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value - * @param cosAmplitude The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value - * @param frequency The frequency of the sine and cosine table data - * @return Returns the sine table - * @see getSinTable - * @see getCosTable + * @method Phaser.Math#sinCosGenerator + * @param {number} length - The length of the wave + * @param {number} sinAmplitude - The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value + * @param {number} cosAmplitude - The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value + * @param {number} frequency - The frequency of the sine and cosine table data + * @return {Array} Returns the sine table */ sinCosGenerator: function (length, sinAmplitude, cosAmplitude, frequency) { @@ -17347,9 +20622,11 @@ Phaser.Math = { /** * Removes the top element from the stack and re-inserts it onto the bottom, then returns it. - * The original stack is modified in the process. - * This effectively moves the position of the data from the start to the end of the table. - * @return The value. + * The original stack is modified in the process. This effectively moves the position of the data from the start to the end of the table. + * + * @method Phaser.Math#shift + * @param {array} stack - The array to shift. + * @return {any} The shifted value. */ shift: function (stack) { @@ -17362,8 +20639,9 @@ Phaser.Math = { /** * Shuffles the data in the given array into a new order - * @param array The array to shuffle - * @return The array + * @method Phaser.Math#shuffleArray + * @param {array} array - The array to shuffle + * @return {array} The array */ shuffleArray: function (array) { @@ -17381,12 +20659,13 @@ Phaser.Math = { /** * Returns the distance between the two given set of coordinates. - * @method distance - * @param {Number} x1 - * @param {Number} y1 - * @param {Number} x2 - * @param {Number} y2 - * @return {Number} The distance between this Point object and the destination Point object. + * + * @method Phaser.Math#distance + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @return {number} The distance between this Point object and the destination Point object. **/ distance: function (x1, y1, x2, y2) { @@ -17397,6 +20676,16 @@ Phaser.Math = { }, + /** + * Returns the rounded distance between the two given set of coordinates. + * + * @method Phaser.Math#distanceRounded + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @return {number} The distance between this Point object and the destination Point object. + **/ distanceRounded: function (x1, y1, x2, y2) { return Math.round(Phaser.Math.distance(x1, y1, x2, y2)); @@ -17404,34 +20693,77 @@ Phaser.Math = { }, /** - * force a value within the boundaries of two values - * + * Force a value within the boundaries of two values. * Clamp value to range + * + * @method Phaser.Math#clamp + * @param {number} x + * @param {number} a + * @param {number} b + * @return {number} */ clamp: function ( x, a, b ) { return ( x < a ) ? a : ( ( x > b ) ? b : x ); }, - - // Clamp value to range to range + /** + * Checks if two values are within the given tolerance of each other. + * + * @method Phaser.Math#within + * @param {number} a - The first number to check + * @param {number} b - The second number to check + * @param {number} tolerance - The tolerance. Anything equal to or less than this is considered within the range. + * @return {boolean} True if a is <= tolerance of b. + */ + within: function ( a, b, tolerance ) { + return (Math.abs(a - b) <= tolerance); + + }, + + /** + * Linear mapping from range to range + * + * @method Phaser.Math#mapLinear + * @param {number} x + * @param {number} a1 + * @param {number} a1 + * @param {number} a2 + * @param {number} b1 + * @param {number} b2 + * @return {number} + */ mapLinear: function ( x, a1, a2, b1, b2 ) { return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 ); }, - // http://en.wikipedia.org/wiki/Smoothstep - + /** + * Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep + * + * @method Phaser.Math#smoothstep + * @param {number} x + * @param {number} min + * @param {number} max + * @return {number} + */ smoothstep: function ( x, min, max ) { if ( x <= min ) return 0; @@ -17443,6 +20775,15 @@ Phaser.Math = { }, + /** + * Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep + * + * @method Phaser.Math#smootherstep + * @param {number} x + * @param {number} min + * @param {number} max + * @return {number} + */ smootherstep: function ( x, min, max ) { if ( x <= min ) return 0; @@ -17455,8 +20796,12 @@ Phaser.Math = { }, /** - * a value representing the sign of the value. + * A value representing the sign of the value. * -1 for negative, +1 for positive, 0 if value is 0 + * + * @method Phaser.Math#sign + * @param {number} x + * @return {number} */ sign: function ( x ) { @@ -17464,6 +20809,12 @@ Phaser.Math = { }, + /** + * Convert degrees to radians. + * + * @method Phaser.Math#degToRad + * @return {function} + */ degToRad: function() { var degreeToRadiansFactor = Math.PI / 180; @@ -17476,6 +20827,12 @@ Phaser.Math = { }(), + /** + * Convert degrees to radians. + * + * @method Phaser.Math#radToDeg + * @return {function} + */ radToDeg: function() { var radianToDegreesFactor = 180 / Math.PI; @@ -17490,7 +20847,13 @@ Phaser.Math = { }; -/* +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** * Javascript QuadTree * @version 1.0 * @author Timo Hausmann @@ -17504,35 +20867,45 @@ Phaser.Math = { * Original version at https://github.com/timohausmann/quadtree-js/ */ -/* - Copyright © 2012 Timo Hausmann - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +/** +* @copyright © 2012 Timo Hausmann +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* -* QuadTree Constructor -* @param Integer maxObjects (optional) max objects a node can hold before splitting into 4 subnodes (default: 10) -* @param Integer maxLevels (optional) total max levels inside root QuadTree (default: 4) -* @param Integer level (optional) deepth level, required for subnodes -*/ +/** + * QuadTree Constructor + * + * @class Phaser.QuadTree + * @classdesc A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked + * it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result. Original version at https://github.com/timohausmann/quadtree-js/ + * @constructor + * @param {Description} physicsManager - Description. + * @param {Description} x - Description. + * @param {Description} y - Description. + * @param {number} width - The width of your game in game pixels. + * @param {number} height - The height of your game in game pixels. + * @param {number} maxObjects - Description. + * @param {number} maxLevels - Description. + * @param {number} level - Description. + */ Phaser.QuadTree = function (physicsManager, x, y, width, height, maxObjects, maxLevels, level) { this.physicsManager = physicsManager; @@ -17562,8 +20935,10 @@ Phaser.QuadTree = function (physicsManager, x, y, width, height, maxObjects, max Phaser.QuadTree.prototype = { /* - * Split the node into 4 subnodes - */ + * Split the node into 4 subnodes + * + * @method Phaser.QuadTree#split + */ split: function() { this.level++; @@ -17586,7 +20961,9 @@ Phaser.QuadTree.prototype = { * Insert the object into the node. If the node * exceeds the capacity, it will split and add all * objects to their corresponding subnodes. - * @param Object pRect bounds of the object to be added, with x, y, width, height + * + * @method Phaser.QuadTree#insert + * @param {object} body - Description. */ insert: function (body) { @@ -17634,9 +21011,11 @@ Phaser.QuadTree.prototype = { }, /* - * Determine which node the object belongs to - * @param Object pRect bounds of the area to be checked, with x, y, width, height - * @return Integer index of the subnode (0-3), or -1 if pRect cannot completely fit within a subnode and is part of the parent node + * Determine which node the object belongs to. + * + * @method Phaser.QuadTree#getIndex + * @param {object} rect - Description. + * @return {number} index - Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node. */ getIndex: function (rect) { @@ -17676,9 +21055,11 @@ Phaser.QuadTree.prototype = { }, /* - * Return all objects that could collide with the given object - * @param Object pRect bounds of the object to be checked, with x, y, width, height - * @Return Array array with all detected objects + * Return all objects that could collide with the given object. + * + * @method Phaser.QuadTree#retrieve + * @param {object} rect - Description. + * @Return {array} - Array with all detected objects. */ retrieve: function (sprite) { @@ -17711,7 +21092,8 @@ Phaser.QuadTree.prototype = { }, /* - * Clear the quadtree + * Clear the quadtree. + * @method Phaser.QuadTree#clear */ clear: function () { @@ -17731,15 +21113,20 @@ Phaser.QuadTree.prototype = { }; /** -* Phaser - Circle -* +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** * Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created. * @class Circle +* @classdesc Phaser - Circle * @constructor -* @param {Number} [x] The x coordinate of the center of the circle. -* @param {Number} [y] The y coordinate of the center of the circle. -* @param {Number} [diameter] The diameter of the circle. -* @return {Circle} This circle object +* @param {number} [x] The x coordinate of the center of the circle. +* @param {number} [y] The y coordinate of the center of the circle. +* @param {number} [diameter] The diameter of the circle. +* @return {Phaser.Circle} This circle object **/ Phaser.Circle = function (x, y, diameter) { @@ -17748,23 +21135,27 @@ Phaser.Circle = function (x, y, diameter) { diameter = diameter || 0; /** - * The x coordinate of the center of the circle - * @property x - * @type Number + * @property {number} x - The x coordinate of the center of the circle. **/ this.x = x; /** - * The y coordinate of the center of the circle - * @property y - * @type Number + * @property {number} y - The y coordinate of the center of the circle. **/ this.y = y; + /** + * @property {number} _diameter - The diameter of the circle. + * @private + **/ this._diameter = diameter; if (diameter > 0) { + /** + * @property {number} _radius - The radius of the circle. + * @private + **/ this._radius = diameter * 0.5; } else @@ -17778,8 +21169,8 @@ Phaser.Circle.prototype = { /** * The circumference of the circle. - * @method circumference - * @return {Number} + * @method Phaser.Circle#circumference + * @return {number} **/ circumference: function () { return 2 * (Math.PI * this._radius); @@ -17787,11 +21178,11 @@ Phaser.Circle.prototype = { /** * Sets the members of Circle to the specified values. - * @method setTo - * @param {Number} x The x coordinate of the center of the circle. - * @param {Number} y The y coordinate of the center of the circle. - * @param {Number} diameter The diameter of the circle in pixels. - * @return {Circle} This circle object + * @method Phaser.Circle#setTo + * @param {number} x - The x coordinate of the center of the circle. + * @param {number} y - The y coordinate of the center of the circle. + * @param {number} diameter - The diameter of the circle in pixels. + * @return {Circle} This circle object. **/ setTo: function (x, y, diameter) { this.x = x; @@ -17803,7 +21194,7 @@ Phaser.Circle.prototype = { /** * Copies the x, y and diameter properties from any given object to this Circle. - * @method copyFrom + * @method Phaser.Circle#copyFrom * @param {any} source - The object to copy from. * @return {Circle} This Circle object. **/ @@ -17813,7 +21204,7 @@ Phaser.Circle.prototype = { /** * Copies the x, y and diameter properties from this Circle to any given object. - * @method copyTo + * @method Phaser.Circle#copyTo * @param {any} dest - The object to copy to. * @return {Object} This dest object. **/ @@ -17827,10 +21218,10 @@ Phaser.Circle.prototype = { /** * Returns the distance from the center of the Circle object to the given object * (can be Circle, Point or anything with x/y properties) - * @method distance - * @param {object} dest The target object. Must have visible x and y properties that represent the center of the object. - * @param {bool} [optional] round Round the distance to the nearest integer (default false) - * @return {Number} The distance between this Point object and the destination Point object. + * @method Phaser.Circle#distance + * @param {object} dest - The target object. Must have visible x and y properties that represent the center of the object. + * @param {boolean} [round] - Round the distance to the nearest integer (default false). + * @return {number} The distance between this Point object and the destination Point object. */ distance: function (dest, round) { @@ -17849,8 +21240,8 @@ Phaser.Circle.prototype = { /** * Returns a new Circle object with the same values for the x, y, width, and height properties as this Circle object. - * @method clone - * @param {Phaser.Circle} out Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned. + * @method Phaser.Circle#clone + * @param {Phaser.Circle} out - Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned. * @return {Phaser.Circle} The cloned Circle object. */ clone: function(out) { @@ -17863,10 +21254,10 @@ Phaser.Circle.prototype = { /** * Return true if the given x/y coordinates are within this Circle object. - * @method contains - * @param {Number} x The X value of the coordinate to test. - * @param {Number} y The Y value of the coordinate to test. - * @return {bool} True if the coordinates are within this circle, otherwise false. + * @method Phaser.Circle#contains + * @param {number} x - The X value of the coordinate to test. + * @param {number} y - The Y value of the coordinate to test. + * @return {boolean} True if the coordinates are within this circle, otherwise false. */ contains: function (x, y) { return Phaser.Circle.contains(this, x, y); @@ -17874,10 +21265,10 @@ Phaser.Circle.prototype = { /** * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. - * @method circumferencePoint - * @param {Number} angle The angle in radians (unless asDegrees is true) to return the point from. - * @param {bool} asDegrees Is the given angle in radians (false) or degrees (true)? - * @param {Phaser.Point} [optional] output An optional Point object to put the result in to. If none specified a new Point object will be created. + * @method Phaser.Circle#circumferencePoint + * @param {number} angle - The angle in radians (unless asDegrees is true) to return the point from. + * @param {boolean} asDegrees - Is the given angle in radians (false) or degrees (true)? + * @param {Phaser.Point} [out] - An optional Point object to put the result in to. If none specified a new Point object will be created. * @return {Phaser.Point} The Point object holding the result. */ circumferencePoint: function (angle, asDegrees, out) { @@ -17886,9 +21277,9 @@ Phaser.Circle.prototype = { /** * Adjusts the location of the Circle object, as determined by its center coordinate, by the specified amounts. - * @method offset - * @param {Number} dx Moves the x value of the Circle object by this amount. - * @param {Number} dy Moves the y value of the Circle object by this amount. + * @method Phaser.Circle#offset + * @param {number} dx - Moves the x value of the Circle object by this amount. + * @param {number} dy - Moves the y value of the Circle object by this amount. * @return {Circle} This Circle object. **/ offset: function (dx, dy) { @@ -17899,7 +21290,7 @@ Phaser.Circle.prototype = { /** * Adjusts the location of the Circle object using a Point object as a parameter. This method is similar to the Circle.offset() method, except that it takes a Point object as a parameter. - * @method offsetPoint + * @method Phaser.Circle#offsetPoint * @param {Point} point A Point object to use to offset this Circle object (or any valid object with exposed x and y properties). * @return {Circle} This Circle object. **/ @@ -17909,7 +21300,7 @@ Phaser.Circle.prototype = { /** * Returns a string representation of this object. - * @method toString + * @method Phaser.Circle#toString * @return {string} a string representation of the instance. **/ toString: function () { @@ -17918,24 +21309,17 @@ Phaser.Circle.prototype = { }; -// Getters / Setters - +/** +* The largest distance between any two points on the circle. The same as the radius * 2. +* @name Phaser.Circle#diameter +* @property {number} diameter - Gets or sets the diameter of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "diameter", { - /** - * The diameter of the circle. The largest distance between any two points on the circle. The same as the radius * 2. - * @method diameter - * @return {Number} - **/ get: function () { return this._diameter; }, - /** - * The diameter of the circle. The largest distance between any two points on the circle. The same as the radius * 2. - * @method diameter - * @param {Number} The diameter of the circle. - **/ set: function (value) { if (value > 0) { this._diameter = value; @@ -17945,22 +21329,17 @@ Object.defineProperty(Phaser.Circle.prototype, "diameter", { }); +/** +* The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter. +* @name Phaser.Circle#radius +* @property {number} radius - Gets or sets the radius of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "radius", { - /** - * The radius of the circle. The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter. - * @method radius - * @return {Number} - **/ get: function () { return this._radius; }, - /** - * The radius of the circle. The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter. - * @method radius - * @param {Number} The radius of the circle. - **/ set: function (value) { if (value > 0) { this._radius = value; @@ -17970,22 +21349,17 @@ Object.defineProperty(Phaser.Circle.prototype, "radius", { }); +/** +* The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. +* @name Phaser.Circle#left +* @propety {number} left - Gets or sets the value of the leftmost point of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "left", { - /** - * The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - * @method left - * @return {Number} The x coordinate of the leftmost point of the circle. - **/ get: function () { return this.x - this._radius; }, - /** - * The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - * @method left - * @param {Number} The value to adjust the position of the leftmost point of the circle by. - **/ set: function (value) { if (value > this.x) { this._radius = 0; @@ -17997,22 +21371,17 @@ Object.defineProperty(Phaser.Circle.prototype, "left", { }); +/** +* The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. +* @name Phaser.Circle#right +* @property {number} right - Gets or sets the value of the rightmost point of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "right", { - /** - * The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - * @method right - * @return {Number} - **/ get: function () { return this.x + this._radius; }, - /** - * The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - * @method right - * @param {Number} The amount to adjust the diameter of the circle by. - **/ set: function (value) { if (value < this.x) { this._radius = 0; @@ -18024,22 +21393,17 @@ Object.defineProperty(Phaser.Circle.prototype, "right", { }); +/** +* The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter. +* @name Phaser.Circle#top +* @property {number} top - Gets or sets the top of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "top", { - /** - * The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter. - * @method bottom - * @return {Number} - **/ get: function () { return this.y - this._radius; }, - /** - * The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter. - * @method bottom - * @param {Number} The amount to adjust the height of the circle by. - **/ set: function (value) { if (value > this.y) { this._radius = 0; @@ -18051,22 +21415,17 @@ Object.defineProperty(Phaser.Circle.prototype, "top", { }); +/** +* The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter. +* @name Phaser.Circle#bottom +* @property {number} bottom - Gets or sets the bottom of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "bottom", { - /** - * The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter. - * @method bottom - * @return {Number} - **/ get: function () { return this.y + this._radius; }, - /** - * The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter. - * @method bottom - * @param {Number} The value to adjust the height of the circle by. - **/ set: function (value) { if (value < this.y) { @@ -18079,13 +21438,14 @@ Object.defineProperty(Phaser.Circle.prototype, "bottom", { }); +/** +* The area of this Circle. +* @name Phaser.Circle#area +* @property {number} area - The area of this circle. +* @readonly +*/ Object.defineProperty(Phaser.Circle.prototype, "area", { - /** - * Gets the area of this Circle. - * @method area - * @return {Number} This area of this circle. - **/ get: function () { if (this._radius > 0) { return Math.PI * this._radius * this._radius; @@ -18096,37 +21456,31 @@ Object.defineProperty(Phaser.Circle.prototype, "area", { }); +/** +* Determines whether or not this Circle object is empty. Will return a value of true if the Circle objects diameter is less than or equal to 0; otherwise false. +* If set to true it will reset all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0. +* @name Phaser.Circle#empty +* @property {boolean} empty - Gets or sets the empty state of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "empty", { - /** - * Determines whether or not this Circle object is empty. - * @method empty - * @return {bool} A value of true if the Circle objects diameter is less than or equal to 0; otherwise false. - **/ get: function () { return (this._diameter == 0); }, - /** - * Sets all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0. - * @method setEmpty - * @return {Circle} This Circle object - **/ set: function (value) { this.setTo(0, 0, 0); } }); -// Statics - /** * Return true if the given x/y coordinates are within the Circle object. -* @method contains -* @param {Phaser.Circle} a The Circle to be checked. -* @param {Number} x The X value of the coordinate to test. -* @param {Number} y The Y value of the coordinate to test. -* @return {bool} True if the coordinates are within this circle, otherwise false. +* @method Phaser.Circle.contains +* @param {Phaser.Circle} a - The Circle to be checked. +* @param {number} x - The X value of the coordinate to test. +* @param {number} y - The Y value of the coordinate to test. +* @return {boolean} True if the coordinates are within this circle, otherwise false. */ Phaser.Circle.contains = function (a, x, y) { @@ -18146,10 +21500,10 @@ Phaser.Circle.contains = function (a, x, y) { /** * Determines whether the two Circle objects match. This method compares the x, y and diameter properties. -* @method equals -* @param {Phaser.Circle} a The first Circle object. -* @param {Phaser.Circle} b The second Circle object. -* @return {bool} A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false. +* @method Phaser.Circle.equals +* @param {Phaser.Circle} a - The first Circle object. +* @param {Phaser.Circle} b - The second Circle object. +* @return {boolean} A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false. */ Phaser.Circle.equals = function (a, b) { return (a.x == b.x && a.y == b.y && a.diameter == b.diameter); @@ -18158,10 +21512,10 @@ Phaser.Circle.equals = function (a, b) { /** * Determines whether the two Circle objects intersect. * This method checks the radius distances between the two Circle objects to see if they intersect. -* @method intersects -* @param {Phaser.Circle} a The first Circle object. -* @param {Phaser.Circle} b The second Circle object. -* @return {bool} A value of true if the specified object intersects with this Circle object; otherwise false. +* @method Phaser.Circle.intersects +* @param {Phaser.Circle} a - The first Circle object. +* @param {Phaser.Circle} b - The second Circle object. +* @return {boolean} A value of true if the specified object intersects with this Circle object; otherwise false. */ Phaser.Circle.intersects = function (a, b) { return (Phaser.Math.distance(a.x, a.y, b.x, b.y) <= (a.radius + b.radius)); @@ -18169,11 +21523,11 @@ Phaser.Circle.intersects = function (a, b) { /** * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. -* @method circumferencePoint -* @param {Phaser.Circle} a The first Circle object. -* @param {Number} angle The angle in radians (unless asDegrees is true) to return the point from. -* @param {bool} asDegrees Is the given angle in radians (false) or degrees (true)? -* @param {Phaser.Point} [optional] output An optional Point object to put the result in to. If none specified a new Point object will be created. +* @method Phaser.Circle.circumferencePoint +* @param {Phaser.Circle} a - The first Circle object. +* @param {number} angle - The angle in radians (unless asDegrees is true) to return the point from. +* @param {boolean} asDegrees - Is the given angle in radians (false) or degrees (true)? +* @param {Phaser.Point} [out] - An optional Point object to put the result in to. If none specified a new Point object will be created. * @return {Phaser.Point} The Point object holding the result. */ Phaser.Circle.circumferencePoint = function (a, angle, asDegrees, out) { @@ -18194,10 +21548,10 @@ Phaser.Circle.circumferencePoint = function (a, angle, asDegrees, out) { /** * Checks if the given Circle and Rectangle objects intersect. -* @method intersectsRectangle -* @param {Phaser.Circle} c The Circle object to test. -* @param {Phaser.Rectangle} r The Rectangle object to test. -* @return {bool} True if the two objects intersect, otherwise false. +* @method Phaser.Circle.intersectsRectangle +* @param {Phaser.Circle} c - The Circle object to test. +* @param {Phaser.Rectangle} r - The Rectangle object to test. +* @return {boolean} True if the two objects intersect, otherwise false. */ Phaser.Circle.intersectsRectangle = function (c, r) { @@ -18230,29 +21584,32 @@ Phaser.Circle.intersectsRectangle = function (c, r) { }; /** -* Phaser - Point -* -* The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis. -* * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** * Creates a new Point. If you pass no parameters a Point is created set to (0,0). -* @class Point +* @class Phaser.Point +* @classdesc The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis. * @constructor -* @param {Number} x The horizontal position of this Point (default 0) -* @param {Number} y The vertical position of this Point (default 0) +* @param {number} x The horizontal position of this Point (default 0) +* @param {number} y The vertical position of this Point (default 0) **/ Phaser.Point = function (x, y) { x = x || 0; y = y || 0; + /** + * @property {number} x - The x coordinate of the point. + **/ this.x = x; + + /** + * @property {number} y - The y coordinate of the point. + **/ this.y = y; }; @@ -18261,7 +21618,7 @@ Phaser.Point.prototype = { /** * Copies the x and y properties from any given object to this Point. - * @method copyFrom + * @method Phaser.Point#copyFrom * @param {any} source - The object to copy from. * @return {Point} This Point object. **/ @@ -18271,7 +21628,7 @@ Phaser.Point.prototype = { /** * Inverts the x and y values of this Point - * @method invert + * @method Phaser.Point#invert * @return {Point} This Point object. **/ invert: function () { @@ -18280,17 +21637,26 @@ Phaser.Point.prototype = { /** * Sets the x and y values of this Point object to the given coordinates. - * @method setTo - * @param {Number} x - The horizontal position of this point. - * @param {Number} y - The vertical position of this point. + * @method Phaser.Point#setTo + * @param {number} x - The horizontal position of this point. + * @param {number} y - The vertical position of this point. * @return {Point} This Point object. Useful for chaining method calls. **/ setTo: function (x, y) { + this.x = x; this.y = y; return this; + }, + /** + * Adds the given x and y values to this Point. + * @method Phaser.Point#add + * @param {number} x - The value to add to Point.x. + * @param {number} y - The value to add to Point.y. + * @return {Phaser.Point} This Point object. Useful for chaining method calls. + **/ add: function (x, y) { this.x += x; @@ -18299,6 +21665,13 @@ Phaser.Point.prototype = { }, + /** + * Subtracts the given x and y values from this Point. + * @method Phaser.Point#subtract + * @param {number} x - The value to subtract from Point.x. + * @param {number} y - The value to subtract from Point.y. + * @return {Phaser.Point} This Point object. Useful for chaining method calls. + **/ subtract: function (x, y) { this.x -= x; @@ -18307,6 +21680,13 @@ Phaser.Point.prototype = { }, + /** + * Multiplies Point.x and Point.y by the given x and y values. + * @method Phaser.Point#multiply + * @param {number} x - The value to multiply Point.x by. + * @param {number} y - The value to multiply Point.x by. + * @return {Phaser.Point} This Point object. Useful for chaining method calls. + **/ multiply: function (x, y) { this.x *= x; @@ -18315,6 +21695,13 @@ Phaser.Point.prototype = { }, + /** + * Divides Point.x and Point.y by the given x and y values. + * @method Phaser.Point#divide + * @param {number} x - The value to divide Point.x by. + * @param {number} y - The value to divide Point.x by. + * @return {Phaser.Point} This Point object. Useful for chaining method calls. + **/ divide: function (x, y) { this.x /= x; @@ -18324,10 +21711,10 @@ Phaser.Point.prototype = { }, /** - * Clamps the x value of this Point to be between the given min and max - * @method clampX - * @param {Number} min The minimum value to clamp this Point to - * @param {Number} max The maximum value to clamp this Point to + * Clamps the x value of this Point to be between the given min and max. + * @method Phaser.Point#clampX + * @param {number} min - The minimum value to clamp this Point to. + * @param {number} max - The maximum value to clamp this Point to. * @return {Phaser.Point} This Point object. */ clampX: function (min, max) { @@ -18339,9 +21726,9 @@ Phaser.Point.prototype = { /** * Clamps the y value of this Point to be between the given min and max - * @method clampY - * @param {Number} min The minimum value to clamp this Point to - * @param {Number} max The maximum value to clamp this Point to + * @method Phaser.Point#clampY + * @param {number} min - The minimum value to clamp this Point to. + * @param {number} max - The maximum value to clamp this Point to. * @return {Phaser.Point} This Point object. */ clampY: function (min, max) { @@ -18352,10 +21739,10 @@ Phaser.Point.prototype = { }, /** - * Clamps this Point object values to be between the given min and max - * @method clamp - * @param {Number} min The minimum value to clamp this Point to - * @param {Number} max The maximum value to clamp this Point to + * Clamps this Point object values to be between the given min and max. + * @method Phaser.Point#clamp + * @param {number} min - The minimum value to clamp this Point to. + * @param {number} max - The maximum value to clamp this Point to. * @return {Phaser.Point} This Point object. */ clamp: function (min, max) { @@ -18368,8 +21755,8 @@ Phaser.Point.prototype = { /** * Creates a copy of the given Point. - * @method clone - * @param {Phaser.Point} output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned. + * @method Phaser.Point#clone + * @param {Phaser.Point} [output] Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned. * @return {Phaser.Point} The new Point object. */ clone: function (output) { @@ -18382,7 +21769,7 @@ Phaser.Point.prototype = { /** * Copies the x and y properties from any given object to this Point. - * @method copyFrom + * @method Phaser.Point#copyFrom * @param {any} source - The object to copy from. * @return {Point} This Point object. **/ @@ -18392,7 +21779,7 @@ Phaser.Point.prototype = { /** * Copies the x and y properties from this Point to any given object. - * @method copyTo + * @method Phaser.Point#copyTo * @param {any} dest - The object to copy to. * @return {Object} The dest object. **/ @@ -18407,10 +21794,10 @@ Phaser.Point.prototype = { /** * Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties) - * @method distance - * @param {object} dest The target object. Must have visible x and y properties that represent the center of the object. - * @param {bool} [optional] round Round the distance to the nearest integer (default false) - * @return {Number} The distance between this Point object and the destination Point object. + * @method Phaser.Point#distance + * @param {object} dest - The target object. Must have visible x and y properties that represent the center of the object. + * @param {boolean} [round] - Round the distance to the nearest integer (default false). + * @return {number} The distance between this Point object and the destination Point object. */ distance: function (dest, round) { @@ -18420,9 +21807,9 @@ Phaser.Point.prototype = { /** * Determines whether the given objects x/y values are equal to this Point object. - * @method equals - * @param {Phaser.Point} a The first object to compare. - * @return {bool} A value of true if the Points are equal, otherwise false. + * @method Phaser.Point#equals + * @param {Phaser.Point} a - The first object to compare. + * @return {boolean} A value of true if the Points are equal, otherwise false. */ equals: function (a) { return (a.x == this.x && a.y == this.y); @@ -18430,13 +21817,13 @@ Phaser.Point.prototype = { /** * Rotates this Point around the x/y coordinates given to the desired angle. - * @method rotate - * @param {Number} x The x coordinate of the anchor point - * @param {Number} y The y coordinate of the anchor point - * @param {Number} angle The angle in radians (unless asDegrees is true) to rotate the Point to. - * @param {bool} asDegrees Is the given rotation in radians (false) or degrees (true)? - * @param {Number} distance An optional distance constraint between the Point and the anchor. - * @return {Phaser.Point} The modified point object + * @method Phaser.Point#rotate + * @param {number} x - The x coordinate of the anchor point + * @param {number} y - The y coordinate of the anchor point + * @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the Point to. + * @param {boolean} asDegrees - Is the given rotation in radians (false) or degrees (true)? + * @param {number} [distance] - An optional distance constraint between the Point and the anchor. + * @return {Phaser.Point} The modified point object. */ rotate: function (x, y, angle, asDegrees, distance) { return Phaser.Point.rotate(this, x, y, angle, asDegrees, distance); @@ -18444,8 +21831,8 @@ Phaser.Point.prototype = { /** * Returns a string representation of this object. - * @method toString - * @return {string} a string representation of the instance. + * @method Phaser.Point#toString + * @return {string} A string representation of the instance. **/ toString: function () { return '[{Point (x=' + this.x + ' y=' + this.y + ')}]'; @@ -18453,14 +21840,12 @@ Phaser.Point.prototype = { }; -// Statics - /** * Adds the coordinates of two points together to create a new point. -* @method add -* @param {Phaser.Point} a The first Point object. -* @param {Phaser.Point} b The second Point object. -* @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created. +* @method Phaser.Point.add +* @param {Phaser.Point} a - The first Point object. +* @param {Phaser.Point} b - The second Point object. +* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created. * @return {Phaser.Point} The new Point object. */ Phaser.Point.add = function (a, b, out) { @@ -18476,10 +21861,10 @@ Phaser.Point.add = function (a, b, out) { /** * Subtracts the coordinates of two points to create a new point. -* @method subtract -* @param {Phaser.Point} a The first Point object. -* @param {Phaser.Point} b The second Point object. -* @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created. +* @method Phaser.Point.subtract +* @param {Phaser.Point} a - The first Point object. +* @param {Phaser.Point} b - The second Point object. +* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created. * @return {Phaser.Point} The new Point object. */ Phaser.Point.subtract = function (a, b, out) { @@ -18495,10 +21880,10 @@ Phaser.Point.subtract = function (a, b, out) { /** * Multiplies the coordinates of two points to create a new point. -* @method subtract -* @param {Phaser.Point} a The first Point object. -* @param {Phaser.Point} b The second Point object. -* @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created. +* @method Phaser.Point.multiply +* @param {Phaser.Point} a - The first Point object. +* @param {Phaser.Point} b - The second Point object. +* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created. * @return {Phaser.Point} The new Point object. */ Phaser.Point.multiply = function (a, b, out) { @@ -18514,10 +21899,10 @@ Phaser.Point.multiply = function (a, b, out) { /** * Divides the coordinates of two points to create a new point. -* @method subtract -* @param {Phaser.Point} a The first Point object. -* @param {Phaser.Point} b The second Point object. -* @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created. +* @method Phaser.Point.divide +* @param {Phaser.Point} a - The first Point object. +* @param {Phaser.Point} b - The second Point object. +* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created. * @return {Phaser.Point} The new Point object. */ Phaser.Point.divide = function (a, b, out) { @@ -18533,22 +21918,22 @@ Phaser.Point.divide = function (a, b, out) { /** * Determines whether the two given Point objects are equal. They are considered equal if they have the same x and y values. -* @method equals -* @param {Phaser.Point} a The first Point object. -* @param {Phaser.Point} b The second Point object. -* @return {bool} A value of true if the Points are equal, otherwise false. +* @method Phaser.Point.equals +* @param {Phaser.Point} a - The first Point object. +* @param {Phaser.Point} b - The second Point object. +* @return {boolean} A value of true if the Points are equal, otherwise false. */ Phaser.Point.equals = function (a, b) { return (a.x == b.x && a.y == b.y); }; /** -* Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties) -* @method distance -* @param {object} a The target object. Must have visible x and y properties that represent the center of the object. -* @param {object} b The target object. Must have visible x and y properties that represent the center of the object. -* @param {bool} [optional] round Round the distance to the nearest integer (default false) -* @return {Number} The distance between this Point object and the destination Point object. +* Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties). +* @method Phaser.Point.distance +* @param {object} a - The target object. Must have visible x and y properties that represent the center of the object. +* @param {object} b - The target object. Must have visible x and y properties that represent the center of the object. +* @param {boolean} [round] - Round the distance to the nearest integer (default false). +* @return {number} The distance between this Point object and the destination Point object. */ Phaser.Point.distance = function (a, b, round) { @@ -18567,14 +21952,14 @@ Phaser.Point.distance = function (a, b, round) { /** * Rotates a Point around the x/y coordinates given to the desired angle. -* @method rotate -* @param {Phaser.Point} a The Point object to rotate. -* @param {Number} x The x coordinate of the anchor point -* @param {Number} y The y coordinate of the anchor point -* @param {Number} angle The angle in radians (unless asDegrees is true) to rotate the Point to. -* @param {bool} asDegrees Is the given rotation in radians (false) or degrees (true)? -* @param {Number} distance An optional distance constraint between the Point and the anchor. -* @return {Phaser.Point} The modified point object +* @method Phaser.Point.rotate +* @param {Phaser.Point} a - The Point object to rotate. +* @param {number} x - The x coordinate of the anchor point +* @param {number} y - The y coordinate of the anchor point +* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the Point to. +* @param {boolean} asDegrees - Is the given rotation in radians (false) or degrees (true)? +* @param {number} distance - An optional distance constraint between the Point and the anchor. +* @return {Phaser.Point} The modified point object. */ Phaser.Point.rotate = function (a, x, y, angle, asDegrees, distance) { @@ -18596,18 +21981,22 @@ Phaser.Point.rotate = function (a, x, y, angle, asDegrees, distance) { }; - +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ /** * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. If you call this function without parameters, a Rectangle with x, y, width, and height properties set to 0 is created. * -* @class Rectangle +* @class Phaser.Rectangle * @constructor -* @param {Number} x The x coordinate of the top-left corner of the Rectangle. -* @param {Number} y The y coordinate of the top-left corner of the Rectangle. -* @param {Number} width The width of the Rectangle in pixels. -* @param {Number} height The height of the Rectangle in pixels. -* @return {Rectangle} This Rectangle object +* @param {number} x - The x coordinate of the top-left corner of the Rectangle. +* @param {number} y - The y coordinate of the top-left corner of the Rectangle. +* @param {number} width - The width of the Rectangle in pixels. +* @param {number} height - The height of the Rectangle in pixels. +* @return {Rectangle} This Rectangle object. **/ Phaser.Rectangle = function (x, y, width, height) { @@ -18617,31 +22006,23 @@ Phaser.Rectangle = function (x, y, width, height) { height = height || 0; /** - * @property x - * @type Number - * @default 0 - */ + * @property {number} x - Description. + */ this.x = x; /** - * @property y - * @type Number - * @default 0 - */ + * @property {number} y - Description. + */ this.y = y; /** - * @property width - * @type Number - * @default 0 - */ + * @property {number} width - Description. + */ this.width = width; /** - * @property height - * @type Number - * @default 0 - */ + * @property {number} height - Description. + */ this.height = height; }; @@ -18650,9 +22031,9 @@ Phaser.Rectangle.prototype = { /** * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts. - * @method offset - * @param {Number} dx Moves the x value of the Rectangle object by this amount. - * @param {Number} dy Moves the y value of the Rectangle object by this amount. + * @method Phaser.Rectangle#offset + * @param {number} dx - Moves the x value of the Rectangle object by this amount. + * @param {number} dy - Moves the y value of the Rectangle object by this amount. * @return {Rectangle} This Rectangle object. **/ offset: function (dx, dy) { @@ -18666,8 +22047,8 @@ Phaser.Rectangle.prototype = { /** * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter. - * @method offsetPoint - * @param {Point} point A Point object to use to offset this Rectangle object. + * @method Phaser.Rectangle#offsetPoint + * @param {Point} point - A Point object to use to offset this Rectangle object. * @return {Rectangle} This Rectangle object. **/ offsetPoint: function (point) { @@ -18676,11 +22057,11 @@ Phaser.Rectangle.prototype = { /** * Sets the members of Rectangle to the specified values. - * @method setTo - * @param {Number} x The x coordinate of the top-left corner of the Rectangle. - * @param {Number} y The y coordinate of the top-left corner of the Rectangle. - * @param {Number} width The width of the Rectangle in pixels. - * @param {Number} height The height of the Rectangle in pixels. + * @method Phaser.Rectangle#setTo + * @param {number} x - The x coordinate of the top-left corner of the Rectangle. + * @param {number} y - The y coordinate of the top-left corner of the Rectangle. + * @param {number} width - The width of the Rectangle in pixels. + * @param {number} height - The height of the Rectangle in pixels. * @return {Rectangle} This Rectangle object **/ setTo: function (x, y, width, height) { @@ -18696,7 +22077,7 @@ Phaser.Rectangle.prototype = { /** * Runs Math.floor() on both the x and y values of this Rectangle. - * @method floor + * @method Phaser.Rectangle#floor **/ floor: function () { @@ -18705,9 +22086,22 @@ Phaser.Rectangle.prototype = { }, + /** + * Runs Math.floor() on the x, y, width and height values of this Rectangle. + * @method Phaser.Rectangle#floorAll + **/ + floorAll: function () { + + this.x = Math.floor(this.x); + this.y = Math.floor(this.y); + this.width = Math.floor(this.width); + this.height = Math.floor(this.height); + + }, + /** * Copies the x, y, width and height properties from any given object to this Rectangle. - * @method copyFrom + * @method Phaser.Rectangle#copyFrom * @param {any} source - The object to copy from. * @return {Rectangle} This Rectangle object. **/ @@ -18717,7 +22111,7 @@ Phaser.Rectangle.prototype = { /** * Copies the x, y, width and height properties from this Rectangle to any given object. - * @method copyTo + * @method Phaser.Rectangle#copyTo * @param {any} source - The object to copy to. * @return {object} This object. **/ @@ -18734,9 +22128,9 @@ Phaser.Rectangle.prototype = { /** * Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. - * @method inflate - * @param {Number} dx The amount to be added to the left side of the Rectangle. - * @param {Number} dy The amount to be added to the bottom side of the Rectangle. + * @method Phaser.Rectangle#inflate + * @param {number} dx - The amount to be added to the left side of the Rectangle. + * @param {number} dy - The amount to be added to the bottom side of the Rectangle. * @return {Phaser.Rectangle} This Rectangle object. */ inflate: function (dx, dy) { @@ -18745,9 +22139,9 @@ Phaser.Rectangle.prototype = { /** * The size of the Rectangle object, expressed as a Point object with the values of the width and height properties. - * @method size - * @param {Phaser.Point} output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. - * @return {Phaser.Point} The size of the Rectangle object + * @method Phaser.Rectangle#size + * @param {Phaser.Point} [output] - Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. + * @return {Phaser.Point} The size of the Rectangle object. */ size: function (output) { return Phaser.Rectangle.size(this, output); @@ -18755,9 +22149,9 @@ Phaser.Rectangle.prototype = { /** * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @method clone - * @param {Phaser.Rectangle} output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. - * @return {Phaser.Rectangle} + * @method Phaser.Rectangle#clone + * @param {Phaser.Rectangle} [output] - Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. + * @return {Phaser.Rectangle} */ clone: function (output) { return Phaser.Rectangle.clone(this, output); @@ -18765,10 +22159,10 @@ Phaser.Rectangle.prototype = { /** * Determines whether the specified coordinates are contained within the region defined by this Rectangle object. - * @method contains - * @param {Number} x The x coordinate of the point to test. - * @param {Number} y The y coordinate of the point to test. - * @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false. + * @method Phaser.Rectangle#contains + * @param {number} x - The x coordinate of the point to test. + * @param {number} y - The y coordinate of the point to test. + * @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false. */ contains: function (x, y) { return Phaser.Rectangle.contains(this, x, y); @@ -18777,9 +22171,9 @@ Phaser.Rectangle.prototype = { /** * Determines whether the first Rectangle object is fully contained within the second Rectangle object. * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. - * @method containsRect - * @param {Phaser.Rectangle} b The second Rectangle object. - * @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false. + * @method Phaser.Rectangle#containsRect + * @param {Phaser.Rectangle} b - The second Rectangle object. + * @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false. */ containsRect: function (b) { return Phaser.Rectangle.containsRect(this, b); @@ -18788,9 +22182,9 @@ Phaser.Rectangle.prototype = { /** * Determines whether the two Rectangles are equal. * This method compares the x, y, width and height properties of each Rectangle. - * @method equals - * @param {Phaser.Rectangle} b The second Rectangle object. - * @return {bool} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false. + * @method Phaser.Rectangle#equals + * @param {Phaser.Rectangle} b - The second Rectangle object. + * @return {boolean} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false. */ equals: function (b) { return Phaser.Rectangle.equals(this, b); @@ -18798,9 +22192,9 @@ Phaser.Rectangle.prototype = { /** * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0. - * @method intersection - * @param {Phaser.Rectangle} b The second Rectangle object. - * @param {Phaser.Rectangle} output Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. + * @method Phaser.Rectangle#intersection + * @param {Phaser.Rectangle} b - The second Rectangle object. + * @param {Phaser.Rectangle} out - Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. * @return {Phaser.Rectangle} A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0. */ intersection: function (b, out) { @@ -18810,10 +22204,10 @@ Phaser.Rectangle.prototype = { /** * Determines whether the two Rectangles intersect with each other. * This method checks the x, y, width, and height properties of the Rectangles. - * @method intersects - * @param {Phaser.Rectangle} b The second Rectangle object. - * @param {Number} tolerance A tolerance value to allow for an intersection test with padding, default to 0 - * @return {bool} A value of true if the specified object intersects with this Rectangle object; otherwise false. + * @method Phaser.Rectangle#intersects + * @param {Phaser.Rectangle} b - The second Rectangle object. + * @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0. + * @return {boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false. */ intersects: function (b, tolerance) { return Phaser.Rectangle.intersects(this, b, tolerance); @@ -18821,13 +22215,13 @@ Phaser.Rectangle.prototype = { /** * Determines whether the object specified intersects (overlaps) with the given values. - * @method intersectsRaw - * @param {Number} left - * @param {Number} right - * @param {Number} top - * @param {Number} bottomt - * @param {Number} tolerance A tolerance value to allow for an intersection test with padding, default to 0 - * @return {bool} A value of true if the specified object intersects with the Rectangle; otherwise false. + * @method Phaser.Rectangle#intersectsRaw + * @param {number} left - Description. + * @param {number} right - Description. + * @param {number} top - Description. + * @param {number} bottomt - Description. + * @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0 + * @return {boolean} A value of true if the specified object intersects with the Rectangle; otherwise false. */ intersectsRaw: function (left, right, top, bottom, tolerance) { return Phaser.Rectangle.intersectsRaw(this, left, right, top, bottom, tolerance); @@ -18835,9 +22229,9 @@ Phaser.Rectangle.prototype = { /** * Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles. - * @method union - * @param {Phaser.Rectangle} b The second Rectangle object. - * @param {Phaser.Rectangle} output Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. + * @method Phaser.Rectangle#union + * @param {Phaser.Rectangle} b - The second Rectangle object. + * @param {Phaser.Rectangle} [out] - Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. * @return {Phaser.Rectangle} A Rectangle object that is the union of the two Rectangles. */ union: function (b, out) { @@ -18846,8 +22240,8 @@ Phaser.Rectangle.prototype = { /** * Returns a string representation of this object. - * @method toString - * @return {string} a string representation of the instance. + * @method Phaser.Rectangle#toString + * @return {string} A string representation of the instance. **/ toString: function () { return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.empty + ")}]"; @@ -18855,50 +22249,43 @@ Phaser.Rectangle.prototype = { }; -// Getters / Setters - +/** +* @name Phaser.Rectangle#halfWidth +* @property {number} halfWidth - Half of the width of the Rectangle. +* @readonly +*/ Object.defineProperty(Phaser.Rectangle.prototype, "halfWidth", { - /** - * Half of the width of the Rectangle - * @property halfWidth - * @type Number - **/ get: function () { return Math.round(this.width / 2); } }); +/** +* @name Phaser.Rectangle#halfHeight +* @property {number} halfHeight - Half of the height of the Rectangle. +* @readonly +*/ Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", { - /** - * Half of the height of the Rectangle - * @property halfHeight - * @type Number - **/ get: function () { return Math.round(this.height / 2); } }); +/** +* 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. +* @name Phaser.Rectangle#bottom +* @property {number} bottom - The sum of the y and height properties. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "bottom", { - /** - * 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. - * @method bottom - * @return {Number} - **/ get: function () { return this.y + this.height; }, - - /** - * 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. - * @method bottom - * @param {Number} value - **/ + set: function (value) { if (value <= this.y) { this.height = 0; @@ -18909,21 +22296,17 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottom", { }); +/** +* The location of the Rectangles bottom right corner as a Point object. +* @name Phaser.Rectangle#bottom +* @property {Phaser.Point} bottomRight - Gets or sets the location of the Rectangles bottom right corner as a Point object. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", { - /** - * Get the location of the Rectangles bottom right corner as a Point object. - * @return {Phaser.Point} The new Point object. - */ get: function () { return new Phaser.Point(this.right, this.bottom); }, - /** - * Sets the bottom-right corner of the Rectangle, determined by the values of the given Point object. - * @method bottomRight - * @param {Point} value - **/ set: function (value) { this.right = value.x; this.bottom = value.y; @@ -18931,23 +22314,17 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", { }); +/** +* 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. +* @name Phaser.Rectangle#left +* @property {number} left - The x coordinate of the left of the Rectangle. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "left", { - - /** - * 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. - * @method left - * @ return {number} - **/ + get: function () { return this.x; }, - /** - * 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, whereas changing the x value does not affect the width property. - * @method left - * @param {Number} value - **/ set: function (value) { if (value >= this.right) { this.width = 0; @@ -18959,24 +22336,17 @@ Object.defineProperty(Phaser.Rectangle.prototype, "left", { }); +/** +* 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. +* @name Phaser.Rectangle#right +* @property {number} right - The sum of the x and width properties. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "right", { - - /** - * 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. - * @method right - * @return {Number} - **/ + get: function () { return this.x + this.width; }, - /** - * 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. - * @method right - * @param {Number} value - **/ set: function (value) { if (value <= this.x) { this.width = 0; @@ -18987,94 +22357,80 @@ Object.defineProperty(Phaser.Rectangle.prototype, "right", { }); +/** +* The volume of the Rectangle derived from width * height. +* @name Phaser.Rectangle#volume +* @property {number} volume - The volume of the Rectangle derived from width * height. +* @readonly +*/ Object.defineProperty(Phaser.Rectangle.prototype, "volume", { - - /** - * The volume of the Rectangle derived from width * height - * @method volume - * @return {Number} - **/ + get: function () { return this.width * this.height; } }); +/** +* The perimeter size of the Rectangle. This is the sum of all 4 sides. +* @name Phaser.Rectangle#perimeter +* @property {number} perimeter - The perimeter size of the Rectangle. This is the sum of all 4 sides. +* @readonly +*/ Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", { - /** - * The perimeter size of the Rectangle. This is the sum of all 4 sides. - * @method perimeter - * @return {Number} - **/ get: function () { return (this.width * 2) + (this.height * 2); } }); +/** +* The x coordinate of the center of the Rectangle. +* @name Phaser.Rectangle#centerX +* @property {number} centerX - The x coordinate of the center of the Rectangle. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "centerX", { - /** - * The x coordinate of the center of the Rectangle. - * @method centerX - * @return {Number} - **/ get: function () { return this.x + this.halfWidth; }, - /** - * The x coordinate of the center of the Rectangle. - * @method centerX - * @param {Number} value - **/ set: function (value) { this.x = value - this.halfWidth; } }); +/** +* The y coordinate of the center of the Rectangle. +* @name Phaser.Rectangle#centerY +* @property {number} centerY - The y coordinate of the center of the Rectangle. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "centerY", { - /** - * The y coordinate of the center of the Rectangle. - * @method centerY - * @return {Number} - **/ get: function () { return this.y + this.halfHeight; }, - /** - * The y coordinate of the center of the Rectangle. - * @method centerY - * @param {Number} value - **/ set: function (value) { this.y = value - this.halfHeight; } }); +/** +* 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. +* @name Phaser.Rectangle#top +* @property {number} top - The y coordinate of the top of the Rectangle. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "top", { - /** - * 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. - * @method top - * @return {Number} - **/ get: function () { return this.y; }, - /** - * 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. - * @method top - * @param {Number} value - **/ set: function (value) { if (value >= this.bottom) { this.height = 0; @@ -19086,21 +22442,17 @@ Object.defineProperty(Phaser.Rectangle.prototype, "top", { }); +/** +* The location of the Rectangles top left corner as a Point object. +* @name Phaser.Rectangle#topLeft +* @property {Phaser.Point} topLeft - The location of the Rectangles top left corner as a Point object. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", { - /** - * Get the location of the Rectangles top left corner as a Point object. - * @return {Phaser.Point} The new Point object. - */ get: function () { return new Phaser.Point(this.x, this.y); }, - - /** - * The location of the Rectangles top-left corner, determined by the x and y coordinates of the Point. - * @method topLeft - * @param {Point} value - **/ + set: function (value) { this.x = value.x; this.y = value.y; @@ -19108,36 +22460,30 @@ Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", { }); +/** +* Determines whether or not this Rectangle object is empty. A Rectangle object is empty if its width or height is less than or equal to 0. +* If set to true then all of the Rectangle properties are set to 0. +* @name Phaser.Rectangle#empty +* @property {boolean} empty - Gets or sets the Rectangles empty state. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "empty", { - /** - * Determines whether or not this Rectangle object is empty. - * @method isEmpty - * @return {bool} A value of true if the Rectangle objects width or height is less than or equal to 0; otherwise false. - **/ get: function () { return (!this.width || !this.height); }, - /** - * Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0. - * @method setEmpty - * @return {Rectangle} This Rectangle object - **/ set: function (value) { this.setTo(0, 0, 0, 0); } }); -// Statics - /** * Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. -* @method inflate -* @param {Phaser.Rectangle} a The Rectangle object. -* @param {Number} dx The amount to be added to the left side of the Rectangle. -* @param {Number} dy The amount to be added to the bottom side of the Rectangle. +* @method Phaser.Rectangle.inflate +* @param {Phaser.Rectangle} a - The Rectangle object. +* @param {number} dx - The amount to be added to the left side of the Rectangle. +* @param {number} dy - The amount to be added to the bottom side of the Rectangle. * @return {Phaser.Rectangle} This Rectangle object. */ Phaser.Rectangle.inflate = function (a, dx, dy) { @@ -19150,20 +22496,20 @@ Phaser.Rectangle.inflate = function (a, dx, dy) { /** * Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter. -* @method inflatePoint -* @param {Phaser.Rectangle} a The Rectangle object. -* @param {Phaser.Point} point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. +* @method Phaser.Rectangle.inflatePoint +* @param {Phaser.Rectangle} a - The Rectangle object. +* @param {Phaser.Point} point - The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. * @return {Phaser.Rectangle} The Rectangle object. */ Phaser.Rectangle.inflatePoint = function (a, point) { - return Phaser.Phaser.Rectangle.inflate(a, point.x, point.y); + return Phaser.Rectangle.inflate(a, point.x, point.y); }; /** * The size of the Rectangle object, expressed as a Point object with the values of the width and height properties. -* @method size -* @param {Phaser.Rectangle} a The Rectangle object. -* @param {Phaser.Point} output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. +* @method Phaser.Rectangle.size +* @param {Phaser.Rectangle} a - The Rectangle object. +* @param {Phaser.Point} [output] - Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. * @return {Phaser.Point} The size of the Rectangle object */ Phaser.Rectangle.size = function (a, output) { @@ -19173,9 +22519,9 @@ Phaser.Rectangle.size = function (a, output) { /** * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. -* @method clone -* @param {Phaser.Rectangle} a The Rectangle object. -* @param {Phaser.Rectangle} output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. +* @method Phaser.Rectangle.clone +* @param {Phaser.Rectangle} a - The Rectangle object. +* @param {Phaser.Rectangle} [output] - Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. * @return {Phaser.Rectangle} */ Phaser.Rectangle.clone = function (a, output) { @@ -19185,34 +22531,38 @@ Phaser.Rectangle.clone = function (a, output) { /** * Determines whether the specified coordinates are contained within the region defined by this Rectangle object. -* @method contains -* @param {Phaser.Rectangle} a The Rectangle object. -* @param {Number} x The x coordinate of the point to test. -* @param {Number} y The y coordinate of the point to test. -* @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false. +* @method Phaser.Rectangle.contains +* @param {Phaser.Rectangle} a - The Rectangle object. +* @param {number} x - The x coordinate of the point to test. +* @param {number} y - The y coordinate of the point to test. +* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false. */ Phaser.Rectangle.contains = function (a, x, y) { return (x >= a.x && x <= a.right && y >= a.y && y <= a.bottom); }; +Phaser.Rectangle.containsRaw = function (rx, ry, rw, rh, x, y) { + return (x >= rx && x <= (rx + rw) && y >= ry && y <= (ry + rh)); +}; + /** * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter. -* @method containsPoint -* @param {Phaser.Rectangle} a The Rectangle object. -* @param {Phaser.Point} point The point object being checked. Can be Point or any object with .x and .y values. -* @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false. +* @method Phaser.Rectangle.containsPoint +* @param {Phaser.Rectangle} a - The Rectangle object. +* @param {Phaser.Point} point - The point object being checked. Can be Point or any object with .x and .y values. +* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false. */ Phaser.Rectangle.containsPoint = function (a, point) { - return Phaser.Phaser.Rectangle.contains(a, point.x, point.y); + return Phaser.Rectangle.contains(a, point.x, point.y); }; /** * Determines whether the first Rectangle object is fully contained within the second Rectangle object. * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. -* @method containsRect -* @param {Phaser.Rectangle} a The first Rectangle object. -* @param {Phaser.Rectangle} b The second Rectangle object. -* @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false. +* @method Phaser.Rectangle.containsRect +* @param {Phaser.Rectangle} a - The first Rectangle object. +* @param {Phaser.Rectangle} b - The second Rectangle object. +* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false. */ Phaser.Rectangle.containsRect = function (a, b) { @@ -19229,10 +22579,10 @@ Phaser.Rectangle.containsRect = function (a, b) { /** * Determines whether the two Rectangles are equal. * This method compares the x, y, width and height properties of each Rectangle. -* @method equals -* @param {Phaser.Rectangle} a The first Rectangle object. -* @param {Phaser.Rectangle} b The second Rectangle object. -* @return {bool} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false. +* @method Phaser.Rectangle.equals +* @param {Phaser.Rectangle} a - The first Rectangle object. +* @param {Phaser.Rectangle} b - The second Rectangle object. +* @return {boolean} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false. */ Phaser.Rectangle.equals = function (a, b) { return (a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height); @@ -19240,10 +22590,10 @@ Phaser.Rectangle.equals = function (a, b) { /** * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0. -* @method intersection -* @param {Phaser.Rectangle} a The first Rectangle object. -* @param {Phaser.Rectangle} b The second Rectangle object. -* @param {Phaser.Rectangle} output Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. +* @method Phaser.Rectangle.intersection +* @param {Phaser.Rectangle} a - The first Rectangle object. +* @param {Phaser.Rectangle} b - The second Rectangle object. +* @param {Phaser.Rectangle} [out] - Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. * @return {Phaser.Rectangle} A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0. */ Phaser.Rectangle.intersection = function (a, b, out) { @@ -19265,29 +22615,31 @@ Phaser.Rectangle.intersection = function (a, b, out) { /** * Determines whether the two Rectangles intersect with each other. * This method checks the x, y, width, and height properties of the Rectangles. -* @method intersects -* @param {Phaser.Rectangle} a The first Rectangle object. -* @param {Phaser.Rectangle} b The second Rectangle object. -* @param {Number} tolerance A tolerance value to allow for an intersection test with padding, default to 0 -* @return {bool} A value of true if the specified object intersects with this Rectangle object; otherwise false. +* @method Phaser.Rectangle.intersects +* @param {Phaser.Rectangle} a - The first Rectangle object. +* @param {Phaser.Rectangle} b - The second Rectangle object. +* @return {boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false. */ -Phaser.Rectangle.intersects = function (a, b, tolerance) { +Phaser.Rectangle.intersects = function (a, b) { - tolerance = tolerance || 0; + return (a.x < b.right && b.x < a.right && a.y < b.bottom && b.y < a.bottom); - return !(a.x > b.right + tolerance || a.right < b.x - tolerance || a.y > b.bottom + tolerance || a.bottom < b.y - tolerance); + // return (a.x <= b.right && b.x <= a.right && a.y <= b.bottom && b.y <= a.bottom); + + // return (a.left <= b.right && b.left <= a.right && a.top <= b.bottom && b.top <= a.bottom); + // return !(a.x > b.right + tolerance || a.right < b.x - tolerance || a.y > b.bottom + tolerance || a.bottom < b.y - tolerance); }; /** * Determines whether the object specified intersects (overlaps) with the given values. -* @method intersectsRaw -* @param {Number} left -* @param {Number} right -* @param {Number} top -* @param {Number} bottomt -* @param {Number} tolerance A tolerance value to allow for an intersection test with padding, default to 0 -* @return {bool} A value of true if the specified object intersects with the Rectangle; otherwise false. +* @method Phaser.Rectangle.intersectsRaw +* @param {number} left - Description. +* @param {number} right - Description. +* @param {number} top - Description. +* @param {number} bottom - Description. +* @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0 +* @return {boolean} A value of true if the specified object intersects with the Rectangle; otherwise false. */ Phaser.Rectangle.intersectsRaw = function (a, left, right, top, bottom, tolerance) { @@ -19299,20 +22651,33 @@ Phaser.Rectangle.intersectsRaw = function (a, left, right, top, bottom, toleranc /** * Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles. -* @method union -* @param {Phaser.Rectangle} a The first Rectangle object. -* @param {Phaser.Rectangle} b The second Rectangle object. -* @param {Phaser.Rectangle} output Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. +* @method Phaser.Rectangle.union +* @param {Phaser.Rectangle} a - The first Rectangle object. +* @param {Phaser.Rectangle} b - The second Rectangle object. +* @param {Phaser.Rectangle} [out] - Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. * @return {Phaser.Rectangle} A Rectangle object that is the union of the two Rectangles. */ Phaser.Rectangle.union = function (a, b, out) { if (typeof out === "undefined") { out = new Phaser.Rectangle(); } - return out.setTo(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.right, b.right), Math.max(a.bottom, b.bottom)); + return out.setTo(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.right, b.right) - Math.min(a.left, b.left), Math.max(a.bottom, b.bottom) - Math.min(a.top, b.top)); }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Description of Phaser.Net +* +* @class Phaser.Net +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +*/ Phaser.Net = function (game) { this.game = game; @@ -19323,6 +22688,9 @@ Phaser.Net.prototype = { /** * Returns the hostname given by the browser. + * + * @method Phaser.Net#getHostName + * @return {string} */ getHostName: function () { @@ -19339,6 +22707,10 @@ Phaser.Net.prototype = { * If the domain name is found it returns true. * You can specify a part of a domain, for example 'google' would match 'google.com', 'google.co.uk', etc. * Do not include 'http://' at the start. + * + * @method Phaser.Net#checkDomainName + * @param {string} domain + * @return {boolean} */ checkDomainName: function (domain) { return window.location.hostname.indexOf(domain) !== -1; @@ -19349,6 +22721,13 @@ Phaser.Net.prototype = { * If the value doesn't already exist it is set. * If the value exists it is replaced with the new value given. If you don't provide a new value it is removed from the query string. * Optionally you can redirect to the new url, or just return it as a string. + * + * @method Phaser.Net#updateQueryString + * @param {string} key - The querystring key to update. + * @param {string} value - The new value to be set. If it already exists it will be replaced. + * @param {boolean} redirect - If true the browser will issue a redirect to the url with the new querystring. + * @param {string} url - The URL to modify. If none is given it uses window.location.href. + * @return {string} If redirect is false then the modified url and query string is returned. */ updateQueryString: function (key, value, redirect, url) { @@ -19408,6 +22787,10 @@ Phaser.Net.prototype = { /** * Returns the Query String as an object. * If you specify a parameter it will return just the value of that parameter, should it exist. + * + * @method Phaser.Net#getQueryString + * @param {string} [parameter=''] - If specified this will return just the value for that key. + * @return {string|object} An object containing the key value pairs found in the query string or just the value if a parameter was given. */ getQueryString: function (parameter) { @@ -19437,28 +22820,59 @@ Phaser.Net.prototype = { }, + /** + * Returns the Query String as an object. + * If you specify a parameter it will return just the value of that parameter, should it exist. + * + * @method Phaser.Net#decodeURI + * @param {string} value - The URI component to be decoded. + * @return {string} The decoded value. + */ decodeURI: function (value) { return decodeURIComponent(value.replace(/\+/g, " ")); } }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ /** * Phaser - TweenManager -* +* +* @class Phaser.TweenManager +* @classdesc * Phaser.Game has a single instance of the TweenManager through which all Tween objects are created and updated. * Tweens are hooked into the game clock and pause system, adjusting based on the game state. * -* TweenManager is based heavily on tween.js by sole (http://soledadpenades.com). +* TweenManager is based heavily on tween.js by http://soledadpenades.com. * The difference being that tweens belong to a games instance of TweenManager, rather than to a global TWEEN object. * It also has callbacks swapped for Signals and a few issues patched with regard to properties and completion errors. * Please see https://github.com/sole/tween.js for a full list of contributors. +* @constructor +* +* @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.TweenManager = function (game) { + /** + * @property {Phaser.Game} game - Local reference to game. + */ this.game = game; + + /** + * @property {array} _tweens - Description. + * @private + */ this._tweens = []; + + /** + * @property {array} _add - Description. + * @private + */ this._add = []; this.game.onPause.add(this.pauseAll, this); @@ -19468,11 +22882,17 @@ Phaser.TweenManager = function (game) { Phaser.TweenManager.prototype = { + /** + * Version number of this library. + * @property {string} REVISION + * @default + */ REVISION: '11dev', /** * Get all the tween objects in an array. - * @return {Phaser.Tween[]} Array with all tween objects. + * @method Phaser.TweenManager#getAll + * @returns {Phaser.Tween[]} Array with all tween objects. */ getAll: function () { @@ -19482,6 +22902,7 @@ Phaser.TweenManager.prototype = { /** * Remove all tween objects. + * @method Phaser.TweenManager#removeAll */ removeAll: function () { @@ -19492,8 +22913,9 @@ Phaser.TweenManager.prototype = { /** * Add a new tween into the TweenManager. * - * @param tween {Phaser.Tween} The tween object you want to add. - * @return {Phaser.Tween} The tween object you added to the manager. + * @method Phaser.TweenManager#add + * @param {Phaser.Tween} tween - The tween object you want to add. + * @returns {Phaser.Tween} The tween object you added to the manager. */ add: function ( tween ) { @@ -19502,11 +22924,12 @@ Phaser.TweenManager.prototype = { }, /** - * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. - * - * @param obj {object} Object the tween will be run on. - * @return {Phaser.Tween} The newly created tween object. - */ + * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. + * + * @method Phaser.TweenManager#create + * @param {Object} object - Object the tween will be run on. + * @returns {Phaser.Tween} The newly created tween object. + */ create: function (object) { return new Phaser.Tween(object, this.game); @@ -19516,7 +22939,8 @@ Phaser.TweenManager.prototype = { /** * Remove a tween from this manager. * - * @param tween {Phaser.Tween} The tween object you want to remove. + * @method Phaser.TweenManager#remove + * @param {Phaser.Tween} tween - The tween object you want to remove. */ remove: function ( tween ) { @@ -19533,7 +22957,8 @@ Phaser.TweenManager.prototype = { /** * Update all the tween objects you added to this manager. * - * @return {bool} Return false if there's no tween to update, otherwise return true. + * @method Phaser.TweenManager#update + * @returns {boolean} Return false if there's no tween to update, otherwise return true. */ update: function () { @@ -19571,8 +22996,10 @@ Phaser.TweenManager.prototype = { /** * Pauses all currently running tweens. + * + * @method Phaser.TweenManager#update */ - pauseAll: function () { + pauseAll: function () { for (var i = this._tweens.length - 1; i >= 0; i--) { this._tweens[i].pause(); @@ -19582,8 +23009,10 @@ Phaser.TweenManager.prototype = { /** * Pauses all currently paused tweens. + * + * @method Phaser.TweenManager#resumeAll */ - resumeAll: function () { + resumeAll: function () { for (var i = this._tweens.length - 1; i >= 0; i--) { this._tweens[i].resume(); @@ -19592,55 +23021,179 @@ Phaser.TweenManager.prototype = { } }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + /** * Tween constructor * Create a new Tween. * -* @param object {object} Target object will be affected by this tween. -* @param game {Phaser.Game} Current game instance. +* @class Phaser.Tween +* @constructor +* @param {object} object - Target object will be affected by this tween. +* @param {Phaser.Game} game - Current game instance. */ - Phaser.Tween = function (object, game) { /** * Reference to the target object. - * @type {object} + * @property {object} _object + * @private */ this._object = object; + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; + + /** + * @property {object} _manager - Description. + * @private + */ this._manager = this.game.tweens; - this._valuesStart = {}; - this._valuesEnd = {}; - this._valuesStartRepeat = {}; - this._duration = 1000; - this._repeat = 0; - this._yoyo = false; - this._reversed = false; - this._delayTime = 0; - this._startTime = null; - this._easingFunction = Phaser.Easing.Linear.None; - this._interpolationFunction = Phaser.Math.linearInterpolation; - this._chainedTweens = []; - this._onStartCallback = null; - this._onStartCallbackFired = false; - this._onUpdateCallback = null; - this._onCompleteCallback = null; + /** + * @property {object} _valuesStart - Description. + * @private + */ + this._valuesStart = {}; + /** + * @property {object} _valuesEnd - Description. + * @private + */ + this._valuesEnd = {}; + + /** + * @property {object} _valuesStartRepeat - Description. + * @private + */ + this._valuesStartRepeat = {}; + + /** + * @property {number} _duration - Description. + * @private + * @default + */ + this._duration = 1000; + + /** + * @property {number} _repeat - Description. + * @private + * @default + */ + this._repeat = 0; + + /** + * @property {boolean} _yoyo - Description. + * @private + * @default + */ + this._yoyo = false; + + /** + * @property {boolean} _reversed - Description. + * @private + * @default + */ + this._reversed = false; + + /** + * @property {number} _delayTime - Description. + * @private + * @default + */ + this._delayTime = 0; + + /** + * @property {Description} _startTime - Description. + * @private + * @default null + */ + this._startTime = null; + + /** + * @property {Description} _easingFunction - Description. + * @private + */ + this._easingFunction = Phaser.Easing.Linear.None; + + /** + * @property {Description} _interpolationFunction - Description. + * @private + */ + this._interpolationFunction = Phaser.Math.linearInterpolation; + + /** + * @property {Description} _chainedTweens - Description. + * @private + */ + this._chainedTweens = []; + + /** + * @property {Description} _onStartCallback - Description. + * @private + * @default + */ + this._onStartCallback = null; + + /** + * @property {boolean} _onStartCallbackFired - Description. + * @private + * @default + */ + this._onStartCallbackFired = false; + + /** + * @property {Description} _onUpdateCallback - Description. + * @private + * @default null + */ + this._onUpdateCallback = null; + + /** + * @property {Description} _onCompleteCallback - Description. + * @private + * @default null + */ + this._onCompleteCallback = null; + + /** + * @property {number} _pausedTime - Description. + * @private + * @default + */ this._pausedTime = 0; - this._parent = null; + /** + * @property {boolean} pendingDelete - If this tween is ready to be deleted by the TweenManager. + * @default + */ this.pendingDelete = false; - // Set all starting values present on the target object - for ( var field in object ) { - this._valuesStart[ field ] = parseFloat(object[field], 10); - } - + // Set all starting values present on the target object + for ( var field in object ) { + this._valuesStart[ field ] = parseFloat(object[field], 10); + } + + /** + * @property {Phaser.Signal} onStart - Description. + */ this.onStart = new Phaser.Signal(); + + /** + * @property {Phaser.Signal} onComplete - Description. + */ this.onComplete = new Phaser.Signal(); + /** + * @property {boolean} isRunning - Description. + * @default + */ this.isRunning = false; }; @@ -19649,13 +23202,16 @@ Phaser.Tween.prototype = { /** * Configure the Tween - * @param properties {object} Propertis you want to tween. - * @param [duration] {number} duration of this tween. - * @param [ease] {any} Easing function. - * @param [autoStart] {bool} Whether this tween will start automatically or not. - * @param [delay] {number} delay before this tween will start, defaults to 0 (no delay) - * @param [loop] {bool} Should the tween automatically restart once complete? (ignores any chained tweens) - * @return {Tween} Itself. + * + * @method Phaser.Tween#to + * @param {object} properties - Properties you want to tween. + * @param {number} duration - Duration of this tween. + * @param {function} ease - Easing function. + * @param {boolean} autoStart - Whether this tween will start automatically or not. + * @param {number} delay - Delay before this tween will start, defaults to 0 (no delay). + * @param {boolean} repeat - Should the tween automatically restart once complete? (ignores any chained tweens). + * @param {Phaser.Tween} yoyo - Description. + * @return {Phaser.Tween} Itself. */ to: function ( properties, duration, ease, autoStart, delay, repeat, yoyo ) { @@ -19670,13 +23226,14 @@ Phaser.Tween.prototype = { if (this._parent) { self = this._manager.create(this._object); - self._parent = this._parent; - this.chain(self); + this._lastChild.chain(self); + this._lastChild = self; } else { self = this; - self._parent = self; + this._parent = this; + this._lastChild = this; } self._repeat = repeat; @@ -19696,13 +23253,20 @@ Phaser.Tween.prototype = { self._yoyo = yoyo; if (autoStart) { - return self.start(); + return this.start(); } else { - return self; + return this; } }, + /** + * Starts the tween running. Can also be called by the autoStart parameter of Tween.to. + * + * @method Phaser.Tween#start + * @param {number} time - Description. + * @return {Phaser.Tween} Itself. + */ start: function ( time ) { if (this.game === null || this._object === null) { @@ -19749,6 +23313,12 @@ Phaser.Tween.prototype = { }, + /** + * Stops the tween if running and removes it from the TweenManager. If there are any onComplete callbacks or events they are not dispatched. + * + * @method Phaser.Tween#stop + * @return {Phaser.Tween} Itself. + */ stop: function () { this._manager.remove(this); @@ -19758,6 +23328,13 @@ Phaser.Tween.prototype = { }, + /** + * Sets a delay time before this tween will start. + * + * @method Phaser.Tween#delay + * @param {number} amount - The amount of the delay in ms. + * @return {Phaser.Tween} Itself. + */ delay: function ( amount ) { this._delayTime = amount; @@ -19765,6 +23342,13 @@ Phaser.Tween.prototype = { }, + /** + * Sets the number of times this tween will repeat. + * + * @method Phaser.Tween#repeat + * @param {number} times - How many times to repeat. + * @return {Phaser.Tween} Itself. + */ repeat: function ( times ) { this._repeat = times; @@ -19772,6 +23356,14 @@ Phaser.Tween.prototype = { }, + /** + * A tween that has yoyo set to true will run through from start to finish, then reverse from finish to start. + * Used in combination with repeat you can create endless loops. + * + * @method Phaser.Tween#yoyo + * @param {boolean} yoyo - Set to true to yoyo this tween. + * @return {Phaser.Tween} Itself. + */ yoyo: function( yoyo ) { this._yoyo = yoyo; @@ -19779,6 +23371,13 @@ Phaser.Tween.prototype = { }, + /** + * Set easing function this tween will use, i.e. Phaser.Easing.Linear.None. + * + * @method Phaser.Tween#easing + * @param {function} easing - The easing function this tween will use, i.e. Phaser.Easing.Linear.None. + * @return {Phaser.Tween} Itself. + */ easing: function ( easing ) { this._easingFunction = easing; @@ -19786,6 +23385,13 @@ Phaser.Tween.prototype = { }, + /** + * Set interpolation function the tween will use, by default it uses Phaser.Math.linearInterpolation. + * + * @method Phaser.Tween#interpolation + * @param {function} interpolation - The interpolation function to use (Phaser.Math.linearInterpolation by default) + * @return {Phaser.Tween} Itself. + */ interpolation: function ( interpolation ) { this._interpolationFunction = interpolation; @@ -19793,6 +23399,13 @@ Phaser.Tween.prototype = { }, + /** + * You can chain tweens together by passing a reference to the chain function. This enables one tween to call another on completion. + * You can pass as many tweens as you like to this function, they will each be chained in sequence. + * + * @method Phaser.Tween#chain + * @return {Phaser.Tween} Itself. + */ chain: function () { this._chainedTweens = arguments; @@ -19809,14 +23422,23 @@ Phaser.Tween.prototype = { * .to({ x: 0 }, 1000, Phaser.Easing.Linear.None) * .to({ y: 0 }, 1000, Phaser.Easing.Linear.None) * .loop(); - * - * @return {Tween} Itself. + * @method Phaser.Tween#loop + * @return {Phaser.Tween} Itself. */ loop: function() { - if (this._parent) this.chain(this._parent); + + this._lastChild.chain(this); return this; + }, + /** + * Sets a callback to be fired when the tween starts. Note: callback will be called in the context of the global scope. + * + * @method Phaser.Tween#onStartCallback + * @param {function} callback - The callback to invoke on start. + * @return {Phaser.Tween} Itself. + */ onStartCallback: function ( callback ) { this._onStartCallback = callback; @@ -19824,6 +23446,13 @@ Phaser.Tween.prototype = { }, + /** + * Sets a callback to be fired each time this tween updates. Note: callback will be called in the context of the global scope. + * + * @method Phaser.Tween#onUpdateCallback + * @param {function} callback - The callback to invoke each time this tween is updated. + * @return {Phaser.Tween} Itself. + */ onUpdateCallback: function ( callback ) { this._onUpdateCallback = callback; @@ -19831,6 +23460,13 @@ Phaser.Tween.prototype = { }, + /** + * Sets a callback to be fired when the tween completes. Note: callback will be called in the context of the global scope. + * + * @method Phaser.Tween#onCompleteCallback + * @param {function} callback - The callback to invoke on completion. + * @return {Phaser.Tween} Itself. + */ onCompleteCallback: function ( callback ) { this._onCompleteCallback = callback; @@ -19838,15 +23474,33 @@ Phaser.Tween.prototype = { }, + /** + * Pauses the tween. + * + * @method Phaser.Tween#pause + */ pause: function () { this._paused = true; + this._pausedTime = this.game.time.now; }, + /** + * Resumes a paused tween. + * + * @method Phaser.Tween#resume + */ resume: function () { this._paused = false; - this._startTime += this.game.time.pauseDuration; + this._startTime += (this.game.time.now - this._pausedTime); }, + /** + * Core tween update function called by the TweenManager. Does not need to be invoked directly. + * + * @method Phaser.Tween#update + * @param {number} time - A timestamp passed in by the TweenManager. + * @return {boolean} false if the tween has completed and should be deleted from the manager, otherwise true (still active). + */ update: function ( time ) { if (this.pendingDelete) @@ -19977,11 +23631,33 @@ Phaser.Tween.prototype = { }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ +/** +* A collection of easing methods defining ease-in ease-out curves. +* +* @class Phaser.Easing +*/ Phaser.Easing = { + /** + * Linear easing. + * + * @class Phaser.Easing.Linear + */ Linear: { + /** + * Ease-in. + * + * @method Phaser.Easing.Linear#In + * @param {number} k - The value to be tweened. + * @returns {number} k^2. + */ None: function ( k ) { return k; @@ -19990,20 +23666,46 @@ Phaser.Easing = { }, + /** + * Quadratic easing. + * + * @class Phaser.Easing.Quadratic + */ Quadratic: { + /** + * Ease-in. + * + * @method Phaser.Easing.Quadratic#In + * @param {number} k - The value to be tweened. + * @returns {number} k^2. + */ In: function ( k ) { return k * k; }, + /** + * Ease-out. + * + * @method Phaser.Easing.Quadratic#Out + * @param {number} k - The value to be tweened. + * @returns {number} k* (2-k). + */ Out: function ( k ) { return k * ( 2 - k ); }, + /** + * Ease-in/out. + * + * @method Phaser.Easing.Quadratic#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ InOut: function ( k ) { if ( ( k *= 2 ) < 1 ) return 0.5 * k * k; @@ -20013,20 +23715,46 @@ Phaser.Easing = { }, + /** + * Cubic easing. + * + * @class Phaser.Easing.Cubic + */ Cubic: { + /** + * Cubic ease-in. + * + * @method Phaser.Easing.Cubic#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ In: function ( k ) { return k * k * k; }, + /** + * Cubic ease-out. + * + * @method Phaser.Easing.Cubic#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ Out: function ( k ) { return --k * k * k + 1; }, + /** + * Cubic ease-in/out. + * + * @method Phaser.Easing.Cubic#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ InOut: function ( k ) { if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k; @@ -20036,20 +23764,46 @@ Phaser.Easing = { }, + /** + * Quartic easing. + * + * @class Phaser.Easing.Quartic + */ Quartic: { + /** + * Quartic ease-in. + * + * @method Phaser.Easing.Quartic#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ In: function ( k ) { return k * k * k * k; }, + /** + * Quartic ease-out. + * + * @method Phaser.Easing.Quartic#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ Out: function ( k ) { return 1 - ( --k * k * k * k ); }, + /** + * Quartic ease-in/out. + * + * @method Phaser.Easing.Quartic#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ InOut: function ( k ) { if ( ( k *= 2 ) < 1) return 0.5 * k * k * k * k; @@ -20059,20 +23813,46 @@ Phaser.Easing = { }, + /** + * Quintic easing. + * + * @class Phaser.Easing.Quintic + */ Quintic: { + /** + * Quintic ease-in. + * + * @method Phaser.Easing.Quintic#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ In: function ( k ) { return k * k * k * k * k; }, + /** + * Quintic ease-out. + * + * @method Phaser.Easing.Quintic#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ Out: function ( k ) { return --k * k * k * k * k + 1; }, + /** + * Quintic ease-in/out. + * + * @method Phaser.Easing.Quintic#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ InOut: function ( k ) { if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k * k * k; @@ -20082,20 +23862,46 @@ Phaser.Easing = { }, + /** + * Sinusoidal easing. + * + * @class Phaser.Easing.Sinusoidal + */ Sinusoidal: { + /** + * Sinusoidal ease-in. + * + * @method Phaser.Easing.Sinusoidal#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ In: function ( k ) { return 1 - Math.cos( k * Math.PI / 2 ); }, + /** + * Sinusoidal ease-out. + * + * @method Phaser.Easing.Sinusoidal#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ Out: function ( k ) { return Math.sin( k * Math.PI / 2 ); }, + /** + * Sinusoidal ease-in/out. + * + * @method Phaser.Easing.Sinusoidal#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ InOut: function ( k ) { return 0.5 * ( 1 - Math.cos( Math.PI * k ) ); @@ -20104,20 +23910,46 @@ Phaser.Easing = { }, + /** + * Exponential easing. + * + * @class Phaser.Easing.Exponential + */ Exponential: { + /** + * Exponential ease-in. + * + * @method Phaser.Easing.Exponential#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ In: function ( k ) { return k === 0 ? 0 : Math.pow( 1024, k - 1 ); }, + /** + * Exponential ease-out. + * + * @method Phaser.Easing.Exponential#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ Out: function ( k ) { return k === 1 ? 1 : 1 - Math.pow( 2, - 10 * k ); }, + /** + * Exponential ease-in/out. + * + * @method Phaser.Easing.Exponential#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ InOut: function ( k ) { if ( k === 0 ) return 0; @@ -20129,20 +23961,46 @@ Phaser.Easing = { }, + /** + * Circular easing. + * + * @class Phaser.Easing.Circular + */ Circular: { + /** + * Circular ease-in. + * + * @method Phaser.Easing.Circular#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ In: function ( k ) { return 1 - Math.sqrt( 1 - k * k ); }, + /** + * Circular ease-out. + * + * @method Phaser.Easing.Circular#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ Out: function ( k ) { return Math.sqrt( 1 - ( --k * k ) ); }, + /** + * Circular ease-in/out. + * + * @method Phaser.Easing.Circular#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ InOut: function ( k ) { if ( ( k *= 2 ) < 1) return - 0.5 * ( Math.sqrt( 1 - k * k) - 1); @@ -20152,8 +24010,20 @@ Phaser.Easing = { }, + /** + * Elastic easing. + * + * @class Phaser.Easing.Elastic + */ Elastic: { + /** + * Elastic ease-in. + * + * @method Phaser.Easing.Elastic#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ In: function ( k ) { var s, a = 0.1, p = 0.4; @@ -20165,6 +24035,13 @@ Phaser.Easing = { }, + /** + * Elastic ease-out. + * + * @method Phaser.Easing.Elastic#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ Out: function ( k ) { var s, a = 0.1, p = 0.4; @@ -20176,6 +24053,13 @@ Phaser.Easing = { }, + /** + * Elastic ease-in/out. + * + * @method Phaser.Easing.Elastic#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ InOut: function ( k ) { var s, a = 0.1, p = 0.4; @@ -20190,8 +24074,20 @@ Phaser.Easing = { }, + /** + * Back easing. + * + * @class Phaser.Easing.Back + */ Back: { + /** + * Back ease-in. + * + * @method Phaser.Easing.Back#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ In: function ( k ) { var s = 1.70158; @@ -20199,6 +24095,13 @@ Phaser.Easing = { }, + /** + * Back ease-out. + * + * @method Phaser.Easing.Back#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ Out: function ( k ) { var s = 1.70158; @@ -20206,6 +24109,13 @@ Phaser.Easing = { }, + /** + * Back ease-in/out. + * + * @method Phaser.Easing.Back#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ InOut: function ( k ) { var s = 1.70158 * 1.525; @@ -20216,14 +24126,33 @@ Phaser.Easing = { }, + /** + * Bounce easing. + * + * @class Phaser.Easing.Bounce + */ Bounce: { + /** + * Bounce ease-in. + * + * @method Phaser.Easing.Bounce#In + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ In: function ( k ) { - return 1 - TWEEN.Easing.Bounce.Out( 1 - k ); + return 1 - Phaser.Easing.Bounce.Out( 1 - k ); }, + /** + * Bounce ease-out. + * + * @method Phaser.Easing.Bounce#Out + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ Out: function ( k ) { if ( k < ( 1 / 2.75 ) ) { @@ -20246,10 +24175,17 @@ Phaser.Easing = { }, + /** + * Bounce ease-in/out. + * + * @method Phaser.Easing.Bounce#InOut + * @param {number} k - The value to be tweened. + * @returns {number} The tweened value. + */ InOut: function ( k ) { - if ( k < 0.5 ) return TWEEN.Easing.Bounce.In( k * 2 ) * 0.5; - return TWEEN.Easing.Bounce.Out( k * 2 - 1 ) * 0.5 + 0.5; + if ( k < 0.5 ) return Phaser.Easing.Bounce.In( k * 2 ) * 0.5; + return Phaser.Easing.Bounce.Out( k * 2 - 1 ) * 0.5 + 0.5; } @@ -20260,160 +24196,143 @@ Phaser.Easing = { /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Time +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** -* This is the core internal game clock. It manages the elapsed time and calculation of elapsed values, -* used for game object motion and tweens. +* Time constructor. * -* @class Time +* @class Phaser.Time +* @classdesc This is the core internal game clock. It manages the elapsed time and calculation of elapsed values, used for game object motion and tweens. * @constructor * @param {Phaser.Game} game A reference to the currently running game. */ Phaser.Time = function (game) { /** - * A reference to the currently running Game. - * @property game - * @type {Phaser.Game} + * @property {Phaser.Game} game - Local reference to game. */ this.game = game; /** * The time at which the Game instance started. - * @property _started + * @property {number} _started * @private - * @type {Number} + * @default */ this._started = 0; /** * The time (in ms) that the last second counter ticked over. - * @property _timeLastSecond + * @property {number} _timeLastSecond * @private - * @type {Number} + * @default */ this._timeLastSecond = 0; /** * The time the game started being paused. - * @property _pauseStarted + * @property {number} _pauseStarted * @private - * @type {Number} + * @default */ this._pauseStarted = 0; /** * The elapsed time calculated for the physics motion updates. - * @property physicsElapsed - * @public - * @type {Number} + * @property {number} physicsElapsed + * @default */ this.physicsElapsed = 0; /** * Game time counter. - * @property time - * @public - * @type {Number} + * @property {number} time + * @default */ this.time = 0; /** * Records how long the game has been paused for. Is reset each time the game pauses. - * @property pausedTime - * @public - * @type {Number} + * @property {number} pausedTime + * @default */ this.pausedTime = 0; /** * The time right now. - * @property now - * @public - * @type {Number} + * @property {number} now + * @default */ this.now = 0; /** * Elapsed time since the last frame. - * @property elapsed - * @public - * @type {Number} + * @property {number} elapsed + * @default */ this.elapsed = 0; /** * Frames per second. - * @property fps - * @public - * @type {Number} + * @property {number} fps + * @default */ this.fps = 0; /** * The lowest rate the fps has dropped to. - * @property fpsMin - * @public - * @type {Number} + * @property {number} fpsMin + * @default */ this.fpsMin = 1000; /** * The highest rate the fps has reached (usually no higher than 60fps). - * @property fpsMax - * @public - * @type {Number} + * @property {number} fpsMax + * @default */ this.fpsMax = 0; /** * The minimum amount of time the game has taken between two frames. - * @property msMin - * @public - * @type {Number} + * @property {number} msMin + * @default */ this.msMin = 1000; /** * The maximum amount of time the game has taken between two frames. - * @property msMax - * @public - * @type {Number} + * @property {number} msMax + * @default */ this.msMax = 0; /** * The number of frames record in the last second. - * @property frames - * @public - * @type {Number} + * @property {number} frames + * @default */ this.frames = 0; /** * Records how long the game was paused for in miliseconds. - * @property pauseDuration - * @public - * @type {Number} + * @property {number} pauseDuration + * @default */ this.pauseDuration = 0; /** * The value that setTimeout needs to work out when to next update - * @property timeToCall - * @public - * @type {Number} + * @property {number} timeToCall + * @default */ this.timeToCall = 0; /** * Internal value used by timeToCall as part of the setTimeout loop - * @property lastTime - * @public - * @type {Number} + * @property {number} lastTime + * @default */ this.lastTime = 0; @@ -20421,6 +24340,11 @@ Phaser.Time = function (game) { this.game.onPause.add(this.gamePaused, this); this.game.onResume.add(this.gameResumed, this); + /** + * Description. + * @property {boolean} _justResumed + * @default + */ this._justResumed = false; }; @@ -20429,18 +24353,17 @@ Phaser.Time.prototype = { /** * The number of seconds that have elapsed since the game was started. - * @method totalElapsedSeconds - * @return {Number} + * @method Phaser.Time#totalElapsedSeconds + * @return {number} */ totalElapsedSeconds: function() { return (this.now - this._started) * 0.001; }, /** - * Updates the game clock and calculate the fps. - * This is called automatically by Phaser.Game - * @method update - * @param {Number} time The current timestamp, either performance.now or Date.now depending on the browser + * Updates the game clock and calculate the fps. This is called automatically by Phaser.Game. + * @method Phaser.Time#update + * @param {number} time - The current timestamp, either performance.now or Date.now depending on the browser. */ update: function (time) { @@ -20474,6 +24397,12 @@ Phaser.Time.prototype = { this.lastTime = time + this.timeToCall; this.physicsElapsed = 1.0 * (this.elapsed / 1000); + // Clamp the delta + if (this.physicsElapsed > 1) + { + this.physicsElapsed = 1; + } + // Paused? if (this.game.paused) { @@ -20484,7 +24413,7 @@ Phaser.Time.prototype = { /** * Called when the game enters a paused state. - * @method gamePaused + * @method Phaser.Time#gamePaused * @private */ gamePaused: function () { @@ -20495,7 +24424,7 @@ Phaser.Time.prototype = { /** * Called when the game resumes from a paused state. - * @method gameResumed + * @method Phaser.Time#gameResumed * @private */ gameResumed: function () { @@ -20509,9 +24438,9 @@ Phaser.Time.prototype = { /** * How long has passed since the given time. - * @method elapsedSince - * @param {Number} since The time you want to measure against. - * @return {Number} The difference between the given time and now. + * @method Phaser.Time#elapsedSince + * @param {number} since - The time you want to measure against. + * @return {number} The difference between the given time and now. */ elapsedSince: function (since) { return this.now - since; @@ -20519,9 +24448,9 @@ Phaser.Time.prototype = { /** * How long has passed since the given time (in seconds). - * @method elapsedSecondsSince - * @param {Number} since The time you want to measure (in seconds). - * @return {Number} Duration between given time and now (in seconds). + * @method Phaser.Time#elapsedSecondsSince + * @param {number} since - The time you want to measure (in seconds). + * @return {number} Duration between given time and now (in seconds). */ elapsedSecondsSince: function (since) { return (this.now - since) * 0.001; @@ -20529,7 +24458,7 @@ Phaser.Time.prototype = { /** * Resets the private _started value to now. - * @method reset + * @method Phaser.Time#reset */ reset: function () { this._started = this.now; @@ -20539,75 +24468,64 @@ Phaser.Time.prototype = { /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Animation +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** -* The AnimationManager is used to add, play and update Phaser Animations. +* The Animation Manager is used to add, play and update Phaser Animations. * Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance. * -* @class AnimationManager +* @class Phaser.AnimationManager * @constructor -* @param {Phaser.Sprite} sprite A reference to the Game Object that owns this AnimationManager. +* @param {Phaser.Sprite} sprite - A reference to the Game Object that owns this AnimationManager. */ Phaser.AnimationManager = function (sprite) { /** - * A reference to the parent Sprite that owns this AnimationManager. - * @property sprite - * @public - * @type {Phaser.Sprite} + * @property {Phaser.Sprite} sprite - A reference to the parent Sprite that owns this AnimationManager. */ this.sprite = sprite; /** - * A reference to the currently running Game. - * @property game - * @public - * @type {Phaser.Game} + * @property {Phaser.Game} game - A reference to the currently running Game. */ this.game = sprite.game; - /** - * The currently displayed Frame of animation, if any. - * @property currentFrame - * @public - * @type {Phaser.Animation.Frame} - */ + /** + * @property {Phaser.Frame} currentFrame - The currently displayed Frame of animation, if any. + * @default + */ this.currentFrame = null; - - /** - * Should the animation data continue to update even if the Sprite.visible is set to false. - * @property updateIfVisible - * @public - * @type {Boolean} - * @default true - */ + + /** + * @property {boolean} updateIfVisible - Should the animation data continue to update even if the Sprite.visible is set to false. + * @default + */ this.updateIfVisible = true; - /** - * A temp. var for holding the currently playing Animations FrameData. - * @property _frameData - * @private - * @type {Phaser.Animation.FrameData} - */ + /** + * @property {boolean} isLoaded - Set to true once animation data has been loaded. + * @default + */ + this.isLoaded = false; + + /** + * @property {Phaser.FrameData} _frameData - A temp. var for holding the currently playing Animations FrameData. + * @private + * @default + */ this._frameData = null; - /** - * An internal object that stores all of the Animation instances. - * @property _anims - * @private - * @type {Object} - */ + /** + * @property {object} _anims - An internal object that stores all of the Animation instances. + * @private + */ this._anims = {}; - /** - * An internal object to help avoid gc. - * @property _outputFrames - * @private - * @type {Object} - */ + /** + * @property {object} _outputFrames - An internal object to help avoid gc. + * @private + */ this._outputFrames = []; }; @@ -20618,14 +24536,15 @@ Phaser.AnimationManager.prototype = { * Loads FrameData into the internal temporary vars and resets the frame index to zero. * This is called automatically when a new Sprite is created. * - * @method loadFrameData + * @method Phaser.AnimationManager#loadFrameData * @private - * @param {Phaser.Animation.FrameData} frameData The FrameData set to load. + * @param {Phaser.FrameData} frameData - The FrameData set to load. */ loadFrameData: function (frameData) { this._frameData = frameData; this.frame = 0; + this.isLoaded = true; }, @@ -20633,12 +24552,12 @@ Phaser.AnimationManager.prototype = { * Adds a new animation under the given key. Optionally set the frames, frame rate and loop. * Animations added in this way are played back with the play function. * - * @method add - * @param {String} name The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk". - * @param {Array} [frames=null] An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used. - * @param {Number} [frameRate=60] The speed at which the animation should play. The speed is given in frames per second. - * @param {Boolean} [loop=false] {bool} Whether or not the animation is looped or just plays once. - * @param {Boolean} [useNumericIndex=true] Are the given frames using numeric indexes (default) or strings? (false) + * @method Phaser.AnimationManager#add + * @param {string} name - The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk". + * @param {Array} [frames=null] - An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used. + * @param {number} [frameRate=60] - The speed at which the animation should play. The speed is given in frames per second. + * @param {boolean} [loop=false] - Whether or not the animation is looped or just plays once. + * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? * @return {Phaser.Animation} The Animation object that was created. */ add: function (name, frames, frameRate, loop, useNumericIndex) { @@ -20652,7 +24571,19 @@ Phaser.AnimationManager.prototype = { frameRate = frameRate || 60; if (typeof loop === 'undefined') { loop = false; } - if (typeof useNumericIndex === 'undefined') { useNumericIndex = true; } + + // If they didn't set the useNumericIndex then let's at least try and guess it + if (typeof useNumericIndex === 'undefined') + { + if (frames && typeof frames[0] === 'number') + { + useNumericIndex = true; + } + else + { + useNumericIndex = false; + } + } // Create the signals the AnimationManager will emit if (this.sprite.events.onAnimationStart == null) @@ -20678,10 +24609,10 @@ Phaser.AnimationManager.prototype = { /** * Check whether the frames in the given array are valid and exist. * - * @method validateFrames - * @param {Array} frames An array of frames to be validated. - * @param {Boolean} [useNumericIndex=true] Validate the frames based on their numeric index (true) or string index (false) - * @return {Boolean} True if all given Frames are valid, otherwise false. + * @method Phaser.AnimationManager#validateFrames + * @param {Array} frames - An array of frames to be validated. + * @param {boolean} [useNumericIndex=true] - Validate the frames based on their numeric index (true) or string index (false) + * @return {boolean} True if all given Frames are valid, otherwise false. */ validateFrames: function (frames, useNumericIndex) { @@ -20713,13 +24644,14 @@ Phaser.AnimationManager.prototype = { * Play an animation based on the given key. The animation should previously have been added via sprite.animations.add() * If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself. * - * @method play - * @param {String} name The name of the animation to be played, e.g. "fire", "walk", "jump". - * @param {Number} [frameRate=null] The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. - * @param {Boolean} [loop=null] Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. + * @method Phaser.AnimationManager#play + * @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump". + * @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. + * @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. + * @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. * @return {Phaser.Animation} A reference to playing Animation instance. */ - play: function (name, frameRate, loop) { + play: function (name, frameRate, loop, killOnComplete) { if (this._anims[name]) { @@ -20727,13 +24659,13 @@ Phaser.AnimationManager.prototype = { { if (this.currentAnim.isPlaying == false) { - return this.currentAnim.play(frameRate, loop); + return this.currentAnim.play(frameRate, loop, killOnComplete); } } else { this.currentAnim = this._anims[name]; - return this.currentAnim.play(frameRate, loop); + return this.currentAnim.play(frameRate, loop, killOnComplete); } } @@ -20743,9 +24675,9 @@ Phaser.AnimationManager.prototype = { * Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the current animation is stopped. * The currentAnim property of the AnimationManager is automatically set to the animation given. * - * @method stop - * @param {String} [name=null] The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped. - * @param {Boolean} [resetFrame=false] When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false) + * @method Phaser.AnimationManager#stop + * @param {string} [name=null] - The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped. + * @param {boolean} [resetFrame=false] - When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false) */ stop: function (name, resetFrame) { @@ -20772,9 +24704,9 @@ Phaser.AnimationManager.prototype = { /** * The main update function is called by the Sprites update loop. It's responsible for updating animation frames and firing related events. * - * @method update + * @method Phaser.AnimationManager#update * @protected - * @return {Boolean} True if a new animation frame has been set, otherwise false. + * @return {boolean} True if a new animation frame has been set, otherwise false. */ update: function () { @@ -20794,10 +24726,22 @@ Phaser.AnimationManager.prototype = { }, + /** + * Refreshes the current frame data back to the parent Sprite and also resets the texture data. + * + * @method Phaser.AnimationManager#refreshFrame + */ + refreshFrame: function () { + + this.sprite.currentFrame = this.currentFrame; + this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + + }, + /** * Destroys all references this AnimationManager contains. Sets the _anims to a new object and nulls the current animation. * - * @method destroy + * @method Phaser.AnimationManager#destroy */ destroy: function () { @@ -20811,24 +24755,26 @@ Phaser.AnimationManager.prototype = { }; +/** +* @name Phaser.AnimationManager#frameData +* @property {Phaser.FrameData} frameData - The current animations FrameData. +* @readonly +*/ Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", { - /** - * @method frameData - * @return {Phaser.Animation.FrameData} Returns the FrameData of the current animation. - */ get: function () { return this._frameData; } }); +/** +* @name Phaser.AnimationManager#frameTotal +* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded. +* @readonly +*/ Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", { - - /** - * @method frameTotal - * @return {Number} Returns the total number of frames in the loaded FrameData, or -1 if no FrameData is loaded. - */ + get: function () { if (this._frameData) @@ -20843,12 +24789,32 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", { }); +/** +* @name Phaser.AnimationManager#paused +* @property {boolean} paused - Gets and sets the paused state of the current animation. +*/ +Object.defineProperty(Phaser.AnimationManager.prototype, "paused", { + + get: function () { + + return this.currentAnim.isPaused; + + }, + + set: function (value) { + + this.currentAnim.paused = value; + + } + +}); + +/** +* @name Phaser.AnimationManager#frame +* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display. +*/ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", { - /** - * @method frame - * @return {Number} Returns the index of the current frame. - */ get: function () { if (this.currentFrame) @@ -20858,13 +24824,9 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", { }, - /** - * @method frame - * @param {Number} value Sets the current frame on the Sprite and updates the texture cache for display. - */ set: function (value) { - if (this._frameData && this._frameData.getFrame(value) !== null) + if (typeof value === 'number' && this._frameData && this._frameData.getFrame(value) !== null) { this.currentFrame = this._frameData.getFrame(value); this._frameIndex = value; @@ -20876,12 +24838,12 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", { }); +/** +* @name Phaser.AnimationManager#frameName +* @property {string} frameName - Gets or sets the current frame name and updates the Texture Cache for display. +*/ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", { - /** - * @method frameName - * @return {String} Returns the name of the current frame if it has one. - */ get: function () { if (this.currentFrame) @@ -20891,13 +24853,9 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", { }, - /** - * @method frameName - * @param {String} value Sets the current frame on the Sprite and updates the texture cache for display. - */ set: function (value) { - if (this._frameData && this._frameData.getFrameByName(value) !== null) + if (typeof value === 'string' && this._frameData && this._frameData.getFrameByName(value) !== null) { this.currentFrame = this._frameData.getFrameByName(value); this._frameIndex = this.currentFrame.index; @@ -20915,8 +24873,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", { /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Animation +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** @@ -20928,7 +24885,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", { * @param {Phaser.Game} game - A reference to the currently running game. * @param {Phaser.Sprite} parent - A reference to the owner of this Animation. * @param {string} name - The unique name for this animation, used in playback commands. -* @param {Phaser.Animation.FrameData} frameData - The FrameData object that contains all frames used by this Animation. +* @param {Phaser.FrameData} frameData - The FrameData object that contains all frames used by this Animation. * @param {(Array.|Array.)} frames - An array of numbers or strings indicating which frames to play in which order. * @param {number} delay - The time between each frame of the animation, given in ms. * @param {boolean} looped - Should this animation loop or play through once. @@ -20974,6 +24931,11 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope */ this.looped = looped; + /** + * @property {boolean} looped - The loop state of the Animation. + */ + this.killOnComplete = false; + /** * @property {boolean} isFinished - The finished state of the Animation. Set to true once playback completes, false during playback. * @default @@ -20986,6 +24948,19 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope */ this.isPlaying = false; + /** + * @property {boolean} isPaused - The paused state of the Animation. + * @default + */ + this.isPaused = false; + + /** + * @property {boolean} _pauseStartTime - The time the animation paused. + * @private + * @default + */ + this._pauseStartTime = 0; + /** * @property {number} _frameIndex * @private @@ -20994,7 +24969,21 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope this._frameIndex = 0; /** - * @property {Phaser.Animation.Frame} currentFrame - The currently displayed frame of the Animation. + * @property {number} _frameDiff + * @private + * @default + */ + this._frameDiff = 0; + + /** + * @property {number} _frameSkip + * @private + * @default + */ + this._frameSkip = 1; + + /** + * @property {Phaser.Frame} currentFrame - The currently displayed frame of the Animation. */ this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); @@ -21005,28 +24994,33 @@ Phaser.Animation.prototype = { /** * Plays this animation. * - * @method play - * @param {Number} [frameRate=null] The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. - * @param {Boolean} [loop=null] Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. - * @return {Phaser.Animation} A reference to this Animation instance. + * @method Phaser.Animation#play + * @memberof Phaser.Animation + * @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. + * @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. + * @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. + * @return {Phaser.Animation} - A reference to this Animation instance. */ - play: function (frameRate, loop) { + play: function (frameRate, loop, killOnComplete) { - frameRate = frameRate || null; - loop = loop || null; - - if (frameRate !== null) + if (typeof frameRate === 'number') { + // If they set a new frame rate then use it, otherwise use the one set on creation this.delay = 1000 / frameRate; - // this.delay = frameRate; } - if (loop !== null) + if (typeof loop === 'boolean') { - // If they set a new loop value then use it, otherwise use the default set on creation + // If they set a new loop value then use it, otherwise use the one set on creation this.looped = loop; } + if (typeof killOnComplete !== 'undefined') + { + // Remove the parent sprite once the animation has finished? + this.killOnComplete = killOnComplete; + } + this.isPlaying = true; this.isFinished = false; @@ -21050,7 +25044,8 @@ Phaser.Animation.prototype = { /** * Sets this animation back to the first frame and restarts the animation. * - * @method restart + * @method Phaser.Animation#restart + * @memberof Phaser.Animation */ restart: function () { @@ -21069,8 +25064,9 @@ Phaser.Animation.prototype = { /** * Stops playback of this animation and set it to a finished state. If a resetFrame is provided it will stop playback and set frame to the first in the animation. * - * @method stop - * @param {Boolean} [resetFrame=false] If true after the animation stops the currentFrame value will be set to the first frame in this animation. + * @method Phaser.Animation#stop + * @memberof Phaser.Animation + * @param {boolean} [resetFrame=false] - If true after the animation stops the currentFrame value will be set to the first frame in this animation. */ stop: function (resetFrame) { @@ -21089,21 +25085,50 @@ Phaser.Animation.prototype = { /** * Updates this animation. Called automatically by the AnimationManager. * - * @method update + * @method Phaser.Animation#update + * @memberof Phaser.Animation */ update: function () { + if (this.isPaused) + { + return false; + } + if (this.isPlaying == true && this.game.time.now >= this._timeNextFrame) { - this._frameIndex++; + this._frameSkip = 1; - if (this._frameIndex == this._frames.length) + // Lagging? + this._frameDiff = this.game.time.now - this._timeNextFrame; + + this._timeLastFrame = this.game.time.now; + + if (this._frameDiff > this.delay) + { + // We need to skip a frame, work out how many + this._frameSkip = Math.floor(this._frameDiff / this.delay); + + this._frameDiff -= (this._frameSkip * this.delay); + } + + // And what's left now? + this._timeNextFrame = this.game.time.now + (this.delay - this._frameDiff); + + this._frameIndex += this._frameSkip; + + if (this._frameIndex >= this._frames.length) { if (this.looped) { - this._frameIndex = 0; + this._frameIndex %= this._frames.length; this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); - this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + + if (this.currentFrame) + { + this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + } + this._parent.events.onAnimationLoop.dispatch(this._parent, this); } else @@ -21117,9 +25142,6 @@ Phaser.Animation.prototype = { this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); } - this._timeLastFrame = this.game.time.now; - this._timeNextFrame = this.game.time.now + this.delay; - return true; } @@ -21130,7 +25152,8 @@ Phaser.Animation.prototype = { /** * Cleans up this animation ready for deletion. Nulls all values and references. * - * @method destroy + * @method Phaser.Animation#destroy + * @memberof Phaser.Animation */ destroy: function () { @@ -21146,7 +25169,8 @@ Phaser.Animation.prototype = { /** * Called internally when the animation finishes playback. Sets the isPlaying and isFinished states and dispatches the onAnimationComplete event if it exists on the parent. * - * @method onComplete + * @method Phaser.Animation#onComplete + * @memberof Phaser.Animation */ onComplete: function () { @@ -21158,28 +25182,68 @@ Phaser.Animation.prototype = { this._parent.events.onAnimationComplete.dispatch(this._parent, this); } + if (this.killOnComplete) + { + this._parent.kill(); + } + } }; +/** +* @name Phaser.Animation#paused +* @property {boolean} paused - Gets and sets the paused state of this Animation. +*/ +Object.defineProperty(Phaser.Animation.prototype, "paused", { + + get: function () { + + return this.isPaused; + + }, + + set: function (value) { + + this.isPaused = value; + + if (value) + { + // Paused + this._pauseStartTime = this.game.time.now; + } + else + { + // Un-paused + if (this.isPlaying) + { + this._timeNextFrame = this.game.time.now + this.delay; + } + } + + } + +}); + +/** +* @name Phaser.Animation#frameTotal +* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded. +* @readonly +*/ Object.defineProperty(Phaser.Animation.prototype, "frameTotal", { - /** - * @method frameTotal - * @return {Number} The total number of frames in this animation. - */ get: function () { return this._frames.length; } }); +/** +* @name Phaser.Animation#frame +* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display. +*/ Object.defineProperty(Phaser.Animation.prototype, "frame", { - /** - * @method frame - * @return {Animation.Frame} Returns the current frame, or if not set the index of the most recent frame. - */ get: function () { if (this.currentFrame !== null) @@ -21193,10 +25257,6 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", { }, - /** - * @method frame - * @return {Number} Sets the current frame to the given frame index and updates the texture cache. - */ set: function (value) { this.currentFrame = this._frameData.getFrame(value); @@ -21211,201 +25271,206 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", { }); +/** +* Really handy function for when you are creating arrays of animation data but it's using frame names and not numbers. +* For example imagine you've got 30 frames named: 'explosion_0001-large' to 'explosion_0030-large' +* You could use this function to generate those by doing: Phaser.Animation.generateFrameNames('explosion_', 1, 30, '-large', 4); +* +* @method Phaser.Animation.generateFrameNames +* @param {string} prefix - The start of the filename. If the filename was 'explosion_0001-large' the prefix would be 'explosion_'. +* @param {number} start - The number to start sequentially counting from. If your frames are named 'explosion_0001' to 'explosion_0034' the start is 1. +* @param {number} stop - The number to count to. If your frames are named 'explosion_0001' to 'explosion_0034' the stop value is 34. +* @param {string} [suffix=''] - The end of the filename. If the filename was 'explosion_0001-large' the prefix would be '-large'. +* @param {number} [zeroPad=0] - The number of zeroes to pad the min and max values with. If your frames are named 'explosion_0001' to 'explosion_0034' then the zeroPad is 4. +*/ +Phaser.Animation.generateFrameNames = function (prefix, start, stop, suffix, zeroPad) { + + if (typeof suffix == 'undefined') { suffix = ''; } + + var output = []; + var frame = ''; + + if (start < stop) + { + for (var i = start; i <= stop; i++) + { + if (typeof zeroPad == 'number') + { + // str, len, pad, dir + frame = Phaser.Utils.pad(i.toString(), zeroPad, '0', 1); + } + else + { + frame = i.toString(); + } + + frame = prefix + frame + suffix; + + output.push(frame); + } + } + else + { + for (var i = start; i >= stop; i--) + { + if (typeof zeroPad == 'number') + { + // str, len, pad, dir + frame = Phaser.Utils.pad(i.toString(), zeroPad, '0', 1); + } + else + { + frame = i.toString(); + } + + frame = prefix + frame + suffix; + + output.push(frame); + } + } + + return output; + +} + /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Animation +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** * A Frame is a single frame of an animation and is part of a FrameData collection. * -* @class Frame +* @class Phaser.Frame * @constructor -* @param {Number} index The index of this Frame within the FrameData set it is being added to. -* @param {Number} x X position of the frame within the texture image. -* @param {Number} y Y position of the frame within the texture image. -* @param {Number} width Width of the frame within the texture image. -* @param {Number} height Height of the frame within the texture image. -* @param {String} name The name of the frame. In Texture Atlas data this is usually set to the filename. -* @param {String} uuid Internal UUID key. +* @param {number} index - The index of this Frame within the FrameData set it is being added to. +* @param {number} x - X position of the frame within the texture image. +* @param {number} y - Y position of the frame within the texture image. +* @param {number} width - Width of the frame within the texture image. +* @param {number} height - Height of the frame within the texture image. +* @param {string} name - The name of the frame. In Texture Atlas data this is usually set to the filename. +* @param {string} uuid - Internal UUID key. */ -Phaser.Animation.Frame = function (index, x, y, width, height, name, uuid) { +Phaser.Frame = function (index, x, y, width, height, name, uuid) { /** - * The index of this Frame within the FrameData set it is being added to. - * @property index - * @public - * @type {Number} + * @property {number} index - The index of this Frame within the FrameData set it is being added to. */ this.index = index; - + /** - * X position within the image to cut from. - * @property x - * @public - * @type {Number} + * @property {number} x - X position within the image to cut from. */ this.x = x; /** - * Y position within the image to cut from. - * @property y - * @public - * @type {Number} + * @property {number} y - Y position within the image to cut from. */ this.y = y; /** - * Width of the frame. - * @property width - * @public - * @type {Number} + * @property {number} width - Width of the frame. */ this.width = width; /** - * Height of the frame. - * @property height - * @public - * @type {Number} + * @property {number} height - Height of the frame. */ this.height = height; /** - * Useful for Texture Atlas files. (is set to the filename value) - * @property name - * @public - * @type {String} + * @property {string} name - Useful for Texture Atlas files (is set to the filename value). */ this.name = name; /** - * A link to the PIXI.TextureCache entry - * @property uuid - * @public - * @type {String} + * @property {string} uuid - A link to the PIXI.TextureCache entry. */ this.uuid = uuid; /** - * center X position within the image to cut from. - * @property centerX - * @public - * @type {Number} + * @property {number} centerX - Center X position within the image to cut from. */ this.centerX = Math.floor(width / 2); /** - * center Y position within the image to cut from. - * @property centerY - * @public - * @type {Number} + * @property {number} centerY - Center Y position within the image to cut from. */ this.centerY = Math.floor(height / 2); /** - * The distance from the top left to the bottom-right of this Frame. - * @property distance - * @public - * @type {Number} + * @property {number} distance - The distance from the top left to the bottom-right of this Frame. */ this.distance = Phaser.Math.distance(0, 0, width, height); /** - * Rotated? (not yet implemented) - * @property rotated - * @public - * @type {Boolean} - * @default false + * @property {boolean} rotated - Rotated? (not yet implemented) + * @default */ this.rotated = false; /** - * Either cw or ccw, rotation is always 90 degrees. - * @property rotationDirection - * @public - * @type {String} - * @default "cw" + * @property {string} rotationDirection - Either 'cw' or 'ccw', rotation is always 90 degrees. + * @default 'cw' */ this.rotationDirection = 'cw'; /** - * Was it trimmed when packed? - * @property trimmed - * @public - * @type {Boolean} + * @property {boolean} trimmed - Was it trimmed when packed? + * @default */ this.trimmed = false; /** - * Width of the original sprite. - * @property sourceSizeW - * @public - * @type {Number} + * @property {number} sourceSizeW - Width of the original sprite. */ this.sourceSizeW = width; /** - * Height of the original sprite. - * @property sourceSizeH - * @public - * @type {Number} + * @property {number} sourceSizeH - Height of the original sprite. */ this.sourceSizeH = height; /** - * X position of the trimmed sprite inside original sprite. - * @property spriteSourceSizeX - * @public - * @type {Number} - * @default 0 + * @property {number} spriteSourceSizeX - X position of the trimmed sprite inside original sprite. + * @default */ this.spriteSourceSizeX = 0; /** - * Y position of the trimmed sprite inside original sprite. - * @property spriteSourceSizeY - * @public - * @type {Number} - * @default 0 + * @property {number} spriteSourceSizeY - Y position of the trimmed sprite inside original sprite. + * @default */ this.spriteSourceSizeY = 0; /** - * Width of the trimmed sprite. - * @property spriteSourceSizeW - * @public - * @type {Number} - * @default 0 + * @property {number} spriteSourceSizeW - Width of the trimmed sprite. + * @default */ this.spriteSourceSizeW = 0; /** - * Height of the trimmed sprite. - * @property spriteSourceSizeH - * @public - * @type {Number} - * @default 0 + * @property {number} spriteSourceSizeH - Height of the trimmed sprite. + * @default */ this.spriteSourceSizeH = 0; }; -Phaser.Animation.Frame.prototype = { +Phaser.Frame.prototype = { /** * If the frame was trimmed when added to the Texture Atlas this records the trim and source data. * - * @method setTrim - * @param {Boolean} trimmed If this frame was trimmed or not. - * @param {Number} actualWidth The width of the frame before being trimmed. - * @param {Number} actualHeight The height of the frame before being trimmed. - * @param {Number} destX The destination X position of the trimmed frame for display. - * @param {Number} destY The destination Y position of the trimmed frame for display. - * @param {Number} destWidth The destination width of the trimmed frame for display. - * @param {Number} destHeight The destination height of the trimmed frame for display. + * @method Phaser.Frame#setTrim + * @param {boolean} trimmed - If this frame was trimmed or not. + * @param {number} actualWidth - The width of the frame before being trimmed. + * @param {number} actualHeight - The height of the frame before being trimmed. + * @param {number} destX - The destination X position of the trimmed frame for display. + * @param {number} destY - The destination Y position of the trimmed frame for display. + * @param {number} destWidth - The destination width of the trimmed frame for display. + * @param {number} destHeight - The destination height of the trimmed frame for display. */ setTrim: function (trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) { @@ -21432,44 +25497,40 @@ Phaser.Animation.Frame.prototype = { /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Animation.FrameData +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** * FrameData is a container for Frame objects, which are the internal representation of animation data in Phaser. * -* @class FrameData +* @class Phaser.FrameData * @constructor */ -Phaser.Animation.FrameData = function () { +Phaser.FrameData = function () { - /** - * Local array of frames. - * @property _frames - * @private - * @type {Array} - */ + /** + * @property {Array} _frames - Local array of frames. + * @private + */ this._frames = []; - /** - * Local array of frame names for name to index conversions. - * @property _frameNames - * @private - * @type {Array} - */ + + /** + * @property {Array} _frameNames - Local array of frame names for name to index conversions. + * @private + */ this._frameNames = []; }; -Phaser.Animation.FrameData.prototype = { +Phaser.FrameData.prototype = { /** * Adds a new Frame to this FrameData collection. Typically called by the Animation.Parser and not directly. * - * @method addFrame - * @param {Phaser.Animation.Frame} frame The frame to add to this FrameData set. - * @return {Phaser.Animation.Frame} The frame that was just added. + * @method Phaser.FrameData#addFrame + * @param {Phaser.Frame} frame - The frame to add to this FrameData set. + * @return {Phaser.Frame} The frame that was just added. */ addFrame: function (frame) { @@ -21489,13 +25550,13 @@ Phaser.Animation.FrameData.prototype = { /** * Get a Frame by its numerical index. * - * @method getFrame - * @param {Number} index The index of the frame you want to get. - * @return {Phaser.Animation.Frame} The frame, if found. + * @method Phaser.FrameData#getFrame + * @param {number} index - The index of the frame you want to get. + * @return {Phaser.Frame} The frame, if found. */ getFrame: function (index) { - if (this._frames[index]) + if (this._frames.length > index) { return this._frames[index]; } @@ -21507,9 +25568,9 @@ Phaser.Animation.FrameData.prototype = { /** * Get a Frame by its frame name. * - * @method getFrameByName - * @param {String} name The name of the frame you want to get. - * @return {Phaser.Animation.Frame} The frame, if found. + * @method Phaser.FrameData#getFrameByName + * @param {string} name - The name of the frame you want to get. + * @return {Phaser.Frame} The frame, if found. */ getFrameByName: function (name) { @@ -21525,9 +25586,9 @@ Phaser.Animation.FrameData.prototype = { /** * Check if there is a Frame with the given name. * - * @method checkFrameName - * @param {String} name The name of the frame you want to check. - * @return {Boolean} True if the frame is found, otherwise false. + * @method Phaser.FrameData#checkFrameName + * @param {string} name - The name of the frame you want to check. + * @return {boolean} True if the frame is found, otherwise false. */ checkFrameName: function (name) { @@ -21543,10 +25604,10 @@ Phaser.Animation.FrameData.prototype = { /** * Returns a range of frames based on the given start and end frame indexes and returns them in an Array. * - * @method getFrameRange - * @param {Number} start The starting frame index. - * @param {Number} end The ending frame index. - * @param {Array} [output] Optional array. If given the results will be appended to the end of this Array. + * @method Phaser.FrameData#getFrameRange + * @param {number} start - The starting frame index. + * @param {number} end - The ending frame index. + * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created. * @return {Array} An array of Frames between the start and end index values, or an empty array if none were found. */ getFrameRange: function (start, end, output) { @@ -21566,10 +25627,10 @@ Phaser.Animation.FrameData.prototype = { * Returns all of the Frames in this FrameData set where the frame index is found in the input array. * The frames are returned in the output array, or if none is provided in a new Array object. * - * @method getFrames - * @param {Array} frames An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned. - * @param {Boolean} [useNumericIndex=true] Are the given frames using numeric indexes (default) or strings? (false) - * @param {Array} [output] Optional array. If given the results will be appended to the end of this Array, otherwise a new array is created. + * @method Phaser.FrameData#getFrames + * @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned. + * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false) + * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created. * @return {Array} An array of all Frames in this FrameData set matching the given names or IDs. */ getFrames: function (frames, useNumericIndex, output) { @@ -21613,10 +25674,10 @@ Phaser.Animation.FrameData.prototype = { * Returns all of the Frame indexes in this FrameData set. * The frames indexes are returned in the output array, or if none is provided in a new Array object. * - * @method getFrameIndexes - * @param {Array} frames An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned. - * @param {Boolean} [useNumericIndex=true] Are the given frames using numeric indexes (default) or strings? (false) - * @param {Array} [output] Optional array. If given the results will be appended to the end of this Array, otherwise a new array is created. + * @method Phaser.FrameData#getFrameIndexes + * @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned. + * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false) + * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created. * @return {Array} An array of all Frame indexes matching the given names or IDs. */ getFrameIndexes: function (frames, useNumericIndex, output) { @@ -21644,7 +25705,10 @@ Phaser.Animation.FrameData.prototype = { } else { - output.push(this.getFrameByName(frames[i]).index); + if (this.getFrameByName(frames[i])) + { + output.push(this.getFrameByName(frames[i]).index); + } } } } @@ -21655,42 +25719,42 @@ Phaser.Animation.FrameData.prototype = { }; -Object.defineProperty(Phaser.Animation.FrameData.prototype, "total", { +/** +* @name Phaser.FrameData#total +* @property {number} total - The total number of frames in this FrameData set. +* @readonly +*/ +Object.defineProperty(Phaser.FrameData.prototype, "total", { - /** - * Returns the total number of frames in this FrameData set. - * - * @method total - * @return {Number} The total number of frames in this FrameData set. - */ get: function () { return this._frames.length; } }); +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ /** * Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations. * -* @author Richard Davey -* @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Animation +* @class Phaser.AnimationParser */ - -Phaser.Animation.Parser = { +Phaser.AnimationParser = { /** * Parse a Sprite Sheet and extract the animation frame data from it. * - * @method spriteSheet - * @param {Phaser.Game} game A reference to the currently running game. - * @param {String} key The Game.Cache asset key of the Sprite Sheet image. - * @param {Number} frameWidth The fixed width of each frame of the animation. If negative, indicates how many columns there are. - * @param {Number} frameHeight The fixed height of each frame of the animation. If negative, indicates how many rows there are. - * @param {Number} [frameMax=-1] The total number of animation frames to extact from the Sprite Sheet. The default value of -1 means "extract all frames". - * @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames. + * @method Phaser.AnimationParser.spriteSheet + * @param {Phaser.Game} game - A reference to the currently running game. + * @param {string} key - The Game.Cache asset key of the Sprite Sheet image. + * @param {number} frameWidth - The fixed width of each frame of the animation. + * @param {number} frameHeight - The fixed height of each frame of the animation. + * @param {number} [frameMax=-1] - The total number of animation frames to extact from the Sprite Sheet. The default value of -1 means "extract all frames". + * @return {Phaser.FrameData} A FrameData object containing the parsed frames. */ spriteSheet: function (game, key, frameWidth, frameHeight, frameMax) { @@ -21704,14 +25768,17 @@ Phaser.Animation.Parser = { var width = img.width; var height = img.height; + if (frameWidth <= 0) { - frameWidth = Math.floor(-width/Math.min(-1, frameWidth)); + frameWidth = Math.floor(-width / Math.min(-1, frameWidth)); } + if (frameHeight <= 0) { - frameHeight = Math.floor(-height/Math.min(-1, frameHeight)); + frameHeight = Math.floor(-height / Math.min(-1, frameHeight)); } + var row = Math.round(width / frameWidth); var column = Math.round(height / frameHeight); var total = row * column; @@ -21724,12 +25791,12 @@ Phaser.Animation.Parser = { // Zero or smaller than frame sizes? if (width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0) { - console.warn("Phaser.Animation.Parser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight"); + console.warn("Phaser.AnimationParser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight"); return null; } // Let's create some frames then - var data = new Phaser.Animation.FrameData(); + var data = new Phaser.FrameData(); var x = 0; var y = 0; @@ -21737,7 +25804,7 @@ Phaser.Animation.Parser = { { var uuid = game.rnd.uuid(); - data.addFrame(new Phaser.Animation.Frame(i, x, y, frameWidth, frameHeight, '', uuid)); + data.addFrame(new Phaser.Frame(i, x, y, frameWidth, frameHeight, '', uuid)); PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[key], { x: x, @@ -21762,24 +25829,24 @@ Phaser.Animation.Parser = { /** * Parse the JSON data and extract the animation frame data from it. * - * @method JSONData - * @param {Phaser.Game} game A reference to the currently running game. - * @param {Object} json The JSON data from the Texture Atlas. Must be in Array format. - * @param {String} cacheKey The Game.Cache asset key of the texture image. - * @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames. + * @method Phaser.AnimationParser.JSONData + * @param {Phaser.Game} game - A reference to the currently running game. + * @param {Object} json - The JSON data from the Texture Atlas. Must be in Array format. + * @param {string} cacheKey - The Game.Cache asset key of the texture image. + * @return {Phaser.FrameData} A FrameData object containing the parsed frames. */ JSONData: function (game, json, cacheKey) { // Malformed? if (!json['frames']) { - console.warn("Phaser.Animation.Parser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"); + console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"); console.log(json); return; } // Let's create some frames then - var data = new Phaser.Animation.FrameData(); + var data = new Phaser.FrameData(); // By this stage frames is a fully parsed array var frames = json['frames']; @@ -21789,7 +25856,7 @@ Phaser.Animation.Parser = { { var uuid = game.rnd.uuid(); - newFrame = data.addFrame(new Phaser.Animation.Frame( + newFrame = data.addFrame(new Phaser.Frame( i, frames[i].frame.x, frames[i].frame.y, @@ -21818,9 +25885,11 @@ Phaser.Animation.Parser = { frames[i].spriteSourceSize.h ); - PIXI.TextureCache[uuid].realSize = frames[i].spriteSourceSize; - // PIXI.TextureCache[uuid].realSize = frames[i].sourceSize; - PIXI.TextureCache[uuid].trim.x = 0; + // We had to hack Pixi to get this to work :( + PIXI.TextureCache[uuid].trimmed = true; + PIXI.TextureCache[uuid].trim.x = frames[i].spriteSourceSize.x; + PIXI.TextureCache[uuid].trim.y = frames[i].spriteSourceSize.y; + } } @@ -21831,24 +25900,24 @@ Phaser.Animation.Parser = { /** * Parse the JSON data and extract the animation frame data from it. * - * @method JSONDataHash - * @param {Phaser.Game} game A reference to the currently running game. - * @param {Object} json The JSON data from the Texture Atlas. Must be in JSON Hash format. - * @param {String} cacheKey The Game.Cache asset key of the texture image. - * @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames. + * @method Phaser.AnimationParser.JSONDataHash + * @param {Phaser.Game} game - A reference to the currently running game. + * @param {Object} json - The JSON data from the Texture Atlas. Must be in JSON Hash format. + * @param {string} cacheKey - The Game.Cache asset key of the texture image. + * @return {Phaser.FrameData} A FrameData object containing the parsed frames. */ JSONDataHash: function (game, json, cacheKey) { // Malformed? if (!json['frames']) { - console.warn("Phaser.Animation.Parser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"); + console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"); console.log(json); return; } // Let's create some frames then - var data = new Phaser.Animation.FrameData(); + var data = new Phaser.FrameData(); // By this stage frames is a fully parsed array var frames = json['frames']; @@ -21859,7 +25928,7 @@ Phaser.Animation.Parser = { { var uuid = game.rnd.uuid(); - newFrame = data.addFrame(new Phaser.Animation.Frame( + newFrame = data.addFrame(new Phaser.Frame( i, frames[key].frame.x, frames[key].frame.y, @@ -21888,9 +25957,11 @@ Phaser.Animation.Parser = { frames[key].spriteSourceSize.h ); - PIXI.TextureCache[uuid].realSize = frames[key].spriteSourceSize; - // PIXI.TextureCache[uuid].realSize = frames[key].sourceSize; - PIXI.TextureCache[uuid].trim.x = 0; + // We had to hack Pixi to get this to work :( + PIXI.TextureCache[uuid].trimmed = true; + PIXI.TextureCache[uuid].trim.x = frames[key].spriteSourceSize.x; + PIXI.TextureCache[uuid].trim.y = frames[key].spriteSourceSize.y; + } i++; @@ -21903,23 +25974,23 @@ Phaser.Animation.Parser = { /** * Parse the XML data and extract the animation frame data from it. * - * @method XMLData - * @param {Phaser.Game} game A reference to the currently running game. - * @param {Object} xml The XML data from the Texture Atlas. Must be in Starling XML format. - * @param {String} cacheKey The Game.Cache asset key of the texture image. - * @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames. + * @method Phaser.AnimationParser.XMLData + * @param {Phaser.Game} game - A reference to the currently running game. + * @param {Object} xml - The XML data from the Texture Atlas. Must be in Starling XML format. + * @param {string} cacheKey - The Game.Cache asset key of the texture image. + * @return {Phaser.FrameData} A FrameData object containing the parsed frames. */ XMLData: function (game, xml, cacheKey) { // Malformed? if (!xml.getElementsByTagName('TextureAtlas')) { - console.warn("Phaser.Animation.Parser.XMLData: Invalid Texture Atlas XML given, missing tag"); + console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing tag"); return; } // Let's create some frames then - var data = new Phaser.Animation.FrameData(); + var data = new Phaser.FrameData(); var frames = xml.getElementsByTagName('SubTexture'); var newFrame; @@ -21929,7 +26000,7 @@ Phaser.Animation.Parser = { var frame = frames[i].attributes; - newFrame = data.addFrame(new Phaser.Animation.Frame( + newFrame = data.addFrame(new Phaser.Frame( i, frame.x.nodeValue, frame.y.nodeValue, @@ -21947,7 +26018,8 @@ Phaser.Animation.Parser = { }); // Trimmed? - if (frame.frameX.nodeValue != '-0' || frame.frameY.nodeValue != '-0') { + if (frame.frameX.nodeValue != '-0' || frame.frameY.nodeValue != '-0') + { newFrame.setTrim( true, frame.width.nodeValue, @@ -21965,7 +26037,10 @@ Phaser.Animation.Parser = { h: frame.frameHeight.nodeValue }; - PIXI.TextureCache[uuid].trim.x = 0; + // We had to hack Pixi to get this to work :( + PIXI.TextureCache[uuid].trimmed = true; + PIXI.TextureCache[uuid].trim.x = Math.abs(frame.frameX.nodeValue); + PIXI.TextureCache[uuid].trim.y = Math.abs(frame.frameY.nodeValue); } } @@ -21977,62 +26052,74 @@ Phaser.Animation.Parser = { }; /** -* Cache +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser.Cache constructor. * -* A game only has one instance of a Cache and it is used to store all externally loaded assets such +* @class Phaser.Cache +* @classdesc A game only has one instance of a Cache and it is used to store all externally loaded assets such * as images, sounds and data files as a result of Loader calls. Cache items use string based keys for look-up. -* -* @package Phaser.Cache -* @author Richard Davey -* @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.Cache = function (game) { /** - * Local reference to Game. - */ + * @property {Phaser.Game} game - Local reference to game. + */ this.game = game; - /** - * Canvas key-value container. - * @type {object} - * @private - */ + /** + * @property {object} game - Canvas key-value container. + * @private + */ this._canvases = {}; /** - * Image key-value container. - * @type {object} - */ + * @property {object} _images - Image key-value container. + * @private + */ this._images = {}; /** - * RenderTexture key-value container. - * @type {object} - */ + * @property {object} _textures - RenderTexture key-value container. + * @private + */ this._textures = {}; /** - * Sound key-value container. - * @type {object} - */ + * @property {object} _sounds - Sound key-value container. + * @private + */ this._sounds = {}; /** - * Text key-value container. - * @type {object} - */ + * @property {object} _text - Text key-value container. + * @private + */ this._text = {}; /** - * Tilemap key-value container. - * @type {object} - */ + * @property {object} _tilemaps - Tilemap key-value container. + * @private + */ this._tilemaps = {}; + /** + * @property {object} _tilesets - Tileset key-value container. + * @private + */ + this._tilesets = {}; + this.addDefaultImage(); + /** + * @property {Phaser.Signal} onSoundUnlock - Description. + */ this.onSoundUnlock = new Phaser.Signal; }; @@ -22040,11 +26127,12 @@ Phaser.Cache = function (game) { Phaser.Cache.prototype = { /** - * Add a new canvas. - * @param key {string} Asset key for this canvas. - * @param canvas {HTMLCanvasElement} Canvas DOM element. - * @param context {CanvasRenderingContext2D} Render context of this canvas. - */ + * Add a new canvas object in to the cache. + * @method Phaser.Cache#addCanvas + * @param {string} key - Asset key for this canvas. + * @param {HTMLCanvasElement} canvas - Canvas DOM element. + * @param {CanvasRenderingContext2D} context - Render context of this canvas. + */ addCanvas: function (key, canvas, context) { this._canvases[key] = { canvas: canvas, context: context }; @@ -22052,27 +26140,31 @@ Phaser.Cache.prototype = { }, /** - * Add a new canvas. - * @param key {string} Asset key for this canvas. - * @param canvas {RenderTexture} A RenderTexture. - */ + * Add a new Phaser.RenderTexture in to the cache. + * + * @method Phaser.Cache#addRenderTexture + * @param {string} key - The unique key by which you will reference this object. + * @param {Phaser.Texture} textue - The texture to use as the base of the RenderTexture. + */ addRenderTexture: function (key, texture) { - var frame = new Phaser.Animation.Frame(0, 0, 0, texture.width, texture.height, '', ''); + var frame = new Phaser.Frame(0, 0, 0, texture.width, texture.height, '', ''); this._textures[key] = { texture: texture, frame: frame }; }, /** - * Add a new sprite sheet. - * @param key {string} Asset key for the sprite sheet. - * @param url {string} URL of this sprite sheet file. - * @param data {object} Extra sprite sheet data. - * @param frameWidth {number} Width of the sprite sheet. - * @param frameHeight {number} Height of the sprite sheet. - * @param frameMax {number} How many frames stored in the sprite sheet. - */ + * Add a new sprite sheet in to the cache. + * + * @method Phaser.Cache#addSpriteSheet + * @param {string} key - The unique key by which you will reference this object. + * @param {string} url - URL of this sprite sheet file. + * @param {object} data - Extra sprite sheet data. + * @param {number} frameWidth - Width of the sprite sheet. + * @param {number} frameHeight - Height of the sprite sheet. + * @param {number} frameMax - How many frames stored in the sprite sheet. + */ addSpriteSheet: function (key, url, data, frameWidth, frameHeight, frameMax) { this._images[key] = { url: url, data: data, spriteSheet: true, frameWidth: frameWidth, frameHeight: frameHeight }; @@ -22080,33 +26172,61 @@ Phaser.Cache.prototype = { PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data); PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]); - this._images[key].frameData = Phaser.Animation.Parser.spriteSheet(this.game, key, frameWidth, frameHeight, frameMax); + this._images[key].frameData = Phaser.AnimationParser.spriteSheet(this.game, key, frameWidth, frameHeight, frameMax); }, /** - * Add a new tilemap. - * @param key {string} Asset key for the texture atlas. - * @param url {string} URL of this texture atlas file. - * @param data {object} Extra texture atlas data. - * @param atlasData {object} Texture atlas frames data. - */ - addTilemap: function (key, url, data, mapData, format) { + * Add a new tile set in to the cache. + * + * @method Phaser.Cache#addTileset + * @param {string} key - The unique key by which you will reference this object. + * @param {string} url - URL of this tile set file. + * @param {object} data - Extra tile set data. + * @param {number} tileWidth - Width of the sprite sheet. + * @param {number} tileHeight - Height of the sprite sheet. + * @param {number} tileMax - How many tiles stored in the sprite sheet. + * @param {number} [tileMargin=0] - If the tiles have been drawn with a margin, specify the amount here. + * @param {number} [tileSpacing=0] - If the tiles have been drawn with spacing between them, specify the amount here. + */ + addTileset: function (key, url, data, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing) { - this._tilemaps[key] = { url: url, data: data, spriteSheet: true, mapData: mapData, format: format }; + this._tilesets[key] = { url: url, data: data, tileWidth: tileWidth, tileHeight: tileHeight, tileMargin: tileMargin, tileSpacing: tileSpacing }; PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data); PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]); + this._tilesets[key].tileData = Phaser.TilemapParser.tileset(this.game, key, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing); + }, /** - * Add a new texture atlas. - * @param key {string} Asset key for the texture atlas. - * @param url {string} URL of this texture atlas file. - * @param data {object} Extra texture atlas data. - * @param atlasData {object} Texture atlas frames data. - */ + * Add a new tilemap. + * + * @method Phaser.Cache#addTilemap + * @param {string} key - The unique key by which you will reference this object. + * @param {string} url - URL of the tilemap image. + * @param {object} mapData - The tilemap data object. + * @param {number} format - The format of the tilemap data. + */ + addTilemap: function (key, url, mapData, format) { + + this._tilemaps[key] = { url: url, data: mapData, format: format }; + + this._tilemaps[key].layers = Phaser.TilemapParser.parse(this.game, mapData, format); + + }, + + /** + * Add a new texture atlas. + * + * @method Phaser.Cache#addTextureAtlas + * @param {string} key - The unique key by which you will reference this object. + * @param {string} url - URL of this texture atlas file. + * @param {object} data - Extra texture atlas data. + * @param {object} atlasData - Texture atlas frames data. + * @param {number} format - The format of the texture atlas. + */ addTextureAtlas: function (key, url, data, atlasData, format) { this._images[key] = { url: url, data: data, spriteSheet: true }; @@ -22116,26 +26236,28 @@ Phaser.Cache.prototype = { if (format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY) { - this._images[key].frameData = Phaser.Animation.Parser.JSONData(this.game, atlasData, key); + this._images[key].frameData = Phaser.AnimationParser.JSONData(this.game, atlasData, key); } else if (format == Phaser.Loader.TEXTURE_ATLAS_JSON_HASH) { - this._images[key].frameData = Phaser.Animation.Parser.JSONDataHash(this.game, atlasData, key); + this._images[key].frameData = Phaser.AnimationParser.JSONDataHash(this.game, atlasData, key); } else if (format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING) { - this._images[key].frameData = Phaser.Animation.Parser.XMLData(this.game, atlasData, key); + this._images[key].frameData = Phaser.AnimationParser.XMLData(this.game, atlasData, key); } }, /** - * Add a new Bitmap Font. - * @param key {string} Asset key for the font texture. - * @param url {string} URL of this font xml file. - * @param data {object} Extra font data. - * @param xmlData {object} Texture atlas frames data. - */ + * Add a new Bitmap Font. + * + * @method Phaser.Cache#addBitmapFont + * @param {string} key - The unique key by which you will reference this object. + * @param {string} url - URL of this font xml file. + * @param {object} data - Extra font data. + * @param xmlData {object} Texture atlas frames data. + */ addBitmapFont: function (key, url, data, xmlData) { this._images[key] = { url: url, data: data, spriteSheet: true }; @@ -22143,40 +26265,59 @@ Phaser.Cache.prototype = { PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data); PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]); - Phaser.Loader.Parser.bitmapFont(this.game, xmlData, key); - // this._images[key].frameData = Phaser.Animation.Parser.XMLData(this.game, xmlData, key); + Phaser.LoaderParser.bitmapFont(this.game, xmlData, key); + // this._images[key].frameData = Phaser.AnimationParser.XMLData(this.game, xmlData, key); }, /** - * Adds a default image to be used when a key is wrong / missing. - * Is mapped to the key __default - */ + * Adds a default image to be used when a key is wrong / missing. Is mapped to the key __default. + * + * @method Phaser.Cache#addDefaultImage + */ addDefaultImage: function () { - this._images['__default'] = { url: null, data: null, spriteSheet: false }; - this._images['__default'].frame = new Phaser.Animation.Frame(0, 0, 0, 32, 32, '', ''); + var img = new Image(); + img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=="; - var base = new PIXI.BaseTexture(); - base.width = 32; - base.height = 32; - base.hasLoaded = true; // avoids a hanging event listener + this._images['__default'] = { url: null, data: img, spriteSheet: false }; + this._images['__default'].frame = new Phaser.Frame(0, 0, 0, 32, 32, '', ''); - PIXI.BaseTextureCache['__default'] = base; - PIXI.TextureCache['__default'] = new PIXI.Texture(base); + PIXI.BaseTextureCache['__default'] = new PIXI.BaseTexture(img); + PIXI.TextureCache['__default'] = new PIXI.Texture(PIXI.BaseTextureCache['__default']); }, /** - * Add a new image. - * @param key {string} Asset key for the image. - * @param url {string} URL of this image file. - * @param data {object} Extra image data. - */ + * Add a new text data. + * + * @method Phaser.Cache#addText + * @param {string} key - Asset key for the text data. + * @param {string} url - URL of this text data file. + * @param {object} data - Extra text data. + */ + addText: function (key, url, data) { + + this._text[key] = { + url: url, + data: data + }; + + }, + + /** + * Add a new image. + * + * @method Phaser.Cache#addImage + * @param {string} key - The unique key by which you will reference this object. + * @param {string} url - URL of this image file. + * @param {object} data - Extra image data. + */ addImage: function (key, url, data) { this._images[key] = { url: url, data: data, spriteSheet: false }; - this._images[key].frame = new Phaser.Animation.Frame(0, 0, 0, data.width, data.height, '', ''); + + this._images[key].frame = new Phaser.Frame(0, 0, 0, data.width, data.height, key, this.game.rnd.uuid()); PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data); PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]); @@ -22184,11 +26325,15 @@ Phaser.Cache.prototype = { }, /** - * Add a new sound. - * @param key {string} Asset key for the sound. - * @param url {string} URL of this sound file. - * @param data {object} Extra sound data. - */ + * Add a new sound. + * + * @method Phaser.Cache#addSound + * @param {string} key - Asset key for the sound. + * @param {string} url - URL of this sound file. + * @param {object} data - Extra sound data. + * @param {boolean} webAudio - True if the file is using web audio. + * @param {boolean} audioTag - True if the file is using legacy HTML audio. + */ addSound: function (key, url, data, webAudio, audioTag) { webAudio = webAudio || true; @@ -22206,6 +26351,11 @@ Phaser.Cache.prototype = { }, + /** + * Reload a sound. + * @method Phaser.Cache#reloadSound + * @param {string} key - Asset key for the sound. + */ reloadSound: function (key) { var _this = this; @@ -22222,6 +26372,11 @@ Phaser.Cache.prototype = { } }, + /** + * Description. + * @method Phaser.Cache#reloadSoundComplete + * @param {string} key - Asset key for the sound. + */ reloadSoundComplete: function (key) { if (this._sounds[key]) @@ -22232,6 +26387,11 @@ Phaser.Cache.prototype = { }, + /** + * Description. + * @method Phaser.Cache#updateSound + * @param {string} key - Asset key for the sound. + */ updateSound: function (key, property, value) { if (this._sounds[key]) @@ -22243,8 +26403,10 @@ Phaser.Cache.prototype = { /** * Add a new decoded sound. - * @param key {string} Asset key for the sound. - * @param data {object} Extra sound data. + * + * @method Phaser.Cache#decodedSound + * @param {string} key - Asset key for the sound. + * @param {object} data - Extra sound data. */ decodedSound: function (key, data) { @@ -22255,23 +26417,10 @@ Phaser.Cache.prototype = { }, /** - * Add a new text data. - * @param key {string} Asset key for the text data. - * @param url {string} URL of this text data file. - * @param data {object} Extra text data. - */ - addText: function (key, url, data) { - - this._text[key] = { - url: url, - data: data - }; - - }, - - /** - * Get canvas by key. - * @param key Asset key of the canvas you want. + * Get acanvas object from the cache by its key. + * + * @method Phaser.Cache#getCanvas + * @param {string} key - Asset key of the canvas you want. * @return {object} The canvas you want. */ getCanvas: function (key) { @@ -22286,7 +26435,9 @@ Phaser.Cache.prototype = { /** * Checks if an image key exists. - * @param key Asset key of the image you want. + * + * @method Phaser.Cache#checkImageKey + * @param {string} key - Asset key of the image you want. * @return {boolean} True if the key exists, otherwise false. */ checkImageKey: function (key) { @@ -22302,7 +26453,9 @@ Phaser.Cache.prototype = { /** * Get image data by key. - * @param key Asset key of the image you want. + * + * @method Phaser.Cache#getImage + * @param {string} key - Asset key of the image you want. * @return {object} The image data you want. */ getImage: function (key) { @@ -22315,12 +26468,50 @@ Phaser.Cache.prototype = { return null; }, + /** + * Get tile set image data by key. + * + * @method Phaser.Cache#getTileSetImage + * @param {string} key - Asset key of the image you want. + * @return {object} The image data you want. + */ + getTilesetImage: function (key) { + + if (this._tilesets[key]) + { + return this._tilesets[key].data; + } + + return null; + + }, + + /** + * Get tile set image data by key. + * + * @method Phaser.Cache#getTileset + * @param {string} key - Asset key of the image you want. + * @return {Phaser.Tileset} The tileset data. The tileset image is in the data property, the tile data in tileData. + */ + getTileset: function (key) { + + if (this._tilesets[key]) + { + return this._tilesets[key].tileData; + } + + return null; + + }, + /** * Get tilemap data by key. - * @param key Asset key of the tilemap you want. - * @return {object} The tilemap data. The tileset image is in the data property, the map data in mapData. + * + * @method Phaser.Cache#getTilemap + * @param {string} key - Asset key of the tilemap you want. + * @return {Object} The tilemap data. The tileset image is in the data property, the map data in mapData. */ - getTilemap: function (key) { + getTilemapData: function (key) { if (this._tilemaps[key]) { @@ -22332,8 +26523,10 @@ Phaser.Cache.prototype = { /** * Get frame data by key. - * @param key Asset key of the frame data you want. - * @return {object} The frame data you want. + * + * @method Phaser.Cache#getFrameData + * @param {string} key - Asset key of the frame data you want. + * @return {Phaser.FrameData} The frame data you want. */ getFrameData: function (key) { @@ -22347,8 +26540,10 @@ Phaser.Cache.prototype = { /** * Get a single frame out of a frameData set by key. - * @param key Asset key of the frame data you want. - * @return {object} The frame data you want. + * + * @method Phaser.Cache#getFrameByIndex + * @param {string} key - Asset key of the frame data you want. + * @return {Phaser.Frame} The frame data you want. */ getFrameByIndex: function (key, frame) { @@ -22362,8 +26557,10 @@ Phaser.Cache.prototype = { /** * Get a single frame out of a frameData set by key. - * @param key Asset key of the frame data you want. - * @return {object} The frame data you want. + * + * @method Phaser.Cache#getFrameByName + * @param {string} key - Asset key of the frame data you want. + * @return {Phaser.Frame} The frame data you want. */ getFrameByName: function (key, frame) { @@ -22377,8 +26574,10 @@ Phaser.Cache.prototype = { /** * Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image. - * @param key Asset key of the frame data you want. - * @return {object} The frame data you want. + * + * @method Phaser.Cache#getFrame + * @param {string} key - Asset key of the frame data you want. + * @return {Phaser.Frame} The frame data you want. */ getFrame: function (key) { @@ -22392,8 +26591,10 @@ Phaser.Cache.prototype = { /** * Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image. - * @param key Asset key of the frame data you want. - * @return {object} The frame data you want. + * + * @method Phaser.Cache#getTextureFrame + * @param {string} key - Asset key of the frame data you want. + * @return {Phaser.Frame} The frame data you want. */ getTextureFrame: function (key) { @@ -22407,8 +26608,10 @@ Phaser.Cache.prototype = { /** * Get a RenderTexture by key. - * @param key Asset key of the RenderTexture you want. - * @return {object} The RenderTexture you want. + * + * @method Phaser.Cache#getTexture + * @param {string} key - Asset key of the RenderTexture you want. + * @return {Phaser.RenderTexture} The RenderTexture you want. */ getTexture: function (key) { @@ -22423,8 +26626,10 @@ Phaser.Cache.prototype = { /** * Get sound by key. - * @param key Asset key of the sound you want. - * @return {object} The sound you want. + * + * @method Phaser.Cache#getSound + * @param {string} key - Asset key of the sound you want. + * @return {Phaser.Sound} The sound you want. */ getSound: function (key) { @@ -22439,7 +26644,9 @@ Phaser.Cache.prototype = { /** * Get sound data by key. - * @param key Asset key of the sound you want. + * + * @method Phaser.Cache#getSoundData + * @param {string} key - Asset key of the sound you want. * @return {object} The sound data you want. */ getSoundData: function (key) { @@ -22454,9 +26661,11 @@ Phaser.Cache.prototype = { }, /** - * Check whether an asset is decoded sound. - * @param key Asset key of the sound you want. - * @return {object} The sound data you want. + * Check if the given sound has finished decoding. + * + * @method Phaser.Cache#isSoundDecoded + * @param {string} key - Asset key of the sound you want. + * @return {boolean} The decoded state of the Sound object. */ isSoundDecoded: function (key) { @@ -22468,9 +26677,11 @@ Phaser.Cache.prototype = { }, /** - * Check whether an asset is decoded sound. - * @param key Asset key of the sound you want. - * @return {object} The sound data you want. + * Check if the given sound is ready for playback. A sound is considered ready when it has finished decoding and the device is no longer touch locked. + * + * @method Phaser.Cache#isSoundReady + * @param {string} key - Asset key of the sound you want. + * @return {boolean} True if the sound is decoded and the device is not touch locked. */ isSoundReady: function (key) { @@ -22479,9 +26690,11 @@ Phaser.Cache.prototype = { }, /** - * Check whether an asset is sprite sheet. - * @param key Asset key of the sprite sheet you want. - * @return {object} The sprite sheet data you want. + * Check whether an image asset is sprite sheet or not. + * + * @method Phaser.Cache#isSpriteSheet + * @param {string} key - Asset key of the sprite sheet you want. + * @return {boolean} True if the image is a sprite sheet. */ isSpriteSheet: function (key) { @@ -22496,7 +26709,9 @@ Phaser.Cache.prototype = { /** * Get text data by key. - * @param key Asset key of the text data you want. + * + * @method Phaser.Cache#getText + * @param {string} key - Asset key of the text data you want. * @return {object} The text data you want. */ getText: function (key) { @@ -22510,6 +26725,14 @@ Phaser.Cache.prototype = { }, + /** + * Get the cache keys from a given array of objects. + * Normally you don't call this directly but instead use getImageKeys, getSoundKeys, etc. + * + * @method Phaser.Cache#getKeys + * @param {Array} array - An array of items to return the keys for. + * @return {Array} The array of item keys. + */ getKeys: function (array) { var output = []; @@ -22528,6 +26751,8 @@ Phaser.Cache.prototype = { /** * Returns an array containing all of the keys of Images in the Cache. + * + * @method Phaser.Cache#getImageKeys * @return {Array} The string based keys in the Cache. */ getImageKeys: function () { @@ -22536,6 +26761,8 @@ Phaser.Cache.prototype = { /** * Returns an array containing all of the keys of Sounds in the Cache. + * + * @method Phaser.Cache#getSoundKeys * @return {Array} The string based keys in the Cache. */ getSoundKeys: function () { @@ -22544,30 +26771,58 @@ Phaser.Cache.prototype = { /** * Returns an array containing all of the keys of Text Files in the Cache. + * + * @method Phaser.Cache#getTextKeys * @return {Array} The string based keys in the Cache. */ getTextKeys: function () { return this.getKeys(this._text); }, + /** + * Removes a canvas from the cache. + * + * @method Phaser.Cache#removeCanvas + * @param {string} key - Key of the asset you want to remove. + */ removeCanvas: function (key) { delete this._canvases[key]; }, + /** + * Removes an image from the cache. + * + * @method Phaser.Cache#removeImage + * @param {string} key - Key of the asset you want to remove. + */ removeImage: function (key) { delete this._images[key]; }, + /** + * Removes a sound from the cache. + * + * @method Phaser.Cache#removeSound + * @param {string} key - Key of the asset you want to remove. + */ removeSound: function (key) { delete this._sounds[key]; }, + /** + * Removes a text from the cache. + * + * @method Phaser.Cache#removeText + * @param {string} key - Key of the asset you want to remove. + */ removeText: function (key) { delete this._text[key]; }, /** - * Clean up cache memory. + * Clears the cache. Removes every local cache object reference. + * + * @method Phaser.Cache#destroy */ destroy: function () { @@ -22595,73 +26850,87 @@ Phaser.Cache.prototype = { }; /** -* Phaser.Loader -* +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser loader constructor. * The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. * It uses a combination of Image() loading and xhr and provides progress and completion callbacks. +* @class Phaser.Loader +* @classdesc The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. +* It uses a combination of Image() loading and xhr and provides progress and completion callbacks. +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.Loader = function (game) { /** - * Local reference to Game. + * @property {Phaser.Game} game - Local reference to game. */ this.game = game; /** - * Array stores assets keys. So you can get that asset by its unique key. - */ + * @property {array} _keys - Array stores assets keys. So you can get that asset by its unique key. + * @private + */ this._keys = []; /** - * Contains all the assets file infos. - */ + * @property {Description} _fileList - Contains all the assets file infos. + * @private + */ this._fileList = {}; /** - * Indicates assets loading progress. (from 0 to 100) - * @type {number} + * @property {number} _progressChunk - Indicates assets loading progress. (from 0 to 100) + * @private + * @default */ this._progressChunk = 0; /** - * An XMLHttpRequest object used for loading text and audio data - * @type {XMLHttpRequest} + * @property {XMLHttpRequest} - An XMLHttpRequest object used for loading text and audio data. + * @private */ this._xhr = new XMLHttpRequest(); - /** - * Length of assets queue. - * @type {number} + /** + * @property {number} - Length of assets queue. + * @default */ this.queueSize = 0; /** - * True if the Loader is in the process of loading the queue. - * @type {bool} + * @property {boolean} isLoading - True if the Loader is in the process of loading the queue. + * @default */ this.isLoading = false; /** - * True if all assets in the queue have finished loading. - * @type {bool} + * @property {boolean} hasLoaded - True if all assets in the queue have finished loading. + * @default */ this.hasLoaded = false; /** - * The Load progress percentage value (from 0 to 100) - * @type {number} + * @property {number} progress - The Load progress percentage value (from 0 to 100) + * @default */ this.progress = 0; /** * You can optionally link a sprite to the preloader. * If you do so the Sprite's width or height will be cropped based on the percentage loaded. + * @property {Description} preloadSprite + * @default */ this.preloadSprite = null; /** - * The crossOrigin value applied to loaded images - * @type {string} + * @property {string} crossOrigin - The crossOrigin value applied to loaded images */ this.crossOrigin = ''; @@ -22669,29 +26938,62 @@ Phaser.Loader = function (game) { * If you want to append a URL before the path of any asset you can set this here. * Useful if you need to allow an asset url to be configured outside of the game code. * MUST have / on the end of it! - * @type {string} + * @property {string} baseURL + * @default */ this.baseURL = ''; /** - * Event Signals - */ + * @property {Phaser.Signal} onFileComplete - Event signal. + */ this.onFileComplete = new Phaser.Signal; + + /** + * @property {Phaser.Signal} onFileError - Event signal. + */ this.onFileError = new Phaser.Signal; + + /** + * @property {Phaser.Signal} onLoadStart - Event signal. + */ this.onLoadStart = new Phaser.Signal; + + /** + * @property {Phaser.Signal} onLoadComplete - Event signal. + */ this.onLoadComplete = new Phaser.Signal; }; /** - * TextureAtlas data format constants - */ +* @constant +* @type {number} +*/ Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY = 0; + +/** +* @constant +* @type {number} +*/ Phaser.Loader.TEXTURE_ATLAS_JSON_HASH = 1; + +/** +* @constant +* @type {number} +*/ Phaser.Loader.TEXTURE_ATLAS_XML_STARLING = 2; Phaser.Loader.prototype = { + /** + * You can set a Sprite to be a "preload" sprite by passing it to this method. + * A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time. + * This allows you to easily make loading bars for games. + * + * @method Phaser.Loader#setPreloadSprite + * @param {Phaser.Sprite} sprite - The sprite that will be cropped during the load. + * @param {number} [direction=0] - A value of zero means the sprite width will be cropped, a value of 1 means its height will be cropped. + */ setPreloadSprite: function (sprite, direction) { direction = direction || 0; @@ -22701,22 +27003,25 @@ Phaser.Loader.prototype = { if (direction == 0) { // Horizontal crop - this.preloadSprite.crop = new Phaser.Rectangle(0, 0, 0, sprite.height); + this.preloadSprite.crop = new Phaser.Rectangle(0, 0, 1, sprite.height); } else { // Vertical crop - this.preloadSprite.crop = new Phaser.Rectangle(0, 0, sprite.width, 0); + this.preloadSprite.crop = new Phaser.Rectangle(0, 0, sprite.width, 1); } sprite.crop = this.preloadSprite.crop; + sprite.cropEnabled = true; }, /** * Check whether asset exists with a specific key. - * @param key {string} Key of the asset you want to check. - * @return {bool} Return true if exists, otherwise return false. + * + * @method Phaser.Loader#checkKeyExists + * @param {string} key - Key of the asset you want to check. + * @return {boolean} Return true if exists, otherwise return false. */ checkKeyExists: function (key) { @@ -22732,8 +27037,10 @@ Phaser.Loader.prototype = { }, /** - * Reset loader, this will remove all loaded assets. - */ + * Reset loader, this will remove all loaded assets. + * + * @method Phaser.Loader#reset + */ reset: function () { this.preloadSprite = null; @@ -22743,7 +27050,14 @@ Phaser.Loader.prototype = { }, /** - * Internal function that adds a new entry to the file list. + * Internal function that adds a new entry to the file list. Do not call directly. + * + * @method Phaser.Loader#addToFileList + * @param {Description} type - Description. + * @param {string} key - Description. + * @param {string} url - URL of Description. + * @param {Description} properties - Description. + * @protected */ addToFileList: function (type, key, url, properties) { @@ -22774,9 +27088,11 @@ Phaser.Loader.prototype = { /** * Add an image to the Loader. - * @param key {string} Unique asset key of this image file. - * @param url {string} URL of image file. - * @param overwrite {boolean} If an entry with a matching key already exists this will over-write it + * + * @method Phaser.Loader#image + * @param {string} key - Unique asset key of this image file. + * @param {string} url - URL of image file. + * @param {boolean} overwrite - If an entry with a matching key already exists this will over-write it */ image: function (key, url, overwrite) { @@ -22787,12 +27103,17 @@ Phaser.Loader.prototype = { this.addToFileList('image', key, url); } + return this; + }, /** * Add a text file to the Loader. - * @param key {string} Unique asset key of the text file. - * @param url {string} URL of the text file. + * + * @method Phaser.Loader#text + * @param {string} key - Unique asset key of the text file. + * @param {string} url - URL of the text file. + * @param {boolean} overwrite - True if Description. */ text: function (key, url, overwrite) { @@ -22803,15 +27124,19 @@ Phaser.Loader.prototype = { this.addToFileList('text', key, url); } + return this; + }, /** - * Add a new sprite sheet loading request. - * @param key {string} Unique asset key of the sheet file. - * @param url {string} URL of sheet file. - * @param frameWidth {number} Width of each single frame. - * @param frameHeight {number} Height of each single frame. - * @param frameMax {number} How many frames in this sprite sheet. + * Add a new sprite sheet to the loader. + * + * @method Phaser.Loader#spritesheet + * @param {string} key - Unique asset key of the sheet file. + * @param {string} url - URL of the sheet file. + * @param {number} frameWidth - Width of each single frame. + * @param {number} frameHeight - Height of each single frame. + * @param {number} [frameMax=-1] - How many frames in this sprite sheet. If not specified it will divide the whole image into frames. */ spritesheet: function (key, url, frameWidth, frameHeight, frameMax) { @@ -22822,13 +27147,44 @@ Phaser.Loader.prototype = { this.addToFileList('spritesheet', key, url, { frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax }); } + return this; + }, /** - * Add a new audio file loading request. - * @param key {string} Unique asset key of the audio file. - * @param urls {Array} An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ] - * @param autoDecode {bool} When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process. + * Add a new tile set to the loader. These are used in the rendering of tile maps. + * + * @method Phaser.Loader#tileset + * @param {string} key - Unique asset key of the tileset file. + * @param {string} url - URL of the tileset. + * @param {number} tileWidth - Width of each single tile in pixels. + * @param {number} tileHeight - Height of each single tile in pixels. + * @param {number} [tileMax=-1] - How many tiles in this tileset. If not specified it will divide the whole image into tiles. + * @param {number} [tileMargin=0] - If the tiles have been drawn with a margin, specify the amount here. + * @param {number} [tileSpacing=0] - If the tiles have been drawn with spacing between them, specify the amount here. + */ + tileset: function (key, url, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing) { + + if (typeof tileMax === "undefined") { tileMax = -1; } + if (typeof tileMargin === "undefined") { tileMargin = 0; } + if (typeof tileSpacing === "undefined") { tileSpacing = 0; } + + if (this.checkKeyExists(key) === false) + { + this.addToFileList('tileset', key, url, { tileWidth: tileWidth, tileHeight: tileHeight, tileMax: tileMax, tileMargin: tileMargin, tileSpacing: tileSpacing }); + } + + return this; + + }, + + /** + * Add a new audio file to the loader. + * + * @method Phaser.Loader#audio + * @param {string} key - Unique asset key of the audio file. + * @param {Array} urls - An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ]. + * @param {boolean} autoDecode - When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process. */ audio: function (key, urls, autoDecode) { @@ -22839,28 +27195,39 @@ Phaser.Loader.prototype = { this.addToFileList('audio', key, urls, { buffer: null, autoDecode: autoDecode }); } + return this; + }, /** * Add a new tilemap loading request. - * @param key {string} Unique asset key of the tilemap data. - * @param tilesetURL {string} The url of the tile set image file. - * @param [mapDataURL] {string} The url of the map data file (csv/json) - * @param [mapData] {object} An optional JSON data object (can be given in place of a URL). - * @param [format] {string} The format of the map data. + * + * @method Phaser.Loader#tilemap + * @param {string} key - Unique asset key of the tilemap data. + * @param {string} tilesetURL - The url of the tile set image file. + * @param {string} [mapDataURL] - The url of the map data file (csv/json) + * @param {object} [mapData] - An optional JSON data object (can be given in place of a URL). + * @param {string} [format] - The format of the map data. */ - tilemap: function (key, tilesetURL, mapDataURL, mapData, format) { + tilemap: function (key, mapDataURL, mapData, format) { if (typeof mapDataURL === "undefined") { mapDataURL = null; } if (typeof mapData === "undefined") { mapData = null; } if (typeof format === "undefined") { format = Phaser.Tilemap.CSV; } + if (mapDataURL == null && mapData == null) + { + console.warn('Phaser.Loader.tilemap - Both mapDataURL and mapData are null. One must be set.'); + + return this; + } + if (this.checkKeyExists(key) === false) { // A URL to a json/csv file has been given if (mapDataURL) { - this.addToFileList('tilemap', key, tilesetURL, { mapDataURL: mapDataURL, format: format }); + this.addToFileList('tilemap', key, mapDataURL, { format: format }); } else { @@ -22871,7 +27238,7 @@ Phaser.Loader.prototype = { break; // An xml string or object has been given - case Phaser.Tilemap.JSON: + case Phaser.Tilemap.TILED_JSON: if (typeof mapData === 'string') { @@ -22880,19 +27247,23 @@ Phaser.Loader.prototype = { break; } - this.addToFileList('tilemap', key, tilesetURL, { mapDataURL: null, mapData: mapData, format: format }); + this.game.cache.addTilemap(key, null, mapData, format); } } + return this; + }, /** * Add a new bitmap font loading request. - * @param key {string} Unique asset key of the bitmap font. - * @param textureURL {string} The url of the font image file. - * @param [xmlURL] {string} The url of the font data file (xml/fnt) - * @param [xmlData] {object} An optional XML data object. + * + * @method Phaser.Loader#bitmapFont + * @param {string} key - Unique asset key of the bitmap font. + * @param {string} textureURL - The url of the font image file. + * @param {string} [xmlURL] - The url of the font data file (xml/fnt) + * @param {object} [xmlData] - An optional XML data object. */ bitmapFont: function (key, textureURL, xmlURL, xmlData) { @@ -22943,33 +27314,61 @@ Phaser.Loader.prototype = { } } - }, - - atlasJSONArray: function (key, textureURL, atlasURL, atlasData) { - - this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY); - - }, - - atlasJSONHash: function (key, textureURL, atlasURL, atlasData) { - - this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH); - - }, - - atlasXML: function (key, textureURL, atlasURL, atlasData) { - - this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); + return this; }, /** - * Add a new texture atlas loading request. - * @param key {string} Unique asset key of the texture atlas file. - * @param textureURL {string} The url of the texture atlas image file. - * @param [atlasURL] {string} The url of the texture atlas data file (json/xml) - * @param [atlasData] {object} A JSON or XML data object. - * @param [format] {number} A value describing the format of the data. + * Add a new texture atlas to the loader. This atlas uses the JSON Array data format. + * + * @method Phaser.Loader#atlasJSONArray + * @param {string} key - Unique asset key of the bitmap font. + * @param {Description} atlasURL - The url of the Description. + * @param {Description} atlasData - Description. + */ + atlasJSONArray: function (key, textureURL, atlasURL, atlasData) { + + return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY); + + }, + + /** + * Add a new texture atlas to the loader. This atlas uses the JSON Hash data format. + * + * @method Phaser.Loader#atlasJSONHash + * @param {string} key - Unique asset key of the bitmap font. + * @param {Description} atlasURL - The url of the Description. + * @param {Description} atlasData - Description. + */ + atlasJSONHash: function (key, textureURL, atlasURL, atlasData) { + + return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH); + + }, + + /** + * Add a new texture atlas to the loader. This atlas uses the Starling XML data format. + * + * @method Phaser.Loader#atlasXML + * @param {string} key - Unique asset key of the bitmap font. + * @param {Description} atlasURL - The url of the Description. + * @param {Description} atlasData - Description. + */ + atlasXML: function (key, textureURL, atlasURL, atlasData) { + + return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); + + }, + + /** + * Add a new texture atlas to the loader. + * + * @method Phaser.Loader#atlas + * @param {string} key - Unique asset key of the texture atlas file. + * @param {string} textureURL - The url of the texture atlas image file. + * @param {string} [atlasURL] - The url of the texture atlas data file (json/xml). You don't need this if you are passing an atlasData object instead. + * @param {object} [atlasData] - A JSON or XML data object. You don't need this if the data is being loaded from a URL. + * @param {number} [format] - A value describing the format of the data, the default is Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY. */ atlas: function (key, textureURL, atlasURL, atlasData, format) { @@ -23040,12 +27439,16 @@ Phaser.Loader.prototype = { } + return this; + }, /** - * Remove loading request of a file. - * @param key {string} Key of the file you want to remove. - */ + * Remove loading request of a file. + * + * @method Phaser.Loader#removeFile + * @param key {string} Key of the file you want to remove. + */ removeFile: function (key) { delete this._fileList[key]; @@ -23053,8 +27456,10 @@ Phaser.Loader.prototype = { }, /** - * Remove all file loading requests. - */ + * Remove all file loading requests. + * + * @method Phaser.Loader#removeAll + */ removeAll: function () { this._fileList = {}; @@ -23062,8 +27467,10 @@ Phaser.Loader.prototype = { }, /** - * Load assets. - */ + * Start loading the assets. Normally you don't need to call this yourself as the StateManager will do so. + * + * @method Phaser.Loader#start + */ start: function () { if (this.isLoading) @@ -23093,6 +27500,8 @@ Phaser.Loader.prototype = { /** * Load files. Private method ONLY used by loader. + * + * @method Phaser.Loader#loadFile * @private */ loadFile: function () { @@ -23107,7 +27516,7 @@ Phaser.Loader.prototype = { case 'spritesheet': case 'textureatlas': case 'bitmapfont': - case 'tilemap': + case 'tileset': file.data = new Image(); file.data.name = file.key; file.data.onload = function () { @@ -23170,6 +27579,29 @@ Phaser.Loader.prototype = { break; + case 'tilemap': + this._xhr.open("GET", this.baseURL + file.url, true); + this._xhr.responseType = "text"; + + if (file.format == Phaser.Tilemap.TILED_JSON) + { + this._xhr.onload = function () { + return _this.jsonLoadComplete(file.key); + }; + } + else if (file.format == Phaser.Tilemap.CSV) + { + this._xhr.onload = function () { + return _this.csvLoadComplete(file.key); + }; + } + + this._xhr.onerror = function () { + return _this.dataLoadError(file.key); + }; + this._xhr.send(); + break; + case 'text': this._xhr.open("GET", this.baseURL + file.url, true); this._xhr.responseType = "text"; @@ -23185,6 +27617,12 @@ Phaser.Loader.prototype = { }, + /** + * Private method ONLY used by loader. + * @method Phaser.Loader#getAudioURL + * @param {Description} urls - Description. + * @private + */ getAudioURL: function (urls) { var extension; @@ -23206,9 +27644,11 @@ Phaser.Loader.prototype = { }, /** - * Error occured when load a file. - * @param key {string} Key of the error loading file. - */ + * Error occured when load a file. + * + * @method Phaser.Loader#fileError + * @param {string} key - Key of the error loading file. + */ fileError: function (key) { this._fileList[key].loaded = true; @@ -23216,16 +27656,18 @@ Phaser.Loader.prototype = { this.onFileError.dispatch(key); - console.warn("Phaser.Loader error loading file: " + key); + console.warn("Phaser.Loader error loading file: " + key + ' from URL ' + this._fileList[key].url); this.nextFile(key, false); }, /** - * Called when a file is successfully loaded. - * @param key {string} Key of the successfully loaded file. - */ + * Called when a file is successfully loaded. + * + * @method Phaser.Loader#fileComplete + * @param {string} key - Key of the successfully loaded file. + */ fileComplete: function (key) { if (!this._fileList[key]) @@ -23252,37 +27694,9 @@ Phaser.Loader.prototype = { this.game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax); break; - case 'tilemap': + case 'tileset': - if (file.mapDataURL == null) - { - this.game.cache.addTilemap(file.key, file.url, file.data, file.mapData, file.format); - } - else - { - // Load the JSON or CSV before carrying on with the next file - loadNext = false; - this._xhr.open("GET", this.baseURL + file.mapDataURL, true); - this._xhr.responseType = "text"; - - if (file.format == Phaser.Tilemap.JSON) - { - this._xhr.onload = function () { - return _this.jsonLoadComplete(file.key); - }; - } - else if (file.format == Phaser.Tilemap.CSV) - { - this._xhr.onload = function () { - return _this.csvLoadComplete(file.key); - }; - } - - this._xhr.onerror = function () { - return _this.dataLoadError(file.key); - }; - this._xhr.send(); - } + this.game.cache.addTileset(file.key, file.url, file.data, file.tileWidth, file.tileHeight, file.tileMax, file.tileMargin, file.tileSpacing); break; case 'textureatlas': @@ -23373,7 +27787,7 @@ Phaser.Loader.prototype = { break; case 'text': - file.data = this._xhr.response; + file.data = this._xhr.responseText; this.game.cache.addText(file.key, file.url, file.data); break; } @@ -23386,17 +27800,19 @@ Phaser.Loader.prototype = { }, /** - * Successfully loaded a JSON file. - * @param key {string} Key of the loaded JSON file. - */ + * Successfully loaded a JSON file. + * + * @method Phaser.Loader#jsonLoadComplete + * @param {string} key - Key of the loaded JSON file. + */ jsonLoadComplete: function (key) { - var data = JSON.parse(this._xhr.response); + var data = JSON.parse(this._xhr.responseText); var file = this._fileList[key]; if (file.type == 'tilemap') { - this.game.cache.addTilemap(file.key, file.url, file.data, data, file.format); + this.game.cache.addTilemap(file.key, file.url, data, file.format); } else { @@ -23408,24 +27824,28 @@ Phaser.Loader.prototype = { }, /** - * Successfully loaded a CSV file. - * @param key {string} Key of the loaded CSV file. - */ + * Successfully loaded a CSV file. + * + * @method Phaser.Loader#csvLoadComplete + * @param {string} key - Key of the loaded CSV file. + */ csvLoadComplete: function (key) { - var data = this._xhr.response; + var data = this._xhr.responseText; var file = this._fileList[key]; - this.game.cache.addTilemap(file.key, file.url, file.data, data, file.format); + this.game.cache.addTilemap(file.key, file.url, data, file.format); this.nextFile(key, true); }, /** - * Error occured when load a JSON. - * @param key {string} Key of the error loading JSON file. - */ + * Error occured when load a JSON. + * + * @method Phaser.Loader#dataLoadError + * @param {string} key - Key of the error loading JSON file. + */ dataLoadError: function (key) { var file = this._fileList[key]; @@ -23438,9 +27858,15 @@ Phaser.Loader.prototype = { }, + /** + * Successfully loaded an XML file. + * + * @method Phaser.Loader#xmlLoadComplete + * @param {string} key - Key of the loaded XML file. + */ xmlLoadComplete: function (key) { - var data = this._xhr.response; + var data = this._xhr.responseText; var xml; try @@ -23483,10 +27909,12 @@ Phaser.Loader.prototype = { }, /** - * Handle loading next file. - * @param previousKey {string} Key of previous loaded asset. - * @param success {bool} Whether the previous asset loaded successfully or not. - */ + * Handle loading next file. + * + * @param previousKey {string} Key of previous loaded asset. + * @param success {boolean} Whether the previous asset loaded successfully or not. + * @private + */ nextFile: function (previousKey, success) { this.progress = Math.round(this.progress + this._progressChunk); @@ -23500,11 +27928,11 @@ Phaser.Loader.prototype = { { if (this.preloadSprite.direction == 0) { - this.preloadSprite.crop.width = (this.preloadSprite.width / 100) * this.progress; + this.preloadSprite.crop.width = Math.floor((this.preloadSprite.width / 100) * this.progress); } else { - this.preloadSprite.crop.height = (this.preloadSprite.height / 100) * this.progress; + this.preloadSprite.crop.height = Math.floor((this.preloadSprite.height / 100) * this.progress); } this.preloadSprite.sprite.crop = this.preloadSprite.crop; @@ -23529,11 +27957,23 @@ Phaser.Loader.prototype = { } }; -Phaser.Loader.Parser = { +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser.LoaderParser parses data objects from Phaser.Loader that need more preparation before they can be inserted into the Cache. +* +* @class Phaser.LoaderParser +*/ +Phaser.LoaderParser = { /** * Parse frame data from an XML file. - * @param xml {object} XML data you want to parse. + * @method Phaser.LoaderParser.bitmapFont + * @param {object} xml - XML data you want to parse. * @return {FrameData} Generated FrameData object. */ bitmapFont: function (game, xml, cacheKey) { @@ -23541,7 +27981,7 @@ Phaser.Loader.Parser = { // Malformed? if (!xml.getElementsByTagName('font')) { - console.warn("Phaser.Loader.Parser.bitmapFont: Invalid XML given, missing tag"); + console.warn("Phaser.LoaderParser.bitmapFont: Invalid XML given, missing tag"); return; } @@ -23601,14 +28041,21 @@ Phaser.Loader.Parser = { }; /** -* The Sound class +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* The Sound class constructor. * -* @class Sound +* @class Phaser.Sound +* @classdesc The Sound class * @constructor -* @param {Phaser.Game} game Reference to the current game instance. -* @param {string} key Asset key for the sound. -* @param {number} volume Default value for the volume. -* @param {bool} loop Whether or not the sound will loop. +* @param {Phaser.Game} game - Reference to the current game instance. +* @param {string} key - Asset key for the sound. +* @param {number} [volume=1] - Default value for the volume, between 0 and 1. +* @param {boolean} [loop=false] - Whether or not the sound will loop. */ Phaser.Sound = function (game, key, volume, loop) { @@ -23617,100 +28064,163 @@ Phaser.Sound = function (game, key, volume, loop) { /** * A reference to the currently running Game. - * @property game - * @public - * @type {Phaser.Game} + * @property {Phaser.Game} game */ this.game = game; /** - * Name of the sound - * @property name - * @public - * @type {string} + * Name of the sound. + * @property {string} name + * @default */ this.name = key; /** * Asset key for the sound. - * @property key - * @public - * @type {string} + * @property {string} key */ this.key = key; /** * Whether or not the sound will loop. - * @property loop - * @public - * @type {bool} + * @property {boolean} loop */ this.loop = loop; /** - * The global audio volume. A value between 0 (silence) and 1 (full volume) - * @property _volume + * The global audio volume. A value between 0 (silence) and 1 (full volume). + * @property {number} _volume * @private - * @type {number} */ this._volume = volume; /** - * The sound markers, empty by default - * @property markers - * @public - * @type {object} + * The sound markers, empty by default. + * @property {object} markers */ this.markers = {}; /** * Reference to AudioContext instance. - * @property context - * @public - * @type {AudioContext} + * @property {AudioContext} context + * @default */ this.context = null; /** * Decoded data buffer / Audio tag. + * @property {Description} _buffer + * @private */ this._buffer = null; /** - * Boolean indicating whether the game is on "mute" - * @property _muted + * Boolean indicating whether the game is on "mute". + * @property {boolean} _muted * @private - * @type {bool} + * @default */ this._muted = false; /** - * Boolean indicating whether the sound should start automatically - * @property autoplay - * @public - * @type {bool} + * Boolean indicating whether the sound should start automatically. + * @property {boolean} autoplay + * @private */ this.autoplay = false; /** * The total duration of the sound, in milliseconds - * @property autoplay - * @public - * @type {bool} + * @property {number} totalDuration + * @default */ this.totalDuration = 0; + + /** + * Description. + * @property {number} startTime + * @default + */ this.startTime = 0; + + /** + * Description. + * @property {number} currentTime + * @default + */ this.currentTime = 0; + + /** + * Description. + * @property {number} duration + * @default + */ this.duration = 0; + + /** + * Description. + * @property {number} stopTime + */ this.stopTime = 0; + + /** + * Description. + * @property {boolean} paused + * @default + */ this.paused = false; - this.isPlaying = false; - this.currentMarker = ''; - this.pendingPlayback = false; - this.override = false; + + /** + * Description. + * @property {number} pausedPosition + */ + this.pausedPosition = 0; + /** + * Description. + * @property {number} pausedTime + */ + this.pausedTime = 0; + + /** + * Description. + * @property {boolean} isPlaying + * @default + */ + this.isPlaying = false; + + /** + * Description. + * @property {string} currentMarker + * @default + */ + this.currentMarker = ''; + + /** + * Description. + * @property {boolean} pendingPlayback + * @default + */ + this.pendingPlayback = false; + + /** + * Description. + * @property {boolean} override + * @default + */ + this.override = false; + + /** + * Description. + * @property {boolean} usingWebAudio + */ this.usingWebAudio = this.game.sound.usingWebAudio; + + /** + * Description. + * @property {Description} usingAudioTag + */ this.usingAudioTag = this.game.sound.usingAudioTag; if (this.usingWebAudio) @@ -23748,30 +28258,83 @@ Phaser.Sound = function (game, key, volume, loop) { } } + /** + * Description. + * @property {Phaser.Signal} onDecoded + */ this.onDecoded = new Phaser.Signal; + + /** + * Description. + * @property {Phaser.Signal} onPlay + */ this.onPlay = new Phaser.Signal; + + /** + * Description. + * @property {Phaser.Signal} onPause + */ this.onPause = new Phaser.Signal; + + /** + * Description. + * @property {Phaser.Signal} onResume + */ this.onResume = new Phaser.Signal; + + /** + * Description. + * @property {Phaser.Signal} onLoop + */ this.onLoop = new Phaser.Signal; + + /** + * Description. + * @property {Phaser.Signal} onStop + */ this.onStop = new Phaser.Signal; + + /** + * Description. + * @property {Phaser.Signal} onMute + */ this.onMute = new Phaser.Signal; + + /** + * Description. + * @property {Phaser.Signal} onMarkerComplete + */ this.onMarkerComplete = new Phaser.Signal; }; Phaser.Sound.prototype = { + /** + * Called automatically when this sound is unlocked. + * @method Phaser.Sound#soundHasUnlocked + * @param {string} key - Description. + * @protected + */ soundHasUnlocked: function (key) { if (key == this.key) { this._sound = this.game.cache.getSoundData(this.key); this.totalDuration = this._sound.duration; - console.log('sound has unlocked' + this._sound); + // console.log('sound has unlocked' + this._sound); } }, + /** + * Description. + * @method Phaser.Sound#addMarker + * @param {string} name - Description. + * @param {Description} start - Description. + * @param {Description} stop - Description. + * @param {Description} volume - Description. + * @param {Description} loop - Description. addMarker: function (name, start, stop, volume, loop) { volume = volume || 1; @@ -23787,13 +28350,52 @@ Phaser.Sound.prototype = { }; }, + */ + /** + * Adds a marker into the current Sound. A marker is represented by a unique key and a start time and duration. + * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback. + * + * @method Phaser.Sound#addMarker + * @param {string} name - A unique name for this marker, i.e. 'explosion', 'gunshot', etc. + * @param {number} start - The start point of this marker in the audio file, given in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc. + * @param {number} duration - The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc. + * @param {number} [volume=1] - The volume the sound will play back at, between 0 (silent) and 1 (full volume). + * @param {boolean} [loop=false] - Sets if the sound will loop or not. + */ + addMarker: function (name, start, duration, volume, loop) { + + volume = volume || 1; + if (typeof loop == 'undefined') { loop = false; } + + this.markers[name] = { + name: name, + start: start, + stop: start + duration, + volume: volume, + duration: duration, + durationMS: duration * 1000, + loop: loop + }; + + }, + + /** + * Removes a marker from the sound. + * @method Phaser.Sound#removeMarker + * @param {string} name - The key of the marker to remove. + */ removeMarker: function (name) { delete this.markers[name]; }, + /** + * Called automatically by Phaser.SoundManager. + * @method Phaser.Sound#update + * @protected + */ update: function () { if (this.pendingPlayback && this.game.cache.isSoundReady(this.key)) @@ -23806,7 +28408,7 @@ Phaser.Sound.prototype = { { this.currentTime = this.game.time.now - this.startTime; - if (this.currentTime >= this.duration) + if (this.currentTime >= this.durationMS) { //console.log(this.currentMarker, 'has hit duration'); if (this.usingWebAudio) @@ -23853,11 +28455,12 @@ Phaser.Sound.prototype = { /** * Play this sound, or a marked section of it. - * @method play - * @param {string} marker Assets key of the sound you want to play. - * @param {number} position The starting position - * @param {number} [volume] Volume of the sound you want to play. - * @param {bool} [loop] Loop when it finished playing? (Default to false) + * @method Phaser.Sound#play + * @param {string} [marker=''] - If you want to play a marker then give the key here, otherwise leave blank to play the full sound. + * @param {number} [position=0] - The starting position to play the sound from - this is ignored if you provide a marker. + * @param {number} [volume=1] - Volume of the sound you want to play. + * @param {boolean} [loop=false] - Loop when it finished playing? + * @param {boolean} [forceRestart=true] - If the sound is already playing you can set forceRestart to restart it from the beginning. * @return {Sound} The playing sound object. */ play: function (marker, position, volume, loop, forceRestart) { @@ -23866,9 +28469,9 @@ Phaser.Sound.prototype = { position = position || 0; volume = volume || 1; if (typeof loop == 'undefined') { loop = false; } - if (typeof forceRestart == 'undefined') { forceRestart = false; } + if (typeof forceRestart == 'undefined') { forceRestart = true; } - console.log(this.name + ' play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop); + // console.log(this.name + ' play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop, 'force', forceRestart); if (this.isPlaying == true && forceRestart == false && this.override == false) { @@ -23900,25 +28503,38 @@ Phaser.Sound.prototype = { this.currentMarker = marker; - if (marker !== '' && this.markers[marker]) + if (marker !== '') { - this.position = this.markers[marker].start; - this.volume = this.markers[marker].volume; - this.loop = this.markers[marker].loop; - this.duration = this.markers[marker].duration * 1000; + if (this.markers[marker]) + { + this.position = this.markers[marker].start; + this.volume = this.markers[marker].volume; + this.loop = this.markers[marker].loop; + this.duration = this.markers[marker].duration; + this.durationMS = this.markers[marker].durationMS; - // console.log('marker info loaded', this.loop, this.duration); - this._tempMarker = marker; - this._tempPosition = this.position; - this._tempVolume = this.volume; - this._tempLoop = this.loop; + // console.log('Marker Loaded: ', marker, 'start:', this.position, 'end: ', this.duration, 'loop', this.loop); + + this._tempMarker = marker; + this._tempPosition = this.position; + this._tempVolume = this.volume; + this._tempLoop = this.loop; + } + else + { + console.warn("Phaser.Sound.play: audio marker " + marker + " doesn't exist"); + return; + } } else { + // console.log('no marker info loaded', marker); + this.position = position; this.volume = volume; this.loop = loop; this.duration = 0; + this.durationMS = 0; this._tempMarker = marker; this._tempPosition = position; @@ -23944,7 +28560,9 @@ Phaser.Sound.prototype = { if (this.duration == 0) { - this.duration = this.totalDuration * 1000; + // console.log('duration reset'); + this.duration = this.totalDuration; + this.durationMS = this.totalDuration * 1000; } if (this.loop && marker == '') @@ -23955,18 +28573,20 @@ Phaser.Sound.prototype = { // Useful to cache this somewhere perhaps? if (typeof this._sound.start === 'undefined') { - this._sound.noteGrainOn(0, this.position, this.duration / 1000); + this._sound.noteGrainOn(0, this.position, this.duration); + // this._sound.noteGrainOn(0, this.position, this.duration / 1000); //this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it } else { - this._sound.start(0, this.position, this.duration / 1000); + // this._sound.start(0, this.position, this.duration / 1000); + this._sound.start(0, this.position, this.duration); } this.isPlaying = true; this.startTime = this.game.time.now; this.currentTime = 0; - this.stopTime = this.startTime + this.duration; + this.stopTime = this.startTime + this.durationMS; this.onPlay.dispatch(this); } else @@ -23999,7 +28619,8 @@ Phaser.Sound.prototype = { if (this.duration == 0) { - this.duration = this.totalDuration * 1000; + this.duration = this.totalDuration; + this.durationMS = this.totalDuration * 1000; } // console.log('playing', this._sound); @@ -24018,7 +28639,7 @@ Phaser.Sound.prototype = { this.isPlaying = true; this.startTime = this.game.time.now; this.currentTime = 0; - this.stopTime = this.startTime + this.duration; + this.stopTime = this.startTime + this.durationMS; this.onPlay.dispatch(this); } else @@ -24031,11 +28652,11 @@ Phaser.Sound.prototype = { /** * Restart the sound, or a marked section of it. - * @method restart - * @param {string} marker Assets key of the sound you want to play. - * @param {number} position The starting position - * @param {number} [volume] Volume of the sound you want to play. - * @param {bool} [loop] Loop when it finished playing? (Default to false) + * @method Phaser.Sound#restart + * @param {string} [marker=''] - If you want to play a marker then give the key here, otherwise leave blank to play the full sound. + * @param {number} [position=0] - The starting position to play the sound from - this is ignored if you provide a marker. + * @param {number} [volume=1] - Volume of the sound you want to play. + * @param {boolean} [loop=false] - Loop when it finished playing? */ restart: function (marker, position, volume, loop) { @@ -24050,7 +28671,7 @@ Phaser.Sound.prototype = { /** * Pauses the sound - * @method pause + * @method Phaser.Sound#pause */ pause: function () { @@ -24059,13 +28680,16 @@ Phaser.Sound.prototype = { this.stop(); this.isPlaying = false; this.paused = true; + this.pausedPosition = this.currentTime; + this.pausedTime = this.game.time.now; this.onPause.dispatch(this); } }, + /** * Resumes the sound - * @method pause + * @method Phaser.Sound#resume */ resume: function () { @@ -24073,14 +28697,20 @@ Phaser.Sound.prototype = { { if (this.usingWebAudio) { + var p = this.position + (this.pausedPosition / 1000); + + this._sound = this.context.createBufferSource(); + this._sound.buffer = this._buffer; + this._sound.connect(this.gainNode); + if (typeof this._sound.start === 'undefined') { - this._sound.noteGrainOn(0, this.position, this.duration); + this._sound.noteGrainOn(0, p, this.duration); //this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it } else { - this._sound.start(0, this.position, this.duration); + this._sound.start(0, p, this.duration); } } else @@ -24090,6 +28720,7 @@ Phaser.Sound.prototype = { this.isPlaying = true; this.paused = false; + this.startTime += (this.game.time.now - this.pausedTime); this.onResume.dispatch(this); } @@ -24097,7 +28728,7 @@ Phaser.Sound.prototype = { /** * Stop playing this sound. - * @method stop + * @method Phaser.Sound#stop */ stop: function () { @@ -24131,6 +28762,11 @@ Phaser.Sound.prototype = { }; +/** +* @name Phaser.Sound#isDecoding +* @property {boolean} isDecoding - Returns true if the sound file is still decoding. +* @readonly +*/ Object.defineProperty(Phaser.Sound.prototype, "isDecoding", { get: function () { @@ -24139,6 +28775,11 @@ Object.defineProperty(Phaser.Sound.prototype, "isDecoding", { }); +/** +* @name Phaser.Sound#isDecoded +* @property {boolean} isDecoded - Returns true if the sound file has decoded. +* @readonly +*/ Object.defineProperty(Phaser.Sound.prototype, "isDecoded", { get: function () { @@ -24147,22 +28788,16 @@ Object.defineProperty(Phaser.Sound.prototype, "isDecoded", { }); +/** +* @name Phaser.Sound#mute +* @property {boolean} mute - Gets or sets the muted state of this sound. +*/ Object.defineProperty(Phaser.Sound.prototype, "mute", { - - /** - * Mutes sound. - * @method mute - * @return {bool} whether or not the sound is muted - */ get: function () { return this._muted; }, - /** - * Mutes sound. - * @method mute - * @return {bool} whether or not the sound is muted - */ + set: function (value) { value = value || null; @@ -24202,20 +28837,17 @@ Object.defineProperty(Phaser.Sound.prototype, "mute", { }); +/** +* @name Phaser.Sound#volume +* @property {number} volume - Gets or sets the volume of this sound, a value between 0 and 1. +* @readonly +*/ Object.defineProperty(Phaser.Sound.prototype, "volume", { - /** - * @method volume - * @return {number} The current volume. A value between 0 (silence) and 1 (full volume) - */ get: function () { return this._volume; }, - /** - * @method volume - * @return {number} Sets the current volume. A value between 0 (silence) and 1 (full volume) - */ set: function (value) { if (this.usingWebAudio) @@ -24237,58 +28869,93 @@ Object.defineProperty(Phaser.Sound.prototype, "volume", { }); /** -* Phaser - SoundManager +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Sound Manager constructor. * -* @class SoundManager +* @class Phaser.SoundManager +* @classdesc Phaser Sound Manager. * @constructor * @param {Phaser.Game} game reference to the current game instance. */ Phaser.SoundManager = function (game) { - /** - * A reference to the currently running Game. - * @property game - * @public - * @type {Phaser.Game} - */ + /** + * @property {Phaser.Game} game - Local reference to game. + */ this.game = game; - + + /** + * @property {Phaser.Signal} onSoundDecode - Description. + */ this.onSoundDecode = new Phaser.Signal; - - - /** - * Boolean indicating whether the game is on "mute" - * @property _muted - * @private - * @type {bool} - */ + + /** + * @property {boolean} _muted - Description. + * @private + * @default + */ this._muted = false; + + /** + * @property {Description} _unlockSource - Description. + * @private + * @default + */ this._unlockSource = null; /** - * The global audio volume. A value between 0 (silence) and 1 (full volume) - * @property _volume + * @property {number} _volume - The global audio volume. A value between 0 (silence) and 1 (full volume). * @private - * @type {number} + * @default */ this._volume = 1; /** - * An array containing all the sounds - * @property _sounds + * @property {array} _sounds - An array containing all the sounds * @private - * @type {array} + * @default The empty array. */ this._sounds = []; - + /** + * @property {Description} context - Description. + * @default + */ this.context = null; + + /** + * @property {boolean} usingWebAudio - Description. + * @default + */ this.usingWebAudio = true; + + /** + * @property {boolean} usingAudioTag - Description. + * @default + */ this.usingAudioTag = false; + + /** + * @property {boolean} noAudio - Description. + * @default + */ this.noAudio = false; + /** + * @property {boolean} touchLocked - Description. + * @default + */ this.touchLocked = false; + /** + * @property {number} channels - Description. + * @default + */ this.channels = 32; }; @@ -24296,8 +28963,9 @@ Phaser.SoundManager = function (game) { Phaser.SoundManager.prototype = { /** - * Initialises the sound manager - * @method boot + * Initialises the sound manager. + * @method Phaser.SoundManager#boot + * @protected */ boot: function () { @@ -24378,8 +29046,8 @@ Phaser.SoundManager.prototype = { }, /** - * Enables the audio, usually after the first touch - * @method unlock + * Enables the audio, usually after the first touch. + * @method Phaser.SoundManager#unlock */ unlock: function () { @@ -24412,8 +29080,8 @@ Phaser.SoundManager.prototype = { }, /** - * Stops all the sounds in the game - * @method stopAll + * Stops all the sounds in the game. + * @method Phaser.SoundManager#stopAll */ stopAll: function () { @@ -24428,8 +29096,8 @@ Phaser.SoundManager.prototype = { }, /** - * Pauses all the sounds in the game - * @method pauseAll + * Pauses all the sounds in the game. + * @method Phaser.SoundManager#pauseAll */ pauseAll: function () { @@ -24444,8 +29112,8 @@ Phaser.SoundManager.prototype = { }, /** - * resumes every sound in the game - * @method resumeAll + * resumes every sound in the game. + * @method Phaser.SoundManager#resumeAll */ resumeAll: function () { @@ -24460,10 +29128,10 @@ Phaser.SoundManager.prototype = { }, /** - * Decode a sound with its assets key. - * @method decode - * @param key {string} Assets key of the sound to be decoded. - * @param [sound] {Phaser.Sound} its bufer will be set to decoded data. + * Decode a sound by its assets key. + * @method Phaser.SoundManager#decode + * @param {string} key - Assets key of the sound to be decoded. + * @param {Phaser.Sound} [sound] - Its buffer will be set to decoded data. */ decode: function (key, sound) { @@ -24492,8 +29160,8 @@ Phaser.SoundManager.prototype = { }, /** - * updates every sound in the game - * @method update + * Updates every sound in the game. + * @method Phaser.SoundManager#update */ update: function () { @@ -24518,21 +29186,18 @@ Phaser.SoundManager.prototype = { }, - /** - * - * @method add - * @param {string} key Asset key for the sound. - * @param {number} volume Default value for the volume. - * @param {bool} loop Whether or not the sound will loop. + * Adds a new Sound into the SoundManager. + * @method Phaser.SoundManager#add + * @param {string} key - Asset key for the sound. + * @param {number} [volume=1] - Default value for the volume. + * @param {boolean} [loop=false] - Whether or not the sound will loop. */ add: function (key, volume, loop) { volume = volume || 1; if (typeof loop == 'undefined') { loop = false; } - - var sound = new Phaser.Sound(this.game, key, volume, loop); this._sounds.push(sound); @@ -24543,24 +29208,18 @@ Phaser.SoundManager.prototype = { }; +/** +* @name Phaser.SoundManager#mute +* @property {boolean} mute - Gets or sets the muted state of the SoundManager. This effects all sounds in the game. +*/ Object.defineProperty(Phaser.SoundManager.prototype, "mute", { - /** - * A global audio mute toggle. - * @method mute - * @return {bool} whether or not the game is on "mute" - */ get: function () { return this._muted; }, - /** - * Mute sounds. - * @method mute - * @return {bool} whether or not the game is on "mute" - */ set: function (value) { value = value || null; @@ -24616,12 +29275,12 @@ Object.defineProperty(Phaser.SoundManager.prototype, "mute", { }); +/** +* @name Phaser.SoundManager#volume +* @property {number} volume - Gets or sets the global volume of the SoundManager, a value between 0 and 1. +*/ Object.defineProperty(Phaser.SoundManager.prototype, "volume", { - /** - * @method volume - * @return {number} The global audio volume. A value between 0 (silence) and 1 (full volume) - */ get: function () { if (this.usingWebAudio) @@ -24635,11 +29294,6 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", { }, - /** - * Sets the global volume - * @method volume - * @return {number} The global audio volume. A value between 0 (silence) and 1 (full volume) - */ set: function (value) { value = this.game.math.clamp(value, 1, 0); @@ -24667,38 +29321,73 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", { /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** -* A collection of methods for displaying debug information about game objects. +* A collection of methods for displaying debug information about game objects. Phaser.Debug requires a CANVAS game type in order to render, so if you've got +* your game set to use Phaser.AUTO then swap it for Phaser.CANVAS to ensure WebGL doesn't kick in, then the Debug functions will all display. * -* @class DebugUtils +* @class Phaser.Utils.Debug +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.Utils.Debug = function (game) { + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; + + /** + * @property {Context} context - The canvas context on which to render the debug information. + */ this.context = game.context; + /** + * @property {string} font - The font that the debug information is rendered in. + * @default '14px Courier' + */ this.font = '14px Courier'; + + /** + * @property {number} lineHeight - The line height between the debug text. + */ this.lineHeight = 16; + + /** + * @property {boolean} renderShadow - Should the text be rendered with a slight shadow? Makes it easier to read on different types of background. + */ this.renderShadow = true; + + /** + * @property {Context} currentX - The current X position the debug information will be rendered at. + * @default + */ this.currentX = 0; + + /** + * @property {number} currentY - The current Y position the debug information will be rendered at. + * @default + */ this.currentY = 0; + + /** + * @property {number} currentAlpha - The current alpha the debug information will be rendered at. + * @default + */ this.currentAlpha = 1; }; Phaser.Utils.Debug.prototype = { - /** - * Internal method that resets the debug output values. - * @method start - * @param {Number} x The X value the debug info will start from. - * @param {Number} y The Y value the debug info will start from. - * @param {String} color The color the debug info will drawn in. + * Internal method that resets and starts the debug output values. + * @method Phaser.Utils.Debug#start + * @param {number} x - The X value the debug info will start from. + * @param {number} y - The Y value the debug info will start from. + * @param {string} color - The color the debug info will drawn in. */ start: function (x, y, color) { @@ -24707,17 +29396,14 @@ Phaser.Utils.Debug.prototype = { return; } - x = x || null; - y = y || null; + if (typeof x !== 'number') { x = 0; } + if (typeof y !== 'number') { y = 0; } + color = color || 'rgb(255,255,255)'; - if (x && y) - { - this.currentX = x; - this.currentY = y; - this.currentColor = color; - } - + this.currentX = x; + this.currentY = y; + this.currentColor = color; this.currentAlpha = this.context.globalAlpha; this.context.save(); @@ -24728,8 +29414,13 @@ Phaser.Utils.Debug.prototype = { }, + /** + * Internal method that stops the debug output. + * @method Phaser.Utils.Debug#stop + */ stop: function () { + this.context.restore(); this.context.globalAlpha = this.currentAlpha; @@ -24737,10 +29428,10 @@ Phaser.Utils.Debug.prototype = { /** * Internal method that outputs a single line of text. - * @method line - * @param {String} text The line of text to draw. - * @param {Number} x The X value the debug info will start from. - * @param {Number} y The Y value the debug info will start from. + * @method Phaser.Utils.Debug#line + * @param {string} text - The line of text to draw. + * @param {number} x - The X value the debug info will start from. + * @param {number} y - The Y value the debug info will start from. */ line: function (text, x, y) { @@ -24772,6 +29463,12 @@ Phaser.Utils.Debug.prototype = { }, + /** + * Visually renders a QuadTree to the display. + * @method Phaser.Utils.Debug#renderQuadTree + * @param {Phaser.QuadTree} quadtree - The quadtree to render. + * @param {string} color - The color of the lines in the quadtree. + */ renderQuadTree: function (quadtree, color) { color = color || 'rgba(255,0,0,0.3)'; @@ -24806,6 +29503,14 @@ Phaser.Utils.Debug.prototype = { }, + /** + * Renders the corners and point information of the given Sprite. + * @method Phaser.Utils.Debug#renderSpriteCorners + * @param {Phaser.Sprite} sprite - The sprite to be rendered. + * @param {boolean} [showText=false] - If true the x/y coordinates of each point will be rendered. + * @param {boolean} [showBounds=false] - If true the bounds will be rendered over the top of the sprite. + * @param {string} [color='rgb(255,0,255)'] - The color the text is rendered in. + */ renderSpriteCorners: function (sprite, showText, showBounds, color) { if (this.context == null) @@ -24815,14 +29520,16 @@ Phaser.Utils.Debug.prototype = { showText = showText || false; showBounds = showBounds || false; - color = color || 'rgb(255,0,255)'; + color = color || 'rgb(255,255,255)'; this.start(0, 0, color); if (showBounds) { - this.context.strokeStyle = 'rgba(255,0,255,0.5)'; + this.context.beginPath(); + this.context.strokeStyle = 'rgba(0, 255, 0, 0.7)'; this.context.strokeRect(sprite.bounds.x, sprite.bounds.y, sprite.bounds.width, sprite.bounds.height); + this.context.closePath(); this.context.stroke(); } @@ -24832,7 +29539,7 @@ Phaser.Utils.Debug.prototype = { this.context.lineTo(sprite.bottomRight.x, sprite.bottomRight.y); this.context.lineTo(sprite.bottomLeft.x, sprite.bottomLeft.y); this.context.closePath(); - this.context.strokeStyle = 'rgba(0,0,255,0.8)'; + this.context.strokeStyle = 'rgba(255, 0, 255, 0.7)'; this.context.stroke(); this.renderPoint(sprite.center); @@ -24855,10 +29562,12 @@ Phaser.Utils.Debug.prototype = { }, /** - * Render debug infos. (including id, position, rotation, scrolling factor, worldBounds and some other properties) - * @param x {number} X position of the debug info to be rendered. - * @param y {number} Y position of the debug info to be rendered. - * @param [color] {number} color of the debug info to be rendered. (format is css color string) + * Render Sound information, including decoded state, duration, volume and more. + * @method Phaser.Utils.Debug#renderSoundInfo + * @param {Phaser.Sound} sound - The sound object to debug. + * @param {number} x - X position of the debug info to be rendered. + * @param {number} y - Y position of the debug info to be rendered. + * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string). */ renderSoundInfo: function (sound, x, y, color) { @@ -24890,10 +29599,12 @@ Phaser.Utils.Debug.prototype = { }, /** - * Render debug infos. (including id, position, rotation, scrolling factor, worldBounds and some other properties) - * @param x {number} X position of the debug info to be rendered. - * @param y {number} Y position of the debug info to be rendered. - * @param [color] {number} color of the debug info to be rendered. (format is css color string) + * Render camera information including dimensions and location. + * @method Phaser.Utils.Debug#renderCameraInfo + * @param {Phaser.Camera} camera - Description. + * @param {number} x - X position of the debug info to be rendered. + * @param {number} y - Y position of the debug info to be rendered. + * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string). */ renderCameraInfo: function (camera, x, y, color) { @@ -24902,18 +29613,25 @@ Phaser.Utils.Debug.prototype = { return; } - color = color || 'rgb(255,255,0)'; + color = color || 'rgb(255,255,255)'; this.start(x, y, color); this.line('Camera (' + camera.width + ' x ' + camera.height + ')'); this.line('X: ' + camera.x + ' Y: ' + camera.y); + this.line('Bounds x: ' + camera.bounds.x + ' Y: ' + camera.bounds.y + ' w: ' + camera.bounds.width + ' h: ' + camera.bounds.height); + this.line('View x: ' + camera.view.x + ' Y: ' + camera.view.y + ' w: ' + camera.view.width + ' h: ' + camera.view.height); this.stop(); }, /** - * Renders the Pointer.circle object onto the stage in green if down or red if up. - * @method renderDebug + * Renders the Pointer.circle object onto the stage in green if down or red if up along with debug text. + * @method Phaser.Utils.Debug#renderDebug + * @param {Phaser.Pointer} pointer - Description. + * @param {boolean} [hideIfUp=false] - Doesn't render the circle if the pointer is up. + * @param {string} [downColor='rgba(0,255,0,0.5)'] - The color the circle is rendered in if down. + * @param {string} [upColor='rgba(255,0,0,0.5)'] - The color the circle is rendered in if up (and hideIfUp is false). + * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string). */ renderPointer: function (pointer, hideIfUp, downColor, upColor, color) { @@ -24922,7 +29640,7 @@ Phaser.Utils.Debug.prototype = { return; } - hideIfUp = hideIfUp || false; + if (typeof hideIfUp === 'undefined') { hideIfUp = false; } downColor = downColor || 'rgba(0,255,0,0.5)'; upColor = upColor || 'rgba(255,0,0,0.5)'; color = color || 'rgb(255,255,255)'; @@ -24967,10 +29685,12 @@ Phaser.Utils.Debug.prototype = { }, /** - * Render Sprite Input Debug information - * @param x {number} X position of the debug info to be rendered. - * @param y {number} Y position of the debug info to be rendered. - * @param [color] {number} color of the debug info to be rendered. (format is css color string) + * Render Sprite Input Debug information. + * @method Phaser.Utils.Debug#renderSpriteInputInfo + * @param {Phaser.Sprite} sprite - The sprite to be rendered. + * @param {number} x - X position of the debug info to be rendered. + * @param {number} y - Y position of the debug info to be rendered. + * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string). */ renderSpriteInputInfo: function (sprite, x, y, color) { @@ -24986,6 +29706,14 @@ Phaser.Utils.Debug.prototype = { }, + /** + * Render Sprite collision. + * @method Phaser.Utils.Debug#renderSpriteCollision + * @param {Phaser.Sprite} sprite - The sprite to be rendered. + * @param {number} x - X position of the debug info to be rendered. + * @param {number} y - Y position of the debug info to be rendered. + * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string). + */ renderSpriteCollision: function (sprite, x, y, color) { color = color || 'rgb(255,255,255)'; @@ -25004,9 +29732,10 @@ Phaser.Utils.Debug.prototype = { /** * Render debug information about the Input object. - * @param x {number} X position of the debug info to be rendered. - * @param y {number} Y position of the debug info to be rendered. - * @param [color] {number} color of the debug info to be rendered. (format is css color string) + * @method Phaser.Utils.Debug#renderInputInfo + * @param {number} x - X position of the debug info to be rendered. + * @param {number} y - Y position of the debug info to be rendered. + * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string). */ renderInputInfo: function (x, y, color) { @@ -25028,10 +29757,12 @@ Phaser.Utils.Debug.prototype = { }, /** - * Render debug infos. (including name, bounds info, position and some other properties) - * @param x {number} X position of the debug info to be rendered. - * @param y {number} Y position of the debug info to be rendered. - * @param [color] {number} color of the debug info to be rendered. (format is css color string) + * Render debug infos (including name, bounds info, position and some other properties) about the Sprite. + * @method Phaser.Utils.Debug#renderSpriteInfo + * @param {Phaser.Sprite} sprite - Description. + * @param {number} x - X position of the debug info to be rendered. + * @param {number} y - Y position of the debug info to be rendered. + * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string). */ renderSpriteInfo: function (sprite, x, y, color) { @@ -25045,9 +29776,9 @@ Phaser.Utils.Debug.prototype = { this.start(x, y, color); this.line('Sprite: ' + ' (' + sprite.width + ' x ' + sprite.height + ') anchor: ' + sprite.anchor.x + ' x ' + sprite.anchor.y); - this.line('x: ' + sprite.x.toFixed(1) + ' y: ' + sprite.y.toFixed(1) + ' rotation: ' + sprite.rotation.toFixed(1)); - this.line('visible: ' + sprite.visible); - this.line('in camera: ' + sprite.inCamera); + this.line('x: ' + sprite.x.toFixed(1) + ' y: ' + sprite.y.toFixed(1)); + this.line('angle: ' + sprite.angle.toFixed(1) + ' rotation: ' + sprite.rotation.toFixed(1)); + this.line('visible: ' + sprite.visible + ' in camera: ' + sprite.inCamera); this.line('body x: ' + sprite.body.x.toFixed(1) + ' y: ' + sprite.body.y.toFixed(1)); // 0 = scaleX @@ -25064,13 +29795,24 @@ Phaser.Utils.Debug.prototype = { // this.line('ty: ' + sprite.worldTransform[5]); // this.line('skew x: ' + sprite.worldTransform[3]); // this.line('skew y: ' + sprite.worldTransform[1]); - // this.line('dx: ' + sprite.body.deltaX()); - // this.line('dy: ' + sprite.body.deltaY()); + this.line('deltaX: ' + sprite.body.deltaX()); + this.line('deltaY: ' + sprite.body.deltaY()); + // this.line('sdx: ' + sprite.deltaX()); + // this.line('sdy: ' + sprite.deltaY()); // this.line('inCamera: ' + this.game.renderer.spriteRenderer.inCamera(this.game.camera, sprite)); + this.stop(); }, + /** + * Render the World Transform information of the given Sprite. + * @method Phaser.Utils.Debug#renderWorldTransformInfo + * @param {Phaser.Sprite} sprite - Description. + * @param {number} x - X position of the debug info to be rendered. + * @param {number} y - Y position of the debug info to be rendered. + * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string). + */ renderWorldTransformInfo: function (sprite, x, y, color) { if (this.context == null) @@ -25089,9 +29831,18 @@ Phaser.Utils.Debug.prototype = { this.line('scaleY: ' + sprite.worldTransform[4]); this.line('transX: ' + sprite.worldTransform[2]); this.line('transY: ' + sprite.worldTransform[5]); + this.stop(); }, + /** + * Render the Local Transform information of the given Sprite. + * @method Phaser.Utils.Debug#renderLocalTransformInfo + * @param {Phaser.Sprite} sprite - Description. + * @param {number} x - X position of the debug info to be rendered. + * @param {number} y - Y position of the debug info to be rendered. + * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string). + */ renderLocalTransformInfo: function (sprite, x, y, color) { if (this.context == null) @@ -25110,11 +29861,60 @@ Phaser.Utils.Debug.prototype = { this.line('scaleY: ' + sprite.localTransform[4]); this.line('transX: ' + sprite.localTransform[2]); this.line('transY: ' + sprite.localTransform[5]); - this.line('sX: ' + sprite._sx); - this.line('sY: ' + sprite._sy); + this.stop(); }, + renderSpriteCoords: function (sprite, x, y, color) { + + if (this.context == null) + { + return; + } + + color = color || 'rgb(255, 255, 255)'; + + this.start(x, y, color); + + this.line(sprite.name); + this.line('x: ' + sprite.x); + this.line('y: ' + sprite.y); + this.line('local x: ' + sprite.localTransform[2]); + this.line('local y: ' + sprite.localTransform[5]); + this.line('world x: ' + sprite.worldTransform[2]); + this.line('world y: ' + sprite.worldTransform[5]); + + this.stop(); + + }, + + renderGroupInfo: function (group, x, y, color) { + + if (this.context == null) + { + return; + } + + color = color || 'rgb(255, 255, 255)'; + + this.start(x, y, color); + + this.line('Group (size: ' + group.length + ')'); + this.line('x: ' + group.x); + this.line('y: ' + group.y); + + this.stop(); + + }, + + /** + * Renders Point coordinates in the given color. + * @method Phaser.Utils.Debug#renderPointInfo + * @param {Phaser.Point} sprite - Description. + * @param {number} x - X position of the debug info to be rendered. + * @param {number} y - Y position of the debug info to be rendered. + * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string). + */ renderPointInfo: function (point, x, y, color) { if (this.context == null) @@ -25130,6 +29930,12 @@ Phaser.Utils.Debug.prototype = { }, + /** + * Renders just the Sprite.body bounds. + * @method Phaser.Utils.Debug#renderSpriteBody + * @param {Phaser.Sprite} sprite - Description. + * @param {string} [color] - Color of the debug info to be rendered (format is css color string). + */ renderSpriteBody: function (sprite, color) { if (this.context == null) @@ -25142,13 +29948,19 @@ Phaser.Utils.Debug.prototype = { this.start(0, 0, color); this.context.fillStyle = color; - // this.context.fillRect(sprite.body.x - sprite.body.deltaX(), sprite.body.y - sprite.body.deltaY(), sprite.body.width, sprite.body.height); - this.context.fillRect(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height); + this.context.fillRect(sprite.body.screenX, sprite.body.screenY, sprite.body.width, sprite.body.height); this.stop(); }, + /** + * Renders just the full Sprite bounds. + * @method Phaser.Utils.Debug#renderSpriteBounds + * @param {Phaser.Sprite} sprite - Description. + * @param {string} [color] - Color of the debug info to be rendered (format is css color string). + * @param {boolean} [fill=false] - If false the bounds outline is rendered, if true the whole rectangle is rendered. + */ renderSpriteBounds: function (sprite, color, fill) { if (this.context == null) @@ -25158,6 +29970,8 @@ Phaser.Utils.Debug.prototype = { color = color || 'rgb(255,0,255)'; + if (typeof fill === 'undefined') { fill = false; } + this.start(0, 0, color); if (fill) @@ -25176,66 +29990,91 @@ Phaser.Utils.Debug.prototype = { }, - renderPixel: function (x, y, fillStyle) { + /** + * Renders a single pixel. + * @method Phaser.Utils.Debug#renderPixel + * @param {number} x - X position of the debug info to be rendered. + * @param {number} y - Y position of the debug info to be rendered. + * @param {string} [color] - Color of the debug info to be rendered (format is css color string). + */ + renderPixel: function (x, y, color) { if (this.context == null) { return; } - fillStyle = fillStyle || 'rgba(0,255,0,1)'; + color = color || 'rgba(0,255,0,1)'; this.start(); - this.context.fillStyle = fillStyle; + this.context.fillStyle = color; this.context.fillRect(x, y, 2, 2); this.stop(); }, - renderPoint: function (point, fillStyle) { + /** + * Renders a Point object. + * @method Phaser.Utils.Debug#renderPoint + * @param {Phaser.Point} point - The Point to render. + * @param {string} [color] - Color of the debug info to be rendered (format is css color string). + */ + renderPoint: function (point, color) { if (this.context == null) { return; } - fillStyle = fillStyle || 'rgba(0,255,0,1)'; + color = color || 'rgba(0,255,0,1)'; this.start(); - this.context.fillStyle = fillStyle; + this.context.fillStyle = color; this.context.fillRect(point.x, point.y, 4, 4); this.stop(); }, - renderRectangle: function (rect, fillStyle) { + /** + * Renders a Rectangle. + * @method Phaser.Utils.Debug#renderRectangle + * @param {Phaser.Rectangle} rect - The Rectangle to render. + * @param {string} [color] - Color of the debug info to be rendered (format is css color string). + */ + renderRectangle: function (rect, color) { if (this.context == null) { return; } - fillStyle = fillStyle || 'rgba(0,255,0,0.3)'; + color = color || 'rgba(0,255,0,0.3)'; this.start(); - this.context.fillStyle = fillStyle; + this.context.fillStyle = color; this.context.fillRect(rect.x, rect.y, rect.width, rect.height); this.stop(); }, - renderCircle: function (circle, fillStyle) { + /** + * Renders a Circle. + * @method Phaser.Utils.Debug#renderCircle + * @param {Phaser.Circle} circle - The Circle to render. + * @param {string} [color] - Color of the debug info to be rendered (format is css color string). + */ + renderCircle: function (circle, color) { if (this.context == null) { return; } - fillStyle = fillStyle || 'rgba(0,255,0,0.3)'; + color = color || 'rgba(0,255,0,0.3)'; this.start(); this.context.beginPath(); - this.context.fillStyle = fillStyle; + this.context.fillStyle = color; this.context.arc(circle.x, circle.y, circle.radius, 0, Math.PI * 2, false); this.context.fill(); this.context.closePath(); @@ -25244,10 +30083,13 @@ Phaser.Utils.Debug.prototype = { }, /** - * Render text - * @param x {number} X position of the debug info to be rendered. - * @param y {number} Y position of the debug info to be rendered. - * @param [color] {number} color of the debug info to be rendered. (format is css color string) + * Render text. + * @method Phaser.Utils.Debug#renderText + * @param {string} text - The line of text to draw. + * @param {number} x - X position of the debug info to be rendered. + * @param {number} y - Y position of the debug info to be rendered. + * @param {string} [color] - Color of the debug info to be rendered (format is css color string). + * @param {string} font - The font of text to draw. */ renderText: function (text, x, y, color, font) { @@ -25265,55 +30107,136 @@ Phaser.Utils.Debug.prototype = { this.context.fillText(text, x, y); this.stop(); + }, + + /** + * Dumps the Linked List to the console. + * + * @method Phaser.Utils.Debug#Phaser.LinkedList#dump + * @param {Phaser.LinkedList} list - The LinkedList to dump. + */ + dumpLinkedList: function (list) { + + var spacing = 20; + + var output = "\n" + Phaser.Utils.pad('Node', spacing) + "|" + Phaser.Utils.pad('Next', spacing) + "|" + Phaser.Utils.pad('Previous', spacing) + "|" + Phaser.Utils.pad('First', spacing) + "|" + Phaser.Utils.pad('Last', spacing); + console.log(output); + + var output = Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing); + console.log(output); + + var entity = list; + + var testObject = entity.last.next; + entity = entity.first; + + do + { + var name = entity.sprite.name || '*'; + var nameNext = '-'; + var namePrev = '-'; + var nameFirst = '-'; + var nameLast = '-'; + + if (entity.next) + { + nameNext = entity.next.sprite.name; + } + + if (entity.prev) + { + namePrev = entity.prev.sprite.name; + } + + if (entity.first) + { + nameFirst = entity.first.sprite.name; + } + + if (entity.last) + { + nameLast = entity.last.sprite.name; + } + + if (typeof nameNext === 'undefined') + { + nameNext = '-'; + } + + if (typeof namePrev === 'undefined') + { + namePrev = '-'; + } + + if (typeof nameFirst === 'undefined') + { + nameFirst = '-'; + } + + if (typeof nameLast === 'undefined') + { + nameLast = '-'; + } + + var output = Phaser.Utils.pad(name, spacing) + "|" + Phaser.Utils.pad(nameNext, spacing) + "|" + Phaser.Utils.pad(namePrev, spacing) + "|" + Phaser.Utils.pad(nameFirst, spacing) + "|" + Phaser.Utils.pad(nameLast, spacing); + console.log(output); + + entity = entity.next; + + } + while(entity != testObject) + } + }; /** -* A collection of methods useful for manipulating and comparing colors. -* -* @class Color * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +/** +* A collection of methods useful for manipulating and comparing colors. +* +* @class Phaser.Color +*/ Phaser.Color = { - /** - * Given an alpha and 3 color values this will return an integer representation of it + /** + * Given an alpha and 3 color values this will return an integer representation of it. * - * @method getColor32 - * @param {Number} alpha The Alpha value (between 0 and 255) - * @param {Number} red The Red channel value (between 0 and 255) - * @param {Number} green The Green channel value (between 0 and 255) - * @param {Number} blue The Blue channel value (between 0 and 255) - * @return {Number} A native color value integer (format: 0xAARRGGBB) + * @method Phaser.Color.getColor32 + * @param {number} alpha - The Alpha value (between 0 and 255). + * @param {number} red - The Red channel value (between 0 and 255). + * @param {number} green - The Green channel value (between 0 and 255). + * @param {number} blue - The Blue channel value (between 0 and 255). + * @returns {number} A native color value integer (format: 0xAARRGGBB). */ getColor32: function (alpha, red, green, blue) { return alpha << 24 | red << 16 | green << 8 | blue; }, - /** + /** * Given 3 color values this will return an integer representation of it. * - * @method getColor - * @param {Number} red The Red channel value (between 0 and 255) - * @param {Number} green The Green channel value (between 0 and 255) - * @param {Number} blue The Blue channel value (between 0 and 255) - * @return {Number} A native color value integer (format: 0xRRGGBB) + * @method Phaser.Color.getColor + * @param {number} red - The Red channel value (between 0 and 255). + * @param {number} green - The Green channel value (between 0 and 255). + * @param {number} blue - The Blue channel value (between 0 and 255). + * @returns {number} A native color value integer (format: 0xRRGGBB). */ getColor: function (red, green, blue) { return red << 16 | green << 8 | blue; }, - /** + /** * Converts the given hex string into an object containing the RGB values. * - * @method hexToRGB - * @param {String} The string hex color to convert. - * @return {Object} An object with 3 properties: r,g and b. + * @method Phaser.Color.hexToRGB + * @param {string} h - The string hex color to convert. + * @returns {object} An object with 3 properties: r,g and b. */ hexToRGB: function (h) { @@ -25326,234 +30249,269 @@ Phaser.Color = { }, - /** + /** * Returns a string containing handy information about the given color including string hex value, * RGB format information and HSL information. Each section starts on a newline, 3 lines in total. * - * @method getColorInfo - * @param {Number} color A color value in the format 0xAARRGGBB - * @return {String} string containing the 3 lines of information + * @method Phaser.Color.getColorInfo + * @param {number} color - A color value in the format 0xAARRGGBB. + * @returns {string} String containing the 3 lines of information. */ getColorInfo: function (color) { + var argb = Phaser.Color.getRGB(color); var hsl = Phaser.Color.RGBtoHSV(color); + // Hex format var result = Phaser.Color.RGBtoHexstring(color) + "\n"; + // RGB format result = result.concat("Alpha: " + argb.alpha + " Red: " + argb.red + " Green: " + argb.green + " Blue: " + argb.blue) + "\n"; + // HSL info result = result.concat("Hue: " + hsl.hue + " Saturation: " + hsl.saturation + " Lightnes: " + hsl.lightness); + return result; + }, - /** - * Return a string representation of the color in the format 0xAARRGGBB + /** + * Return a string representation of the color in the format 0xAARRGGBB. * - * @method RGBtoHexstring - * @param {Number} color The color to get the string representation for - * @return {String A string of length 10 characters in the format 0xAARRGGBB + * @method Phaser.Color.RGBtoHexstring + * @param {number} color - The color to get the string representation for + * @returns {string} A string of length 10 characters in the format 0xAARRGGBB */ RGBtoHexstring: function (color) { + var argb = Phaser.Color.getRGB(color); + return "0x" + Phaser.Color.colorToHexstring(argb.alpha) + Phaser.Color.colorToHexstring(argb.red) + Phaser.Color.colorToHexstring(argb.green) + Phaser.Color.colorToHexstring(argb.blue); + }, - /** - * Return a string representation of the color in the format #RRGGBB + /** + * Return a string representation of the color in the format #RRGGBB. * - * @method RGBtoWebstring - * @param {Number} color The color to get the string representation for - * @return {String} A string of length 10 characters in the format 0xAARRGGBB + * @method Phaser.Color.RGBtoWebstring + * @param {number} color - The color to get the string representation for. + * @returns {string} A string of length 10 characters in the format 0xAARRGGBB. */ RGBtoWebstring: function (color) { + var argb = Phaser.Color.getRGB(color); + return "#" + Phaser.Color.colorToHexstring(argb.red) + Phaser.Color.colorToHexstring(argb.green) + Phaser.Color.colorToHexstring(argb.blue); + }, - /** - * Return a string containing a hex representation of the given color + /** + * Return a string containing a hex representation of the given color. * - * @method colorToHexstring - * @param {Number} color The color channel to get the hex value for, must be a value between 0 and 255) - * @return {String} A string of length 2 characters, i.e. 255 = FF, 0 = 00 + * @method Phaser.Color.colorToHexstring + * @param {number} color - The color channel to get the hex value for, must be a value between 0 and 255). + * @returns {string} A string of length 2 characters, i.e. 255 = FF, 0 = 00. */ colorToHexstring: function (color) { + var digits = "0123456789ABCDEF"; var lsd = color % 16; var msd = (color - lsd) / 16; var hexified = digits.charAt(msd) + digits.charAt(lsd); return hexified; + }, - /** + /** * Interpolates the two given colours based on the supplied step and currentStep properties. - * @method interpolateColor - * @param {Number} color1 - * @param {Number} color2 - * @param {Number} steps - * @param {Number} currentStep - * @param {Number} alpha - * @return {Number} The interpolated color value. + * @method Phaser.Color.interpolateColor + * @param {number} color1 - Description. + * @param {number} color2 - Description. + * @param {number} steps - Description. + * @param {number} currentStep - Description. + * @param {number} alpha - Description. + * @returns {number} The interpolated color value. */ interpolateColor: function (color1, color2, steps, currentStep, alpha) { + if (typeof alpha === "undefined") { alpha = 255; } + var src1 = Phaser.Color.getRGB(color1); var src2 = Phaser.Color.getRGB(color2); var r = (((src2.red - src1.red) * currentStep) / steps) + src1.red; var g = (((src2.green - src1.green) * currentStep) / steps) + src1.green; var b = (((src2.blue - src1.blue) * currentStep) / steps) + src1.blue; + return Phaser.Color.getColor32(alpha, r, g, b); + }, - /** + /** * Interpolates the two given colours based on the supplied step and currentStep properties. - * @method interpolateColorWithRGB - * @param {Number} color - * @param {Number} r - * @param {Number} g - * @param {Number} b - * @param {Number} steps - * @param {Number} currentStep - * @return {Number} The interpolated color value. + * @method Phaser.Color.interpolateColorWithRGB + * @param {number} color - Description. + * @param {number} r - Description. + * @param {number} g - Description. + * @param {number} b - Description. + * @param {number} steps - Description. + * @param {number} currentStep - Description. + * @returns {number} The interpolated color value. */ interpolateColorWithRGB: function (color, r, g, b, steps, currentStep) { + var src = Phaser.Color.getRGB(color); var or = (((r - src.red) * currentStep) / steps) + src.red; var og = (((g - src.green) * currentStep) / steps) + src.green; var ob = (((b - src.blue) * currentStep) / steps) + src.blue; + return Phaser.Color.getColor(or, og, ob); + }, - /** + /** * Interpolates the two given colours based on the supplied step and currentStep properties. - * @method interpolateRGB - * @param {Number} r1 - * @param {Number} g1 - * @param {Number} b1 - * @param {Number} r2 - * @param {Number} g2 - * @param {Number} b2 - * @param {Number} steps - * @param {Number} currentStep - * @return {Number} The interpolated color value. + * @method Phaser.Color.interpolateRGB + * @param {number} r1 - Description. + * @param {number} g1 - Description. + * @param {number} b1 - Description. + * @param {number} r2 - Description. + * @param {number} g2 - Description. + * @param {number} b2 - Description. + * @param {number} steps - Description. + * @param {number} currentStep - Description. + * @returns {number} The interpolated color value. */ interpolateRGB: function (r1, g1, b1, r2, g2, b2, steps, currentStep) { + var r = (((r2 - r1) * currentStep) / steps) + r1; var g = (((g2 - g1) * currentStep) / steps) + g1; var b = (((b2 - b1) * currentStep) / steps) + b1; + return Phaser.Color.getColor(r, g, b); + }, - /** + /** * Returns a random color value between black and white *

    Set the min value to start each channel from the given offset.

    *

    Set the max value to restrict the maximum color used per channel

    * - * @method getRandomColor - * @param {Number} min The lowest value to use for the color - * @param {Number} max The highest value to use for the color - * @param {Number} alpha The alpha value of the returning color (default 255 = fully opaque) - * @return {Number} 32-bit color value with alpha + * @method Phaser.Color.getRandomColor + * @param {number} min - The lowest value to use for the color. + * @param {number} max - The highest value to use for the color. + * @param {number} alpha - The alpha value of the returning color (default 255 = fully opaque). + * @returns {number} 32-bit color value with alpha. */ getRandomColor: function (min, max, alpha) { + if (typeof min === "undefined") { min = 0; } if (typeof max === "undefined") { max = 255; } if (typeof alpha === "undefined") { alpha = 255; } + // Sanity checks if (max > 255) { return Phaser.Color.getColor(255, 255, 255); } + if (min > max) { return Phaser.Color.getColor(255, 255, 255); } + var red = min + Math.round(Math.random() * (max - min)); var green = min + Math.round(Math.random() * (max - min)); var blue = min + Math.round(Math.random() * (max - min)); + return Phaser.Color.getColor32(alpha, red, green, blue); + }, - /** + /** * Return the component parts of a color as an Object with the properties alpha, red, green, blue * *

    Alpha will only be set if it exist in the given color (0xAARRGGBB)

    * - * @method getRGB - * @param {Number} color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB) - * @return {Object} An Object with properties: alpha, red, green, blue + * @method Phaser.Color.getRGB + * @param {number} color - Color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB). + * @returns {object} An Object with properties: alpha, red, green, blue. */ getRGB: function (color) { + return { alpha: color >>> 24, red: color >> 16 & 0xFF, green: color >> 8 & 0xFF, blue: color & 0xFF }; + }, - /** + /** * Returns a CSS friendly string value from the given color. - * @method getWebRGB - * @param {Number} color - * @return {String} A string in the format: 'rgba(r,g,b,a)' + * @method Phaser.Color.getWebRGB + * @param {number} color + * @returns {string}A string in the format: 'rgba(r,g,b,a)' */ getWebRGB: function (color) { + var alpha = (color >>> 24) / 255; var red = color >> 16 & 0xFF; var green = color >> 8 & 0xFF; var blue = color & 0xFF; + return 'rgba(' + red.toString() + ',' + green.toString() + ',' + blue.toString() + ',' + alpha.toString() + ')'; + }, - /** - * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255 + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255. * - * @method getAlpha - * @param {Number} color In the format 0xAARRGGBB - * @return {Number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)) + * @method Phaser.Color.getAlpha + * @param {number} color - In the format 0xAARRGGBB. + * @returns {number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)). */ getAlpha: function (color) { return color >>> 24; }, - /** - * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1 + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1. * - * @method getAlphaFloat - * @param {Number} color In the format 0xAARRGGBB - * @return {Number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)) + * @method Phaser.Color.getAlphaFloat + * @param {number} color - In the format 0xAARRGGBB. + * @returns {number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)). */ getAlphaFloat: function (color) { return (color >>> 24) / 255; }, - /** - * Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255 + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255. * - * @method getRed - * @param {Number} color In the format 0xAARRGGBB - * @return {Number} The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red) + * @method Phaser.Color.getRed + * @param {number} color In the format 0xAARRGGBB. + * @returns {number} The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red). */ getRed: function (color) { return color >> 16 & 0xFF; }, - /** - * Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255 + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255. * - * @method getGreen - * @param {Number} color In the format 0xAARRGGBB - * @return {Number} The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green) + * @method Phaser.Color.getGreen + * @param {number} color - In the format 0xAARRGGBB. + * @returns {number} The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green). */ getGreen: function (color) { return color >> 8 & 0xFF; }, - /** - * Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255 + /** + * Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255. * - * @method getBlue - * @param {Number} color In the format 0xAARRGGBB - * @return {Number} The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue) + * @method Phaser.Color.getBlue + * @param {number} color - In the format 0xAARRGGBB. + * @returns {number} The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue). */ getBlue: function (color) { return color & 0xFF; @@ -25561,93 +30519,222 @@ Phaser.Color = { }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* @class Phaser.Physics +*/ Phaser.Physics = {}; +/** +* Arcade Physics constructor. +* +* @class Phaser.Physics.Arcade +* @classdesc Arcade Physics Constructor +* @constructor +* @param {Phaser.Game} game reference to the current game instance. +*/ Phaser.Physics.Arcade = function (game) { - - this.game = game; + + /** + * @property {Phaser.Game} game - Local reference to game. + */ + this.game = game; - this.gravity = new Phaser.Point; - this.bounds = new Phaser.Rectangle(0, 0, game.world.width, game.world.height); + /** + * @property {Phaser.Point} gravity - The World gravity setting. Defaults to x: 0, y: 0, or no gravity. + */ + this.gravity = new Phaser.Point; - /** - * Used by the QuadTree to set the maximum number of objects - * @type {number} - */ - this.maxObjects = 10; + /** + * @property {Phaser.Rectangle} bounds - The bounds inside of which the physics world exists. Defaults to match the world bounds. + */ + this.bounds = new Phaser.Rectangle(0, 0, game.world.width, game.world.height); - /** - * Used by the QuadTree to set the maximum number of levels - * @type {number} - */ - this.maxLevels = 4; + /** + * @property {number} maxObjects - Used by the QuadTree to set the maximum number of objects per quad. + */ + this.maxObjects = 10; - this.OVERLAP_BIAS = 4; - this.TILE_OVERLAP = false; + /** + * @property {number} maxLevels - Used by the QuadTree to set the maximum number of iteration levels. + */ + this.maxLevels = 4; + /** + * @property {number} OVERLAP_BIAS - A value added to the delta values during collision checks. + */ + this.OVERLAP_BIAS = 4; + + /** + * @property {Phaser.QuadTree} quadTree - The world QuadTree. + */ this.quadTree = new Phaser.QuadTree(this, this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels); - this.quadTreeID = 0; - // Avoid gc spikes by caching these values for re-use - this._bounds1 = new Phaser.Rectangle; - this._bounds2 = new Phaser.Rectangle; - this._overlap = 0; - this._maxOverlap = 0; - this._velocity1 = 0; - this._velocity2 = 0; - this._newVelocity1 = 0; - this._newVelocity2 = 0; - this._average = 0; + /** + * @property {number} quadTreeID - The QuadTree ID. + */ + this.quadTreeID = 0; + + // Avoid gc spikes by caching these values for re-use + + /** + * @property {Phaser.Rectangle} _bounds1 - Internal cache var. + * @private + */ + this._bounds1 = new Phaser.Rectangle; + + /** + * @property {Phaser.Rectangle} _bounds2 - Internal cache var. + * @private + */ + this._bounds2 = new Phaser.Rectangle; + + /** + * @property {number} _overlap - Internal cache var. + * @private + */ + this._overlap = 0; + + /** + * @property {number} _maxOverlap - Internal cache var. + * @private + */ + this._maxOverlap = 0; + + /** + * @property {number} _velocity1 - Internal cache var. + * @private + */ + this._velocity1 = 0; + + /** + * @property {number} _velocity2 - Internal cache var. + * @private + */ + this._velocity2 = 0; + + /** + * @property {number} _newVelocity1 - Internal cache var. + * @private + */ + this._newVelocity1 = 0; + + /** + * @property {number} _newVelocity2 - Internal cache var. + * @private + */ + this._newVelocity2 = 0; + + /** + * @property {number} _average - Internal cache var. + * @private + */ + this._average = 0; + + /** + * @property {Array} _mapData - Internal cache var. + * @private + */ this._mapData = []; + + /** + * @property {number} _mapTiles - Internal cache var. + * @private + */ + this._mapTiles = 0; + + /** + * @property {boolean} _result - Internal cache var. + * @private + */ this._result = false; + + /** + * @property {number} _total - Internal cache var. + * @private + */ this._total = 0; + /** + * @property {number} _angle - Internal cache var. + * @private + */ + this._angle = 0; + + /** + * @property {number} _dx - Internal cache var. + * @private + */ + this._dx = 0; + + /** + * @property {number} _dy - Internal cache var. + * @private + */ + this._dy = 0; + }; Phaser.Physics.Arcade.prototype = { + /** + * Called automatically by a Physics body, it updates all motion related values on the Body. + * + * @method Phaser.Physics.Arcade#updateMotion + * @param {Phaser.Physics.Arcade.Body} The Body object to be updated. + */ updateMotion: function (body) { - // Rotation - this._velocityDelta = (this.computeVelocity(0, false, body.angularVelocity, body.angularAcceleration, body.angularDrag, body.maxAngular) - body.angularVelocity) / 2; + // If you're wondering why the velocity is halved and applied twice, read this: http://www.niksula.hut.fi/~hkankaan/Homepages/gravity.html + + // Rotation + this._velocityDelta = (this.computeVelocity(0, body, body.angularVelocity, body.angularAcceleration, body.angularDrag, body.maxAngular) - body.angularVelocity) / 2; + body.angularVelocity += this._velocityDelta; + body.rotation += (body.angularVelocity * this.game.time.physicsElapsed); body.angularVelocity += this._velocityDelta; - body.rotation += body.angularVelocity * this.game.time.physicsElapsed; - // Horizontal - this._velocityDelta = (this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x) - body.velocity.x) / 2; + // Horizontal + this._velocityDelta = (this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x, body.maxVelocity.x) - body.velocity.x) / 2; + body.velocity.x += this._velocityDelta; + body.x += (body.velocity.x * this.game.time.physicsElapsed); body.velocity.x += this._velocityDelta; - this._delta = body.velocity.x * this.game.time.physicsElapsed; - body.x += this._delta; - // Vertical - this._velocityDelta = (this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y) - body.velocity.y) / 2; + // Vertical + this._velocityDelta = (this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y, body.maxVelocity.y) - body.velocity.y) / 2; + body.velocity.y += this._velocityDelta; + body.y += (body.velocity.y * this.game.time.physicsElapsed); body.velocity.y += this._velocityDelta; - this._delta = body.velocity.y * this.game.time.physicsElapsed; - body.y += this._delta; }, - /** + /** * A tween-like function that takes a starting velocity and some other factors and returns an altered velocity. * - * @param {number} Velocity Any component of velocity (e.g. 20). - * @param {number} Acceleration Rate at which the velocity is changing. - * @param {number} Drag Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set. - * @param {number} Max An absolute value cap for the velocity. - * + * @method Phaser.Physics.Arcade#computeVelocity + * @param {number} axis - 1 for horizontal, 2 for vertical. + * @param {Phaser.Physics.Arcade.Body} body - The Body object to be updated. + * @param {number} velocity - Any component of velocity (e.g. 20). + * @param {number} acceleration - Rate at which the velocity is changing. + * @param {number} drag - Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set. + * @param {number} mMax - An absolute value cap for the velocity. * @return {number} The altered Velocity value. */ computeVelocity: function (axis, body, velocity, acceleration, drag, max) { - max = max || 10000; + max = max || 10000; - if (axis == 1 && body.allowGravity) + if (axis == 1 && body.allowGravity) { - velocity += this.gravity.x + body.gravity.x; + velocity += this.gravity.x + body.gravity.x; } - else if (axis == 2 && body.allowGravity) + else if (axis == 2 && body.allowGravity) { - velocity += this.gravity.y + body.gravity.y; + velocity += this.gravity.y + body.gravity.y; } if (acceleration !== 0) @@ -25660,7 +30747,7 @@ Phaser.Physics.Arcade.prototype = { if (velocity - this._drag > 0) { - velocity = velocity - this._drag; + velocity -= this._drag; } else if (velocity + this._drag < 0) { @@ -25672,51 +30759,82 @@ Phaser.Physics.Arcade.prototype = { } } - if (velocity != 0) + if (velocity > max) { - if (velocity > max) - { - velocity = max; - } - else if (velocity < -max) - { - velocity = -max; - } + velocity = max; + } + else if (velocity < -max) + { + velocity = -max; } return velocity; }, + /** + * Called automatically by the core game loop. + * + * @method Phaser.Physics.Arcade#preUpdate + * @protected + */ preUpdate: function () { // Clear the tree this.quadTree.clear(); - // Create our tree which all of the Physics bodies will add themselves to + // Create our tree which all of the Physics bodies will add themselves to this.quadTreeID = 0; - this.quadTree = new Phaser.QuadTree(this, this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels); + this.quadTree = new Phaser.QuadTree(this, this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels); }, + /** + * Called automatically by the core game loop. + * + * @method Phaser.Physics.Arcade#postUpdate + * @protected + */ postUpdate: function () { - // Clear the tree ready for the next update - this.quadTree.clear(); + // Clear the tree ready for the next update + this.quadTree.clear(); + + }, + + /** + * Checks if two Sprite objects overlap. + * + * @method Phaser.Physics.Arcade#overlap + * @param {Phaser.Sprite} object1 - The first object to check. Can be an instance of Phaser.Sprite or anything that extends it. + * @param {Phaser.Sprite} object2 - The second object to check. Can be an instance of Phaser.Sprite or anything that extends it. + * @returns {boolean} true if the two objects overlap. + */ + overlap: function (object1, object2) { + + // Only test valid objects + if (object1 && object2 && object1.exists && object2.exists) + { + return (Phaser.Rectangle.intersects(object1.body, object2.body)); + } + + return false; }, /** * Checks for collision between two game objects. The objects can be Sprites, Groups, Emitters or Tilemaps. * You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap or Group vs. Tilemap collisions. + * The objects are also automatically separated. * - * @param object1 The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.Tilemap - * @param object2 The second object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.Tilemap - * @param collideCallback 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 passed them to Collision.overlap. - * @param processCallback A 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 processCallback returns true. - * @param callbackContext The context in which to run the callbacks. - * @returns {boolean} true if any collisions were detected, otherwise false. - **/ + * @method Phaser.Physics.Arcade#collide + * @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object1 - The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.Tilemap + * @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object2 - The second object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.Tilemap + * @param {function} [collideCallback=null] - 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 passed them to Collision.overlap. + * @param {function} [processCallback=null] - A 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 processCallback returns true. + * @param {object} [callbackContext] - The context in which to run the callbacks. + * @returns {number} The number of collisions that were processed. + */ collide: function (object1, object2, collideCallback, processCallback, callbackContext) { collideCallback = collideCallback || null; @@ -25742,9 +30860,9 @@ Phaser.Physics.Arcade.prototype = { { this.collideSpriteVsGroup(object1, object2, collideCallback, processCallback, callbackContext); } - else if (object2.type == Phaser.TILEMAP) + else if (object2.type == Phaser.TILEMAPLAYER) { - this.collideSpriteVsTilemap(object1, object2, collideCallback, processCallback, callbackContext); + this.collideSpriteVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext); } } // GROUPS @@ -25758,21 +30876,21 @@ Phaser.Physics.Arcade.prototype = { { this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext); } - else if (object2.type == Phaser.TILEMAP) + else if (object2.type == Phaser.TILEMAPLAYER) { - this.collideGroupVsTilemap(object1, object2, collideCallback, processCallback, callbackContext); + this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext); } } - // TILEMAPS - else if (object1.type == Phaser.TILEMAP) + // TILEMAP LAYERS + else if (object1.type == Phaser.TILEMAPLAYER) { if (object2.type == Phaser.SPRITE) { - this.collideSpriteVsTilemap(object2, object1, collideCallback, processCallback, callbackContext); + this.collideSpriteVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext); } else if (object2.type == Phaser.GROUP || object2.type == Phaser.EMITTER) { - this.collideGroupVsTilemap(object2, object1, collideCallback, processCallback, callbackContext); + this.collideGroupVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext); } } // EMITTER @@ -25786,9 +30904,9 @@ Phaser.Physics.Arcade.prototype = { { this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext); } - else if (object2.type == Phaser.TILEMAP) + else if (object2.type == Phaser.TILEMAPLAYER) { - this.collideGroupVsTilemap(object1, object2, collideCallback, processCallback, callbackContext); + this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext); } } } @@ -25797,6 +30915,93 @@ Phaser.Physics.Arcade.prototype = { }, + /** + * An internal function. Use Phaser.Physics.Arcade.collide instead. + * + * @method Phaser.Physics.Arcade#collideSpriteVsTilemapLayer + * @private + */ + collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext) { + + this._mapData = tilemapLayer.getTiles(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height, true); + + if (this._mapData.length > 1) + { + for (var i = 1; i < this._mapData.length; i++) + { + this.separateTile(sprite.body, this._mapData[i]); + + if (this._result) + { + // They collided, is there a custom process callback? + if (processCallback) + { + if (processCallback.call(callbackContext, sprite, this._mapData[i])) + { + this._total++; + + if (collideCallback) + { + collideCallback.call(callbackContext, sprite, this._mapData[i]); + } + } + } + else + { + this._total++; + + if (collideCallback) + { + collideCallback.call(callbackContext, sprite, this._mapData[i]); + } + } + } + } + } + + }, + + /** + * An internal function. Use Phaser.Physics.Arcade.collide instead. + * + * @method Phaser.Physics.Arcade#collideGroupVsTilemapLayer + * @private + */ + collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext) { + + if (group.length == 0) + { + return; + } + + if (group.length == 0) + { + return; + } + + if (group._container.first._iNext) + { + var currentNode = group._container.first._iNext; + + do + { + if (currentNode.exists) + { + this.collideSpriteVsTilemapLayer(currentNode, tilemapLayer, collideCallback, processCallback, callbackContext); + } + currentNode = currentNode._iNext; + } + while (currentNode != group._container.last._iNext); + } + + }, + + /** + * An internal function. Use Phaser.Physics.Arcade.collide instead. + * + * @method Phaser.Physics.Arcade#collideSpriteVsSprite + * @private + */ collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext) { this.separate(sprite1.body, sprite2.body); @@ -25829,65 +31034,12 @@ Phaser.Physics.Arcade.prototype = { }, - collideGroupVsTilemap: function (group, tilemap, collideCallback, processCallback, callbackContext) { - - if (group.length == 0) - { - return; - } - - if (group._container.first._iNext) - { - var currentNode = group._container.first._iNext; - - do - { - if (currentNode.exists) - { - this.collideSpriteVsTilemap(currentNode, tilemap, collideCallback, processCallback, callbackContext); - } - currentNode = currentNode._iNext; - } - while (currentNode != group._container.last._iNext); - } - - }, - - collideSpriteVsTilemap: function (sprite, tilemap, collideCallback, processCallback, callbackContext) { - - this._mapData = tilemap.collisionLayer.getTileOverlaps(sprite); - - // If the sprite actually collided with the tilemap then _mapData contains an array of the tiles it collided with - var i = this._mapData.length; - - while (i--) - { - if (processCallback) - { - // We've got a custom process callback to hit first - if (processCallback.call(callbackContext, sprite, this._mapData[i].tile)) - { - this._total++; - - if (collideCallback) - { - collideCallback.call(callbackContext, sprite, this._mapData[i].tile); - } - } - } - else - { - this._total++; - - if (collideCallback) - { - collideCallback.call(callbackContext, sprite, this._mapData[i].tile); - } - } - } - - }, - + /** + * An internal function. Use Phaser.Physics.Arcade.collide instead. + * + * @method Phaser.Physics.Arcade#collideSpriteVsGroup + * @private + */ collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext) { if (group.length == 0) @@ -25924,6 +31076,12 @@ Phaser.Physics.Arcade.prototype = { }, + /** + * An internal function. Use Phaser.Physics.Arcade.collide instead. + * + * @method Phaser.Physics.Arcade#collideGroupVsGroup + * @private + */ collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext) { if (group1.length == 0 || group2.length == 0) @@ -25948,140 +31106,134 @@ Phaser.Physics.Arcade.prototype = { }, - /** - * The core separation function to separate two physics bodies. - * @param body1 The first Sprite.Body to separate - * @param body2 The second Sprite.Body to separate - * @returns {boolean} Returns true if the bodies were separated, otherwise false. - */ + /** + * The core separation function to separate two physics bodies. + * @method Phaser.Physics.Arcade#separate + * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate. + * @param {Phaser.Physics.Arcade.Body} body2 - The Body object to separate. + * @returns {boolean} Returns true if the bodies were separated, otherwise false. + */ separate: function (body1, body2) { this._result = (this.separateX(body1, body2) || this.separateY(body1, body2)); - if (this._result) - { - body1.postUpdate(); - body2.postUpdate(); - } - }, /** - * Separates the two physics bodies on their X axis - * @param body1 The first Sprite.Body to separate - * @param body2 The second Sprite.Body to separate - * @returns {boolean} Whether the objects in fact touched and were separated along the X axis. - */ + * The core separation function to separate two physics bodies on the x axis. + * @method Phaser.Physics.Arcade#separateX + * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate. + * @param {Phaser.Physics.Arcade.Body} body2 - The Body object to separate. + * @returns {boolean} Returns true if the bodies were separated, otherwise false. + */ separateX: function (body1, body2) { - // Can't separate two immovable or non-existing bodys + // Can't separate two immovable bodies if (body1.immovable && body2.immovable) { return false; } - // First, get the two body deltas this._overlap = 0; - if (body1.deltaX() != body2.deltaX()) + // Check if the hulls actually overlap + if (Phaser.Rectangle.intersects(body1, body2)) { - // Check if the X hulls actually overlap + this._maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + this.OVERLAP_BIAS; - this._bounds1.setTo(body1.x - ((body1.deltaX() > 0) ? body1.deltaX() : 0), body1.lastY, body1.width + ((body1.deltaX() > 0) ? body1.deltaX() : -body1.deltaX()), body1.height); - this._bounds2.setTo(body2.x - ((body2.deltaX() > 0) ? body2.deltaX() : 0), body2.lastY, body2.width + ((body2.deltaX() > 0) ? body2.deltaX() : -body2.deltaX()), body2.height); - - if ((this._bounds1.right > this._bounds2.x) && (this._bounds1.x < this._bounds2.right) && (this._bounds1.bottom > this._bounds2.y) && (this._bounds1.y < this._bounds2.bottom)) + if (body1.deltaX() == 0 && body2.deltaX() == 0) { - this._maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + this.OVERLAP_BIAS; + // They overlap but neither of them are moving + body1.embedded = true; + body2.embedded = true; + } + else if (body1.deltaX() > body2.deltaX()) + { + // Body1 is moving right and/or Body2 is moving left + this._overlap = body1.x + body1.width - body2.x; - // If they did overlap (and can), figure out by how much and flip the corresponding flags - if (body1.deltaX() > body2.deltaX()) + if ((this._overlap > this._maxOverlap) || body1.allowCollision.right == false || body2.allowCollision.left == false) { - this._overlap = body1.x + body1.width - body2.x; - - if ((this._overlap > this._maxOverlap) || body1.allowCollision.right == false || body2.allowCollision.left == false) - { - this._overlap = 0; - } - else - { - body1.touching.right = true; - body2.touching.left = true; - } + this._overlap = 0; } - else if (body1.deltaX() < body2.deltaX()) + else { - this._overlap = body1.x - body2.width - body2.x; - - if ((-this._overlap > this._maxOverlap) || body1.allowCollision.left == false || body2.allowCollision.right == false) - { - this._overlap = 0; - } - else - { - body1.touching.left = true; - body2.touching.right = true; - } + body1.touching.right = true; + body2.touching.left = true; } } - } - - // Then adjust their positions and velocities accordingly (if there was any overlap) - if (this._overlap != 0) - { - body1.overlapX = this._overlap; - body2.overlapX = this._overlap; - - if (body1.customSeparateX || body2.customSeparateX) + else if (body1.deltaX() < body2.deltaX()) { + // Body1 is moving left and/or Body2 is moving right + this._overlap = body1.x - body2.width - body2.x; + + if ((-this._overlap > this._maxOverlap) || body1.allowCollision.left == false || body2.allowCollision.right == false) + { + this._overlap = 0; + } + else + { + body1.touching.left = true; + body2.touching.right = true; + } + } + + // Then adjust their positions and velocities accordingly (if there was any overlap) + if (this._overlap != 0) + { + body1.overlapX = this._overlap; + body2.overlapX = this._overlap; + + if (body1.customSeparateX || body2.customSeparateX) + { + return true; + } + + this._velocity1 = body1.velocity.x; + this._velocity2 = body2.velocity.x; + + if (!body1.immovable && !body2.immovable) + { + this._overlap *= 0.5; + + body1.x = body1.x - this._overlap; + body2.x += this._overlap; + + this._newVelocity1 = Math.sqrt((this._velocity2 * this._velocity2 * body2.mass) / body1.mass) * ((this._velocity2 > 0) ? 1 : -1); + this._newVelocity2 = Math.sqrt((this._velocity1 * this._velocity1 * body1.mass) / body2.mass) * ((this._velocity1 > 0) ? 1 : -1); + this._average = (this._newVelocity1 + this._newVelocity2) * 0.5; + this._newVelocity1 -= this._average; + this._newVelocity2 -= this._average; + + body1.velocity.x = this._average + this._newVelocity1 * body1.bounce.x; + body2.velocity.x = this._average + this._newVelocity2 * body2.bounce.x; + } + else if (!body1.immovable) + { + body1.x = body1.x - this._overlap; + body1.velocity.x = this._velocity2 - this._velocity1 * body1.bounce.x; + } + else if (!body2.immovable) + { + body2.x += this._overlap; + body2.velocity.x = this._velocity1 - this._velocity2 * body2.bounce.x; + } + return true; } - - this._velocity1 = body1.velocity.x; - this._velocity2 = body2.velocity.x; - - if (!body1.immovable && !body2.immovable) - { - this._overlap *= 0.5; - - body1.x = body1.x - this._overlap; - body2.x += this._overlap; - - this._newVelocity1 = Math.sqrt((this._velocity2 * this._velocity2 * body2.mass) / body1.mass) * ((this._velocity2 > 0) ? 1 : -1); - this._newVelocity2 = Math.sqrt((this._velocity1 * this._velocity1 * body1.mass) / body2.mass) * ((this._velocity1 > 0) ? 1 : -1); - this._average = (this._newVelocity1 + this._newVelocity2) * 0.5; - this._newVelocity1 -= this._average; - this._newVelocity2 -= this._average; - - body1.velocity.x = this._average + this._newVelocity1 * body1.bounce.x; - body2.velocity.x = this._average + this._newVelocity2 * body2.bounce.x; - } - else if (!body1.immovable) - { - body1.x = body1.x - this._overlap; - body1.velocity.x = this._velocity2 - this._velocity1 * body1.bounce.x; - } - else if (!body2.immovable) - { - body2.x += this._overlap; - body2.velocity.x = this._velocity1 - this._velocity2 * body2.bounce.x; - } - - return true; - } - else - { - return false; } + return false; + }, /** - * Separates the two physics bodies on their Y axis - * @param body1 The first Sprite.Body to separate - * @param body2 The second Sprite.Body to separate - * @returns {boolean} Whether the bodys in fact touched and were separated along the Y axis. - */ + * The core separation function to separate two physics bodies on the y axis. + * @method Phaser.Physics.Arcade#separateY + * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate. + * @param {Phaser.Physics.Arcade.Body} body2 - The Body object to separate. + * @returns {boolean} Returns true if the bodies were separated, otherwise false. + */ separateY: function (body1, body2) { // Can't separate two immovable or non-existing bodys @@ -26090,127 +31242,106 @@ Phaser.Physics.Arcade.prototype = { return false; } - // First, get the two body deltas this._overlap = 0; - if (body1.deltaY() != body2.deltaY()) + // Check if the hulls actually overlap + if (Phaser.Rectangle.intersects(body1, body2)) { - // Check if the Y hulls actually overlap - this._bounds1.setTo(body1.x, body1.y - ((body1.deltaY() > 0) ? body1.deltaY() : 0), body1.width, body1.height + body1.deltaAbsY()); - this._bounds2.setTo(body2.x, body2.y - ((body2.deltaY() > 0) ? body2.deltaY() : 0), body2.width, body2.height + body2.deltaAbsY()); + this._maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + this.OVERLAP_BIAS; - if ((this._bounds1.right > this._bounds2.x) && (this._bounds1.x < this._bounds2.right) && (this._bounds1.bottom > this._bounds2.y) && (this._bounds1.y < this._bounds2.bottom)) + if (body1.deltaY() == 0 && body2.deltaY() == 0) { - this._maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + this.OVERLAP_BIAS; + // They overlap but neither of them are moving + body1.embedded = true; + body2.embedded = true; + } + else if (body1.deltaY() > body2.deltaY()) + { + // Body1 is moving down and/or Body2 is moving up + this._overlap = body1.y + body1.height - body2.y; - // If they did overlap (and can), figure out by how much and flip the corresponding flags - if (body1.deltaY() > body2.deltaY()) + if ((this._overlap > this._maxOverlap) || body1.allowCollision.down == false || body2.allowCollision.up == false) { - this._overlap = body1.y + body1.height - body2.y; - - if ((this._overlap > this._maxOverlap) || body1.allowCollision.down == false || body2.allowCollision.up == false) - { - this._overlap = 0; - } - else - { - body1.touching.down = true; - body2.touching.up = true; - } + this._overlap = 0; } - else if (body1.deltaY() < body2.deltaY()) + else { - this._overlap = body1.y - body2.height - body2.y; - - if ((-this._overlap > this._maxOverlap) || body1.allowCollision.up == false || body2.allowCollision.down == false) - { - this._overlap = 0; - } - else - { - body1.touching.up = true; - body2.touching.down = true; - } + body1.touching.down = true; + body2.touching.up = true; } } - } - - // Then adjust their positions and velocities accordingly (if there was any overlap) - if (this._overlap != 0) - { - body1.overlapY = this._overlap; - body2.overlapY = this._overlap; - - if (body1.customSeparateY || body2.customSeparateY) + else if (body1.deltaY() < body2.deltaY()) { + // Body1 is moving up and/or Body2 is moving down + this._overlap = body1.y - body2.height - body2.y; + + if ((-this._overlap > this._maxOverlap) || body1.allowCollision.up == false || body2.allowCollision.down == false) + { + this._overlap = 0; + } + else + { + body1.touching.up = true; + body2.touching.down = true; + } + } + + // Then adjust their positions and velocities accordingly (if there was any overlap) + if (this._overlap != 0) + { + body1.overlapY = this._overlap; + body2.overlapY = this._overlap; + + if (body1.customSeparateY || body2.customSeparateY) + { + return true; + } + + this._velocity1 = body1.velocity.y; + this._velocity2 = body2.velocity.y; + + if (!body1.immovable && !body2.immovable) + { + this._overlap *= 0.5; + + body1.y = body1.y - this._overlap; + body2.y += this._overlap; + + this._newVelocity1 = Math.sqrt((this._velocity2 * this._velocity2 * body2.mass) / body1.mass) * ((this._velocity2 > 0) ? 1 : -1); + this._newVelocity2 = Math.sqrt((this._velocity1 * this._velocity1 * body1.mass) / body2.mass) * ((this._velocity1 > 0) ? 1 : -1); + this._average = (this._newVelocity1 + this._newVelocity2) * 0.5; + this._newVelocity1 -= this._average; + this._newVelocity2 -= this._average; + + body1.velocity.y = this._average + this._newVelocity1 * body1.bounce.y; + body2.velocity.y = this._average + this._newVelocity2 * body2.bounce.y; + } + else if (!body1.immovable) + { + body1.y = body1.y - this._overlap; + body1.velocity.y = this._velocity2 - this._velocity1 * body1.bounce.y; + + // This is special case code that handles things like horizontal moving platforms you can ride + if (body2.active && body2.moves && (body1.deltaY() > body2.deltaY())) + { + body1.x += body2.x - body2.lastX; + } + } + else if (!body2.immovable) + { + body2.y += this._overlap; + body2.velocity.y = this._velocity1 - this._velocity2 * body2.bounce.y; + + // This is special case code that handles things like horizontal moving platforms you can ride + if (body1.sprite.active && body1.moves && (body1.deltaY() < body2.deltaY())) + { + body2.x += body1.x - body1.lastX; + } + } + return true; } - this._velocity1 = body1.velocity.y; - this._velocity2 = body2.velocity.y; - - if (!body1.immovable && !body2.immovable) - { - this._overlap *= 0.5; - - body1.y = body1.y - this._overlap; - body2.y += this._overlap; - - this._newVelocity1 = Math.sqrt((this._velocity2 * this._velocity2 * body2.mass) / body1.mass) * ((this._velocity2 > 0) ? 1 : -1); - this._newVelocity2 = Math.sqrt((this._velocity1 * this._velocity1 * body1.mass) / body2.mass) * ((this._velocity1 > 0) ? 1 : -1); - this._average = (this._newVelocity1 + this._newVelocity2) * 0.5; - this._newVelocity1 -= this._average; - this._newVelocity2 -= this._average; - - body1.velocity.y = this._average + this._newVelocity1 * body1.bounce.y; - body2.velocity.y = this._average + this._newVelocity2 * body2.bounce.y; - } - else if (!body1.immovable) - { - body1.y = body1.y - this._overlap; - body1.velocity.y = this._velocity2 - this._velocity1 * body1.bounce.y; - - // This is special case code that handles things like horizontal moving platforms you can ride - if (body2.active && body2.moves && (body1.deltaY() > body2.deltaY())) - { - body1.x += body2.x - body2.lastX; - } - } - else if (!body2.immovable) - { - body2.y += this._overlap; - body2.velocity.y = this._velocity1 - this._velocity2 * body2.bounce.y; - - // This is special case code that handles things like horizontal moving platforms you can ride - if (body1.sprite.active && body1.moves && (body1.deltaY() < body2.deltaY())) - { - body2.x += body1.x - body1.lastX; - } - } - - return true; - } - else - { - return false; - } - }, - - /** - * The core Collision separation function used by Collision.overlap. - * @param object1 The first GameObject to separate - * @param object2 The second GameObject to separate - * @returns {boolean} Returns true if the objects were separated, otherwise false. - */ - separateTile: function (object, x, y, width, height, mass, collideLeft, collideRight, collideUp, collideDown, separateX, separateY) { - - var separatedY = this.separateTileY(object.body, x, y, width, height, mass, collideUp, collideDown, separateY); - var separatedX = this.separateTileX(object.body, x, y, width, height, mass, collideLeft, collideRight, separateX); - - if (separatedX || separatedY) - { - object.body.postUpdate(); - return true; } return false; @@ -26218,64 +31349,64 @@ Phaser.Physics.Arcade.prototype = { }, /** - * Separates the two objects on their x axis - * @param object The GameObject to separate - * @param tile The Tile to separate - * @returns {boolean} Whether the objects in fact touched and were separated along the X axis. - */ - separateTileX: function (object, x, y, width, height, mass, collideLeft, collideRight, separate) { + * The core separation function to separate a physics body and a tile. + * @method Phaser.Physics.Arcade#separateTile + * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate. + * @param {Phaser.Tile} tile - The tile to collide against. + * @returns {boolean} Returns true if the bodies were separated, otherwise false. + */ + separateTile: function (body, tile) { + + this._result = (this.separateTileX(body, tile, true) || this.separateTileY(body, tile, true)); + + }, + + /** + * The core separation function to separate a physics body and a tile on the x axis. + * @method Phaser.Physics.Arcade#separateTileX + * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate. + * @param {Phaser.Tile} tile - The tile to collide against. + * @returns {boolean} Returns true if the bodies were separated, otherwise false. + */ + separateTileX: function (body, tile, separate) { // Can't separate two immovable objects (tiles are always immovable) - if (object.immovable) + if (body.immovable || body.deltaX() == 0 || Phaser.Rectangle.intersects(body.hullX, tile) == false) { return false; } - // First, get the object delta this._overlap = 0; - // console.log('separatedX', x, y, object.deltaX()); + // The hulls overlap, let's process it + this._maxOverlap = body.deltaAbsX() + this.OVERLAP_BIAS; - if (object.deltaX() != 0) + if (body.deltaX() < 0) { - this._bounds1.setTo(object.x, object.y, object.width, object.height); + // Moving left + this._overlap = tile.right - body.hullX.x; - if ((this._bounds1.right > x) && (this._bounds1.x < x + width) && (this._bounds1.bottom > y) && (this._bounds1.y < y + height)) + if ((this._overlap > this._maxOverlap) || body.allowCollision.left == false || tile.tile.collideRight == false) { - // The hulls overlap, let's process it - this._maxOverlap = object.deltaAbsX() + this.OVERLAP_BIAS; + this._overlap = 0; + } + else + { + body.touching.left = true; + } + } + else + { + // Moving right + this._overlap = body.hullX.right - tile.x; - // TODO - We need to check if we're already inside of the tile, i.e. jumping through an n-way tile - // in which case we didn't ought to separate because it'll look like tunneling - - if (object.deltaX() > 0) - { - // Going right ... - this._overlap = object.x + object.width - x; - - if ((this._overlap > this._maxOverlap) || !object.allowCollision.right || !collideLeft) - { - this._overlap = 0; - } - else - { - object.touching.right = true; - } - } - else if (object.deltaX() < 0) - { - // Going left ... - this._overlap = object.x - width - x; - - if ((-this._overlap > this._maxOverlap) || !object.allowCollision.left || !collideRight) - { - this._overlap = 0; - } - else - { - object.touching.left = true; - } - } + if ((this._overlap > this._maxOverlap) || body.allowCollision.right == false || tile.tile.collideLeft == false) + { + this._overlap = 0; + } + else + { + body.touching.right = true; } } @@ -26284,17 +31415,27 @@ Phaser.Physics.Arcade.prototype = { { if (separate) { - object.x = object.x - this._overlap; - - if (object.bounce.x == 0) + if (body.deltaX() < 0) { - object.velocity.x = 0; + body.x = body.x + this._overlap; } else { - object.velocity.x = -object.velocity.x * object.bounce.x; + body.x = body.x - this._overlap; } + + if (body.bounce.x == 0) + { + body.velocity.x = 0; + } + else + { + body.velocity.x = -body.velocity.x * body.bounce.x; + } + + body.updateHulls(); } + return true; } else @@ -26305,65 +31446,51 @@ Phaser.Physics.Arcade.prototype = { }, /** - * Separates the two objects on their x axis - * @param object The GameObject to separate - * @param tile The Tile to separate - * @returns {boolean} Whether the objects in fact touched and were separated along the X axis. - */ - separateTileY: function (object, x, y, width, height, mass, collideUp, collideDown, separate) { + * The core separation function to separate a physics body and a tile on the x axis. + * @method Phaser.Physics.Arcade#separateTileY + * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate. + * @param {Phaser.Tile} tile - The tile to collide against. + * @returns {boolean} Returns true if the bodies were separated, otherwise false. + */ + separateTileY: function (body, tile, separate) { // Can't separate two immovable objects (tiles are always immovable) - if (object.immovable) + if (body.immovable || body.deltaY() == 0 || Phaser.Rectangle.intersects(body.hullY, tile) == false) { return false; } - // First, get the object delta this._overlap = 0; - if (object.deltaY() != 0) + // The hulls overlap, let's process it + this._maxOverlap = body.deltaAbsY() + this.OVERLAP_BIAS; + + if (body.deltaY() < 0) { - this._bounds1.setTo(object.x, object.y, object.width, object.height); + // Moving up + this._overlap = tile.bottom - body.hullY.y; - if ((this._bounds1.right > x) && (this._bounds1.x < x + width) && (this._bounds1.bottom > y) && (this._bounds1.y < y + height)) + if ((this._overlap > this._maxOverlap) || body.allowCollision.up == false || tile.tile.collideDown == false) { - // The hulls overlap, let's process it + this._overlap = 0; + } + else + { + body.touching.up = true; + } + } + else + { + // Moving down + this._overlap = body.hullY.bottom - tile.y; - // Not currently used, may need it so keep for now - this._maxOverlap = object.deltaAbsY() + this.OVERLAP_BIAS; - - // TODO - We need to check if we're already inside of the tile, i.e. jumping through an n-way tile - // in which case we didn't ought to separate because it'll look like tunneling - - if (object.deltaY() > 0) - { - // Going down ... - this._overlap = object.bottom - y; - - // if (object.allowCollision.down && collideDown && this._overlap < this._maxOverlap) - if ((this._overlap > this._maxOverlap) || !object.allowCollision.down || !collideDown) - { - this._overlap = 0; - } - else - { - object.touching.down = true; - } - } - else - { - // Going up ... - this._overlap = object.y - height - y; - - if ((-this._overlap > this._maxOverlap) || !object.allowCollision.up || !collideUp) - { - this._overlap = 0; - } - else - { - object.touching.up = true; - } - } + if ((this._overlap > this._maxOverlap) || body.allowCollision.down == false || tile.tile.collideUp == false) + { + this._overlap = 0; + } + else + { + body.touching.down = true; } } @@ -26372,17 +31499,27 @@ Phaser.Physics.Arcade.prototype = { { if (separate) { - object.y = object.y - this._overlap; - - if (object.bounce.y == 0) + if (body.deltaY() < 0) { - object.velocity.y = 0; + body.y = body.y + this._overlap; } else { - object.velocity.y = -object.velocity.y * object.bounce.y; + body.y = body.y - this._overlap; } + + if (body.bounce.y == 0) + { + body.velocity.y = 0; + } + else + { + body.velocity.y = -body.velocity.y * body.bounce.y; + } + + body.updateHulls(); } + return true; } else @@ -26393,440 +31530,686 @@ Phaser.Physics.Arcade.prototype = { }, /** - * Given the angle and speed calculate the velocity and return it as a Point + * Move the given display object towards the destination object at a steady velocity. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) * - * @param angle The angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * @param speed The speed it will move, in pixels per second sq + * @method Phaser.Physics.Arcade#moveToObject + * @param {any} displayObject - The display object to move. + * @param {any} destination - The display object to move towards. Can be any object but must have visible x/y properties. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + moveToObject: function (displayObject, destination, speed, maxTime) { + + speed = speed || 60; + maxTime = maxTime || 0; + + this._angle = Math.atan2(destination.y - displayObject.y, destination.x - displayObject.x); + + if (maxTime > 0) + { + // We know how many pixels we need to move, but how fast? + speed = this.distanceBetween(displayObject, destination) / (maxTime / 1000); + } + + displayObject.body.velocity.x = Math.cos(this._angle) * speed; + displayObject.body.velocity.y = Math.sin(this._angle) * speed; + + return this._angle; + + }, + + /** + * Move the given display object towards the pointer at a steady velocity. If no pointer is given it will use Phaser.Input.activePointer. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. * - * @return A Point where Point.x contains the velocity x value and Point.y contains the velocity y value + * @method Phaser.Physics.Arcade#moveToPointer + * @param {any} displayObject - The display object to move. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {Phaser.Pointer} [pointer] - The pointer to move towards. Defaults to Phaser.Input.activePointer. + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + moveToPointer: function (displayObject, speed, pointer, maxTime) { + + speed = speed || 60; + pointer = pointer || this.game.input.activePointer; + maxTime = maxTime || 0; + + this._angle = this.angleToPointer(displayObject, pointer); + + if (maxTime > 0) + { + // We know how many pixels we need to move, but how fast? + speed = this.distanceToPointer(displayObject, pointer) / (maxTime / 1000); + } + + displayObject.body.velocity.x = Math.cos(this._angle) * speed; + displayObject.body.velocity.y = Math.sin(this._angle) * speed; + + return this._angle; + + }, + + /** + * Move the given display object towards the x/y coordinates at a steady velocity. + * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. + * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all) + * + * @method Phaser.Physics.Arcade#moveToXY + * @param {any} displayObject - The display object to move. + * @param {number} x - The x coordinate to move towards. + * @param {number} y - The y coordinate to move towards. + * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity. + */ + moveToXY: function (displayObject, x, y, speed, maxTime) { + + speed = speed || 60; + maxTime = maxTime || 0; + + this._angle = Math.atan2(y - displayObject.y, x - displayObject.x); + + if (maxTime > 0) + { + // We know how many pixels we need to move, but how fast? + speed = this.distanceToXY(displayObject, x, y) / (maxTime / 1000); + } + + displayObject.body.velocity.x = Math.cos(this._angle) * speed; + displayObject.body.velocity.y = Math.sin(this._angle) * speed; + + return this._angle; + + }, + + /** + * Given the angle (in degrees) and speed calculate the velocity and return it as a Point object, or set it to the given point object. + * One way to use this is: velocityFromAngle(angle, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. + * + * @method Phaser.Physics.Arcade#velocityFromAngle + * @param {number} angle - The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) + * @param {number} [speed=60] - The speed it will move, in pixels per second sq. + * @param {Phaser.Point|object} [point] - The Point object in which the x and y properties will be set to the calculated velocity. + * @return {Phaser.Point} - A Point where point.x contains the velocity x value and point.y contains the velocity y value. */ velocityFromAngle: function (angle, speed, point) { - speed = speed || 0; + speed = speed || 60; point = point || new Phaser.Point; - var a = this.game.math.degToRad(angle); - - return point.setTo((Math.cos(a) * speed), (Math.sin(a) * speed)); + return point.setTo((Math.cos(this.game.math.degToRad(angle)) * speed), (Math.sin(this.game.math.degToRad(angle)) * speed)); }, /** - * Sets the source Sprite x/y velocity so it will move directly towards the destination Sprite at the speed given (in pixels per second)
    - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
    - * Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.
    - * The source object doesn't stop moving automatically should it ever reach the destination coordinates.
    - * If you need the object to accelerate, see accelerateTowardsObject() instead - * Note: Doesn't take into account acceleration, maxVelocity or drag (if you set drag or acceleration too high this object may not move at all) - * - * @param source The Sprite on which the velocity will be set - * @param dest The Sprite where the source object will move to - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms - */ - moveTowardsObject: function (source, dest, speed, maxTime) { + * Given the rotation (in radians) and speed calculate the velocity and return it as a Point object, or set it to the given point object. + * One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. + * + * @method Phaser.Physics.Arcade#velocityFromRotation + * @param {number} rotation - The angle in radians. + * @param {number} [speed=60] - The speed it will move, in pixels per second sq. + * @param {Phaser.Point|object} [point] - The Point object in which the x and y properties will be set to the calculated velocity. + * @return {Phaser.Point} - A Point where point.x contains the velocity x value and point.y contains the velocity y value. + */ + velocityFromRotation: function (rotation, speed, point) { speed = speed || 60; - maxTime = maxTime || 0; + point = point || new Phaser.Point; - var a = this.angleBetween(source, dest); - - if (maxTime > 0) - { - var d = this.distanceBetween(source, dest); - - // We know how many pixels we need to move, but how fast? - speed = d / (maxTime / 1000); - } - - source.body.velocity.x = Math.cos(a) * speed; - source.body.velocity.y = Math.sin(a) * speed; + return point.setTo((Math.cos(rotation) * speed), (Math.sin(rotation) * speed)); }, /** - * Sets the x/y acceleration on the source Sprite so it will move towards the destination Sprite at the speed given (in pixels per second)
    - * You must give a maximum speed value, beyond which the Sprite won't go any faster.
    - * If you don't need acceleration look at moveTowardsObject() instead. - * - * @param source The Sprite on which the acceleration will be set - * @param dest The Sprite where the source object will move towards - * @param speed The speed it will accelerate in pixels per second - * @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally - * @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically - */ - accelerateTowardsObject: function (source, dest, speed, xSpeedMax, ySpeedMax) { - - xSpeedMax = xSpeedMax || 1000; - ySpeedMax = ySpeedMax || 1000; - - var a = this.angleBetween(source, dest); - - source.body.velocity.x = 0; - source.body.velocity.y = 0; - - source.body.acceleration.x = Math.cos(a) * speed; - source.body.acceleration.y = Math.sin(a) * speed; - - source.body.maxVelocity.x = xSpeedMax; - source.body.maxVelocity.y = ySpeedMax; - - }, - - /** - * Move the given Sprite towards the mouse pointer coordinates at a steady velocity - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
    - * Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.
    - * The source object doesn't stop moving automatically should it ever reach the destination coordinates.
    - * - * @param source The Sprite to move - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms - */ - moveTowardsMouse: function (source, speed, maxTime) { + * Given the rotation (in radians) and speed calculate the acceleration and return it as a Point object, or set it to the given point object. + * One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object. + * + * @method Phaser.Physics.Arcade#accelerationFromRotation + * @param {number} rotation - The angle in radians. + * @param {number} [speed=60] - The speed it will move, in pixels per second sq. + * @param {Phaser.Point|object} [point] - The Point object in which the x and y properties will be set to the calculated acceleration. + * @return {Phaser.Point} - A Point where point.x contains the acceleration x value and point.y contains the acceleration y value. + */ + accelerationFromRotation: function (rotation, speed, point) { speed = speed || 60; - maxTime = maxTime || 0; + point = point || new Phaser.Point; - var a = this.angleBetweenMouse(source); - - if (maxTime > 0) - { - var d = this.distanceToMouse(source); - - // We know how many pixels we need to move, but how fast? - speed = d / (maxTime / 1000); - } - - source.body.velocity.x = Math.cos(a) * speed; - source.body.velocity.y = Math.sin(a) * speed; + return point.setTo((Math.cos(rotation) * speed), (Math.sin(rotation) * speed)); }, /** - * Sets the x/y acceleration on the source Sprite so it will move towards the mouse coordinates at the speed given (in pixels per second)
    - * You must give a maximum speed value, beyond which the Sprite won't go any faster.
    - * If you don't need acceleration look at moveTowardsMouse() instead. - * - * @param source The Sprite on which the acceleration will be set - * @param speed The speed it will accelerate in pixels per second - * @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally - * @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically - */ - accelerateTowardsMouse: function (source, speed, xSpeedMax, ySpeedMax) { + * Sets the acceleration.x/y property on the display object so it will move towards the target at the given speed (in pixels per second sq.) + * You must give a maximum speed value, beyond which the display object won't go any faster. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade#accelerateToObject + * @param {any} displayObject - The display object to move. + * @param {any} destination - The display object to move towards. Can be any object but must have visible x/y properties. + * @param {number} [speed=60] - The speed it will accelerate in pixels per second. + * @param {number} [xSpeedMax=500] - The maximum x velocity the display object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the display object can reach. + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new trajectory. + */ + accelerateToObject: function (displayObject, destination, speed, xSpeedMax, ySpeedMax) { - xSpeedMax = xSpeedMax || 1000; - ySpeedMax = ySpeedMax || 1000; + if (typeof speed === 'undefined') { speed = 60; } + if (typeof xSpeedMax === 'undefined') { xSpeedMax = 1000; } + if (typeof ySpeedMax === 'undefined') { ySpeedMax = 1000; } - var a = this.angleBetweenMouse(source); - - source.body.velocity.x = 0; - source.body.velocity.y = 0; - - source.body.acceleration.x = Math.cos(a) * speed; - source.body.acceleration.y = Math.sin(a) * speed; - - source.body.maxVelocity.x = xSpeedMax; - source.body.maxVelocity.y = ySpeedMax; + this._angle = this.angleBetween(displayObject, destination); + + displayObject.body.acceleration.setTo(Math.cos(this._angle) * speed, Math.sin(this._angle) * speed); + displayObject.body.maxVelocity.setTo(xSpeedMax, ySpeedMax); + + return this._angle; }, /** - * Sets the x/y velocity on the source Sprite so it will move towards the target coordinates at the speed given (in pixels per second)
    - * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
    - * Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.
    - * The source object doesn't stop moving automatically should it ever reach the destination coordinates.
    - * - * @param source The Sprite to move - * @param target The Point coordinates to move the source Sprite towards - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms - */ - moveTowardsPoint: function (source, target, speed, maxTime) { + * Sets the acceleration.x/y property on the display object so it will move towards the target at the given speed (in pixels per second sq.) + * You must give a maximum speed value, beyond which the display object won't go any faster. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade#accelerateToPointer + * @param {any} displayObject - The display object to move. + * @param {Phaser.Pointer} [pointer] - The pointer to move towards. Defaults to Phaser.Input.activePointer. + * @param {number} [speed=60] - The speed it will accelerate in pixels per second. + * @param {number} [xSpeedMax=500] - The maximum x velocity the display object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the display object can reach. + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new trajectory. + */ + accelerateToPointer: function (displayObject, pointer, speed, xSpeedMax, ySpeedMax) { - speed = speed || 60; - maxTime = maxTime || 0; + if (typeof speed === 'undefined') { speed = 60; } + if (typeof pointer === 'undefined') { pointer = this.game.input.activePointer; } + if (typeof xSpeedMax === 'undefined') { xSpeedMax = 1000; } + if (typeof ySpeedMax === 'undefined') { ySpeedMax = 1000; } - var a = this.angleBetweenPoint(source, target); + this._angle = this.angleToPointer(displayObject, pointer); - if (maxTime > 0) - { - var d = this.distanceToPoint(source, target); - - // We know how many pixels we need to move, but how fast? - speed = d / (maxTime / 1000); - } - - source.body.velocity.x = Math.cos(a) * speed; - source.body.velocity.y = Math.sin(a) * speed; + displayObject.body.acceleration.setTo(Math.cos(this._angle) * speed, Math.sin(this._angle) * speed); + displayObject.body.maxVelocity.setTo(xSpeedMax, ySpeedMax); + + return this._angle; }, /** - * Sets the x/y acceleration on the source Sprite so it will move towards the target coordinates at the speed given (in pixels per second)
    - * You must give a maximum speed value, beyond which the Sprite won't go any faster.
    - * If you don't need acceleration look at moveTowardsPoint() instead. - * - * @param source The Sprite on which the acceleration will be set - * @param target The Point coordinates to move the source Sprite towards - * @param speed The speed it will accelerate in pixels per second - * @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally - * @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically - */ - accelerateTowardsPoint: function (source, target, speed, xSpeedMax, ySpeedMax) { + * Sets the acceleration.x/y property on the display object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) + * You must give a maximum speed value, beyond which the display object won't go any faster. + * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. + * Note: The display object doesn't stop moving once it reaches the destination coordinates. + * + * @method Phaser.Physics.Arcade#accelerateToXY + * @param {any} displayObject - The display object to move. + * @param {number} x - The x coordinate to accelerate towards. + * @param {number} y - The y coordinate to accelerate towards. + * @param {number} [speed=60] - The speed it will accelerate in pixels per second. + * @param {number} [xSpeedMax=500] - The maximum x velocity the display object can reach. + * @param {number} [ySpeedMax=500] - The maximum y velocity the display object can reach. + * @return {number} The angle (in radians) that the object should be visually set to in order to match its new trajectory. + */ + accelerateToXY: function (displayObject, x, y, speed, xSpeedMax, ySpeedMax) { - xSpeedMax = xSpeedMax || 1000; - ySpeedMax = ySpeedMax || 1000; + if (typeof speed === 'undefined') { speed = 60; } + if (typeof xSpeedMax === 'undefined') { xSpeedMax = 1000; } + if (typeof ySpeedMax === 'undefined') { ySpeedMax = 1000; } - var a = this.angleBetweenPoint(source, target); - - source.body.velocity.x = 0; - source.body.velocity.y = 0; - - source.body.acceleration.x = Math.cos(a) * speed; - source.body.acceleration.y = Math.sin(a) * speed; - - source.body.maxVelocity.x = xSpeedMax; - source.body.maxVelocity.y = ySpeedMax; + this._angle = this.angleToXY(displayObject, x, y); + + displayObject.body.acceleration.setTo(Math.cos(this._angle) * speed, Math.sin(this._angle) * speed); + displayObject.body.maxVelocity.setTo(xSpeedMax, ySpeedMax); + + return this._angle; }, /** - * Find the distance (in pixels, rounded) between two Sprites, taking their origin into account - * - * @param a The first Sprite - * @param b The second Sprite - * @return int Distance (in pixels) - */ - distanceBetween: function (a, b) { + * Find the distance between two display objects (like Sprites). + * + * @method Phaser.Physics.Arcade#distanceBetween + * @param {any} source - The Display Object to test from. + * @param {any} target - The Display Object to test to. + * @return {number} The distance between the source and target objects. + */ + distanceBetween: function (source, target) { - var dx = a.center.x - b.center.x; - var dy = a.center.y - b.center.y; + this._dx = source.x - target.x; + this._dy = source.y - target.y; - return Math.sqrt(dx * dx + dy * dy); + return Math.sqrt(this._dx * this._dx + this._dy * this._dy); }, /** - * Find the distance (in pixels, rounded) from an Sprite to the given Point, taking the source origin into account - * - * @param a The Sprite - * @param target The Point - * @return int Distance (in pixels) - */ - distanceToPoint: function (a, target) { + * Find the distance between a display object (like a Sprite) and the given x/y coordinates. + * The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed. + * If you need to calculate from the center of a display object instead use the method distanceBetweenCenters() + * + * @method Phaser.Physics.Arcade#distanceToXY + * @param {any} displayObject - The Display Object to test from. + * @param {number} x - The x coordinate to move towards. + * @param {number} y - The y coordinate to move towards. + * @return {number} The distance between the object and the x/y coordinates. + */ + distanceToXY: function (displayObject, x, y) { - var dx = a.center.x - target.x; - var dy = a.center.y - target.y; + this._dx = displayObject.x - x; + this._dy = displayObject.y - y; - return Math.sqrt(dx * dx + dy * dy); + return Math.sqrt(this._dx * this._dx + this._dy * this._dy); }, /** - * Find the distance (in pixels, rounded) from the object x/y and the mouse x/y - * - * @param a The Sprite to test against - * @return int The distance between the given sprite and the mouse coordinates - */ - distanceToMouse: function (a) { + * Find the distance between a display object (like a Sprite) and a Pointer. If no Pointer is given the Input.activePointer is used. + * The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed. + * If you need to calculate from the center of a display object instead use the method distanceBetweenCenters() + * + * @method Phaser.Physics.Arcade#distanceToPointer + * @param {any} displayObject - The Display Object to test from. + * @param {Phaser.Pointer} [pointer] - The Phaser.Pointer to test to. If none is given then Input.activePointer is used. + * @return {number} The distance between the object and the Pointer. + */ + distanceToPointer: function (displayObject, pointer) { - var dx = a.center.x - this.game.input.x; - var dy = a.center.y - this.game.input.y; + pointer = pointer || this.game.input.activePointer; + + this._dx = displayObject.worldX - pointer.x; + this._dy = displayObject.worldY - pointer.y; - return Math.sqrt(dx * dx + dy * dy); + return Math.sqrt(this._dx * this._dx + this._dy * this._dy); }, /** - * Find the angle (in radians) between an Sprite and an Point. The source sprite takes its x/y and origin into account. - * The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * - * @param a The Sprite to test from - * @param target The Point to angle the Sprite towards - * @param asDegrees If you need the value in degrees instead of radians, set to true - * - * @return Number The angle (in radians unless asDegrees is true) - */ - angleBetweenPoint: function (a, target, asDegrees) { + * Find the angle in radians between two display objects (like Sprites). + * + * @method Phaser.Physics.Arcade#angleBetween + * @param {any} source - The Display Object to test from. + * @param {any} target - The Display Object to test to. + * @return {number} The angle in radians between the source and target display objects. + */ + angleBetween: function (source, target) { - asDegrees = asDegrees || false; + this._dx = target.x - source.x; + this._dy = target.y - source.y; - var dx = target.x - a.center.x; - var dy = target.y - a.center.y; - - if (asDegrees) - { - return this.game.math.radToDeg(Math.atan2(dy, dx)); - } - else - { - return Math.atan2(dy, dx); - } + return Math.atan2(this._dy, this._dx); }, /** - * Find the angle (in radians) between the two Sprite, taking their x/y and origin into account. - * The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * - * @param a The Sprite to test from - * @param b The Sprite to test to - * @param asDegrees If you need the value in degrees instead of radians, set to true - * - * @return Number The angle (in radians unless asDegrees is true) - */ - angleBetween: function (a, b, asDegrees) { + * Find the angle in radians between a display object (like a Sprite) and the given x/y coordinate. + * + * @method Phaser.Physics.Arcade#angleToXY + * @param {any} displayObject - The Display Object to test from. + * @param {number} x - The x coordinate to get the angle to. + * @param {number} y - The y coordinate to get the angle to. + * @return {number} The angle in radians between displayObject.x/y to Pointer.x/y + */ + angleToXY: function (displayObject, x, y) { - asDegrees = asDegrees || false; - - var dx = b.center.x - a.center.x; - var dy = b.center.y - a.center.y; + this._dx = x - displayObject.x; + this._dy = y - displayObject.y; - if (asDegrees) - { - return this.game.math.radToDeg(Math.atan2(dy, dx)); - } - else - { - return Math.atan2(dy, dx); - } - - }, - - /** - * Given the GameObject and speed calculate the velocity and return it as an Point based on the direction the sprite is facing - * - * @param parent The Sprite to get the facing value from - * @param speed The speed it will move, in pixels per second sq - * - * @return An Point where Point.x contains the velocity x value and Point.y contains the velocity y value - */ - velocityFromFacing: function (parent, speed) { - - /* - var a; - - if (parent.facing == Collision.LEFT) - { - a = this._game.math.degreesToRadians(180); - } - else if (parent.facing == Collision.RIGHT) - { - a = this._game.math.degreesToRadians(0); - } - else if (parent.facing == Collision.UP) - { - a = this._game.math.degreesToRadians(-90); - } - else if (parent.facing == Collision.DOWN) - { - a = this._game.math.degreesToRadians(90); - } - - return new Point(Math.cos(a) * speed, Math.sin(a) * speed); - */ + return Math.atan2(this._dy, this._dx); }, /** - * Find the angle (in radians) between an Sprite and the mouse, taking their x/y and origin into account. - * The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * - * @param a The Object to test from - * @param asDegrees If you need the value in degrees instead of radians, set to true - * - * @return Number The angle (in radians unless asDegrees is true) - */ - angleBetweenMouse: function (a, asDegrees) { + * Find the angle in radians between a display object (like a Sprite) and a Pointer, taking their x/y and center into account. + * + * @method Phaser.Physics.Arcade#angleToPointer + * @param {any} displayObject - The Display Object to test from. + * @param {Phaser.Pointer} [pointer] - The Phaser.Pointer to test to. If none is given then Input.activePointer is used. + * @return {number} The angle in radians between displayObject.x/y to Pointer.x/y + */ + angleToPointer: function (displayObject, pointer) { - asDegrees = asDegrees || false; + pointer = pointer || this.game.input.activePointer; - var dx = this.game.input.x - a.bounds.x; - var dy = this.game.input.y - a.bounds.y; + this._dx = pointer.worldX - displayObject.x; + this._dy = pointer.worldY - displayObject.y; - if (asDegrees) - { - return this.game.math.radToDeg(Math.atan2(dy, dx)); - } - else - { - return Math.atan2(dy, dx); - } + return Math.atan2(this._dy, this._dx); + } }; +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than +* the Sprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body. +* +* @class Phaser.Physics.Arcade.Body +* @classdesc Arcade Physics Body Constructor +* @constructor +* @param {Phaser.Sprite} sprite - The Sprite object this physics body belongs to. +*/ Phaser.Physics.Arcade.Body = function (sprite) { + /** + * @property {Phaser.Sprite} sprite - Reference to the parent Sprite. + */ this.sprite = sprite; + + /** + * @property {Phaser.Game} game - Local reference to game. + */ this.game = sprite.game; + /** + * @property {Phaser.Point} offset - The offset of the Physics Body from the Sprite x/y position. + */ this.offset = new Phaser.Point; + /** + * @property {number} x - The x position of the physics body. + * @readonly + */ this.x = sprite.x; - this.y = sprite.y; - this.lastX = sprite.x; - this.lastY = sprite.y; - // un-scaled original size + /** + * @property {number} y - The y position of the physics body. + * @readonly + */ + this.y = sprite.y; + + /** + * @property {number} preX - The previous x position of the physics body. + * @readonly + */ + this.preX = sprite.x; + + /** + * @property {number} preY - The previous y position of the physics body. + * @readonly + */ + this.preY = sprite.y; + + /** + * @property {number} preRotation - The previous rotation of the physics body. + * @readonly + */ + this.preRotation = sprite.angle; + + /** + * @property {number} screenX - The x position of the physics body translated to screen space. + * @readonly + */ + this.screenX = sprite.x; + + /** + * @property {number} screenY - The y position of the physics body translated to screen space. + * @readonly + */ + this.screenY = sprite.y; + + /** + * @property {number} sourceWidth - The un-scaled original size. + * @readonly + */ this.sourceWidth = sprite.currentFrame.sourceSizeW; + + /** + * @property {number} sourceHeight - The un-scaled original size. + * @readonly + */ this.sourceHeight = sprite.currentFrame.sourceSizeH; - // calculated (scaled) size + /** + * @property {number} width - The calculated width of the physics body. + */ this.width = sprite.currentFrame.sourceSizeW; + + /** + * @property .numInternal ID cache + */ this.height = sprite.currentFrame.sourceSizeH; + + /** + * @property {number} halfWidth - The calculated width / 2 of the physics body. + */ this.halfWidth = Math.floor(sprite.currentFrame.sourceSizeW / 2); + + /** + * @property {number} halfHeight - The calculated height / 2 of the physics body. + */ this.halfHeight = Math.floor(sprite.currentFrame.sourceSizeH / 2); - // Scale value cache + /** + * @property {number} _sx - Internal cache var. + * @private + */ this._sx = sprite.scale.x; + + /** + * @property {number} _sy - Internal cache var. + * @private + */ this._sy = sprite.scale.y; + /** + * @property {Phaser.Point} velocity - The velocity in pixels per second sq. of the Body. + */ this.velocity = new Phaser.Point; + + /** + * @property {Phaser.Point} acceleration - The velocity in pixels per second sq. of the Body. + */ this.acceleration = new Phaser.Point; + + /** + * @property {Phaser.Point} drag - The drag applied to the motion of the Body. + */ this.drag = new Phaser.Point; + + /** + * @property {Phaser.Point} gravity - A private Gravity setting for the Body. + */ this.gravity = new Phaser.Point; + + /** + * @property {Phaser.Point} bounce - The elasticitiy of the Body when colliding. bounce.x/y = 1 means full rebound, bounce.x/y = 0.5 means 50% rebound velocity. + */ this.bounce = new Phaser.Point; + + /** + * @property {Phaser.Point} maxVelocity - The maximum velocity in pixels per second sq. that the Body can reach. + * @default + */ this.maxVelocity = new Phaser.Point(10000, 10000); + /** + * @property {number} angularVelocity - The angular velocity in pixels per second sq. of the Body. + * @default + */ this.angularVelocity = 0; + + /** + * @property {number} angularAcceleration - The angular acceleration in pixels per second sq. of the Body. + * @default + */ this.angularAcceleration = 0; + + /** + * @property {number} angularDrag - The angular drag applied to the rotation of the Body. + * @default + */ this.angularDrag = 0; + + /** + * @property {number} maxAngular - The maximum angular velocity in pixels per second sq. that the Body can reach. + * @default + */ this.maxAngular = 1000; + + /** + * @property {number} mass - The mass of the Body. + * @default + */ this.mass = 1; + /** + * @property {boolean} skipQuadTree - If the Body is an irregular shape you can set this to true to avoid it being added to the World quad tree. + * @default + */ + this.skipQuadTree = false; + + /** + * @property {Array} quadTreeIDs - Internal ID cache. + * @protected + */ this.quadTreeIDs = []; + + /** + * @property {number} quadTreeIndex - Internal ID cache. + * @protected + */ this.quadTreeIndex = -1; // Allow collision + + /** + * Set the allowCollision properties to control which directions collision is processed for this Body. + * For example allowCollision.up = false means it won't collide when the collision happened while moving up. + * @property {object} allowCollision - An object containing allowed collision. + */ this.allowCollision = { none: false, any: true, up: true, down: true, left: true, right: true }; + + /** + * This object is populated with boolean values when the Body collides with another. + * touching.up = true means the collision happened to the top of this Body for example. + * @property {object} touching - An object containing touching results. + */ this.touching = { none: true, up: false, down: false, left: false, right: false }; + + /** + * This object is populated with previous touching values from the bodies previous collision. + * @property {object} wasTouching - An object containing previous touching results. + */ this.wasTouching = { none: true, up: false, down: false, left: false, right: false }; + /** + * @property {number} facing - A const reference to the direction the Body is traveling or facing. + * @default + */ + this.facing = Phaser.NONE; + + /** + * @property {boolean} immovable - An immovable Body will not receive any impacts from other bodies. + * @default + */ this.immovable = false; + + /** + * @property {boolean} moves - Set to true to allow the Physics system to move this Body, other false to move it manually. + * @default + */ this.moves = true; + + /** + * @property {number} rotation - The amount the Body is rotated. + * @default + */ this.rotation = 0; + + /** + * @property {boolean} allowRotation - Allow this Body to be rotated? (via angularVelocity, etc) + * @default + */ this.allowRotation = true; + + /** + * @property {boolean} allowGravity - Allow this Body to be influenced by the global Gravity? + * @default + */ this.allowGravity = true; - // These two flags allow you to disable the custom separation that takes place - // Used in combination with your own collision processHandler you can create whatever - // type of collision response you need. + /** + * This flag allows you to disable the custom x separation that takes place by Physics.Arcade.separate. + * Used in combination with your own collision processHandler you can create whatever type of collision response you need. + * @property {boolean} customSeparateX - Use a custom separation system or the built-in one? + * @default + */ this.customSeparateX = false; + + /** + * This flag allows you to disable the custom y separation that takes place by Physics.Arcade.separate. + * Used in combination with your own collision processHandler you can create whatever type of collision response you need. + * @property {boolean} customSeparateY - Use a custom separation system or the built-in one? + * @default + */ this.customSeparateY = false; - // When this body collides with another the amount of overlap is stored in here - // These values are useful if you want to provide your own custom separation logic. + /** + * When this body collides with another, the amount of overlap is stored here. + * @property {number} overlapX - The amount of horizontal overlap during the collision. + */ this.overlapX = 0; + + /** + * When this body collides with another, the amount of overlap is stored here. + * @property {number} overlapY - The amount of vertical overlap during the collision. + */ this.overlapY = 0; + /** + * @property {Phaser.Rectangle} hullX - The dynamically calculated hull used during collision. + */ + this.hullX = new Phaser.Rectangle(); + + /** + * @property {Phaser.Rectangle} hullY - The dynamically calculated hull used during collision. + */ + this.hullY = new Phaser.Rectangle(); + + /** + * If a body is overlapping with another body, but neither of them are moving (maybe they spawned on-top of each other?) this is set to true. + * @property {boolean} embedded - Body embed value. + */ + this.embedded = false; + + /** + * A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World. + * @property {boolean} collideWorldBounds - Should the Body collide with the World bounds? + */ this.collideWorldBounds = false; }; Phaser.Physics.Arcade.Body.prototype = { + /** + * Internal method. + * + * @method Phaser.Physics.Arcade#updateBounds + * @protected + */ updateBounds: function (centerX, centerY, scaleX, scaleY) { if (scaleX != this._sx || scaleY != this._sy) @@ -26841,7 +32224,13 @@ Phaser.Physics.Arcade.Body.prototype = { }, - update: function () { + /** + * Internal method. + * + * @method Phaser.Physics.Arcade#preUpdate + * @protected + */ + preUpdate: function () { // Store and reset collision flags this.wasTouching.none = this.touching.none; @@ -26856,66 +32245,105 @@ Phaser.Physics.Arcade.Body.prototype = { this.touching.left = false; this.touching.right = false; - this.lastX = this.x; - this.lastY = this.y; - this.rotation = this.sprite.angle; + this.embedded = false; - // There is a bug here in that the worldTransform values are what should be used, otherwise the quadTree gets the wrong rect given to it - this.x = (this.sprite.x - (this.sprite.anchor.x * this.width)) + this.offset.x; - this.y = (this.sprite.y - (this.sprite.anchor.y * this.height)) + this.offset.y; - // this.x = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x; - // this.y = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y; + this.screenX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x; + this.screenY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y; + + this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x; + this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y; + + this.preRotation = this.sprite.angle; + + this.x = this.preX; + this.y = this.preY; + this.rotation = this.preRotation; if (this.moves) { this.game.physics.updateMotion(this); - } - if (this.collideWorldBounds) - { - this.checkWorldBounds(); - } + if (this.collideWorldBounds) + { + this.checkWorldBounds(); + } - if (this.allowCollision.none == false && this.sprite.visible && this.sprite.alive) + this.updateHulls();Array } + + if (this.skipQuadTree == false && this.allowCollision.none == false && this.sprite.visible && this.sprite.alive) { this.quadTreeIDs = []; this.quadTreeIndex = -1; this.game.physics.quadTree.insert(this); } - if (this.deltaX() != 0) - { - this.sprite.x -= this.deltaX(); - } - - if (this.deltaY() != 0) - { - this.sprite.y -= this.deltaY(); - } - - // Adjust the sprite based on all of the above, so the x/y coords will be correct going into the State update - this.sprite.x = this.x - this.offset.x + (this.sprite.anchor.x * this.width); - this.sprite.y = this.y - this.offset.y + (this.sprite.anchor.y * this.height); - - if (this.allowRotation) - { - this.sprite.angle = this.rotation; - } - }, + /** + * Internal method. + * + * @method Phaser.Physics.Arcade#postUpdate + * @protected + */ postUpdate: function () { - this.sprite.x = this.x - this.offset.x + (this.sprite.anchor.x * this.width); - this.sprite.y = this.y - this.offset.y + (this.sprite.anchor.y * this.height); + // Calculate forward-facing edge + if (this.deltaX() == 0 && this.deltaY() == 0) + { + // Can't work it out from the Body, how about from x position? + if (this.sprite.deltaX() == 0 && this.sprite.deltaY() == 0) + { + // still as a statue + } + } + + if (this.deltaX() < 0) + { + this.facing = Phaser.LEFT; + } + else if (this.deltaX() > 0) + { + this.facing = Phaser.RIGHT; + } + + if (this.deltaY() < 0) + { + this.facing = Phaser.UP; + } + else if (this.deltaY() > 0) + { + this.facing = Phaser.DOWN; + } + + this.sprite.x += this.deltaX(); + this.sprite.y += this.deltaY(); if (this.allowRotation) { - this.sprite.angle = this.rotation; + this.sprite.angle += this.deltaZ(); } }, + /** + * Internal method. + * + * @method Phaser.Physics.Arcade#updateHulls + * @protected + */ + updateHulls: function () { + + this.hullX.setTo(this.x, this.preY, this.width, this.height); + this.hullY.setTo(this.preX, this.y, this.width, this.height); + + }, + + /** + * Internal method. + * + * @method Phaser.Physics.Arcade#checkWorldBounds + * @protected + */ checkWorldBounds: function () { if (this.x < this.game.world.bounds.x) @@ -26942,6 +32370,17 @@ Phaser.Physics.Arcade.Body.prototype = { }, + /** + * You can modify the size of the physics Body to be any dimension you need. + * So it could be smaller or larger than the parent Sprite. You can also control the x and y offset, which + * is the position of the Body relative to the top-left of the Sprite. + * + * @method Phaser.Physics.Arcade#setSize + * @param {number} width - The width of the Body. + * @param {number} height - The height of the Body. + * @param {number} offsetX - The X offset of the Body from the Sprite position. + * @param {number} offsetY - The Y offset of the Body from the Sprite position. + */ setSize: function (width, height, offsetX, offsetY) { offsetX = offsetX || this.offset.x; @@ -26957,6 +32396,11 @@ Phaser.Physics.Arcade.Body.prototype = { }, + /** + * Resets all Body values (velocity, acceleration, rotation, etc) + * + * @method Phaser.Physics.Arcade#reset + */ reset: function () { this.velocity.setTo(0, 0); @@ -26964,38 +32408,72 @@ Phaser.Physics.Arcade.Body.prototype = { this.angularVelocity = 0; this.angularAcceleration = 0; + this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x; + this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y; + this.preRotation = this.sprite.angle; - this.x = (this.sprite.x - (this.sprite.anchor.x * this.width)) + this.offset.x; - this.y = (this.sprite.y - (this.sprite.anchor.y * this.height)) + this.offset.y; - this.lastX = this.x; - this.lastY = this.y; + this.x = this.preX; + this.y = this.preY; + this.rotation = this.preRotation; }, + /** + * Returns the absolute delta x value. + * + * @method Phaser.Physics.Arcade.Body#deltaAbsX + * @return {number} The absolute delta value. + */ deltaAbsX: function () { return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX()); }, + /** + * Returns the absolute delta y value. + * + * @method Phaser.Physics.Arcade.Body#deltaAbsY + * @return {number} The absolute delta value. + */ deltaAbsY: function () { return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY()); }, + /** + * Returns the delta x value. + * + * @method Phaser.Physics.Arcade.Body#deltaX + * @return {number} The delta value. + */ deltaX: function () { - return this.x - this.lastX; + return this.x - this.preX; }, + /** + * Returns the delta y value. + * + * @method Phaser.Physics.Arcade.Body#deltaY + * @return {number} The delta value. + */ deltaY: function () { - return this.y - this.lastY; + return this.y - this.preY; + }, + + deltaZ: function () { + return this.rotation - this.preRotation; } }; +/** +* @name Phaser.Physics.Arcade.Body#bottom +* @property {number} bottom - The bottom value of this Body (same as Body.y + Body.height) +*/ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", { /** * 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. * @method bottom - * @return {Number} + * @return {number} **/ get: function () { return this.y + this.height; @@ -27004,7 +32482,7 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", { /** * 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. * @method bottom - * @param {Number} value + * @param {number} value **/ set: function (value) { @@ -27021,13 +32499,17 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", { }); +/** +* @name Phaser.Physics.Arcade.Body#right +* @property {number} right - The right value of this Body (same as Body.x + Body.width) +*/ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", { /** * 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. * @method right - * @return {Number} + * @return {number} **/ get: function () { return this.x + this.width; @@ -27037,7 +32519,7 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", { * 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. * @method right - * @param {Number} value + * @param {number} value **/ set: function (value) { @@ -27054,18 +32536,43 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", { }); +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser.Particles is the Particle Manager for the game. It is called during the game update loop and in turn updates any Emitters attached to it. +* +* @class Phaser.Particles +* @classdesc Phaser Particles +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +*/ Phaser.Particles = function (game) { + /** + * @property {Description} emitters - Description. + */ this.emitters = {}; + /** + * @property {number} ID - Description. + * @default + */ this.ID = 0; }; Phaser.Particles.prototype = { - emitters: null, - + /** + * Adds a new Particle Emitter to the Particle Manager. + * @method Phaser.Particles#add + * @param {Phaser.Emitter} emitter - Description. + * @return {Phaser.Emitter} The emitter that was added. + */ add: function (emitter) { this.emitters[emitter.name] = emitter; @@ -27074,12 +32581,22 @@ Phaser.Particles.prototype = { }, + /** + * Removes an existing Particle Emitter from the Particle Manager. + * @method Phaser.Particles#remove + * @param {Phaser.Emitter} emitter - The emitter to remove. + */ remove: function (emitter) { delete this.emitters[emitter.name]; }, + /** + * Called by the core game loop. Updates all Emitters who have their exists value set to true. + * @method Phaser.Particles#update + * @protected + */ update: function () { for (var key in this.emitters) @@ -27090,152 +32607,212 @@ Phaser.Particles.prototype = { } } - }, + } }; Phaser.Particles.Arcade = {} +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + /** * Phaser - ArcadeEmitter * -* Emitter is a lightweight particle emitter. It can be used for one-time explosions or for +* @class Phaser.Particles.Arcade.Emitter +* @classdesc Emitter is a lightweight particle emitter. It can be used for one-time explosions or for * continuous effects like rain and fire. All it really does is launch Particle objects out * at set intervals, and fixes their positions and velocities accorindgly. +* @constructor +* @extends Phaser.Group +* @param {Phaser.Game} game - Current game instance. +* @param {number} [x=0] - The x coordinate within the Emitter that the particles are emitted from. +* @param {number} [y=0] - The y coordinate within the Emitter that the particles are emitted from. +* @param {number} [maxParticles=50] - The total number of particles in this emitter.. */ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) { - maxParticles = maxParticles || 50; + /** + * The total number of particles in this emitter. + * @property {number} maxParticles - The total number of particles in this emitter.. + * @default + */ + this.maxParticles = maxParticles || 50; Phaser.Group.call(this, game); + /** + * @property {string} name - Description. + */ this.name = 'emitter' + this.game.particles.ID++; + /** + * @property {Description} type - Description. + */ this.type = Phaser.EMITTER; /** - * The X position of the top left corner of the emitter in world space. + * @property {number} x - The X position of the top left corner of the emitter in world space. + * @default */ this.x = 0; /** - * The Y position of the top left corner of emitter in world space. + * @property {number} y - The Y position of the top left corner of emitter in world space. + * @default */ this.y = 0; /** - * The width of the emitter. Particles can be randomly generated from anywhere within this box. + * @property {number} width - The width of the emitter. Particles can be randomly generated from anywhere within this box. + * @default */ this.width = 1; /** - * The height of the emitter. Particles can be randomly generated from anywhere within this box. - */ + * @property {number} height - The height of the emitter. Particles can be randomly generated from anywhere within this box. + * @default + */ this.height = 1; /** - * The minimum possible velocity of a particle. - * The default value is (-100,-100). - */ + * The minimum possible velocity of a particle. + * The default value is (-100,-100). + * @property {Phaser.Point} minParticleSpeed + */ this.minParticleSpeed = new Phaser.Point(-100, -100); /** - * The maximum possible velocity of a particle. - * The default value is (100,100). - */ + * The maximum possible velocity of a particle. + * The default value is (100,100). + * @property {Phaser.Point} maxParticleSpeed + */ this.maxParticleSpeed = new Phaser.Point(100, 100); /** - * The minimum possible scale of a particle. - * The default value is 1. - */ + * The minimum possible scale of a particle. + * The default value is 1. + * @property {number} minParticleScale + * @default + */ this.minParticleScale = 1; /** * The maximum possible scale of a particle. * The default value is 1. + * @property {number} maxParticleScale + * @default */ this.maxParticleScale = 1; /** * The minimum possible angular velocity of a particle. The default value is -360. + * @property {number} minRotation + * @default */ this.minRotation = -360; /** * The maximum possible angular velocity of a particle. The default value is 360. + * @property {number} maxRotation + * @default */ this.maxRotation = 360; /** * Sets the gravity.y of each particle to this value on launch. + * @property {number} gravity + * @default */ this.gravity = 2; /** * Set your own particle class type here. - * Default is Particle. + * @property {Description} particleClass + * @default */ this.particleClass = null; /** * The X and Y drag component of particles launched from the emitter. + * @property {Phaser.Point} particleDrag */ this.particleDrag = new Phaser.Point(); /** * The angular drag component of particles launched from the emitter if they are rotating. + * @property {number} angularDrag + * @default */ this.angularDrag = 0; /** * How often a particle is emitted in ms (if emitter is started with Explode == false). + * @property {boolean} frequency + * @default */ this.frequency = 100; - /** - * The total number of particles in this emitter. - */ - this.maxParticles = maxParticles; - /** * How long each particle lives once it is emitted in ms. Default is 2 seconds. * Set lifespan to 'zero' for particles to live forever. + * @property {number} lifespan + * @default */ this.lifespan = 2000; /** * How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce. + * @property {Phaser.Point} bounce */ this.bounce = new Phaser.Point(); /** * Internal helper for deciding how many particles to launch. + * @property {number} _quantity + * @private + * @default */ this._quantity = 0; /** * Internal helper for deciding when to launch particles or kill them. + * @property {number} _timer + * @private + * @default */ this._timer = 0; /** * Internal counter for figuring out how many particles to launch. + * @property {number} _counter + * @private + * @default */ this._counter = 0; /** * Internal helper for the style of particle emission (all at once, or one at a time). + * @property {boolean} _explode + * @private + * @default */ this._explode = true; /** * Determines whether the emitter is currently emitting particles. * It is totally safe to directly toggle this. + * @property {boolean} on + * @default */ this.on = false; /** * Determines whether the emitter is being updated by the core game loop. + * @property {boolean} exists + * @default */ this.exists = true; @@ -27243,8 +32820,16 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) { * The point the particles are emitted from. * Emitter.x and Emitter.y control the containers location, which updates all current particles * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. + * @property {boolean} emitX */ this.emitX = x; + + /** + * The point the particles are emitted from. + * Emitter.x and Emitter.y control the containers location, which updates all current particles + * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. + * @property {boolean} emitY + */ this.emitY = y; }; @@ -27253,8 +32838,9 @@ Phaser.Particles.Arcade.Emitter.prototype = Object.create(Phaser.Group.prototype Phaser.Particles.Arcade.Emitter.prototype.constructor = Phaser.Particles.Arcade.Emitter; /** - * Called automatically by the game loop, decides when to launch particles and when to "die". - */ +* Called automatically by the game loop, decides when to launch particles and when to "die". +* @method Phaser.Particles.Arcade.Emitter#update +*/ Phaser.Particles.Arcade.Emitter.prototype.update = function () { if (this.on) @@ -27296,15 +32882,16 @@ Phaser.Particles.Arcade.Emitter.prototype.update = function () { } /** - * This function generates a new array of particle sprites to attach to the emitter. - * - * @param graphics If you opted to not pre-configure an array of Sprite objects, you can simply pass in a particle image or sprite sheet. - * @param quantity {number} The number of particles to generate when using the "create from image" option. - * @param multiple {boolean} Whether the image in the Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!). - * @param collide {number} Whether the particles should be flagged as not 'dead' (non-colliding particles are higher performance). 0 means no collisions, 0-1 controls scale of particle's bounding box. - * - * @return This Emitter instance (nice for chaining stuff together, if you're into that). - */ +* This function generates a new array of particle sprites to attach to the emitter. +* +* @method Phaser.Particles.Arcade.Emitter#makeParticles +* @param {Description} keys - Description. +* @param {number} frames - Description. +* @param {number} quantity - The number of particles to generate when using the "create from image" option. +* @param {number} collide - Description. +* @param {boolean} collideWorldBounds - Description. +* @return This Emitter instance (nice for chaining stuff together, if you're into that). +*/ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide, collideWorldBounds) { if (typeof frames == 'undefined') @@ -27374,6 +32961,7 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames /** * Call this function to turn off all the particles and the emitter. + * @method Phaser.Particles.Arcade.Emitter#kill */ Phaser.Particles.Arcade.Emitter.prototype.kill = function () { @@ -27386,6 +32974,7 @@ Phaser.Particles.Arcade.Emitter.prototype.kill = function () { /** * Handy for bringing game objects "back to life". Just sets alive and exists back to true. * In practice, this is most often called by Object.reset(). + * @method Phaser.Particles.Arcade.Emitter#revive */ Phaser.Particles.Arcade.Emitter.prototype.revive = function () { @@ -27396,11 +32985,11 @@ Phaser.Particles.Arcade.Emitter.prototype.revive = function () { /** * Call this function to start emitting particles. - * - * @param explode {boolean} Whether the particles should all burst out at once. - * @param lifespan {number} How long each particle lives once emitted. 0 = forever. - * @param frequency {number} Ignored if Explode is set to true. Frequency is how often to emit a particle in ms. - * @param quantity {number} How many particles to launch. 0 = "all of the particles". + * @method Phaser.Particles.Arcade.Emitter#start + * @param {boolean} explode - Whether the particles should all burst out at once. + * @param {number} lifespan - How long each particle lives once emitted. 0 = forever. + * @param {number} frequency - Ignored if Explode is set to true. Frequency is how often to emit a particle in ms. + * @param {number} quantity - How many particles to launch. 0 = "all of the particles". */ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, frequency, quantity) { @@ -27442,6 +33031,7 @@ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, f /** * This function can be used both internally and externally to emit the next particle. + * @method Phaser.Particles.Arcade.Emitter#emitParticle */ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () { @@ -27454,7 +33044,7 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () { if (this.width > 1 || this.height > 1) { - particle.reset(this.emiteX - this.game.rnd.integerInRange(this.left, this.right), this.emiteY - this.game.rnd.integerInRange(this.top, this.bottom)); + particle.reset(this.game.rnd.integerInRange(this.left, this.right), this.game.rnd.integerInRange(this.top, this.bottom)); } else { @@ -27507,11 +33097,11 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () { } /** - * A more compact way of setting the width and height of the emitter. - * - * @param width {number} The desired width of the emitter (particles are spawned randomly within these dimensions). - * @param height {number} The desired height of the emitter. - */ +* A more compact way of setting the width and height of the emitter. +* @method Phaser.Particles.Arcade.Emitter#setSize +* @param {number} width - The desired width of the emitter (particles are spawned randomly within these dimensions). +* @param {number} height - The desired height of the emitter. +*/ Phaser.Particles.Arcade.Emitter.prototype.setSize = function (width, height) { this.width = width; @@ -27520,11 +33110,11 @@ Phaser.Particles.Arcade.Emitter.prototype.setSize = function (width, height) { } /** - * A more compact way of setting the X velocity range of the emitter. - * - * @param Min {number} The minimum value for this range. - * @param Max {number} The maximum value for this range. - */ +* A more compact way of setting the X velocity range of the emitter. +* @method Phaser.Particles.Arcade.Emitter#setXSpeed +* @param {number} min - The minimum value for this range. +* @param {number} max - The maximum value for this range. +*/ Phaser.Particles.Arcade.Emitter.prototype.setXSpeed = function (min, max) { min = min || 0; @@ -27536,11 +33126,11 @@ Phaser.Particles.Arcade.Emitter.prototype.setXSpeed = function (min, max) { } /** - * A more compact way of setting the Y velocity range of the emitter. - * - * @param Min {number} The minimum value for this range. - * @param Max {number} The maximum value for this range. - */ +* A more compact way of setting the Y velocity range of the emitter. +* @method Phaser.Particles.Arcade.Emitter#setYSpeed +* @param {number} min - The minimum value for this range. +* @param {number} max - The maximum value for this range. +*/ Phaser.Particles.Arcade.Emitter.prototype.setYSpeed = function (min, max) { min = min || 0; @@ -27552,11 +33142,11 @@ Phaser.Particles.Arcade.Emitter.prototype.setYSpeed = function (min, max) { } /** - * A more compact way of setting the angular velocity constraints of the emitter. - * - * @param Min {number} The minimum value for this range. - * @param Max {number} The maximum value for this range. - */ +* A more compact way of setting the angular velocity constraints of the emitter. +* @method Phaser.Particles.Arcade.Emitter#setRotation +* @param {number} min - The minimum value for this range. +* @param {number} max - The maximum value for this range. +*/ Phaser.Particles.Arcade.Emitter.prototype.setRotation = function (min, max) { min = min || 0; @@ -27568,10 +33158,10 @@ Phaser.Particles.Arcade.Emitter.prototype.setRotation = function (min, max) { } /** - * Change the emitter's midpoint to match the midpoint of a Object. - * - * @param Object {object} The Object that you want to sync up with. - */ +* Change the emitter's midpoint to match the midpoint of a Object. +* @method Phaser.Particles.Arcade.Emitter#at +* @param {object} object - The Object that you want to sync up with. +*/ Phaser.Particles.Arcade.Emitter.prototype.at = function (object) { this.emitX = object.center.x; @@ -27579,42 +33169,44 @@ Phaser.Particles.Arcade.Emitter.prototype.at = function (object) { } +/** +* The emitters alpha value. +* @name Phaser.Particles.Arcade.Emitter#alpha +* @property {number} alpha - Gets or sets the alpha value of the Emitter. +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "alpha", { - /** - * Get the emitter alpha. - */ get: function () { return this._container.alpha; }, - /** - * Set the emiter alpha value. - */ set: function (value) { this._container.alpha = value; } }); +/** +* The emitter visible state. +* @name Phaser.Particles.Arcade.Emitter#visible +* @property {boolean} visible - Gets or sets the Emitter visible state. +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "visible", { - /** - * Get the emitter visible state. - */ get: function () { return this._container.visible; }, - /** - * Set the emitter visible state. - */ set: function (value) { this._container.visible = value; } }); +/** +* @name Phaser.Particles.Arcade.Emitter#x +* @property {number} x - Gets or sets the x position of the Emitter. +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "x", { get: function () { @@ -27627,6 +33219,10 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "x", { }); +/** +* @name Phaser.Particles.Arcade.Emitter#y +* @property {number} y - Gets or sets the y position of the Emitter. +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "y", { get: function () { @@ -27639,6 +33235,11 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "y", { }); +/** +* @name Phaser.Particles.Arcade.Emitter#left +* @property {number} left - Gets the left position of the Emitter. +* @readonly +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "left", { get: function () { @@ -27647,6 +33248,11 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "left", { }); +/** +* @name Phaser.Particles.Arcade.Emitter#right +* @property {number} right - Gets the right position of the Emitter. +* @readonly +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "right", { get: function () { @@ -27655,6 +33261,11 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "right", { }); +/** +* @name Phaser.Particles.Arcade.Emitter#top +* @property {number} top - Gets the top position of the Emitter. +* @readonly +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "top", { get: function () { @@ -27663,6 +33274,11 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "top", { }); +/** +* @name Phaser.Particles.Arcade.Emitter#bottom +* @property {number} bottom - Gets the bottom position of the Emitter. +* @readonly +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", { get: function () { @@ -27672,783 +33288,405 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", { }); /** -* Phaser - Tilemap -* -* This GameObject allows for the display of a tilemap within the game world. Tile maps consist of an image, tile data and a size. -* Internally it creates a TilemapLayer for each layer in the tilemap. +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +* @module Phaser.Tile */ + /** -* Tilemap constructor -* Create a new Tilemap. +* Create a new Tile. * -* @param game {Phaser.Game} Current game instance. -* @param key {string} Asset key for this map. -* @param mapData {string} Data of this map. (a big 2d array, normally in csv) -* @param format {number} Format of this map data, available: Tilemap.CSV or Tilemap.JSON. -* @param resizeWorld {bool} Resize the world bound automatically based on this tilemap? -* @param tileWidth {number} Width of tiles in this map (used for CSV maps). -* @param tileHeight {number} Height of tiles in this map (used for CSV maps). +* @class Phaser.Tile +* @classdesc A Tile is a single representation of a tile within a Tilemap. +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {Tilemap} tilemap - The tilemap this tile belongs to. +* @param {number} index - The index of this tile type in the core map data. +* @param {number} width - Width of the tile. +* @param {number} height - Height of the tile. */ -Phaser.Tilemap = function (game, key, x, y, resizeWorld, tileWidth, tileHeight) { - - if (typeof resizeWorld === "undefined") { resizeWorld = true; } - if (typeof tileWidth === "undefined") { tileWidth = 0; } - if (typeof tileHeight === "undefined") { tileHeight = 0; } - - this.game = game; - this.group = null; - this.name = ''; - this.key = key; +Phaser.Tile = function (tileset, index, x, y, width, height) { /** - * Render iteration counter + * @property {string} tileset - The tileset this tile belongs to. */ - this.renderOrderID = 0; + this.tileset = tileset; + + /** + * @property {number} index - The index of this tile within the tileset. + */ + this.index = index; + + /** + * @property {number} width - The width of the tile in pixels. + */ + this.width = width; + + /** + * @property {number} height - The height of the tile in pixels. + */ + this.height = height; /** - * Tilemap collision callback. - * @type {function} + * @property {number} x - The top-left corner of the tile within the tileset. + */ + this.x = x; + + /** + * @property {number} y - The top-left corner of the tile within the tileset. + */ + this.y = y; + + // Any extra meta data info we need here + + /** + * @property {number} mass - The virtual mass of the tile. + * @default + */ + this.mass = 1.0; + + /** + * @property {boolean} collideNone - Indicating this Tile doesn't collide at all. + * @default + */ + this.collideNone = true; + + /** + * @property {boolean} collideLeft - Indicating collide with any object on the left. + * @default + */ + this.collideLeft = false; + + /** + * @property {boolean} collideRight - Indicating collide with any object on the right. + * @default + */ + this.collideRight = false; + + /** + * @property {boolean} collideUp - Indicating collide with any object on the top. + * @default + */ + this.collideUp = false; + + /** + * @property {boolean} collideDown - Indicating collide with any object on the bottom. + * @default + */ + this.collideDown = false; + + /** + * @property {boolean} separateX - Enable separation at x-axis. + * @default + */ + this.separateX = true; + + /** + * @property {boolean} separateY - Enable separation at y-axis. + * @default + */ + this.separateY = true; + + /** + * @property {boolean} collisionCallback - Tilemap collision callback. + * @default */ this.collisionCallback = null; - this.exists = true; - this.visible = true; + /** + * @property {boolean} collisionCallback - Tilemap collision callback. + * @default + */ + this.collisionCallbackContext = this; - this.tiles = []; - this.layers = []; - - var map = this.game.cache.getTilemap(key); - - PIXI.DisplayObjectContainer.call(this); - this.position.x = x; - this.position.y = y; - - this.type = Phaser.TILEMAP; - - this.renderer = new Phaser.TilemapRenderer(this.game); - - this.mapFormat = map.format; - - switch (this.mapFormat) - { - case Phaser.Tilemap.CSV: - this.parseCSV(map.mapData, key, tileWidth, tileHeight); - break; - - case Phaser.Tilemap.JSON: - this.parseTiledJSON(map.mapData, key); - break; - } - - if (this.currentLayer && resizeWorld) - { - this.game.world.setSize(this.currentLayer.widthInPixels, this.currentLayer.heightInPixels, true); - } - }; -// Needed to keep the PIXI.Sprite constructor in the prototype chain (as the core pixi renderer uses an instanceof check sadly) -Phaser.Tilemap.prototype = Object.create(PIXI.DisplayObjectContainer.prototype); -Phaser.Tilemap.prototype.constructor = Phaser.Tilemap; +Phaser.Tile.prototype = { + + /** + * Set callback to be called when this tilemap collides. + * + * @method Phaser.Tilemap.prototype.setCollisionCallback + * @param {Function} callback - Callback function. + * @param {object} context - Callback will be called with this context. + */ + setCollisionCallback: function (callback, context) { + + this.collisionCallbackContext = context; + this.collisionCallback = callback; + + }, + + /** + * Clean up memory. + * @method destroy + */ + destroy: function () { + + this.tileset = null; + + }, + + /** + * Set collision configs. + * @method setCollision + * @param {boolean} left - Indicating collide with any object on the left. + * @param {boolean} right - Indicating collide with any object on the right. + * @param {boolean} up - Indicating collide with any object on the top. + * @param {boolean} down - Indicating collide with any object on the bottom. + * @param {boolean} reset - Description. + * @param {boolean} separateX - Separate at x-axis. + * @param {boolean} separateY - Separate at y-axis. + */ + setCollision: function (left, right, up, down) { + + this.collideLeft = left; + this.collideRight = right; + this.collideUp = up; + this.collideDown = down; + + if (left || right || up || down) + { + this.collideNone = false; + } + else + { + this.collideNone = true; + } + + }, + + /** + * Reset collision status flags. + * @method resetCollision + */ + resetCollision: function () { + + this.collideNone = true; + this.collideLeft = false; + this.collideRight = false; + this.collideUp = false; + this.collideDown = false; + + } + +}; + +Object.defineProperty(Phaser.Tile.prototype, "bottom", { + + /** + * 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. + * @method bottom + * @return {number} + **/ + get: function () { + return this.y + this.height; + } + +}); + +Object.defineProperty(Phaser.Tile.prototype, "right", { + + /** + * 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. + * @method right + * @return {number} + **/ + get: function () { + return this.x + this.width; + } + +}); + +Phaser.Tilemap = function (game, key) { + + /** + * @property {Phaser.Game} game - Description. + */ + this.game = game; + + /** + * @property {array} layers - Description. + */ + this.layers; + + if (typeof key === 'string') + { + this.key = key; + + this.layers = game.cache.getTilemapData(key).layers; + this.calculateIndexes(); + } + else + { + this.layers = []; + } + + this.currentLayer = 0; + + this.debugMap = []; + + this.dirty = false; + + this._results = []; + this._tempA = 0; + this._tempB = 0; + +}; Phaser.Tilemap.CSV = 0; -Phaser.Tilemap.JSON = 1; +Phaser.Tilemap.TILED_JSON = 1; -/** -* Parset csv map data and generate tiles. -* @param data {string} CSV map data. -* @param key {string} Asset key for tileset image. -* @param tileWidth {number} Width of its tile. -* @param tileHeight {number} Height of its tile. -*/ -Phaser.Tilemap.prototype.parseCSV = function (data, key, tileWidth, tileHeight) { +Phaser.Tilemap.prototype = { - var layer = new Phaser.TilemapLayer(this, 0, key, Phaser.Tilemap.CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight); + create: function (name, width, height) { - // Trim any rogue whitespace from the data - data = data.trim(); + var data = []; - var rows = data.split("\n"); - - for (var i = 0; i < rows.length; i++) - { - var column = rows[i].split(","); - - if (column.length > 0) + for (var y = 0; y < height; y++) { - layer.addColumn(column); - } - } + data[y] = []; - layer.updateBounds(); - layer.createCanvas(); - - var tileQuantity = layer.parseTileOffsets(); - - this.currentLayer = layer; - this.collisionLayer = layer; - this.layers.push(layer); - - this.generateTiles(tileQuantity); - -}; - -/** -* Parse JSON map data and generate tiles. -* @param data {string} JSON map data. -* @param key {string} Asset key for tileset image. -*/ -Phaser.Tilemap.prototype.parseTiledJSON = function (json, key) { - - for (var i = 0; i < json.layers.length; i++) - { - var layer = new Phaser.TilemapLayer(this, i, key, Phaser.Tilemap.JSON, json.layers[i].name, json.tilewidth, json.tileheight); - - // Check it's a data layer - if (!json.layers[i].data) - { - continue; - } - - layer.alpha = json.layers[i].opacity; - layer.visible = json.layers[i].visible; - layer.tileMargin = json.tilesets[0].margin; - layer.tileSpacing = json.tilesets[0].spacing; - - var c = 0; - var row; - - for (var t = 0; t < json.layers[i].data.length; t++) - { - if (c == 0) + for (var x = 0; x < width; x++) { - row = []; - } - - row.push(json.layers[i].data[t]); - c++; - - if (c == json.layers[i].width) - { - layer.addColumn(row); - c = 0; + data[y][x] = 0; } } - layer.updateBounds(); - layer.createCanvas(); - - var tileQuantity = layer.parseTileOffsets(); - - this.currentLayer = layer; - this.collisionLayer = layer; - this.layers.push(layer); - } + this.currentLayer = this.layers.push({ - this.generateTiles(tileQuantity); + name: name, + width: width, + height: height, + alpha: 1, + visible: true, + tileMargin: 0, + tileSpacing: 0, + format: Phaser.Tilemap.CSV, + data: data, + indexes: [] -}; + }); -/** -* Create tiles of given quantity. -* @param qty {number} Quentity of tiles to be generated. -*/ -Phaser.Tilemap.prototype.generateTiles = function (qty) { + this.dirty = true; - for (var i = 0; i < qty; i++) - { - this.tiles.push(new Phaser.Tile(this.game, this, i, this.currentLayer.tileWidth, this.currentLayer.tileHeight)); - } + }, -}; + calculateIndexes: function () { -/** -* Set callback to be called when this tilemap collides. -* @param context {object} Callback will be called with this context. -* @param callback {function} Callback function. -*/ -Phaser.Tilemap.prototype.setCollisionCallback = function (context, callback) { - - this.collisionCallbackContext = context; - this.collisionCallback = callback; - -}; - -/** -* Set collision configs of tiles in a range index. -* @param start {number} First index of tiles. -* @param end {number} Last index of tiles. -* @param collision {number} Bit field of flags. (see Tile.allowCollision) -* @param resetCollisions {bool} Reset collision flags before set. -* @param separateX {bool} Enable seprate at x-axis. -* @param separateY {bool} Enable seprate at y-axis. -*/ -Phaser.Tilemap.prototype.setCollisionRange = function (start, end, left, right, up, down, resetCollisions, separateX, separateY) { - - if (typeof resetCollisions === "undefined") { resetCollisions = false; } - if (typeof separateX === "undefined") { separateX = true; } - if (typeof separateY === "undefined") { separateY = true; } - - for (var i = start; i < end; i++) - { - this.tiles[i].setCollision(left, right, up, down, resetCollisions, separateX, separateY); - } - -}; - -/** -* Set collision configs of tiles with given index. -* @param values {number[]} Index array which contains all tile indexes. The tiles with those indexes will be setup with rest parameters. -* @param collision {number} Bit field of flags. (see Tile.allowCollision) -* @param resetCollisions {bool} Reset collision flags before set. -* @param separateX {bool} Enable seprate at x-axis. -* @param separateY {bool} Enable seprate at y-axis. -*/ -Phaser.Tilemap.prototype.setCollisionByIndex = function (values, left, right, up, down, resetCollisions, separateX, separateY) { - - if (typeof resetCollisions === "undefined") { resetCollisions = false; } - if (typeof separateX === "undefined") { separateX = true; } - if (typeof separateY === "undefined") { separateY = true; } - - for (var i = 0; i < values.length; i++) - { - this.tiles[values[i]].setCollision(left, right, up, down, resetCollisions, separateX, separateY); - } - -}; - -// Tile Management - -/** -* Get the tile by its index. -* @param value {number} Index of the tile you want to get. -* @return {Tile} The tile with given index. -*/ -Phaser.Tilemap.prototype.getTileByIndex = function (value) { - - if (this.tiles[value]) - { - return this.tiles[value]; - } - - return null; - -}; - -/** -* Get the tile located at specific position and layer. -* @param x {number} X position of this tile located. -* @param y {number} Y position of this tile located. -* @param [layer] {number} layer of this tile located. -* @return {Tile} The tile with specific properties. -*/ -Phaser.Tilemap.prototype.getTile = function (x, y, layer) { - - if (typeof layer === "undefined") { layer = this.currentLayer.ID; } - - return this.tiles[this.layers[layer].getTileIndex(x, y)]; - -}; - -/** -* Get the tile located at specific position (in world coordinate) and layer. (thus you give a position of a point which is within the tile) -* @param x {number} X position of the point in target tile. -* @param x {number} Y position of the point in target tile. -* @param [layer] {number} layer of this tile located. -* @return {Tile} The tile with specific properties. -*/ -Phaser.Tilemap.prototype.getTileFromWorldXY = function (x, y, layer) { - - if (typeof layer === "undefined") { layer = this.currentLayer.ID; } - - return this.tiles[this.layers[layer].getTileFromWorldXY(x, y)]; - -}; - -/** -* Gets the tile underneath the Input.x/y position -* @param layer The layer to check, defaults to 0 -* @returns {Tile} -*/ -Phaser.Tilemap.prototype.getTileFromInputXY = function (layer) { - - if (typeof layer === "undefined") { layer = this.currentLayer.ID; } - - return this.tiles[this.layers[layer].getTileFromWorldXY(this.game.input.worldX, this.game.input.worldY)]; - -}; - -/** -* Get tiles overlaps the given object. -* @param object {GameObject} Tiles you want to get that overlaps this. -* @return {array} Array with tiles information. (Each contains x, y and the tile.) -*/ -Phaser.Tilemap.prototype.getTileOverlaps = function (object) { - - return this.currentLayer.getTileOverlaps(object); - -}; - -// COLLIDE - -/** -* Check whether this tilemap collides with the given game object or group of objects. -* @param objectOrGroup {function} Target object of group you want to check. -* @param callback {function} This is called if objectOrGroup collides the tilemap. -* @param context {object} Callback will be called with this context. -* @return {bool} Return true if this collides with given object, otherwise return false. -*/ -Phaser.Tilemap.prototype.collide = function (objectOrGroup, callback, context) { - - objectOrGroup = objectOrGroup || this.game.world.group; - callback = callback || null; - context = context || null; - - if (callback && context) - { - this.collisionCallback = callback; - this.collisionCallbackContext = context; - } - - if (objectOrGroup instanceof Phaser.Group) - { - objectOrGroup.forEachAlive(this.collideGameObject, this); - } - else - { - this.collideGameObject(objectOrGroup); - } - -}; - -/** -* Check whether this tilemap collides with the given game object. -* @param object {GameObject} Target object you want to check. -* @return {bool} Return true if this collides with given object, otherwise return false. -*/ -Phaser.Tilemap.prototype.collideGameObject = function (object) { - - if (object instanceof Phaser.Group || object instanceof Phaser.Tilemap) - { - return false; - } - - if (object.exists && object.body.allowCollision.none == false) - { - this._tempCollisionData = this.collisionLayer.getTileOverlaps(object); - - if (this.collisionCallback && this._tempCollisionData.length > 0) + for (var layer = 0; layer < this.layers.length; layer++) { - this.collisionCallback.call(this.collisionCallbackContext, object, this._tempCollisionData); + this.layers[layer].indexes = []; + + for (var y = 0; y < this.layers[layer].height ; y++) + { + for (var x = 0; x < this.layers[layer].width; x++) + { + var idx = this.layers[layer].data[y][x]; + + if (this.layers[layer].indexes.indexOf(idx) === -1) + { + this.layers[layer].indexes.push(idx); + } + } + } } - return true; - } - else - { - return false; - } + }, -}; + setLayer: function (layer) { -/** -* Set a tile to a specific layer. -* @param x {number} X position of this tile. -* @param y {number} Y position of this tile. -* @param index {number} The index of this tile type in the core map data. -* @param [layer] {number} which layer you want to set the tile to. -*/ -Phaser.Tilemap.prototype.putTile = function (x, y, index, layer) { + if (this.layers[layer]) + { + this.currentLayer = layer; + } - if (typeof layer === "undefined") { layer = this.currentLayer.ID; } - - this.layers[layer].putTile(x, y, index); - -}; - -/** -* Calls the renderer -*/ -Phaser.Tilemap.prototype.update = function () { - - this.renderer.render(this); - -}; - -Phaser.Tilemap.prototype.destroy = function () { - - this.tiles.length = 0; - this.layers.length = 0; - -}; - -Object.defineProperty(Phaser.Tilemap.prototype, "widthInPixels", { - - get: function () { - return this.currentLayer.widthInPixels; - } - -}); - -Object.defineProperty(Phaser.Tilemap.prototype, "heightInPixels", { - - get: function () { - return this.currentLayer.heightInPixels; - } - -}); - -/** -* Phaser - TilemapLayer -* -* A Tilemap Layer. Tiled format maps can have multiple overlapping layers. -*/ - -/** -* TilemapLayer constructor -* Create a new TilemapLayer. -* -* @param parent {Tilemap} The tilemap that contains this layer. -* @param id {number} The ID of this layer within the Tilemap array. -* @param key {string} Asset key for this map. -* @param mapFormat {number} Format of this map data, available: Tilemap.CSV or Tilemap.JSON. -* @param name {string} Name of this layer, so you can get this layer by its name. -* @param tileWidth {number} Width of tiles in this map. -* @param tileHeight {number} Height of tiles in this map. -*/ -Phaser.TilemapLayer = function (parent, id, key, mapFormat, name, tileWidth, tileHeight) { + }, /** - * Controls whether update() and draw() are automatically called. - * @type {bool} - */ - this.exists = true; - - /** - * Controls whether draw() are automatically called. - * @type {bool} - */ - this.visible = true; - - /** - * How many tiles in each row. - * Read-only variable, do NOT recommend changing after the map is loaded! - * @type {number} - */ - this.widthInTiles = 0; - - /** - * How many tiles in each column. - * Read-only variable, do NOT recommend changing after the map is loaded! - * @type {number} - */ - this.heightInTiles = 0; - - /** - * Read-only variable, do NOT recommend changing after the map is loaded! - * @type {number} - */ - this.widthInPixels = 0; - - /** - * Read-only variable, do NOT recommend changing after the map is loaded! - * @type {number} - */ - this.heightInPixels = 0; - - /** - * Distance between REAL tiles to the tileset texture bound. - * @type {number} - */ - this.tileMargin = 0; - - /** - * Distance between every 2 neighbor tile in the tileset texture. - * @type {number} - */ - this.tileSpacing = 0; - - this.parent = parent; - this.game = parent.game; - this.ID = id; - this.name = name; - this.key = key; - this.type = Phaser.TILEMAPLAYER; - - this.mapFormat = mapFormat; - this.tileWidth = tileWidth; - this.tileHeight = tileHeight; - - this.boundsInTiles = new Phaser.Rectangle(); - - var map = this.game.cache.getTilemap(key); - - this.tileset = map.data; - - this._alpha = 1; - - this.canvas = null; - this.context = null; - this.baseTexture = null; - this.texture = null; - this.sprite = null; - - this.mapData = []; - this._tempTileBlock = []; - this._tempBlockResults = []; - -}; - -Phaser.TilemapLayer.prototype = { - - /** * Set a specific tile with its x and y in tiles. - * @param x {number} X position of this tile in world coordinates. - * @param y {number} Y position of this tile in world coordinates. - * @param index {number} The index of this tile type in the core map data. + * @method putTile + * @param {number} x - X position of this tile. + * @param {number} y - Y position of this tile. + * @param {number} index - The index of this tile type in the core map data. */ - putTileWorldXY: function (x, y, index) { + putTile: function (index, x, y, layer) { - x = this.game.math.snapToFloor(x, this.tileWidth) / this.tileWidth; - y = this.game.math.snapToFloor(y, this.tileHeight) / this.tileHeight; + if (typeof layer === "undefined") { layer = this.currentLayer; } - if (y >= 0 && y < this.mapData.length) + if (x >= 0 && x < this.layers[this.currentLayer].width && y >= 0 && y < this.layers[this.currentLayer].height) + { + this.layers[this.currentLayer].data[y][x] = index; + } + + this.dirty = true; + + }, + + getTile: function (x, y, layer) { + + if (typeof layer === "undefined") { layer = this.currentLayer; } + + if (x >= 0 && x < this.layers[this.currentLayer].width && y >= 0 && y < this.layers[this.currentLayer].height) { - if (x >= 0 && x < this.mapData[y].length) - { - this.mapData[y][x] = index; - } + return this.layers[this.currentLayer].data[y][x]; } }, - /** + getTileWorldXY: function (x, y, tileWidth, tileHeight, layer) { + + if (typeof layer === "undefined") { layer = this.currentLayer; } + + x = this.game.math.snapToFloor(x, tileWidth) / tileWidth; + y = this.game.math.snapToFloor(y, tileHeight) / tileHeight; + + if (x >= 0 && x < this.layers[this.currentLayer].width && y >= 0 && y < this.layers[this.currentLayer].height) + { + return this.layers[this.currentLayer].data[y][x]; + } + + }, + + /** * Set a specific tile with its x and y in tiles. - * @param x {number} X position of this tile. - * @param y {number} Y position of this tile. - * @param index {number} The index of this tile type in the core map data. + * @method putTileWorldXY + * @param {number} x - X position of this tile in world coordinates. + * @param {number} y - Y position of this tile in world coordinates. + * @param {number} index - The index of this tile type in the core map data. */ - putTile: function (x, y, index) { + putTileWorldXY: function (index, x, y, tileWidth, tileHeight, layer) { - if (y >= 0 && y < this.mapData.length) + x = this.game.math.snapToFloor(x, tileWidth) / tileWidth; + y = this.game.math.snapToFloor(y, tileHeight) / tileHeight; + + if (x >= 0 && x < this.layers[this.currentLayer].width && y >= 0 && y < this.layers[this.currentLayer].height) { - if (x >= 0 && x < this.mapData[y].length) - { - this.mapData[y][x] = index; - } + this.layers[this.currentLayer].data[y][x] = index; } + this.dirty = true; + }, - /** - * Swap tiles with 2 kinds of indexes. - * @param tileA {number} First tile index. - * @param tileB {number} Second tile index. - * @param [x] {number} specify a Rectangle of tiles to operate. The x position in tiles of Rectangle's left-top corner. - * @param [y] {number} specify a Rectangle of tiles to operate. The y position in tiles of Rectangle's left-top corner. - * @param [width] {number} specify a Rectangle of tiles to operate. The width in tiles. - * @param [height] {number} specify a Rectangle of tiles to operate. The height in tiles. - */ - swapTile: function (tileA, tileB, x, y, width, height) { + // Values are in TILEs, not pixels. + copy: function (x, y, width, height, layer) { - x = x || 0; - y = y || 0; - width = width || this.widthInTiles; - height = height || this.heightInTiles; - - this.getTempBlock(x, y, width, height); + if (typeof layer === "undefined") { layer = this.currentLayer; } - for (var r = 0; r < this._tempTileBlock.length; r++) + if (!this.layers[layer]) { - // First sweep marking tileA as needing a new index - if (this._tempTileBlock[r].tile.index == tileA) - { - this._tempTileBlock[r].newIndex = true; - } - - // In the same pass we can swap tileB to tileA - if (this._tempTileBlock[r].tile.index == tileB) - { - this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileA; - } + this._results.length = 0; + return; } - for (var r = 0; r < this._tempTileBlock.length; r++) - { - // And now swap our newIndex tiles for tileB - if (this._tempTileBlock[r].newIndex == true) - { - this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileB; - } - } - - }, - - /** - * Fill a tile block with a specific tile index. - * @param index {number} Index of tiles you want to fill with. - * @param [x] {number} x position (in tiles) of block's left-top corner. - * @param [y] {number} y position (in tiles) of block's left-top corner. - * @param [width] {number} width of block. - * @param [height] {number} height of block. - */ - fillTile: function (index, x, y, width, height) { - - x = x || 0; - y = y || 0; - width = width || this.widthInTiles; - height = height || this.heightInTiles; - - this.getTempBlock(x, y, width, height); - - for (var r = 0; r < this._tempTileBlock.length; r++) - { - this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = index; - } - - }, - - /** - * Set random tiles to a specific tile block. - * @param tiles {number[]} Tiles with indexes in this array will be randomly set to the given block. - * @param [x] {number} x position (in tiles) of block's left-top corner. - * @param [y] {number} y position (in tiles) of block's left-top corner. - * @param [width] {number} width of block. - * @param [height] {number} height of block. - */ - randomiseTiles: function (tiles, x, y, width, height) { - - x = x || 0; - y = y || 0; - width = width || this.widthInTiles; - height = height || this.heightInTiles; - - this.getTempBlock(x, y, width, height); - - for (var r = 0; r < this._tempTileBlock.length; r++) - { - this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = this.game.math.getRandom(tiles); - } - - }, - - /** - * Replace one kind of tiles to another kind. - * @param tileA {number} Index of tiles you want to replace. - * @param tileB {number} Index of tiles you want to set. - * @param [x] {number} x position (in tiles) of block's left-top corner. - * @param [y] {number} y position (in tiles) of block's left-top corner. - * @param [width] {number} width of block. - * @param [height] {number} height of block. - */ - replaceTile: function (tileA, tileB, x, y, width, height) { - - x = x || 0; - y = y || 0; - width = width || this.widthInTiles; - height = height || this.heightInTiles; - - this.getTempBlock(x, y, width, height); - - for (var r = 0; r < this._tempTileBlock.length; r++) - { - if (this._tempTileBlock[r].tile.index == tileA) - { - this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileB; - } - } - - }, - - /** - * Get a tile block with specific position and size.(both are in tiles) - * @param x {number} X position of block's left-top corner. - * @param y {number} Y position of block's left-top corner. - * @param width {number} Width of block. - * @param height {number} Height of block. - */ - getTileBlock: function (x, y, width, height) { - - var output = []; - - this.getTempBlock(x, y, width, height); - - for (var r = 0; r < this._tempTileBlock.length; r++) - { - output.push({ - x: this._tempTileBlock[r].x, - y: this._tempTileBlock[r].y, - tile: this._tempTileBlock[r].tile - }); - } - - return output; - - }, - - /** - * Get a tile with specific position (in world coordinate). (thus you give a position of a point which is within the tile) - * @param x {number} X position of the point in target tile. - * @param x {number} Y position of the point in target tile. - */ - getTileFromWorldXY: function (x, y) { - - x = Phaser.Math.snapToFloor(x, this.tileWidth) / this.tileWidth; - y = Phaser.Math.snapToFloor(y, this.tileHeight) / this.tileHeight; - - return this.getTileIndex(x, y); - - }, - - /** - * Get tiles overlaps the given object. - * @param object {GameObject} Tiles you want to get that overlaps this. - * @return {array} Array with tiles informations. (Each contains x, y and the tile.) - */ - getTileOverlaps: function (object) { - - this._tempBlockResults.length = 0; - - // If the object is outside of the world coordinates then abort the check (tilemap has to exist within world bounds) - if (object.body.x < 0 || object.body.x > this.widthInPixels || object.body.y < 0 || object.body.bottom > this.heightInPixels) - { - return this._tempBlockResults; - } - - // What tiles do we need to check against? - this._tempTileX = this.game.math.snapToFloor(object.body.x, this.tileWidth) / this.tileWidth; - this._tempTileY = this.game.math.snapToFloor(object.body.y, this.tileHeight) / this.tileHeight; - this._tempTileW = (this.game.math.snapToCeil(object.body.width, this.tileWidth) + this.tileWidth) / this.tileWidth; - this._tempTileH = (this.game.math.snapToCeil(object.body.height, this.tileHeight) + this.tileHeight) / this.tileHeight; - - // Loop through the tiles we've got and check overlaps accordingly (the results are stored in this._tempTileBlock) - this.getTempBlock(this._tempTileX, this._tempTileY, this._tempTileW, this._tempTileH, true); - - for (var r = 0; r < this._tempTileBlock.length; r++) - { - // separateTile: function (object, x, y, width, height, mass, collideLeft, collideRight, collideUp, collideDown, separateX, separateY) - if (this.game.physics.separateTile(object, this._tempTileBlock[r].x * this.tileWidth, this._tempTileBlock[r].y * this.tileHeight, this.tileWidth, this.tileHeight, this._tempTileBlock[r].tile.mass, this._tempTileBlock[r].tile.collideLeft, this._tempTileBlock[r].tile.collideRight, this._tempTileBlock[r].tile.collideUp, this._tempTileBlock[r].tile.collideDown, this._tempTileBlock[r].tile.separateX, this._tempTileBlock[r].tile.separateY)) - { - this._tempBlockResults.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile }); - } - } - - return this._tempBlockResults; - - }, - - /** - * Get a tile block with its position and size. (This method does not return, it'll set result to _tempTileBlock) - * @param x {number} X position of block's left-top corner. - * @param y {number} Y position of block's left-top corner. - * @param width {number} Width of block. - * @param height {number} Height of block. - * @param collisionOnly {bool} Whethor or not ONLY return tiles which will collide (its allowCollisions value is not Collision.NONE). - */ - getTempBlock: function (x, y, width, height, collisionOnly) { - - if (typeof collisionOnly === "undefined") { collisionOnly = false; } + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof width === "undefined") { width = this.layers[layer].width; } + if (typeof height === "undefined") { height = this.layers[layer].height; } if (x < 0) { @@ -28460,464 +33698,1354 @@ Phaser.TilemapLayer.prototype = { y = 0; } - if (width > this.widthInTiles) + if (width > this.layers[layer].width) { - width = this.widthInTiles; + width = this.layers[layer].width; } - if (height > this.heightInTiles) + if (height > this.layers[layer].height) { - height = this.heightInTiles; + height = this.layers[layer].height; } - this._tempTileBlock = []; + this._results.length = 0; + + this._results.push( { x: x, y: y, width: width, height: height, layer: layer }); for (var ty = y; ty < y + height; ty++) { for (var tx = x; tx < x + width; tx++) { - if (collisionOnly) + this._results.push({ x: tx, y: ty, index: this.layers[layer].data[ty][tx] }); + } + } + + return this._results; + + }, + + paste: function (x, y, tileblock, layer) { + + if (typeof x === "undefined") { x = 0; } + if (typeof y === "undefined") { y = 0; } + if (typeof layer === "undefined") { layer = this.currentLayer; } + + if (!tileblock || tileblock.length < 2) + { + return; + } + + // Find out the difference between tileblock[1].x/y and x/y and use it as an offset, as it's the top left of the block to paste + var diffX = tileblock[1].x - x; + var diffY = tileblock[1].y - y; + + for (var i = 1; i < tileblock.length; i++) + { + this.layers[layer].data[ diffY + tileblock[i].y ][ diffX + tileblock[i].x ] = tileblock[i].index; + } + + this.dirty = true; + + }, + + /** + * Swap tiles with 2 kinds of indexes. + * @method swapTile + * @param {number} tileA - First tile index. + * @param {number} tileB - Second tile index. + * @param {number} [x] - specify a Rectangle of tiles to operate. The x position in tiles of Rectangle's left-top corner. + * @param {number} [y] - specify a Rectangle of tiles to operate. The y position in tiles of Rectangle's left-top corner. + * @param {number} [width] - specify a Rectangle of tiles to operate. The width in tiles. + * @param {number} [height] - specify a Rectangle of tiles to operate. The height in tiles. + */ + swap: function (tileA, tileB, x, y, width, height, layer) { + + this.copy(x, y, width, height, layer); + + if (this._results.length < 2) + { + return; + } + + this._tempA = tileA; + this._tempB = tileB; + + this._results.forEach(this.swapHandler, this); + + this.paste(x, y, this._results); + + }, + + swapHandler: function (value, index, array) { + + if (value.index === this._tempA) + { + this._results[index].index = this._tempB; + } + else if (value.index === this._tempB) + { + this._results[index].index = this._tempA; + } + + }, + + /** + * Swap tiles with 2 kinds of indexes. + * @method swapTile + * @param {number} tileA - First tile index. + * @param {number} tileB - Second tile index. + * @param {number} [x] - specify a Rectangle of tiles to operate. The x position in tiles of Rectangle's left-top corner. + * @param {number} [y] - specify a Rectangle of tiles to operate. The y position in tiles of Rectangle's left-top corner. + * @param {number} [width] - specify a Rectangle of tiles to operate. The width in tiles. + * @param {number} [height] - specify a Rectangle of tiles to operate. The height in tiles. + */ + forEach: function (callback, context, x, y, width, height, layer) { + + this.copy(x, y, width, height, layer); + + if (this._results.length < 2) + { + return; + } + + this._results.forEach(callback, context); + + this.paste(x, y, this._results); + + }, + + /** + * Replaces one type of tile with another. + * @method replace + * @param {number} tileA - First tile index. + * @param {number} tileB - Second tile index. + * @param {number} [x] - specify a Rectangle of tiles to operate. The x position in tiles of Rectangle's left-top corner. + * @param {number} [y] - specify a Rectangle of tiles to operate. The y position in tiles of Rectangle's left-top corner. + * @param {number} [width] - specify a Rectangle of tiles to operate. The width in tiles. + * @param {number} [height] - specify a Rectangle of tiles to operate. The height in tiles. + */ + replace: function (tileA, tileB, x, y, width, height, layer) { + + this.copy(x, y, width, height, layer); + + if (this._results.length < 2) + { + return; + } + + for (var i = 1; i < this._results.length; i++) + { + if (this._results[i].index === tileA) + { + this._results[i].index = tileB; + } + } + + this.paste(x, y, this._results); + + }, + + /** + * Randomises a set of tiles in a given area. It will only randomise the tiles in that area, so if they're all the same nothing will appear to have changed! + * @method random + * @param {number} tileA - First tile index. + * @param {number} tileB - Second tile index. + * @param {number} [x] - specify a Rectangle of tiles to operate. The x position in tiles of Rectangle's left-top corner. + * @param {number} [y] - specify a Rectangle of tiles to operate. The y position in tiles of Rectangle's left-top corner. + * @param {number} [width] - specify a Rectangle of tiles to operate. The width in tiles. + * @param {number} [height] - specify a Rectangle of tiles to operate. The height in tiles. + */ + random: function (x, y, width, height, layer) { + + if (typeof layer === "undefined") { layer = this.currentLayer; } + + this.copy(x, y, width, height, layer); + + if (this._results.length < 2) + { + return; + } + + var indexes = []; + + for (var t = 1; t < this._results.length; t++) + { + var idx = this._results[t].index; + + if (indexes.indexOf(idx) === -1) + { + indexes.push(idx); + } + } + + for (var i = 1; i < this._results.length; i++) + { + this._results[i].index = this.game.rnd.pick(indexes); + } + + this.paste(x, y, this._results); + + }, + + /** + * Randomises a set of tiles in a given area. It will only randomise the tiles in that area, so if they're all the same nothing will appear to have changed! + * @method random + * @param {number} tileA - First tile index. + * @param {number} tileB - Second tile index. + * @param {number} [x] - specify a Rectangle of tiles to operate. The x position in tiles of Rectangle's left-top corner. + * @param {number} [y] - specify a Rectangle of tiles to operate. The y position in tiles of Rectangle's left-top corner. + * @param {number} [width] - specify a Rectangle of tiles to operate. The width in tiles. + * @param {number} [height] - specify a Rectangle of tiles to operate. The height in tiles. + */ + shuffle: function (x, y, width, height, layer) { + + if (typeof layer === "undefined") { layer = this.currentLayer; } + + this.copy(x, y, width, height, layer); + + if (this._results.length < 2) + { + return; + } + + var header = this._results.shift(); + + Phaser.Utils.shuffle(this._results); + + this._results.unshift(header); + + this.paste(x, y, this._results); + + }, + + /** + * Fill a tile block with a specific tile index. + * @method fill + * @param {number} index - Index of tiles you want to fill with. + * @param {number} [x] - X position (in tiles) of block's left-top corner. + * @param {number} [y] - Y position (in tiles) of block's left-top corner. + * @param {number} [width] - width of block. + * @param {number} [height] - height of block. + */ + fill: function (index, x, y, width, height, layer) { + + this.copy(x, y, width, height, layer); + + if (this._results.length < 2) + { + return; + } + + for (var i = 1; i < this._results.length; i++) + { + this._results[i].index = index; + } + + this.paste(x, y, this._results); + + }, + + removeAllLayers: function () { + + this.layers.length = 0; + this.currentLayer = 0; + + }, + + dump: function () { + + var txt = ''; + var args = ['']; + + for (var y = 0; y < this.layers[this.currentLayer].height; y++) + { + for (var x = 0; x < this.layers[this.currentLayer].width; x++) + { + txt += "%c "; + + if (this.layers[this.currentLayer].data[y][x] > 1) { - // We only want to consider the tile for checking if you can actually collide with it - if (this.mapData[ty] && this.mapData[ty][tx] && this.parent.tiles[this.mapData[ty][tx]].collideNone == false) - { - this._tempTileBlock.push({ - x: tx, - y: ty, - tile: this.parent.tiles[this.mapData[ty][tx]] - }); - } + if (this.debugMap[this.layers[this.currentLayer].data[y][x]]) + { + args.push("background: " + this.debugMap[this.layers[this.currentLayer].data[y][x]]); + } + else + { + args.push("background: #ffffff"); + } } else { - if (this.mapData[ty] && this.mapData[ty][tx]) - { - this._tempTileBlock.push({ - x: tx, - y: ty, - tile: this.parent.tiles[this.mapData[ty][tx]] - }); - } + args.push("background: rgb(0, 0, 0)"); + } + } + + txt += "\n"; + } + + args[0] = txt; + console.log.apply(console, args); + + }, + + destroy: function () { + + this.removeAllLayers(); + this.game = null; + + } + +}; + +// Maybe should extend Sprite? +Phaser.TilemapLayer = function (game, x, y, renderWidth, renderHeight, tileset, tilemap, layer) { + + /** + * @property {Phaser.Game} game - Description. + */ + this.game = game; + + /** + * @property {Description} canvas - Description. + * @default + */ + this.canvas = Phaser.Canvas.create(renderWidth, renderHeight); + + /** + * @property {Description} context - Description. + * @default + */ + this.context = this.canvas.getContext('2d'); + + /** + * @property {Description} baseTexture - Description. + * @default + */ + this.baseTexture = new PIXI.BaseTexture(this.canvas); + + /** + * @property {Description} texture - Description. + * @default + */ + this.texture = new PIXI.Texture(this.baseTexture); + + this.textureFrame = new Phaser.Frame(0, 0, 0, renderWidth, renderHeight, 'tilemaplayer', game.rnd.uuid()); + + Phaser.Sprite.call(this, this.game, x, y, this.texture, this.textureFrame); + + this.type = Phaser.TILEMAPLAYER; + + this.fixedToCamera = true; + + /** + * @property {Description} tileset - Description. + */ + this.tileset = null; + + this.tileWidth = 0; + this.tileHeight = 0; + this.tileMargin = 0; + this.tileSpacing = 0; + + /** + * Read-only variable, do NOT recommend changing after the map is loaded! + * @property {number} widthInPixels + * @default + */ + this.widthInPixels = 0; + + /** + * Read-only variable, do NOT recommend changing after the map is loaded! + * @property {number} heightInPixels + * @default + */ + this.heightInPixels = 0; + + + this.renderWidth = renderWidth; + this.renderHeight = renderHeight; + + /** + * @property {number} _ga - Local render loop var to help avoid gc spikes. + * @private + */ + this._ga = 1; + + /** + * @property {number} _dx - Local render loop var to help avoid gc spikes. + * @private + */ + this._dx = 0; + + /** + * @property {number} _dy - Local render loop var to help avoid gc spikes. + * @private + */ + this._dy = 0; + + /** + * @property {number} _dw - Local render loop var to help avoid gc spikes. + * @private + */ + this._dw = 0; + + /** + * @property {number} _dh - Local render loop var to help avoid gc spikes. + * @private + */ + this._dh = 0; + + /** + * @property {number} _tx - Local render loop var to help avoid gc spikes. + * @private + */ + this._tx = 0; + + /** + * @property {number} _ty - Local render loop var to help avoid gc spikes. + * @private + */ + this._ty = 0; + + this._results = []; + + this._tw = 0; + this._th = 0; + + /** + * @property {number} _tl - Local render loop var to help avoid gc spikes. + * @private + */ + this._tl = 0; + + /** + * @property {number} _maxX - Local render loop var to help avoid gc spikes. + * @private + */ + this._maxX = 0; + + /** + * @property {number} _maxY - Local render loop var to help avoid gc spikes. + * @private + */ + this._maxY = 0; + + /** + * @property {number} _startX - Local render loop var to help avoid gc spikes. + * @private + */ + this._startX = 0; + + /** + * @property {number} _startY - Local render loop var to help avoid gc spikes. + * @private + */ + this._startY = 0; + + this.tilemap = null; + this.layer = null; + this.index = 0; + + this._x = 0; + this._y = 0; + this._prevX = 0; + this._prevY = 0; + + this.dirty = true; + + if (tileset instanceof Phaser.Tileset || typeof tileset === 'string') + { + this.updateTileset(tileset); + } + + if (tilemap instanceof Phaser.Tilemap) + { + this.updateMapData(tilemap, layer); + } + +}; + +Phaser.TilemapLayer.prototype = Phaser.Utils.extend(true, Phaser.Sprite.prototype, PIXI.Sprite.prototype); +Phaser.TilemapLayer.prototype.constructor = Phaser.TilemapLayer; + + +Phaser.TilemapLayer.prototype.update = function () { + + this.scrollX = this.game.camera.x; + this.scrollY = this.game.camera.y; + + this.render(); + +} + +Phaser.TilemapLayer.prototype.resizeWorld = function () { + + this.game.world.setBounds(0, 0, this.widthInPixels, this.heightInPixels); + +} + +Phaser.TilemapLayer.prototype.updateTileset = function (tileset) { + + if (tileset instanceof Phaser.Tileset) + { + this.tileset = tileset; + } + else if (typeof tileset === 'string') + { + this.tileset = this.game.cache.getTileset('tiles'); + } + else + { + return; + } + + this.tileWidth = this.tileset.tileWidth; + this.tileHeight = this.tileset.tileHeight; + this.tileMargin = this.tileset.tileMargin; + this.tileSpacing = this.tileset.tileSpacing; + + this.updateMax(); + +} + +Phaser.TilemapLayer.prototype.updateMapData = function (tilemap, layer) { + + if (typeof layer === 'undefined') + { + layer = 0; + } + + if (tilemap instanceof Phaser.Tilemap) + { + this.tilemap = tilemap; + this.layer = this.tilemap.layers[layer]; + this.index = layer; + this.updateMax(); + this.tilemap.dirty = true; + } + +} + +/** +* Convert a pixel value to a tile coordinate. +* @param {number} x - X position of the point in target tile. +* @param {number} [layer] - layer of this tile located. +* @return {number} The tile with specific properties. +*/ +Phaser.TilemapLayer.prototype.getTileX = function (x) { + + var tileWidth = this.tileWidth * this.scale.x; + + return this.game.math.snapToFloor(x, tileWidth) / tileWidth; + +} + +/** +* Convert a pixel value to a tile coordinate. +* @param {number} x - X position of the point in target tile. +* @param {number} [layer] - layer of this tile located. +* @return {number} The tile with specific properties. +*/ +Phaser.TilemapLayer.prototype.getTileY = function (y) { + + var tileHeight = this.tileHeight * this.scale.y; + + return this.game.math.snapToFloor(y, tileHeight) / tileHeight; + +} + +Phaser.TilemapLayer.prototype.getTileXY = function (x, y, point) { + + point.x = this.getTileX(x); + point.y = this.getTileY(y); + + return point; + +} + +/** +* +* @method getTileOverlaps +* @param {GameObject} object - Tiles you want to get that overlaps this. +* @return {array} Array with tiles informations (each contains x, y, and the tile). +*/ +Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides) { + + if (this.tilemap === null) + { + return; + } + + // Should we only get tiles that have at least one of their collision flags set? (true = yes, false = no just get them all) + if (typeof collides === 'undefined') { collides = false; } + + // Cap the values + + if (x < 0) + { + x = 0; + } + + if (y < 0) + { + y = 0; + } + + if (width > this.widthInPixels) + { + width = this.widthInPixels; + } + + if (height > this.heightInPixels) + { + height = this.heightInPixels; + } + + var tileWidth = this.tileWidth * this.scale.x; + var tileHeight = this.tileHeight * this.scale.y; + + // Convert the pixel values into tile coordinates + this._tx = this.game.math.snapToFloor(x, tileWidth) / tileWidth; + this._ty = this.game.math.snapToFloor(y, tileHeight) / tileHeight; + this._tw = (this.game.math.snapToCeil(width, tileWidth) + tileWidth) / tileWidth; + this._th = (this.game.math.snapToCeil(height, tileHeight) + tileHeight) / tileHeight; + + this._results.length = 0; + + // pretty sure we don't use this any more? + this._results.push( { x: x, y: y, width: width, height: height, tx: this._tx, ty: this._ty, tw: this._tw, th: this._th }); + + var _index = 0; + var _tile = null; + var sx = 0; + var sy = 0; + + for (var wy = this._ty; wy < this._ty + this._th; wy++) + { + for (var wx = this._tx; wx < this._tx + this._tw; wx++) + { + if (this.layer.data[wy] && this.layer.data[wy][wx]) + { + // Could combine + _index = this.layer.data[wy][wx] - 1; + _tile = this.tileset.getTile(_index); + + sx = _tile.width * this.scale.x; + sy = _tile.height * this.scale.y; + + if (collides == false || (collides && _tile.collideNone == false)) + { + this._results.push({ x: wx * sx, right: (wx * sx) + sx, y: wy * sy, bottom: (wy * sy) + sy, width: sx, height: sy, tx: wx, ty: wy, tile: _tile }); } } } - }, - - /** - * Get the tile index of specific position (in tiles). - * @param x {number} X position of the tile. - * @param y {number} Y position of the tile. - * @return {number} Index of the tile at that position. Return null if there isn't a tile there. - */ - getTileIndex: function (x, y) { - - if (y >= 0 && y < this.mapData.length) - { - if (x >= 0 && x < this.mapData[y].length) - { - return this.mapData[y][x]; - } - } - - return null; - - }, - - /** - * Add a column of tiles into the layer. - * @param column {string[]/number[]} An array of tile indexes to be added. - */ - addColumn: function (column) { - - var data = []; - - for (var c = 0; c < column.length; c++) - { - data[c] = parseInt(column[c]); - } - - if (this.widthInTiles == 0) - { - this.widthInTiles = data.length; - this.widthInPixels = this.widthInTiles * this.tileWidth; - } - - this.mapData.push(data); - - this.heightInTiles++; - this.heightInPixels += this.tileHeight; - - }, - - createCanvas: function () { - - var width = this.game.width; - var height = this.game.height; - - if (this.widthInPixels < width) - { - width = this.widthInPixels; - } - - if (this.heightInPixels < height) - { - height = this.heightInPixels; - } - - this.canvas = Phaser.Canvas.create(width, height); - this.context = this.canvas.getContext('2d'); - - this.baseTexture = new PIXI.BaseTexture(this.canvas); - this.texture = new PIXI.Texture(this.baseTexture); - this.sprite = new PIXI.Sprite(this.texture); - - this.parent.addChild(this.sprite); - - }, - - /** - * Update boundsInTiles with widthInTiles and heightInTiles. - */ - updateBounds: function () { - - this.boundsInTiles.setTo(0, 0, this.widthInTiles, this.heightInTiles); - - }, - - /** - * Parse tile offsets from map data. - * Basically this creates a large array of objects that contain the x/y coordinates to grab each tile from - * for the entire map. Yes we could calculate this at run-time by using the tile index and some math, but we're - * trading a quite small bit of memory here to not have to process that in our main render loop. - * @return {number} length of tileOffsets array. - */ - parseTileOffsets: function () { - - this.tileOffsets = []; - - var i = 0; - - if (this.mapFormat == Phaser.Tilemap.JSON) - { - // For some reason Tiled counts from 1 not 0 - this.tileOffsets[0] = null; - i = 1; - } - - for (var ty = this.tileMargin; ty < this.tileset.height; ty += (this.tileHeight + this.tileSpacing)) - { - for (var tx = this.tileMargin; tx < this.tileset.width; tx += (this.tileWidth + this.tileSpacing)) - { - this.tileOffsets[i] = { - x: tx, - y: ty - }; - i++; - } - } - - return this.tileOffsets.length; - } -}; + return this._results; -Object.defineProperty(Phaser.TilemapLayer.prototype, 'alpha', { +} - get: function() { - return this._alpha; - }, +Phaser.TilemapLayer.prototype.updateMax = function () { - set: function(value) { + this._maxX = this.game.math.ceil(this.canvas.width / this.tileWidth) + 1; + this._maxY = this.game.math.ceil(this.canvas.height / this.tileHeight) + 1; - if (this.sprite) + if (this.layer) + { + if (this._maxX > this.layer.width) { - this.sprite.alpha = value; + this._maxX = this.layer.width; } - - this._alpha = value; + + if (this._maxY > this.layer.height) + { + this._maxY = this.layer.height; + } + + this.widthInPixels = this.layer.width * this.tileWidth; + this.heightInPixels = this.layer.height * this.tileHeight; } -}); + this.dirty = true; -/** -* Phaser - Tile -* -* A Tile is a single representation of a tile within a Tilemap -*/ +} -/** -* Tile constructor -* Create a new Tile. -* -* @param tilemap {Tilemap} the tilemap this tile belongs to. -* @param index {number} The index of this tile type in the core map data. -* @param width {number} Width of the tile. -* @param height number} Height of the tile. -*/ -Phaser.Tile = function (game, tilemap, index, width, height) { - - /** - * The virtual mass of the tile. - * @type {number} - */ - this.mass = 1.0; - - /** - * Indicating this Tile doesn't collide at all. - * @type {bool} - */ - this.collideNone = true; - - /** - * Indicating collide with any object on the left. - * @type {bool} - */ - this.collideLeft = false; - - /** - * Indicating collide with any object on the right. - * @type {bool} - */ - this.collideRight = false; - - /** - * Indicating collide with any object on the top. - * @type {bool} - */ - this.collideUp = false; - - /** - * Indicating collide with any object on the bottom. - * @type {bool} - */ - this.collideDown = false; - - /** - * Enable separation at x-axis. - * @type {bool} - */ - this.separateX = true; - - /** - * Enable separation at y-axis. - * @type {bool} - */ - this.separateY = true; - - this.game = game; - this.tilemap = tilemap; - this.index = index; - this.width = width; - this.height = height; - -}; - -Phaser.Tile.prototype = { - - /** - * Clean up memory. - */ - destroy: function () { - this.tilemap = null; - }, - - /** - * Set collision configs. - * @param collision {number} Bit field of flags. (see Tile.allowCollision) - * @param resetCollisions {bool} Reset collision flags before set. - * @param separateX {bool} Enable seprate at x-axis. - * @param separateY {bool} Enable seprate at y-axis. - */ - setCollision: function (left, right, up, down, reset, separateX, separateY) { - - if (reset) - { - this.resetCollision(); - } - - this.separateX = separateX; - this.separateY = separateY; - - this.collideNone = true; - this.collideLeft = left; - this.collideRight = right; - this.collideUp = up; - this.collideDown = down; - - if (left || right || up || down) - { - this.collideNone = false; - } - - }, - - /** - * Reset collision status flags. - */ - resetCollision: function () { - - this.collideNone = true; - this.collideLeft = false; - this.collideRight = false; - this.collideUp = false; - this.collideDown = false; - - }, - - /** - * Returns a string representation of this object. - * @method toString - * @return {string} a string representation of the object. - **/ - toString: function () { - - // return "[{Tile (index=" + this.index + " collisions=" + this.allowCollisions + " width=" + this.width + " height=" + this.height + ")}]"; - return ''; +Phaser.TilemapLayer.prototype.render = function () { + if (this.tilemap && this.tilemap.dirty) + { + this.dirty = true; } -}; -Phaser.TilemapRenderer = function (game) { + if (!this.dirty || !this.tileset || !this.tilemap || !this.visible) + { + return; + } - this.game = game; + this._prevX = this._dx; + this._prevY = this._dy; - // Local rendering related temp vars to help avoid gc spikes through constant var creation - this._ga = 1; - this._dx = 0; - this._dy = 0; - this._dw = 0; - this._dh = 0; - this._tx = 0; - this._ty = 0; - this._tl = 0; - this._maxX = 0; - this._maxY = 0; - this._startX = 0; - this._startY = 0; - -}; + this._dx = -(this._x - (this._startX * this.tileWidth)); + this._dy = -(this._y - (this._startY * this.tileHeight)); -Phaser.TilemapRenderer.prototype = { + this._tx = this._dx; + this._ty = this._dy; - /** - * Render a tilemap to a canvas. - * @param tilemap {Tilemap} The tilemap data to render. - */ - render: function (tilemap) { + this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); - // Loop through the layers - this._tl = tilemap.layers.length; + for (var y = this._startY; y < this._startY + this._maxY; y++) + { + this._column = this.layer.data[y]; - for (var i = 0; i < this._tl; i++) + for (var x = this._startX; x < this._startX + this._maxX; x++) { - if (tilemap.layers[i].visible == false || tilemap.layers[i].alpha < 0.1) + // only -1 on TILED maps, not CSV + var tile = this.tileset.tiles[this._column[x]-1]; + + if (tile) { - continue; + this.context.drawImage( + this.tileset.image, + tile.x, + tile.y, + this.tileWidth, + this.tileHeight, + Math.floor(this._tx), + Math.floor(this._ty), + this.tileWidth, + this.tileHeight + ); } - var layer = tilemap.layers[i]; + this._tx += this.tileWidth; - // Work out how many tiles we can fit into our canvas and round it up for the edges - this._maxX = this.game.math.ceil(layer.canvas.width / layer.tileWidth) + 1; - this._maxY = this.game.math.ceil(layer.canvas.height / layer.tileHeight) + 1; + } - // And now work out where in the tilemap the camera actually is - this._startX = this.game.math.floor(this.game.camera.x / layer.tileWidth); - this._startY = this.game.math.floor(this.game.camera.y / layer.tileHeight); + this._tx = this._dx; + this._ty += this.tileHeight; + } + + // Only needed if running in WebGL, otherwise this array will never get cleared down I don't think! + if (this.game.renderType == Phaser.WEBGL) + { + PIXI.texturesToUpdate.push(this.baseTexture); + } + + this.dirty = false; + + if (this.tilemap.dirty) + { + this.tilemap.dirty = false; + } + + return true; + +} + +Phaser.TilemapLayer.prototype.deltaAbsX = function () { + return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX()); +} + +Phaser.TilemapLayer.prototype.deltaAbsY = function () { + return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY()); +} + +Phaser.TilemapLayer.prototype.deltaX = function () { + return this._dx - this._prevX; +} + +Phaser.TilemapLayer.prototype.deltaY = function () { + return this._dy - this._prevY; +} + +Object.defineProperty(Phaser.TilemapLayer.prototype, "scrollX", { + + get: function () { + return this._x; + }, + + set: function (value) { + + if (value !== this._x && value >= 0 && this.layer) + { + this._x = value; + + if (this._x > (this.widthInPixels - this.renderWidth)) + { + this._x = this.widthInPixels - this.renderWidth; + } + + this._startX = this.game.math.floor(this._x / this.tileWidth); - // Tilemap bounds check if (this._startX < 0) { this._startX = 0; } + if (this._startX + this._maxX > this.layer.width) + { + this._startX = this.layer.width - this._maxX; + } + + this.dirty = true; + } + + } + +}); + +Object.defineProperty(Phaser.TilemapLayer.prototype, "scrollY", { + + get: function () { + return this._y; + }, + + set: function (value) { + + if (value !== this._y && value >= 0 && this.layer) + { + this._y = value; + + if (this._y > (this.heightInPixels - this.renderHeight)) + { + this._y = this.heightInPixels - this.renderHeight; + } + + this._startY = this.game.math.floor(this._y / this.tileHeight); + if (this._startY < 0) { this._startY = 0; } - if (this._maxX > layer.widthInTiles) + if (this._startY + this._maxY > this.layer.height) { - this._maxX = layer.widthInTiles; + this._startY = this.layer.height - this._maxY; } - if (this._maxY > layer.heightInTiles) - { - this._maxY = layer.heightInTiles; - } - - if (this._startX + this._maxX > layer.widthInTiles) - { - this._startX = layer.widthInTiles - this._maxX; - } - - if (this._startY + this._maxY > layer.heightInTiles) - { - this._startY = layer.heightInTiles - this._maxY; - } - - // Finally get the offset to avoid the blocky movement - this._dx = -(this.game.camera.x - (this._startX * layer.tileWidth)); - this._dy = -(this.game.camera.y - (this._startY * layer.tileHeight)); - - this._tx = this._dx; - this._ty = this._dy; - - // Alpha - if (layer.alpha !== 1) - { - this._ga = layer.context.globalAlpha; - layer.context.globalAlpha = layer.alpha; - } - - layer.context.clearRect(0, 0, layer.canvas.width, layer.canvas.height); - - for (var row = this._startY; row < this._startY + this._maxY; row++) - { - this._columnData = layer.mapData[row]; - - for (var tile = this._startX; tile < this._startX + this._maxX; tile++) - { - if (layer.tileOffsets[this._columnData[tile]]) - { - layer.context.drawImage( - layer.tileset, - layer.tileOffsets[this._columnData[tile]].x, - layer.tileOffsets[this._columnData[tile]].y, - layer.tileWidth, - layer.tileHeight, - this._tx, - this._ty, - layer.tileWidth, - layer.tileHeight - ); - } - - this._tx += layer.tileWidth; - - } - - this._tx = this._dx; - this._ty += layer.tileHeight; - - } - - if (this._ga > -1) - { - layer.context.globalAlpha = this._ga; - } - - // Only needed if running in WebGL, otherwise this array will never get cleared down I don't think! - if (this.game.renderType == Phaser.WEBGL) - { - PIXI.texturesToUpdate.push(layer.baseTexture); - } - + this.dirty = true; } - return true; - } -}; +}); + +Phaser.TilemapParser = { + + tileset: function (game, key, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing) { + + // How big is our image? + var img = game.cache.getTilesetImage(key); + + if (img == null) + { + return null; + } + + var width = img.width; + var height = img.height; + + // If no tile width/height is given, try and figure it out (won't work if the tileset has margin/spacing) + if (tileWidth <= 0) + { + tileWidth = Math.floor(-width / Math.min(-1, tileWidth)); + } + + if (tileHeight <= 0) + { + tileHeight = Math.floor(-height / Math.min(-1, tileHeight)); + } + + var row = Math.round(width / tileWidth); + var column = Math.round(height / tileHeight); + var total = row * column; + + if (tileMax !== -1) + { + total = tileMax; + } + + // Zero or smaller than tile sizes? + if (width == 0 || height == 0 || width < tileWidth || height < tileHeight || total === 0) + { + console.warn("Phaser.TilemapParser.tileSet: width/height zero or width/height < given tileWidth/tileHeight"); + return null; + } + + // Let's create some tiles + var x = tileMargin; + var y = tileMargin; + + var tileset = new Phaser.Tileset(img, key, tileWidth, tileHeight, tileMargin, tileSpacing); + + for (var i = 0; i < total; i++) + { + tileset.addTile(new Phaser.Tile(tileset, i, x, y, tileWidth, tileHeight)); + + x += tileWidth + tileSpacing; + + if (x === width) + { + x = tileMargin; + y += tileHeight + tileSpacing; + } + } + + return tileset; + + }, + + parse: function (game, data, format) { + + if (format === Phaser.Tilemap.CSV) + { + return this.parseCSV(data); + } + else if (format === Phaser.Tilemap.TILED_JSON) + { + return this.parseTiledJSON(data); + } + + }, + + /** + * Parse csv map data and generate tiles. + * + * @method Phaser.Tilemap.prototype.parseCSV + * @param {string} data - CSV map data. + */ + parseCSV: function (data) { + + // Trim any rogue whitespace from the data + data = data.trim(); + + var output = []; + var rows = data.split("\n"); + var height = rows.length; + var width = 0; + + for (var i = 0; i < rows.length; i++) + { + output[i] = []; + + var column = rows[i].split(","); + + for (var c = 0; c < column.length; c++) + { + output[i][c] = parseInt(column[c]); + } + + if (width == 0) + { + width = column.length; + } + } + + return [{ name: 'csv', width: width, height: height, alpha: 1, visible: true, indexes: [], tileMargin: 0, tileSpacing: 0, data: output }]; + + }, + + /** + * Parse JSON map data and generate tiles. + * + * @method Phaser.Tilemap.prototype.parseTiledJSON + * @param {string} data - JSON map data. + * @param {string} key - Asset key for tileset image. + */ + parseTiledJSON: function (json) { + + var layers = []; + + for (var i = 0; i < json.layers.length; i++) + { + // Check it's a data layer + if (!json.layers[i].data) + { + continue; + } + + // json.tilewidth + // json.tileheight + + var layer = { + + name: json.layers[i].name, + width: json.layers[i].width, + height: json.layers[i].height, + alpha: json.layers[i].opacity, + visible: json.layers[i].visible, + indexes: [], + + tileMargin: json.tilesets[0].margin, + tileSpacing: json.tilesets[0].spacing, + + }; + + var output = []; + var c = 0; + var row; + + for (var t = 0; t < json.layers[i].data.length; t++) + { + if (c == 0) + { + row = []; + } + + row.push(json.layers[i].data[t]); + c++; + + if (c == json.layers[i].width) + { + output.push(row); + c = 0; + } + } + + layer.data = output; + + layers.push(layer); + + } + + return layers; + + } + +} + + +Phaser.Tileset = function (image, key, tileWidth, tileHeight, tileMargin, tileSpacing) { + + if (typeof tileMargin === "undefined") { tileMargin = 0; } + if (typeof tileSpacing === "undefined") { tileSpacing = 0; } + + /** + * @property {string} key - The cache ID. + */ + this.key = key; + + this.image = image; + + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; + this.margin = tileMargin; + this.spacing = tileSpacing; + + this.tiles = []; + +} + +Phaser.Tileset.prototype = { + + addTile: function (tile) { + + this.tiles.push(tile); + + return tile; + + }, + + getTile: function (index) { + + if (this.tiles[index]) + { + return this.tiles[index]; + } + + return null; + + }, + + setSpacing: function (margin, spacing) { + + this.tileMargin = margin; + this.tileSpacing = spacing; + + }, + + canCollide: function (index) { + + if (this.tiles[index]) + { + return this.tiles[index].collideNone; + } + + return null; + + }, + + checkTileIndex: function (index) { + + return (this.tiles[index]); + + }, + + setCollisionRange: function (start, stop, left, right, up, down) { + + if (this.tiles[start] && this.tiles[stop] && start < stop) + { + for (var i = start; i <= stop; i++) + { + this.tiles[i].setCollision(left, right, up, down); + } + } + + }, + + setCollision: function (index, left, right, up, down) { + + if (this.tiles[index]) + { + this.tiles[index].setCollision(left, right, up, down); + } + + }, + +} + +/** +* @name Phaser.Tileset#total +* @property {number} total - The total number of tiles in this Tileset. +* @readonly +*/ +Object.defineProperty(Phaser.Tileset.prototype, "total", { + + get: function () { + return this.tiles.length; + } + +}); + +/** + * We're replacing a couple of Pixi's methods here to fix or add some vital functionality: + * + * 1) Added support for Trimmed sprite sheets + * 2) Skip display objects with an alpha of zero + * + * Hopefully we can remove this once Pixi has been updated to support these things. + */ + +PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject) +{ + // no loger recurrsive! + var transform; + var context = this.context; + + context.globalCompositeOperation = 'source-over'; + + // one the display object hits this. we can break the loop + var testObject = displayObject.last._iNext; + displayObject = displayObject.first; + + do + { + transform = displayObject.worldTransform; + + if(!displayObject.visible) + { + displayObject = displayObject.last._iNext; + continue; + } + + if(!displayObject.renderable || displayObject.alpha == 0) + { + displayObject = displayObject._iNext; + continue; + } + + if(displayObject instanceof PIXI.Sprite) + { + var frame = displayObject.texture.frame; + + if(frame) + { + context.globalAlpha = displayObject.worldAlpha; + + if (displayObject.texture.trimmed) + { + context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2] + displayObject.texture.trim.x, transform[5] + displayObject.texture.trim.y); + } + else + { + context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]); + } + + context.drawImage(displayObject.texture.baseTexture.source, + frame.x, + frame.y, + frame.width, + frame.height, + (displayObject.anchor.x) * -frame.width, + (displayObject.anchor.y) * -frame.height, + frame.width, + frame.height); + } + } + else if(displayObject instanceof PIXI.Strip) + { + context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]) + this.renderStrip(displayObject); + } + else if(displayObject instanceof PIXI.TilingSprite) + { + context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]) + this.renderTilingSprite(displayObject); + } + else if(displayObject instanceof PIXI.CustomRenderable) + { + displayObject.renderCanvas(this); + } + else if(displayObject instanceof PIXI.Graphics) + { + context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]) + PIXI.CanvasGraphics.renderGraphics(displayObject, context); + } + else if(displayObject instanceof PIXI.FilterBlock) + { + if(displayObject.open) + { + context.save(); + + var cacheAlpha = displayObject.mask.alpha; + var maskTransform = displayObject.mask.worldTransform; + + context.setTransform(maskTransform[0], maskTransform[3], maskTransform[1], maskTransform[4], maskTransform[2], maskTransform[5]) + + displayObject.mask.worldAlpha = 0.5; + + context.worldAlpha = 0; + + PIXI.CanvasGraphics.renderGraphicsMask(displayObject.mask, context); + context.clip(); + + displayObject.mask.worldAlpha = cacheAlpha; + } + else + { + context.restore(); + } + } + // count++ + displayObject = displayObject._iNext; + + + } + while(displayObject != testObject) + +} + +PIXI.WebGLBatch.prototype.update = function() +{ + var gl = this.gl; + var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index, index2, index3 + + var a, b, c, d, tx, ty; + + var indexRun = 0; + + var displayObject = this.head; + + while(displayObject) + { + if(displayObject.vcount === PIXI.visibleCount) + { + width = displayObject.texture.frame.width; + height = displayObject.texture.frame.height; + + // TODO trim?? + aX = displayObject.anchor.x;// - displayObject.texture.trim.x + aY = displayObject.anchor.y; //- displayObject.texture.trim.y + w0 = width * (1-aX); + w1 = width * -aX; + + h0 = height * (1-aY); + h1 = height * -aY; + + index = indexRun * 8; + + worldTransform = displayObject.worldTransform; + + a = worldTransform[0]; + b = worldTransform[3]; + c = worldTransform[1]; + d = worldTransform[4]; + tx = worldTransform[2]; + ty = worldTransform[5]; + + if (displayObject.texture.trimmed) + { + tx += displayObject.texture.trim.x; + ty += displayObject.texture.trim.y; + } + + this.verticies[index + 0 ] = a * w1 + c * h1 + tx; + this.verticies[index + 1 ] = d * h1 + b * w1 + ty; + + this.verticies[index + 2 ] = a * w0 + c * h1 + tx; + this.verticies[index + 3 ] = d * h1 + b * w0 + ty; + + this.verticies[index + 4 ] = a * w0 + c * h0 + tx; + this.verticies[index + 5 ] = d * h0 + b * w0 + ty; + + this.verticies[index + 6] = a * w1 + c * h0 + tx; + this.verticies[index + 7] = d * h0 + b * w1 + ty; + + if(displayObject.updateFrame || displayObject.texture.updateFrame) + { + this.dirtyUVS = true; + + var texture = displayObject.texture; + + var frame = texture.frame; + var tw = texture.baseTexture.width; + var th = texture.baseTexture.height; + + this.uvs[index + 0] = frame.x / tw; + this.uvs[index +1] = frame.y / th; + + this.uvs[index +2] = (frame.x + frame.width) / tw; + this.uvs[index +3] = frame.y / th; + + this.uvs[index +4] = (frame.x + frame.width) / tw; + this.uvs[index +5] = (frame.y + frame.height) / th; + + this.uvs[index +6] = frame.x / tw; + this.uvs[index +7] = (frame.y + frame.height) / th; + + displayObject.updateFrame = false; + } + + // TODO this probably could do with some optimisation.... + if(displayObject.cacheAlpha != displayObject.worldAlpha) + { + displayObject.cacheAlpha = displayObject.worldAlpha; + + var colorIndex = indexRun * 4; + this.colors[colorIndex] = this.colors[colorIndex + 1] = this.colors[colorIndex + 2] = this.colors[colorIndex + 3] = displayObject.worldAlpha; + this.dirtyColors = true; + } + } + else + { + index = indexRun * 8; + + this.verticies[index + 0 ] = 0; + this.verticies[index + 1 ] = 0; + + this.verticies[index + 2 ] = 0; + this.verticies[index + 3 ] = 0; + + this.verticies[index + 4 ] = 0; + this.verticies[index + 5 ] = 0; + + this.verticies[index + 6] = 0; + this.verticies[index + 7] = 0; + } + + indexRun++; + displayObject = displayObject.__next; + } +} + return Phaser; +}); diff --git a/build/phaser.min.js b/build/phaser.min.js index 88d37842..07445092 100644 --- a/build/phaser.min.js +++ b/build/phaser.min.js @@ -1 +1,10 @@ -var PIXI=PIXI||{};var Phaser=Phaser||{VERSION:"1.0.6a",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,SPRITE:0,BUTTON:1,BULLET:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11};PIXI.InteractionManager=function(b){};Phaser.Utils={pad:function(g,b,f,c){if(typeof(b)=="undefined"){var b=0}if(typeof(f)=="undefined"){var f=" "}if(typeof(c)=="undefined"){var c=3}if(b+1>=g.length){switch(c){case 1:g=Array(b+1-g.length).join(f)+g;break;case 3:var d=Math.ceil((padlen=b-g.length)/2);var e=padlen-d;g=Array(e+1).join(f)+g+Array(d+1).join(f);break;default:g=g+Array(b+1-g.length).join(f);break}}return g},isPlainObject:function(c){if(typeof(c)!=="object"||c.nodeType||c===c.window){return false}try{if(c.constructor&&!hasOwn.call(c.constructor.prototype,"isPrototypeOf")){return false}}catch(b){return false}return true},extend:function(){var l,d,b,c,h,j,g=arguments[0]||{},f=1,e=arguments.length,k=false;if(typeof g==="boolean"){k=g;g=arguments[1]||{};f=2}if(e===f){g=this;--f}for(;f>16&255)/255,(b>>8&255)/255,(b&255)/255]}if(typeof Function.prototype.bind!="function"){Function.prototype.bind=(function(){var b=Array.prototype.slice;return function(c){var f=this,g=b.call(arguments,1);if(typeof f!="function"){throw new TypeError()}function d(){var h=g.concat(b.call(arguments));f.apply(this instanceof d?this:c,h)}d.prototype=(function e(h){h&&(e.prototype=h);if(!(this instanceof e)){return new e}})(f.prototype);return d}})()}function determineMatrixArrayType(){PIXI.Matrix=(typeof Float32Array!=="undefined")?Float32Array:Array;return PIXI.Matrix}determineMatrixArrayType();PIXI.mat3={};PIXI.mat3.create=function(){var b=new PIXI.Matrix(9);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=1;b[5]=0;b[6]=0;b[7]=0;b[8]=1;return b};PIXI.mat3.identity=function(b){b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=1;b[5]=0;b[6]=0;b[7]=0;b[8]=1;return b};PIXI.mat4={};PIXI.mat4.create=function(){var b=new PIXI.Matrix(16);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};PIXI.mat3.multiply=function(q,h,i){if(!i){i=q}var v=q[0],u=q[1],t=q[2],g=q[3],f=q[4],e=q[5],o=q[6],n=q[7],m=q[8],l=h[0],k=h[1],j=h[2],s=h[3],r=h[4],p=h[5],d=h[6],c=h[7],b=h[8];i[0]=l*v+k*g+j*o;i[1]=l*u+k*f+j*n;i[2]=l*t+k*e+j*m;i[3]=s*v+r*g+p*o;i[4]=s*u+r*f+p*n;i[5]=s*t+r*e+p*m;i[6]=d*v+c*g+b*o;i[7]=d*u+c*f+b*n;i[8]=d*t+c*e+b*m;return i};PIXI.mat3.clone=function(c){var b=new PIXI.Matrix(9);b[0]=c[0];b[1]=c[1];b[2]=c[2];b[3]=c[3];b[4]=c[4];b[5]=c[5];b[6]=c[6];b[7]=c[7];b[8]=c[8];return b};PIXI.mat3.transpose=function(d,c){if(!c||d===c){var f=d[1],e=d[2],b=d[5];d[1]=d[3];d[2]=d[6];d[3]=f;d[5]=d[7];d[6]=e;d[7]=b;return d}c[0]=d[0];c[1]=d[3];c[2]=d[6];c[3]=d[1];c[4]=d[4];c[5]=d[7];c[6]=d[2];c[7]=d[5];c[8]=d[8];return c};PIXI.mat3.toMat4=function(c,b){if(!b){b=PIXI.mat4.create()}b[15]=1;b[14]=0;b[13]=0;b[12]=0;b[11]=0;b[10]=c[8];b[9]=c[7];b[8]=c[6];b[7]=0;b[6]=c[5];b[5]=c[4];b[4]=c[3];b[3]=0;b[2]=c[2];b[1]=c[1];b[0]=c[0];return b};PIXI.mat4.create=function(){var b=new PIXI.Matrix(16);b[0]=1;b[1]=0;b[2]=0;b[3]=0;b[4]=0;b[5]=1;b[6]=0;b[7]=0;b[8]=0;b[9]=0;b[10]=1;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return b};PIXI.mat4.transpose=function(e,d){if(!d||e===d){var i=e[1],g=e[2],f=e[3],b=e[6],h=e[7],c=e[11];e[1]=e[4];e[2]=e[8];e[3]=e[12];e[4]=i;e[6]=e[9];e[7]=e[13];e[8]=g;e[9]=b;e[11]=e[14];e[12]=f;e[13]=h;e[14]=c;return e}d[0]=e[0];d[1]=e[4];d[2]=e[8];d[3]=e[12];d[4]=e[1];d[5]=e[5];d[6]=e[9];d[7]=e[13];d[8]=e[2];d[9]=e[6];d[10]=e[10];d[11]=e[14];d[12]=e[3];d[13]=e[7];d[14]=e[11];d[15]=e[15];return d};PIXI.mat4.multiply=function(p,i,k){if(!k){k=p}var v=p[0],u=p[1],s=p[2],q=p[3];var h=p[4],f=p[5],d=p[6],b=p[7];var o=p[8],n=p[9],m=p[10],l=p[11];var z=p[12],w=p[13],t=p[14],r=p[15];var j=i[0],g=i[1],e=i[2],c=i[3];k[0]=j*v+g*h+e*o+c*z;k[1]=j*u+g*f+e*n+c*w;k[2]=j*s+g*d+e*m+c*t;k[3]=j*q+g*b+e*l+c*r;j=i[4];g=i[5];e=i[6];c=i[7];k[4]=j*v+g*h+e*o+c*z;k[5]=j*u+g*f+e*n+c*w;k[6]=j*s+g*d+e*m+c*t;k[7]=j*q+g*b+e*l+c*r;j=i[8];g=i[9];e=i[10];c=i[11];k[8]=j*v+g*h+e*o+c*z;k[9]=j*u+g*f+e*n+c*w;k[10]=j*s+g*d+e*m+c*t;k[11]=j*q+g*b+e*l+c*r;j=i[12];g=i[13];e=i[14];c=i[15];k[12]=j*v+g*h+e*o+c*z;k[13]=j*u+g*f+e*n+c*w;k[14]=j*s+g*d+e*m+c*t;k[15]=j*q+g*b+e*l+c*r;return k};PIXI.Point=function(b,c){this.x=b||0;this.y=c||0};PIXI.Point.prototype.clone=function(){return new PIXI.Point(this.x,this.y)};PIXI.Point.prototype.constructor=PIXI.Point;PIXI.Rectangle=function(c,e,d,b){this.x=c||0;this.y=e||0;this.width=d||0;this.height=b||0};PIXI.Rectangle.prototype.clone=function(){return new PIXI.Rectangle(this.x,this.y,this.width,this.height)};PIXI.Rectangle.prototype.contains=function(b,e){if(this.width<=0||this.height<=0){return false}var c=this.x;if(b>=c&&b<=c+this.width){var d=this.y;if(e>=d&&e<=d+this.height){return true}}return false};PIXI.Rectangle.prototype.constructor=PIXI.Rectangle;PIXI.DisplayObject=function(){this.last=this;this.first=this;this.position=new PIXI.Point();this.scale=new PIXI.Point(1,1);this.pivot=new PIXI.Point(0,0);this.rotation=0;this.alpha=1;this.visible=true;this.hitArea=null;this.buttonMode=false;this.renderable=false;this.parent=null;this.stage=null;this.worldAlpha=1;this._interactive=false;this.worldTransform=PIXI.mat3.create();this.localTransform=PIXI.mat3.create();this.color=[];this.dynamic=true;this._sr=0;this._cr=1};PIXI.DisplayObject.prototype.constructor=PIXI.DisplayObject;PIXI.DisplayObject.prototype.setInteractive=function(b){this.interactive=b};Object.defineProperty(PIXI.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(b){this._interactive=b;if(this.stage){this.stage.dirty=true}}});Object.defineProperty(PIXI.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(b){this._mask=b;if(b){this.addFilter(b)}else{this.removeFilter()}}});PIXI.DisplayObject.prototype.addFilter=function(j){if(this.filter){return}this.filter=true;var b=new PIXI.FilterBlock();var e=new PIXI.FilterBlock();b.mask=j;e.mask=j;b.first=b.last=this;e.first=e.last=this;b.open=true;var d=b;var f=b;var i;var h;h=this.first._iPrev;if(h){i=h._iNext;d._iPrev=h;h._iNext=d}else{i=this}if(i){i._iPrev=f;f._iNext=i}var d=e;var f=e;var i=null;var h=null;h=this.last;i=h._iNext;if(i){i._iPrev=f;f._iNext=i}d._iPrev=h;h._iNext=d;var c=this;var g=this.last;while(c){if(c.last==g){c.last=e}c=c.parent}this.first=b;if(this.__renderGroup){this.__renderGroup.addFilterBlocks(b,e)}j.renderable=false};PIXI.DisplayObject.prototype.removeFilter=function(){if(!this.filter){return}this.filter=false;var d=this.first;var g=d._iNext;var h=d._iPrev;if(g){g._iPrev=h}if(h){h._iNext=g}this.first=d._iNext;var e=this.last;var g=e._iNext;var h=e._iPrev;if(g){g._iPrev=h}h._iNext=g;var f=e._iPrev;var c=this;while(c.last==e){c.last=f;c=c.parent;if(!c){break}}var b=d.mask;b.renderable=true;if(this.__renderGroup){this.__renderGroup.removeFilterBlocks(d,e)}};PIXI.DisplayObject.prototype.updateTransform=function(){if(this.rotation!==this.rotationCache){this.rotationCache=this.rotation;this._sr=Math.sin(this.rotation);this._cr=Math.cos(this.rotation)}var r=this.localTransform;var f=this.parent.worldTransform;var b=this.worldTransform;r[0]=this._cr*this.scale.x;r[1]=-this._sr*this.scale.y;r[3]=this._sr*this.scale.x;r[4]=this._cr*this.scale.y;var n=this.pivot.x;var m=this.pivot.y;var i=r[0],h=r[1],g=this.position.x-r[0]*n-m*r[1],q=r[3],p=r[4],o=this.position.y-r[4]*m-n*r[3],l=f[0],k=f[1],j=f[2],e=f[3],d=f[4],c=f[5];r[2]=g;r[5]=o;b[0]=l*i+k*q;b[1]=l*h+k*p;b[2]=l*g+k*o+j;b[3]=e*i+d*q;b[4]=e*h+d*p;b[5]=e*g+d*o+c;this.worldAlpha=this.alpha*this.parent.worldAlpha;this.vcount=PIXI.visibleCount};PIXI.visibleCount=0;PIXI.DisplayObjectContainer=function(){PIXI.DisplayObject.call(this);this.children=[]};PIXI.DisplayObjectContainer.prototype=Object.create(PIXI.DisplayObject.prototype);PIXI.DisplayObjectContainer.prototype.constructor=PIXI.DisplayObjectContainer;PIXI.DisplayObjectContainer.prototype.addChild=function(i){if(i.parent!=undefined){i.parent.removeChild(i)}i.parent=this;this.children.push(i);if(this.stage){var f=i;do{if(f.interactive){this.stage.dirty=true}f.stage=this.stage;f=f._iNext}while(f)}var e=i.first;var d=i.last;var g;var h;if(this.filter){h=this.last._iPrev}else{h=this.last}g=h._iNext;var c=this;var b=h;while(c){if(c.last==b){c.last=i.last}c=c.parent}if(g){g._iPrev=d;d._iNext=g}e._iPrev=h;h._iNext=e;if(this.__renderGroup){if(i.__renderGroup){i.__renderGroup.removeDisplayObjectAndChildren(i)}this.__renderGroup.addDisplayObjectAndChildren(i)}};PIXI.DisplayObjectContainer.prototype.addChildAt=function(c,f){if(f>=0&&f<=this.children.length){if(c.parent!=undefined){c.parent.removeChild(c)}c.parent=this;if(this.stage){var e=c;do{if(e.interactive){this.stage.dirty=true}e.stage=this.stage;e=e._iNext}while(e)}var d=c.first;var g=c.last;var j;var i;if(f==this.children.length){i=this.last;var b=this;var h=this.last;while(b){if(b.last==h){b.last=c.last}b=b.parent}}else{if(f==0){i=this}else{i=this.children[f-1].last}}j=i._iNext;if(j){j._iPrev=g;g._iNext=j}d._iPrev=i;i._iNext=d;this.children.splice(f,0,c);if(this.__renderGroup){if(c.__renderGroup){c.__renderGroup.removeDisplayObjectAndChildren(c)}this.__renderGroup.addDisplayObjectAndChildren(c)}}else{throw new Error(c+" The index "+f+" supplied is out of bounds "+this.children.length)}};PIXI.DisplayObjectContainer.prototype.swapChildren=function(c,b){return};PIXI.DisplayObjectContainer.prototype.getChildAt=function(b){if(b>=0&&b1){h=1}var d=Math.sqrt(c.x*c.x+c.y*c.y);var f=this.texture.height/2;c.x/=d;c.y/=d;c.x*=f;c.y*=f;b[g]=m.x+c.x;b[g+1]=m.y+c.y;b[g+2]=m.x-c.x;b[g+3]=m.y-c.y;l=m}PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)};PIXI.Rope.prototype.setTexture=function(b){this.texture=b;this.updateFrame=true};PIXI.TilingSprite=function(d,c,b){PIXI.DisplayObjectContainer.call(this);this.texture=d;this.width=c;this.height=b;this.tileScale=new PIXI.Point(1,1);this.tilePosition=new PIXI.Point(0,0);this.renderable=true;this.blendMode=PIXI.blendModes.NORMAL};PIXI.TilingSprite.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);PIXI.TilingSprite.prototype.constructor=PIXI.TilingSprite;PIXI.TilingSprite.prototype.setTexture=function(b){this.texture=b;this.updateFrame=true};PIXI.TilingSprite.prototype.onTextureUpdate=function(b){this.updateFrame=true};PIXI.FilterBlock=function(b){this.graphics=b;this.visible=true;this.renderable=true};PIXI.MaskFilter=function(b){this.graphics};PIXI.Graphics=function(){PIXI.DisplayObjectContainer.call(this);this.renderable=true;this.fillAlpha=1;this.lineWidth=0;this.lineColor="black";this.graphicsData=[];this.currentPath={points:[]}};PIXI.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);PIXI.Graphics.prototype.constructor=PIXI.Graphics;PIXI.Graphics.prototype.lineStyle=function(b,c,d){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.lineWidth=b||0;this.lineColor=c||0;this.lineAlpha=(d==undefined)?1:d;this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:PIXI.Graphics.POLY};this.graphicsData.push(this.currentPath)};PIXI.Graphics.prototype.moveTo=function(b,c){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath=this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:PIXI.Graphics.POLY};this.currentPath.points.push(b,c);this.graphicsData.push(this.currentPath)};PIXI.Graphics.prototype.lineTo=function(b,c){this.currentPath.points.push(b,c);this.dirty=true};PIXI.Graphics.prototype.beginFill=function(b,c){this.filling=true;this.fillColor=b||0;this.fillAlpha=(c==undefined)?1:c};PIXI.Graphics.prototype.endFill=function(){this.filling=false;this.fillColor=null;this.fillAlpha=1};PIXI.Graphics.prototype.drawRect=function(c,e,d,b){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[c,e,d,b],type:PIXI.Graphics.RECT};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.drawCircle=function(c,d,b){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[c,d,b,b],type:PIXI.Graphics.CIRC};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.drawElipse=function(c,e,d,b){if(this.currentPath.points.length==0){this.graphicsData.pop()}this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[c,e,d,b],type:PIXI.Graphics.ELIP};this.graphicsData.push(this.currentPath);this.dirty=true};PIXI.Graphics.prototype.clear=function(){this.lineWidth=0;this.filling=false;this.dirty=true;this.clearDirty=true;this.graphicsData=[]};PIXI.Graphics.POLY=0;PIXI.Graphics.RECT=1;PIXI.Graphics.CIRC=2;PIXI.Graphics.ELIP=3;PIXI.CanvasGraphics=function(){};PIXI.CanvasGraphics.renderGraphics=function(u,c){var p=u.worldAlpha;for(var s=0;s1){t=1;console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object")}for(var s=0;s<1;s++){var A=v.graphicsData[s];var r=A.points;if(A.type==PIXI.Graphics.POLY){c.beginPath();c.moveTo(r[0],r[1]);for(var q=1;q0){PIXI.Texture.frameUpdates=[]}};PIXI.CanvasRenderer.prototype.resize=function(c,b){this.width=c;this.height=b;this.view.width=c;this.view.height=b};PIXI.CanvasRenderer.prototype.renderDisplayObject=function(h){var e;var f=this.context;f.globalCompositeOperation="source-over";var d=h.last._iNext;h=h.first;do{e=h.worldTransform;if(!h.visible){h=h.last._iNext;continue}if(!h.renderable){h=h._iNext;continue}if(h instanceof PIXI.Sprite){var g=h.texture.frame;if(g){f.globalAlpha=h.worldAlpha;f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);f.drawImage(h.texture.baseTexture.source,g.x,g.y,g.width,g.height,(h.anchor.x)*-g.width,(h.anchor.y)*-g.height,g.width,g.height)}}else{if(h instanceof PIXI.Strip){f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);this.renderStrip(h)}else{if(h instanceof PIXI.TilingSprite){f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);this.renderTilingSprite(h)}else{if(h instanceof PIXI.CustomRenderable){h.renderCanvas(this)}else{if(h instanceof PIXI.Graphics){f.setTransform(e[0],e[3],e[1],e[4],e[2],e[5]);PIXI.CanvasGraphics.renderGraphics(h,f)}else{if(h instanceof PIXI.FilterBlock){if(h.open){f.save();var c=h.mask.alpha;var b=h.mask.worldTransform;f.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]);h.mask.worldAlpha=0.5;f.worldAlpha=0;PIXI.CanvasGraphics.renderGraphicsMask(h.mask,f);f.clip();h.mask.worldAlpha=c}else{f.restore()}}}}}}}h=h._iNext}while(h!=d)};PIXI.CanvasRenderer.prototype.renderStripFlat=function(d){var e=this.context;var f=d.verticies;var j=d.uvs;var g=f.length/2;this.count++;e.beginPath();for(var k=1;k3){PIXI.WebGLGraphics.buildPoly(d,b._webGL)}}if(d.lineWidth>0){PIXI.WebGLGraphics.buildLine(d,b._webGL)}}else{if(d.type==PIXI.Graphics.RECT){PIXI.WebGLGraphics.buildRectangle(d,b._webGL)}else{if(d.type==PIXI.Graphics.CIRC||d.type==PIXI.Graphics.ELIP){PIXI.WebGLGraphics.buildCircle(d,b._webGL)}}}}b._webGL.lastIndex=b.graphicsData.length;var e=PIXI.gl;b._webGL.glPoints=new Float32Array(b._webGL.points);e.bindBuffer(e.ARRAY_BUFFER,b._webGL.buffer);e.bufferData(e.ARRAY_BUFFER,b._webGL.glPoints,e.STATIC_DRAW);b._webGL.glIndicies=new Uint16Array(b._webGL.indices);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,b._webGL.indexBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,b._webGL.glIndicies,e.STATIC_DRAW)};PIXI.WebGLGraphics.buildRectangle=function(s,i){var f=s.points;var n=f[0];var m=f[1];var d=f[2];var q=f[3];if(s.fill){var h=HEXtoRGB(s.fillColor);var e=s.fillAlpha;var c=h[0]*e;var j=h[1]*e;var l=h[2]*e;var o=i.points;var p=i.indices;var k=o.length/6;o.push(n,m);o.push(c,j,l,e);o.push(n+d,m);o.push(c,j,l,e);o.push(n,m+q);o.push(c,j,l,e);o.push(n+d,m+q);o.push(c,j,l,e);p.push(k,k,k+1,k+2,k+3,k+3)}if(s.lineWidth){s.points=[n,m,n+d,m,n+d,m+q,n,m+q,n,m];PIXI.WebGLGraphics.buildLine(s,i)}};PIXI.WebGLGraphics.buildCircle=function(k,w){var f=k.points;var j=f[0];var h=f[1];var o=f[2];var n=f[3];var l=40;var t=(Math.PI*2)/l;if(k.fill){var p=HEXtoRGB(k.fillColor);var d=k.fillAlpha;var m=p[0]*d;var s=p[1]*d;var u=p[2]*d;var v=w.points;var e=w.indices;var c=v.length/6;e.push(c);for(var q=0;q140*140){h=L-z;f=K-w;m=Math.sqrt(h*h+f*f);h/=m;f/=m;h*=c;f*=c;S.push(B-h,A-f);S.push(M,T,W,Q);S.push(B+h,A+f);S.push(M,T,W,Q);S.push(B-h,A-f);S.push(M,T,W,Q);q++}else{S.push(px,py);S.push(M,T,W,Q);S.push(B-(px-B),A-(py-A));S.push(M,T,W,Q)}}J=H[(u-2)*2];I=H[(u-2)*2+1];B=H[(u-1)*2];A=H[(u-1)*2+1];L=-(I-A);K=J-B;m=Math.sqrt(L*L+K*K);L/=m;K/=m;L*=c;K*=c;S.push(B-L,A-K);S.push(M,T,W,Q);S.push(B+L,A+K);S.push(M,T,W,Q);l.push(U);for(var R=0;R>16&255)/255,(b>>8&255)/255,(b&255)/255]}PIXI._defaultFrame=new PIXI.Rectangle(0,0,1,1);PIXI.gl;PIXI.WebGLRenderer=function(g,b,d,j,c){this.transparent=!!j;this.width=g||800;this.height=b||600;this.view=d||document.createElement("canvas");this.view.width=this.width;this.view.height=this.height;var f=this;this.view.addEventListener("webglcontextlost",function(e){f.handleContextLost(e)},false);this.view.addEventListener("webglcontextrestored",function(e){f.handleContextRestored(e)},false);this.batchs=[];try{PIXI.gl=this.gl=this.view.getContext("experimental-webgl",{alpha:this.transparent,antialias:!!c,premultipliedAlpha:false,stencil:true})}catch(h){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}PIXI.initPrimitiveShader();PIXI.initDefaultShader();PIXI.initDefaultStripShader();PIXI.activateDefaultShader();var i=this.gl;PIXI.WebGLRenderer.gl=i;this.batch=new PIXI.WebGLBatch(i);i.disable(i.DEPTH_TEST);i.disable(i.CULL_FACE);i.enable(i.BLEND);i.colorMask(true,true,true,this.transparent);PIXI.projection=new PIXI.Point(400,300);this.resize(this.width,this.height);this.contextLost=false;this.stageRenderGroup=new PIXI.WebGLRenderGroup(this.gl)};PIXI.WebGLRenderer.prototype.constructor=PIXI.WebGLRenderer;PIXI.WebGLRenderer.getBatch=function(){if(PIXI._batchs.length==0){return new PIXI.WebGLBatch(PIXI.WebGLRenderer.gl)}else{return PIXI._batchs.pop()}};PIXI.WebGLRenderer.returnBatch=function(b){b.clean();PIXI._batchs.push(b)};PIXI.WebGLRenderer.prototype.render=function(b){if(this.contextLost){return}if(this.__stage!==b){this.__stage=b;this.stageRenderGroup.setRenderable(b)}PIXI.WebGLRenderer.updateTextures();PIXI.visibleCount++;b.updateTransform();var d=this.gl;d.colorMask(true,true,true,this.transparent);d.viewport(0,0,this.width,this.height);d.bindFramebuffer(d.FRAMEBUFFER,null);d.clearColor(b.backgroundColorSplit[0],b.backgroundColorSplit[1],b.backgroundColorSplit[2],!this.transparent);d.clear(d.COLOR_BUFFER_BIT);this.stageRenderGroup.backgroundColor=b.backgroundColorSplit;this.stageRenderGroup.render(PIXI.projection);if(b.interactive){if(!b._interactiveEventsAdded){b._interactiveEventsAdded=true;b.interactionManager.setTarget(this)}}if(PIXI.Texture.frameUpdates.length>0){for(var c=0;c0){n=n.children[n.children.length-1];if(n.renderable){b=n}}if(b instanceof PIXI.Sprite){c=b.batch;var l=c.head;if(l==b){h=0}else{h=1;while(l.__next!=b){h++;l=l.__next}}}else{c=b}if(m==c){if(m instanceof PIXI.WebGLBatch){m.render(p,h+1)}else{this.renderSpecial(m,j)}return}d=this.batchs.indexOf(m);q=this.batchs.indexOf(c);if(m instanceof PIXI.WebGLBatch){m.render(p)}else{this.renderSpecial(m,j)}for(var e=d+1;e=2?parseInt(b[b.length-2],10):PIXI.BitmapText.fonts[this.fontName].size;this.dirty=true};PIXI.BitmapText.prototype.updateText=function(){var h=PIXI.BitmapText.fonts[this.fontName];var m=new PIXI.Point();var j=null;var l=[];var q=0;var e=[];var p=0;var f=this.fontSize/h.size;for(var g=0;g0){this.removeChild(this.getChildAt(0))}this.updateText();this.dirty=false}PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)};PIXI.BitmapText.fonts={};PIXI.Text=function(c,b){this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");PIXI.Sprite.call(this,PIXI.Texture.fromCanvas(this.canvas));this.setText(c);this.setStyle(b);this.updateText();this.dirty=false};PIXI.Text.prototype=Object.create(PIXI.Sprite.prototype);PIXI.Text.prototype.constructor=PIXI.Text;PIXI.Text.prototype.setStyle=function(b){b=b||{};b.font=b.font||"bold 20pt Arial";b.fill=b.fill||"black";b.align=b.align||"left";b.stroke=b.stroke||"black";b.strokeThickness=b.strokeThickness||0;b.wordWrap=b.wordWrap||false;b.wordWrapWidth=b.wordWrapWidth||100;this.style=b;this.dirty=true};PIXI.Sprite.prototype.setText=function(b){this.text=b.toString()||" ";this.dirty=true};PIXI.Text.prototype.updateText=function(){this.context.font=this.style.font;var g=this.text;if(this.style.wordWrap){g=this.wordWrap(this.text)}var f=g.split(/(?:\r\n|\r|\n)/);var d=[];var c=0;for(var h=0;hj){return k}else{return arguments.callee(i,l,k,h,j)}}else{return arguments.callee(i,l,m,k,j)}};var f=function(h,j,i){if(h.measureText(j).width<=i||j.length<1){return j}var k=e(h,j,0,j.length,i);return j.substring(0,k)+"\n"+arguments.callee(h,j.substring(k),i)};var b="";var c=g.split("\n");for(var d=0;dthis.baseTexture.width||b.y+b.height>this.baseTexture.height){throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this)}this.updateFrame=true;PIXI.Texture.frameUpdates.push(this)};PIXI.Texture.fromImage=function(c,b){var d=PIXI.TextureCache[c];if(!d){d=new PIXI.Texture(PIXI.BaseTexture.fromImage(c,b));PIXI.TextureCache[c]=d}return d};PIXI.Texture.fromFrame=function(c){var b=PIXI.TextureCache[c];if(!b){throw new Error("The frameId '"+c+"' does not exist in the texture cache "+this)}return b};PIXI.Texture.fromCanvas=function(b){var c=new PIXI.BaseTexture(b);return new PIXI.Texture(c)};PIXI.Texture.addTextureToCache=function(b,c){PIXI.TextureCache[c]=b};PIXI.Texture.removeTextureFromCache=function(c){var b=PIXI.TextureCache[c];PIXI.TextureCache[c]=null;return b};PIXI.Texture.frameUpdates=[];PIXI.RenderTexture=function(c,b){PIXI.EventTarget.call(this);this.width=c||100;this.height=b||100;this.indetityMatrix=PIXI.mat3.create();this.frame=new PIXI.Rectangle(0,0,this.width,this.height);if(PIXI.gl){this.initWebGL()}else{this.initCanvas()}};PIXI.RenderTexture.prototype=Object.create(PIXI.Texture.prototype);PIXI.RenderTexture.prototype.constructor=PIXI.RenderTexture;PIXI.RenderTexture.prototype.initWebGL=function(){var b=PIXI.gl;this.glFramebuffer=b.createFramebuffer();b.bindFramebuffer(b.FRAMEBUFFER,this.glFramebuffer);this.glFramebuffer.width=this.width;this.glFramebuffer.height=this.height;this.baseTexture=new PIXI.BaseTexture();this.baseTexture.width=this.width;this.baseTexture.height=this.height;this.baseTexture._glTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,this.baseTexture._glTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,this.width,this.height,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);this.baseTexture.isRender=true;b.bindFramebuffer(b.FRAMEBUFFER,this.glFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,this.baseTexture._glTexture,0);this.projection=new PIXI.Point(this.width/2,this.height/2);this.render=this.renderWebGL};PIXI.RenderTexture.prototype.resize=function(c,b){this.width=c;this.height=b;if(PIXI.gl){this.projection.x=this.width/2;this.projection.y=this.height/2;var d=PIXI.gl;d.bindTexture(d.TEXTURE_2D,this.baseTexture._glTexture);d.texImage2D(d.TEXTURE_2D,0,d.RGBA,this.width,this.height,0,d.RGBA,d.UNSIGNED_BYTE,null)}else{this.frame.width=this.width;this.frame.height=this.height;this.renderer.resize(this.width,this.height)}};PIXI.RenderTexture.prototype.initCanvas=function(){this.renderer=new PIXI.CanvasRenderer(this.width,this.height,null,0);this.baseTexture=new PIXI.BaseTexture(this.renderer.view);this.frame=new PIXI.Rectangle(0,0,this.width,this.height);this.render=this.renderCanvas};PIXI.RenderTexture.prototype.renderWebGL=function(k,g,h){var f=PIXI.gl;f.colorMask(true,true,true,true);f.viewport(0,0,this.width,this.height);f.bindFramebuffer(f.FRAMEBUFFER,this.glFramebuffer);if(h){f.clearColor(0,0,0,0);f.clear(f.COLOR_BUFFER_BIT)}var c=k.children;var b=k.worldTransform;k.worldTransform=PIXI.mat3.create();k.worldTransform[4]=-1;k.worldTransform[5]=this.projection.y*2;if(g){k.worldTransform[2]=g.x;k.worldTransform[5]-=g.y}PIXI.visibleCount++;k.vcount=PIXI.visibleCount;for(var e=0,d=c.length;e>1;if(k<3){return[]}var u=[];var g=[];for(var s=0;s3){var q=g[(s+0)%o];var m=g[(s+1)%o];var l=g[(s+2)%o];var f=h[2*q],d=h[2*q+1];var v=h[2*m],t=h[2*m+1];var c=h[2*l],b=h[2*l+1];var e=false;if(PIXI.PolyK._convex(f,d,v,t,c,b,z)){e=true;for(var r=0;r3*o){if(z){var u=[];g=[];for(var s=0;s=0)&&(m>=0)&&(n+m<1)};PIXI.PolyK._convex=function(e,d,g,f,b,h,c){return((d-f)*(b-g)+(g-e)*(h-f)>=0)==c};Phaser.Camera=function(d,g,c,f,e,b){this.game=d;this.world=d.world;this.id=0;this.view=new Phaser.Rectangle(c,f,e,b);this.screenView=new Phaser.Rectangle(c,f,e,b);this.deadzone=null;this.visible=true;this.atLimit={x:false,y:false};this.target=null;this._edge=0};Phaser.Camera.FOLLOW_LOCKON=0;Phaser.Camera.FOLLOW_PLATFORMER=1;Phaser.Camera.FOLLOW_TOPDOWN=2;Phaser.Camera.FOLLOW_TOPDOWN_TIGHT=3;Phaser.Camera.prototype={follow:function(f,d){if(typeof d==="undefined"){d=Phaser.Camera.FOLLOW_LOCKON}this.target=f;var e;switch(d){case Phaser.Camera.FOLLOW_PLATFORMER:var b=this.width/8;var c=this.height/3;this.deadzone=new Phaser.Rectangle((this.width-b)/2,(this.height-c)/2-c*0.25,b,c);break;case Phaser.Camera.FOLLOW_TOPDOWN:e=Math.max(this.width,this.height)/4;this.deadzone=new Phaser.Rectangle((this.width-e)/2,(this.height-e)/2,e,e);break;case Phaser.Camera.FOLLOW_TOPDOWN_TIGHT:e=Math.max(this.width,this.height)/8;this.deadzone=new Phaser.Rectangle((this.width-e)/2,(this.height-e)/2,e,e);break;case Phaser.Camera.FOLLOW_LOCKON:default:this.deadzone=null;break}},focusOnXY:function(b,c){this.view.x=Math.round(b-this.view.halfWidth);this.view.y=Math.round(c-this.view.halfHeight)},update:function(){if(this.target!==null){if(this.deadzone){this._edge=this.target.x-this.deadzone.x;if(this.view.x>this._edge){this.view.x=this._edge}this._edge=this.target.x+this.target.width-this.deadzone.x-this.deadzone.width;if(this.view.xthis._edge){this.view.y=this._edge}this._edge=this.target.y+this.target.height-this.deadzone.y-this.deadzone.height;if(this.view.ythis.world.bounds.right-this.width){this.atLimit.x=true;this.view.x=(this.world.bounds.right-this.width)+1}if(this.view.ythis.world.bounds.bottom-this.height){this.atLimit.y=true;this.view.y=(this.world.bounds.bottom-this.height)+1}this.view.floor()},setPosition:function(b,c){this.view.x=b;this.view.y=c;this.checkWorldBounds()},setSize:function(c,b){this.view.width=c;this.view.height=b}};Object.defineProperty(Phaser.Camera.prototype,"x",{get:function(){return this.view.x},set:function(b){this.view.x=b;this.checkWorldBounds()}});Object.defineProperty(Phaser.Camera.prototype,"y",{get:function(){return this.view.y},set:function(b){this.view.y=b;this.checkWorldBounds()}});Object.defineProperty(Phaser.Camera.prototype,"width",{get:function(){return this.view.width},set:function(b){this.view.width=b}});Object.defineProperty(Phaser.Camera.prototype,"height",{get:function(){return this.view.height},set:function(b){this.view.height=b}});Phaser.State=function(){this.game=null;this.add=null;this.camera=null;this.cache=null;this.input=null;this.load=null;this.math=null;this.sound=null;this.stage=null;this.time=null;this.tweens=null;this.world=null;this.particles=null;this.physics=null};Phaser.State.prototype={preload:function(){},create:function(){},update:function(){},render:function(){},paused:function(){},destroy:function(){}};Phaser.StateManager=function(c,b){this.game=c;this.states={};if(b!==null){this._pendingState=b}};Phaser.StateManager.prototype={game:null,_pendingState:null,_created:false,states:{},current:"",onInitCallback:null,onPreloadCallback:null,onCreateCallback:null,onUpdateCallback:null,onRenderCallback:null,onPreRenderCallback:null,onLoadUpdateCallback:null,onLoadRenderCallback:null,onPausedCallback:null,onShutDownCallback:null,boot:function(){if(this._pendingState!==null){if(typeof this._pendingState==="string"){this.start(this._pendingState,false,false)}else{this.add("default",this._pendingState,true)}}},add:function(c,d,b){if(typeof b==="undefined"){b=false}var e;if(d instanceof Phaser.State){e=d}else{if(typeof d==="object"){e=d;e.game=this.game}else{if(typeof d==="function"){e=new d(this.game)}}}this.states[c]=e;if(b){if(this.game.isBooted){this.start(c)}else{this._pendingState=c}}return e},remove:function(b){if(this.current==b){this.callbackContext=null;this.onInitCallback=null;this.onShutDownCallback=null;this.onPreloadCallback=null;this.onLoadRenderCallback=null;this.onLoadUpdateCallback=null;this.onCreateCallback=null;this.onUpdateCallback=null;this.onRenderCallback=null;this.onPausedCallback=null;this.onDestroyCallback=null}delete this.states[b]},start:function(c,b,d){if(typeof b==="undefined"){b=true}if(typeof d==="undefined"){d=false}if(this.game.isBooted==false){this._pendingState=c;return}if(this.checkState(c)==false){return}else{if(this.current){this.onShutDownCallback.call(this.callbackContext)}if(b){this.game.world.destroy();if(d==true){this.game.cache.destroy()}}this.setCurrentState(c)}if(this.onPreloadCallback){this.game.load.reset();this.onPreloadCallback.call(this.callbackContext);if(this.game.load.queueSize==0){this.game.loadComplete()}else{this.game.load.start()}}else{this.game.loadComplete()}},dummy:function(){},checkState:function(b){if(this.states[b]){var c=false;if(this.states[b]["preload"]){c=true}if(c==false&&this.states[b]["loadRender"]){c=true}if(c==false&&this.states[b]["loadUpdate"]){c=true}if(c==false&&this.states[b]["create"]){c=true}if(c==false&&this.states[b]["update"]){c=true}if(c==false&&this.states[b]["preRender"]){c=true}if(c==false&&this.states[b]["render"]){c=true}if(c==false&&this.states[b]["paused"]){c=true}if(c==false){console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions.");return false}return true}else{console.warn("Phaser.StateManager - No state found with the key: "+b);return false}},link:function(b){this.states[b].game=this.game;this.states[b].add=this.game.add;this.states[b].camera=this.game.camera;this.states[b].cache=this.game.cache;this.states[b].input=this.game.input;this.states[b].load=this.game.load;this.states[b].math=this.game.math;this.states[b].sound=this.game.sound;this.states[b].stage=this.game.stage;this.states[b].time=this.game.time;this.states[b].tweens=this.game.tweens;this.states[b].world=this.game.world;this.states[b].particles=this.game.particles;this.states[b].physics=this.game.physics;this.states[b].rnd=this.game.rnd},setCurrentState:function(b){this.callbackContext=this.states[b];this.link(b);this.onInitCallback=this.states[b]["init"]||this.dummy;this.onPreloadCallback=this.states[b]["preload"]||null;this.onLoadRenderCallback=this.states[b]["loadRender"]||null;this.onLoadUpdateCallback=this.states[b]["loadUpdate"]||null;this.onCreateCallback=this.states[b]["create"]||null;this.onUpdateCallback=this.states[b]["update"]||null;this.onPreRenderCallback=this.states[b]["preRender"]||null;this.onRenderCallback=this.states[b]["render"]||null;this.onPausedCallback=this.states[b]["paused"]||null;this.onShutDownCallback=this.states[b]["shutdown"]||this.dummy;this.current=b;this._created=false;this.onInitCallback.call(this.callbackContext)},loadComplete:function(){if(this._created==false&&this.onCreateCallback){this._created=true;this.onCreateCallback.call(this.callbackContext)}else{this._created=true}},update:function(){if(this._created&&this.onUpdateCallback){this.onUpdateCallback.call(this.callbackContext)}else{if(this.onLoadUpdateCallback){this.onLoadUpdateCallback.call(this.callbackContext)}}},preRender:function(){if(this.onPreRenderCallback){this.onPreRenderCallback.call(this.callbackContext)}},render:function(){if(this._created&&this.onRenderCallback){this.onRenderCallback.call(this.callbackContext)}else{if(this.onLoadRenderCallback){this.onLoadRenderCallback.call(this.callbackContext)}}},destroy:function(){this.callbackContext=null;this.onInitCallback=null;this.onShutDownCallback=null;this.onPreloadCallback=null;this.onLoadRenderCallback=null;this.onLoadUpdateCallback=null;this.onCreateCallback=null;this.onUpdateCallback=null;this.onRenderCallback=null;this.onPausedCallback=null;this.onDestroyCallback=null;this.game=null;this.states={};this._pendingState=null}};Phaser.LinkedList=function(){this.next=null;this.prev=null;this.first=null;this.last=null;this.total=0};Phaser.LinkedList.prototype={add:function(b){if(this.total==0&&this.first==null&&this.last==null){this.first=b;this.last=b;this.next=b;b.prev=this;this.total++;return}this.last.next=b;b.prev=this.last;this.last=b;this.total++;return b},remove:function(c){if(this.first==null&&this.last==null){return}this.total--;if(this.first==c&&this.last==c){this.first=null;this.last=null;this.next=null;c.next=null;c.prev=null;return}var b=c.prev;if(c.next){c.next.prev=c.prev}b.next=c.next},callAll:function(c){if(!this.first||!this.last){return}var b=this.first;do{if(b&&b[c]){b[c].call(b)}b=b.next}while(b!=this.last.next)},dump:function(){var j=20;var e="\n"+Phaser.Utils.pad("Node",j)+"|"+Phaser.Utils.pad("Next",j)+"|"+Phaser.Utils.pad("Previous",j)+"|"+Phaser.Utils.pad("First",j)+"|"+Phaser.Utils.pad("Last",j);console.log(e);var e=Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j)+"|"+Phaser.Utils.pad("----------",j);console.log(e);var g=this;var c=g.last.next;g=g.first;do{var d=g.sprite.name||"*";var f="-";var b="-";var h="-";var i="-";if(g.next){f=g.next.sprite.name}if(g.prev){b=g.prev.sprite.name}if(g.first){h=g.first.sprite.name}if(g.last){i=g.last.sprite.name}if(typeof f==="undefined"){f="-"}if(typeof b==="undefined"){b="-"}if(typeof h==="undefined"){h="-"}if(typeof i==="undefined"){i="-"}var e=Phaser.Utils.pad(d,j)+"|"+Phaser.Utils.pad(f,j)+"|"+Phaser.Utils.pad(b,j)+"|"+Phaser.Utils.pad(h,j)+"|"+Phaser.Utils.pad(i,j);console.log(e);g=g.next}while(g!=c)}};Phaser.Signal=function(){this._bindings=[];this._prevParams=null;var b=this;this.dispatch=function(){Phaser.Signal.prototype.dispatch.apply(b,arguments)}};Phaser.Signal.prototype={memorize:false,_shouldPropagate:true,active:true,validateListener:function(b,c){if(typeof b!=="function"){throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",c))}},_registerListener:function(f,d,e,c){var b=this._indexOfListener(f,e),g;if(b!==-1){g=this._bindings[b];if(g.isOnce()!==d){throw new Error("You cannot add"+(d?"":"Once")+"() then add"+(!d?"":"Once")+"() the same listener without removing the relationship first.")}}else{g=new Phaser.SignalBinding(this,f,d,e,c);this._addBinding(g)}if(this.memorize&&this._prevParams){g.execute(this._prevParams)}return g},_addBinding:function(b){var c=this._bindings.length;do{--c}while(this._bindings[c]&&b._priority<=this._bindings[c]._priority);this._bindings.splice(c+1,0,b)},_indexOfListener:function(c,b){var e=this._bindings.length,d;while(e--){d=this._bindings[e];if(d._listener===c&&d.context===b){return e}}return -1},has:function(c,b){return this._indexOfListener(c,b)!==-1},add:function(d,c,b){this.validateListener(d,"add");return this._registerListener(d,false,c,b)},addOnce:function(d,c,b){this.validateListener(d,"addOnce");return this._registerListener(d,true,c,b)},remove:function(d,c){this.validateListener(d,"remove");var b=this._indexOfListener(d,c);if(b!==-1){this._bindings[b]._destroy();this._bindings.splice(b,1)}return d},removeAll:function(){var b=this._bindings.length;while(b--){this._bindings[b]._destroy()}this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=false},dispatch:function(c){if(!this.active){return}var b=Array.prototype.slice.call(arguments),e=this._bindings.length,d;if(this.memorize){this._prevParams=b}if(!e){return}d=this._bindings.slice();this._shouldPropagate=true;do{e--}while(d[e]&&this._shouldPropagate&&d[e].execute(b)!==false)},forget:function(){this._prevParams=null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};Phaser.SignalBinding=function(f,e,c,d,b){this._listener=e;this._isOnce=c;this.context=d;this._signal=f;this._priority=b||0};Phaser.SignalBinding.prototype={active:true,params:null,execute:function(b){var d,c;if(this.active&&!!this._listener){c=this.params?this.params.concat(b):b;d=this._listener.apply(this.context,c);if(this._isOnce){this.detach()}}return d},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return(!!this._signal&&!!this._listener)},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal;delete this._listener;delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}};Phaser.Plugin=function(b,c){this.game=b;this.parent=c;this.active=false;this.visible=false;this.hasPreUpdate=false;this.hasUpdate=false;this.hasRender=false;this.hasPostRender=false};Phaser.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null;this.parent=null;this.active=false;this.visible=false}};Phaser.PluginManager=function(b,c){this.game=b;this._parent=c;this.plugins=[];this._pluginsLength=0};Phaser.PluginManager.prototype={add:function(c){var b=false;if(typeof c==="function"){c=new c(this.game,this._parent)}else{c.game=this.game;c.parent=this._parent}if(typeof c.preUpdate==="function"){c.hasPreUpdate=true;b=true}if(typeof c.update==="function"){c.hasUpdate=true;b=true}if(typeof c.render==="function"){c.hasRender=true;b=true}if(typeof c.postRender==="function"){c.hasPostRender=true;b=true}if(b){if(c.hasPreUpdate||c.hasUpdate){c.active=true}if(c.hasRender||c.hasPostRender){c.visible=true}this._pluginsLength=this.plugins.push(c);return c}else{return null}},remove:function(b){this._pluginsLength--},preUpdate:function(){if(this._pluginsLength==0){return}for(this._p=0;this._p0&&this._container.first._iNext){var d=this._container.first._iNext;do{if((c==false||(c&&d.alive))&&(g==false||(g&&d.visible))){this.setProperty(d,e,f,b)}d=d._iNext}while(d!=this._container.last._iNext)}},addAll:function(c,d,b,e){this.setAll(c,d,b,e,1)},subAll:function(c,d,b,e){this.setAll(c,d,b,e,2)},multiplyAll:function(c,d,b,e){this.setAll(c,d,b,e,3)},divideAll:function(c,d,b,e){this.setAll(c,d,b,e,4)},callAllExists:function(f,b,e){var c=Array.prototype.splice.call(arguments,3);if(this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do{if(d.exists==e&&d[f]){d[f].apply(d,c)}d=d._iNext}while(d!=this._container.last._iNext)}},callAll:function(e,b){var c=Array.prototype.splice.call(arguments,2);if(this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do{if(d[e]){d[e].apply(d,c)}d=d._iNext}while(d!=this._container.last._iNext)}},forEach:function(e,b,d){if(typeof d=="undefined"){d=false}if(this._container.children.length>0&&this._container.first._iNext){var c=this._container.first._iNext;do{if(d==false||(d&&c.exists)){e.call(b,c)}c=c._iNext}while(c!=this._container.last._iNext)}},forEachAlive:function(d,b){if(this._container.children.length>0&&this._container.first._iNext){var c=this._container.first._iNext;do{if(c.alive){d.call(b,c)}c=c._iNext}while(c!=this._container.last._iNext)}},forEachDead:function(d,b){if(this._container.children.length>0&&this._container.first._iNext){var c=this._container.first._iNext;do{if(c.alive==false){d.call(b,c)}c=c._iNext}while(c!=this._container.last._iNext)}},getFirstExists:function(c){if(typeof c!=="boolean"){c=true}if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(b.exists===c){return b}b=b._iNext}while(b!=this._container.last._iNext)}return null},getFirstAlive:function(){if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(b.alive){return b}b=b._iNext}while(b!=this._container.last._iNext)}return null},getFirstDead:function(){if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(!b.alive){return b}b=b._iNext}while(b!=this._container.last._iNext)}return null},countLiving:function(){var c=-1;if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(b.alive){c++}b=b._iNext}while(b!=this._container.last._iNext)}return c},countDead:function(){var c=-1;if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(!b.alive){c++}b=b._iNext}while(b!=this._container.last._iNext)}return c},getRandom:function(c,b){if(this._container.children.length==0){return null}c=c||0;b=b||this._container.children.length;return this.game.math.getRandom(this._container.children,c,b)},remove:function(b){b.events.onRemovedFromGroup.dispatch(b,this);this._container.removeChild(b);b.group=null},removeAll:function(){if(this._container.children.length==0){return}do{if(this._container.children[0].events){this._container.children[0].events.onRemovedFromGroup.dispatch(this._container.children[0],this)}this._container.removeChild(this._container.children[0])}while(this._container.children.length>0)},removeBetween:function(d,c){if(this._container.children.length==0){return}if(d>c||d<0||c>this._container.children.length){return false}for(var b=d;b=this.game.width){this.bounds.width=c}if(b>=this.game.height){this.bounds.height=b}},destroy:function(){this.camera.x=0;this.camera.y=0;this.game.input.reset(true);this.group.removeAll()}};Object.defineProperty(Phaser.World.prototype,"width",{get:function(){return this.bounds.width},set:function(b){this.bounds.width=b}});Object.defineProperty(Phaser.World.prototype,"height",{get:function(){return this.bounds.height},set:function(b){this.bounds.height=b}});Object.defineProperty(Phaser.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth}});Object.defineProperty(Phaser.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight}});Object.defineProperty(Phaser.World.prototype,"randomX",{get:function(){return Math.round(Math.random()*this.bounds.width)}});Object.defineProperty(Phaser.World.prototype,"randomY",{get:function(){return Math.round(Math.random()*this.bounds.height)}});Phaser.Game=function(e,b,g,d,f,h,c){e=e||800;b=b||600;g=g||Phaser.AUTO;d=d||"";f=f||null;h=h||false;c=typeof c==="undefined"?true:c;this.id=Phaser.GAMES.push(this)-1;this.parent=d;this.width=e;this.height=b;this.transparent=h;this.antialias=c;this.renderer=null;this.state=new Phaser.StateManager(this,f);this._paused=false;this.renderType=g;this._loadComplete=false;this.isBooted=false;this.isRunning=false;this.raf=null;this.add=null;this.cache=null;this.input=null;this.load=null;this.math=null;this.net=null;this.sound=null;this.stage=null;this.time=null;this.tweens=null;this.world=null;this.physics=null;this.rnd=null;this.device=null;this.camera=null;this.canvas=null;this.context=null;this.debug=null;this.particles=null;var i=this;this._onBoot=function(){return i.boot()};if(document.readyState==="complete"||document.readyState==="interactive"){window.setTimeout(this._onBoot,0)}else{document.addEventListener("DOMContentLoaded",this._onBoot,false);window.addEventListener("load",this._onBoot,false)}return this};Phaser.Game.prototype={boot:function(){if(this.isBooted){return}if(!document.body){window.setTimeout(this._onBoot,20)}else{document.removeEventListener("DOMContentLoaded",this._onBoot);window.removeEventListener("load",this._onBoot);this.onPause=new Phaser.Signal;this.onResume=new Phaser.Signal;this.isBooted=true;this.device=new Phaser.Device();this.math=Phaser.Math;this.rnd=new Phaser.RandomDataGenerator([(Date.now()*Math.random()).toString()]);this.stage=new Phaser.Stage(this,this.width,this.height);this.setUpRenderer();this.world=new Phaser.World(this);this.add=new Phaser.GameObjectFactory(this);this.cache=new Phaser.Cache(this);this.load=new Phaser.Loader(this);this.time=new Phaser.Time(this);this.tweens=new Phaser.TweenManager(this);this.input=new Phaser.Input(this);this.sound=new Phaser.SoundManager(this);this.physics=new Phaser.Physics.Arcade(this);this.particles=new Phaser.Particles(this);this.plugins=new Phaser.PluginManager(this,this);this.net=new Phaser.Net(this);this.debug=new Phaser.Utils.Debug(this);this.load.onLoadComplete.add(this.loadComplete,this);this.stage.boot();this.world.boot();this.input.boot();this.sound.boot();this.state.boot();if(this.renderType==Phaser.CANVAS){console.log("%cPhaser "+Phaser.VERSION+" initialized. Rendering to Canvas","color: #ffff33; background: #000000")}else{console.log("%cPhaser "+Phaser.VERSION+" initialized. Rendering to WebGL","color: #ffff33; background: #000000")}this.isRunning=true;this._loadComplete=false;this.raf=new Phaser.RequestAnimationFrame(this);this.raf.start()}},setUpRenderer:function(){if(this.renderType===Phaser.CANVAS||(this.renderType===Phaser.AUTO&&this.device.webGL==false)){if(this.device.canvas){this.renderType=Phaser.CANVAS;this.renderer=new PIXI.CanvasRenderer(this.width,this.height,this.stage.canvas,this.transparent);Phaser.Canvas.setSmoothingEnabled(this.renderer.context,this.antialias);this.canvas=this.renderer.view;this.context=this.renderer.context}else{throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting.")}}else{this.renderType=Phaser.WEBGL;this.renderer=new PIXI.WebGLRenderer(this.width,this.height,this.stage.canvas,this.transparent,this.antialias);this.canvas=this.renderer.view;this.context=null}Phaser.Canvas.addToDOM(this.renderer.view,this.parent,true);Phaser.Canvas.setTouchAction(this.renderer.view)},loadComplete:function(){this._loadComplete=true;this.state.loadComplete()},update:function(b){this.time.update(b);if(!this._paused){this.plugins.preUpdate();this.physics.preUpdate();this.input.update();this.tweens.update();this.sound.update();this.world.update();this.particles.update();this.state.update();this.plugins.update();this.renderer.render(this.stage._stage);this.plugins.render();this.state.render();this.plugins.postRender()}},destroy:function(){this.state.destroy();this.state=null;this.cache=null;this.input=null;this.load=null;this.sound=null;this.stage=null;this.time=null;this.world=null;this.isBooted=false}};Object.defineProperty(Phaser.Game.prototype,"paused",{get:function(){return this._paused},set:function(b){if(b===true){if(this._paused==false){this._paused=true;this.onPause.dispatch(this)}}else{if(this._paused){this._paused=false;this.onResume.dispatch(this)}}}});Phaser.Input=function(b){this.game=b;this.hitCanvas=null;this.hitContext=null};Phaser.Input.MOUSE_OVERRIDES_TOUCH=0;Phaser.Input.TOUCH_OVERRIDES_MOUSE=1;Phaser.Input.MOUSE_TOUCH_COMBINE=2;Phaser.Input.prototype={game:null,pollRate:0,_pollCounter:0,_oldPosition:null,_x:0,_y:0,disabled:false,multiInputOverride:Phaser.Input.MOUSE_TOUCH_COMBINE,position:null,speed:null,circle:null,scale:null,maxPointers:10,currentPointers:0,tapRate:200,doubleTapRate:300,holdRate:2000,justPressedRate:200,justReleasedRate:200,recordPointerHistory:false,recordRate:100,recordLimit:100,pointer1:null,pointer2:null,pointer3:null,pointer4:null,pointer5:null,pointer6:null,pointer7:null,pointer8:null,pointer9:null,pointer10:null,activePointer:null,mousePointer:null,mouse:null,keyboard:null,touch:null,mspointer:null,onDown:null,onUp:null,onTap:null,onHold:null,interactiveItems:new Phaser.LinkedList(),boot:function(){this.mousePointer=new Phaser.Pointer(this.game,0);this.pointer1=new Phaser.Pointer(this.game,1);this.pointer2=new Phaser.Pointer(this.game,2);this.mouse=new Phaser.Mouse(this.game);this.keyboard=new Phaser.Keyboard(this.game);this.touch=new Phaser.Touch(this.game);this.mspointer=new Phaser.MSPointer(this.game);this.onDown=new Phaser.Signal();this.onUp=new Phaser.Signal();this.onTap=new Phaser.Signal();this.onHold=new Phaser.Signal();this.scale=new Phaser.Point(1,1);this.speed=new Phaser.Point();this.position=new Phaser.Point();this._oldPosition=new Phaser.Point();this.circle=new Phaser.Circle(0,0,44);this.activePointer=this.mousePointer;this.currentPointers=0;this.hitCanvas=document.createElement("canvas");this.hitCanvas.width=1;this.hitCanvas.height=1;this.hitContext=this.hitCanvas.getContext("2d");this.mouse.start();this.keyboard.start();this.touch.start();this.mspointer.start();this.mousePointer.active=true},addPointer:function(){var c=0;for(var b=10;b>0;b--){if(this["pointer"+b]===null){c=b}}if(c==0){console.warn("You can only have 10 Pointer objects");return null}else{this["pointer"+c]=new Phaser.Pointer(this.game,c);return this["pointer"+c]}},update:function(){if(this.pollRate>0&&this._pollCounter0&&this._pollCounter=this.game.input.holdRate){if(this.game.input.multiInputOverride==Phaser.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==Phaser.Input.MOUSE_TOUCH_COMBINE||(this.game.input.multiInputOverride==Phaser.Input.TOUCH_OVERRIDES_MOUSE&&this.game.input.currentPointers==0)){this.game.input.onHold.dispatch(this)}this._holdSent=true}if(this.game.input.recordPointerHistory&&this.game.time.now>=this._nextDrop){this._nextDrop=this.game.time.now+this.game.input.recordRate;this._history.push({x:this.position.x,y:this.position.y});if(this._history.length>this.game.input.recordLimit){this._history.shift()}}}},move:function(c){if(this.game.input.pollLocked){return}if(c.button){this.button=c.button}this.clientX=c.clientX;this.clientY=c.clientY;this.pageX=c.pageX;this.pageY=c.pageY;this.screenX=c.screenX;this.screenY=c.screenY;this.x=(this.pageX-this.game.stage.offset.x)*this.game.input.scale.x;this.y=(this.pageY-this.game.stage.offset.y)*this.game.input.scale.y;this.position.setTo(this.x,this.y);this.circle.x=this.x;this.circle.y=this.y;if(this.game.input.multiInputOverride==Phaser.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==Phaser.Input.MOUSE_TOUCH_COMBINE||(this.game.input.multiInputOverride==Phaser.Input.TOUCH_OVERRIDES_MOUSE&&this.game.input.currentPointers==0)){this.game.input.activePointer=this;this.game.input.x=this.x;this.game.input.y=this.y;this.game.input.position.setTo(this.game.input.x,this.game.input.y);this.game.input.circle.x=this.game.input.x;this.game.input.circle.y=this.game.input.y}if(this.game.paused){return this}if(this.targetObject!==null&&this.targetObject.isDragged==true){if(this.targetObject.update(this)==false){this.targetObject=null}return this}this._highestRenderOrderID=-1;this._highestRenderObject=null;this._highestInputPriorityID=-1;if(this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do{if(b.pixelPerfect||b.priorityID>this._highestInputPriorityID||(b.priorityID==this._highestInputPriorityID&&b.sprite.renderOrderID>this._highestRenderOrderID)){if(b.checkPointerOver(this)){this._highestRenderOrderID=b.sprite.renderOrderID;this._highestInputPriorityID=b.priorityID;this._highestRenderObject=b}}b=b.next}while(b!=null)}if(this._highestRenderObject==null){if(this.targetObject){this.targetObject._pointerOutHandler(this);this.targetObject=null}}else{if(this.targetObject==null){this.targetObject=this._highestRenderObject;this._highestRenderObject._pointerOverHandler(this)}else{if(this.targetObject==this._highestRenderObject){if(this._highestRenderObject.update(this)==false){this.targetObject=null}}else{this.targetObject._pointerOutHandler(this);this.targetObject=this._highestRenderObject;this.targetObject._pointerOverHandler(this)}}}return this},leave:function(b){this.withinGame=false;this.move(b)},stop:function(c){if(this._stateReset){c.preventDefault();return}this.timeUp=this.game.time.now;if(this.game.input.multiInputOverride==Phaser.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==Phaser.Input.MOUSE_TOUCH_COMBINE||(this.game.input.multiInputOverride==Phaser.Input.TOUCH_OVERRIDES_MOUSE&&this.game.input.currentPointers==0)){this.game.input.onUp.dispatch(this);if(this.duration>=0&&this.duration<=this.game.input.tapRate){if(this.timeUp-this.previousTapTime0){this.active=false}this.withinGame=false;this.isDown=false;this.isUp=true;if(this.isMouse==false){this.game.input.currentPointers--}if(this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do{if(b){b._releasedHandler(this)}b=b.next}while(b!=null)}if(this.targetObject){this.targetObject._releasedHandler(this)}this.targetObject=null;return this},justPressed:function(b){b=b||this.game.input.justPressedRate;return(this.isDown===true&&(this.timeDown+b)>this.game.time.now)},justReleased:function(b){b=b||this.game.input.justReleasedRate;return(this.isUp===true&&(this.timeUp+b)>this.game.time.now)},reset:function(){if(this.isMouse==false){this.active=false}this.identifier=null;this.isDown=false;this.isUp=true;this.totalTouches=0;this._holdSent=false;this._history.length=0;this._stateReset=true;if(this.targetObject){this.targetObject._releasedHandler(this)}this.targetObject=null},toString:function(){return"[{Pointer (id="+this.id+" identifer="+this.identifier+" active="+this.active+" duration="+this.duration+" withinGame="+this.withinGame+" x="+this.x+" y="+this.y+" clientX="+this.clientX+" clientY="+this.clientY+" screenX="+this.screenX+" screenY="+this.screenY+" pageX="+this.pageX+" pageY="+this.pageY+")}]"}};Object.defineProperty(Phaser.Pointer.prototype,"duration",{get:function(){if(this.isUp){return -1}return this.game.time.now-this.timeDown}});Object.defineProperty(Phaser.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}});Object.defineProperty(Phaser.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}});Phaser.Touch=function(b){this.game=b;this.callbackContext=this.game;this.touchStartCallback=null;this.touchMoveCallback=null;this.touchEndCallback=null;this.touchEnterCallback=null;this.touchLeaveCallback=null;this.touchCancelCallback=null;this.preventDefault=true};Phaser.Touch.prototype={game:null,disabled:false,_onTouchStart:null,_onTouchMove:null,_onTouchEnd:null,_onTouchEnter:null,_onTouchLeave:null,_onTouchCancel:null,_onTouchMove:null,start:function(){var b=this;if(this.game.device.touch){this._onTouchStart=function(c){return b.onTouchStart(c)};this._onTouchMove=function(c){return b.onTouchMove(c)};this._onTouchEnd=function(c){return b.onTouchEnd(c)};this._onTouchEnter=function(c){return b.onTouchEnter(c)};this._onTouchLeave=function(c){return b.onTouchLeave(c)};this._onTouchCancel=function(c){return b.onTouchCancel(c)};this.game.renderer.view.addEventListener("touchstart",this._onTouchStart,false);this.game.renderer.view.addEventListener("touchmove",this._onTouchMove,false);this.game.renderer.view.addEventListener("touchend",this._onTouchEnd,false);this.game.renderer.view.addEventListener("touchenter",this._onTouchEnter,false);this.game.renderer.view.addEventListener("touchleave",this._onTouchLeave,false);this.game.renderer.view.addEventListener("touchcancel",this._onTouchCancel,false)}},consumeDocumentTouches:function(){this._documentTouchMove=function(b){b.preventDefault()};document.addEventListener("touchmove",this._documentTouchMove,false)},onTouchStart:function(c){if(this.touchStartCallback){this.touchStartCallback.call(this.callbackContext,c)}if(this.game.input.disabled||this.disabled){return}if(this.preventDefault){c.preventDefault()}for(var b=0;bb&&this._tempPoint.xc&&this._tempPoint.y=this.pixelPerfectAlpha){return true}}return false},update:function(b){if(this.enabled==false||this.sprite.visible==false){this._pointerOutHandler(b);return false}if(this.draggable&&this._draggedPointerID==b.id){return this.updateDrag(b)}else{if(this._pointerData[b.id].isOver==true){if(this.checkPointerOver(b)){this._pointerData[b.id].x=b.x-this.sprite.x;this._pointerData[b.id].y=b.y-this.sprite.y;return true}else{this._pointerOutHandler(b);return false}}}},_pointerOverHandler:function(b){if(this._pointerData[b.id].isOver==false){this._pointerData[b.id].isOver=true;this._pointerData[b.id].isOut=false;this._pointerData[b.id].timeOver=this.game.time.now;this._pointerData[b.id].x=b.x-this.sprite.x;this._pointerData[b.id].y=b.y-this.sprite.y;if(this.useHandCursor&&this._pointerData[b.id].isDragged==false){this.game.stage.canvas.style.cursor="pointer"}this.sprite.events.onInputOver.dispatch(this.sprite,b)}},_pointerOutHandler:function(b){this._pointerData[b.id].isOver=false;this._pointerData[b.id].isOut=true;this._pointerData[b.id].timeOut=this.game.time.now;if(this.useHandCursor&&this._pointerData[b.id].isDragged==false){this.game.stage.canvas.style.cursor="default"}this.sprite.events.onInputOut.dispatch(this.sprite,b)},_touchedHandler:function(b){if(this._pointerData[b.id].isDown==false&&this._pointerData[b.id].isOver==true){this._pointerData[b.id].isDown=true;this._pointerData[b.id].isUp=false;this._pointerData[b.id].timeDown=this.game.time.now;this.sprite.events.onInputDown.dispatch(this.sprite,b);if(this.draggable&&this.isDragged==false){this.startDrag(b)}if(this.bringToTop){this.sprite.bringToTop()}}return this.consumePointerEvent},_releasedHandler:function(b){if(this._pointerData[b.id].isDown&&b.isUp){this._pointerData[b.id].isDown=false;this._pointerData[b.id].isUp=true;this._pointerData[b.id].timeUp=this.game.time.now;this._pointerData[b.id].downDuration=this._pointerData[b.id].timeUp-this._pointerData[b.id].timeDown;if(this.checkPointerOver(b)){this.sprite.events.onInputUp.dispatch(this.sprite,b)}else{if(this.useHandCursor){this.game.stage.canvas.style.cursor="default"}}if(this.draggable&&this.isDragged&&this._draggedPointerID==b.id){this.stopDrag(b)}}},updateDrag:function(b){if(b.isUp){this.stopDrag(b);return false}if(this.allowHorizontalDrag){this.sprite.x=b.x+this._dragPoint.x+this.dragOffset.x}if(this.allowVerticalDrag){this.sprite.y=b.y+this._dragPoint.y+this.dragOffset.y}if(this.boundsRect){this.checkBoundsRect()}if(this.boundsSprite){this.checkBoundsSprite()}if(this.snapOnDrag){this.sprite.x=Math.floor(this.sprite.x/this.snapX)*this.snapX;this.sprite.y=Math.floor(this.sprite.y/this.snapY)*this.snapY}return true},justOver:function(c,b){c=c||0;b=b||500;return(this._pointerData[c].isOver&&this.overDuration(c)this.boundsRect.right){this.sprite.x=this.boundsRect.right-this.sprite.width}}if(this.sprite.ythis.boundsRect.bottom){this.sprite.y=this.boundsRect.bottom-this.sprite.height}}},checkBoundsSprite:function(){if(this.sprite.x(this.boundsSprite.x+this.boundsSprite.width)){this.sprite.x=(this.boundsSprite.x+this.boundsSprite.width)-this.sprite.width}}if(this.sprite.y(this.boundsSprite.y+this.boundsSprite.height)){this.sprite.y=(this.boundsSprite.y+this.boundsSprite.height)-this.sprite.height}}}};Phaser.Events=function(b){this.parent=b;this.onAddedToGroup=new Phaser.Signal;this.onRemovedFromGroup=new Phaser.Signal;this.onKilled=new Phaser.Signal;this.onRevived=new Phaser.Signal;this.onOutOfBounds=new Phaser.Signal;this.onInputOver=null;this.onInputOut=null;this.onInputDown=null;this.onInputUp=null;this.onDragStart=null;this.onDragStop=null;this.onAnimationStart=null;this.onAnimationComplete=null;this.onAnimationLoop=null};Phaser.GameObjectFactory=function(b){this.game=b;this.world=this.game.world};Phaser.GameObjectFactory.prototype={game:null,world:null,existing:function(b){return this.world.group.add(b)},sprite:function(b,e,c,d){return this.world.group.add(new Phaser.Sprite(this.game,b,e,c,d))},child:function(d,b,g,c,e){var f=this.world.group.add(new Phaser.Sprite(this.game,b,g,c,e));d.addChild(f);return f},tween:function(b){return this.game.tweens.create(b)},group:function(c,b){return new Phaser.Group(this.game,c,b)},audio:function(c,d,b){return this.game.sound.add(c,d,b)},tileSprite:function(c,g,e,b,d,f){return this.world.group.add(new Phaser.TileSprite(this.game,c,g,e,b,d,f))},text:function(b,e,d,c){return this.world.group.add(new Phaser.Text(this.game,b,e,d,c))},button:function(b,i,g,h,e,d,f,c){return this.world.group.add(new Phaser.Button(this.game,b,i,g,h,e,d,f,c))},graphics:function(b,c){return this.world.group.add(new Phaser.Graphics(this.game,b,c))},emitter:function(b,d,c){return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game,b,d,c))},bitmapText:function(b,e,d,c){return this.world.group.add(new Phaser.BitmapText(this.game,b,e,d,c))},tilemap:function(b,g,d,e,f,c){return this.world.group.add(new Phaser.Tilemap(this.game,d,b,g,e,f,c))},renderTexture:function(c,d,b){var e=new Phaser.RenderTexture(this.game,c,d,b);this.game.cache.addRenderTexture(c,e);return e}};Phaser.Sprite=function(c,b,f,d,e){b=b||0;f=f||0;d=d||null;e=e||null;this.game=c;this.exists=true;this.alive=true;this.group=null;this.name="";this.type=Phaser.SPRITE;this.renderOrderID=-1;this.lifespan=0;this.events=new Phaser.Events(this);this.animations=new Phaser.AnimationManager(this);this.input=new Phaser.InputHandler(this);this.key=d;if(d instanceof Phaser.RenderTexture){PIXI.Sprite.call(this,d);this.currentFrame=this.game.cache.getTextureFrame(d.name)}else{if(d==null||this.game.cache.checkImageKey(d)==false){d="__default"}PIXI.Sprite.call(this,PIXI.TextureCache[d]);if(this.game.cache.isSpriteSheet(d)){this.animations.loadFrameData(this.game.cache.getFrameData(d));if(e!==null){if(typeof e==="string"){this.frameName=e}else{this.frame=e}}}else{this.currentFrame=this.game.cache.getFrame(d)}}this.anchor=new Phaser.Point();this._cropUUID=null;this._cropRect=null;this.x=b;this.y=f;this.position.x=b;this.position.y=f;this.autoCull=false;this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:f,id:1,i01:0,i10:0,idi:1,left:null,right:null,top:null,bottom:null,x:-1,y:-1,scaleX:1,scaleY:1,width:this.currentFrame.sourceSizeW,height:this.currentFrame.sourceSizeH,halfWidth:Math.floor(this.currentFrame.sourceSizeW/2),halfHeight:Math.floor(this.currentFrame.sourceSizeH/2),frameID:this.currentFrame.uuid,frameWidth:this.currentFrame.width,frameHeight:this.currentFrame.height,boundsX:0,boundsY:0,cameraVisible:true};this.offset=new Phaser.Point;this.center=new Phaser.Point(b+Math.floor(this._cache.width/2),f+Math.floor(this._cache.height/2));this.topLeft=new Phaser.Point(b,f);this.topRight=new Phaser.Point(b+this._cache.width,f);this.bottomRight=new Phaser.Point(b+this._cache.width,f+this._cache.height);this.bottomLeft=new Phaser.Point(b,f+this._cache.height);this.bounds=new Phaser.Rectangle(b,f,this._cache.width,this._cache.height);this.body=new Phaser.Physics.Arcade.Body(this);this.velocity=this.body.velocity;this.acceleration=this.body.acceleration;this.inWorld=Phaser.Rectangle.intersects(this.bounds,this.game.world.bounds);this.inWorldThreshold=0;this._outOfBoundsFired=false};Phaser.Sprite.prototype=Object.create(PIXI.Sprite.prototype);Phaser.Sprite.prototype.constructor=Phaser.Sprite;Phaser.Sprite.prototype.preUpdate=function(){if(!this.exists){this.renderOrderID=-1;return}if(this.lifespan>0){this.lifespan-=this.game.time.elapsed;if(this.lifespan<=0){this.kill();return}}this._cache.dirty=false;if(this.animations.update()){this._cache.dirty=true}this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);if(this.position.x!=this._cache.x||this.position.y!=this._cache.y){this.position.x=this._cache.x;this.position.y=this._cache.y;this._cache.dirty=true}if(this.visible){this.renderOrderID=this.game.world.currentRenderOrderID++}if(this.worldTransform[0]!=this._cache.a00||this.worldTransform[1]!=this._cache.a01){this._cache.a00=this.worldTransform[0];this._cache.a01=this.worldTransform[1];this._cache.i01=this.worldTransform[1];this._cache.scaleX=Math.sqrt((this._cache.a00*this._cache.a00)+(this._cache.a01*this._cache.a01));this._cache.a01*=-1;this._cache.dirty=true}if(this.worldTransform[3]!=this._cache.a10||this.worldTransform[4]!=this._cache.a11){this._cache.a10=this.worldTransform[3];this._cache.i10=this.worldTransform[3];this._cache.a11=this.worldTransform[4];this._cache.scaleY=Math.sqrt((this._cache.a10*this._cache.a10)+(this._cache.a11*this._cache.a11));this._cache.a10*=-1;this._cache.dirty=true}if(this.worldTransform[2]!=this._cache.a02||this.worldTransform[5]!=this._cache.a12){this._cache.a02=this.worldTransform[2];this._cache.a12=this.worldTransform[5];this._cache.dirty=true}if(this.currentFrame.uuid!=this._cache.frameID){this._cache.frameWidth=this.texture.frame.width;this._cache.frameHeight=this.texture.frame.height;this._cache.frameID=this.currentFrame.uuid;this._cache.dirty=true}if(this._cache.dirty){this._cache.width=Math.floor(this.currentFrame.sourceSizeW*this._cache.scaleX);this._cache.height=Math.floor(this.currentFrame.sourceSizeH*this._cache.scaleY);this._cache.halfWidth=Math.floor(this._cache.width/2);this._cache.halfHeight=Math.floor(this._cache.height/2);this._cache.id=1/(this._cache.a00*this._cache.a11+this._cache.a01*-this._cache.a10);this._cache.idi=1/(this._cache.a00*this._cache.a11+this._cache.i01*-this._cache.i10);this.updateBounds()}if(this._cache.dirty){this._cache.cameraVisible=Phaser.Rectangle.intersects(this.game.world.camera.screenView,this.bounds,0);if(this.autoCull==true){this.renderable=this._cache.cameraVisible}this.body.updateBounds(this.center.x,this.center.y,this._cache.scaleX,this._cache.scaleY)}this.body.update()};Phaser.Sprite.prototype.postUpdate=function(){if(this.exists){this.body.postUpdate()}};Phaser.Sprite.prototype.centerOn=function(b,c){this.x=b+(this.x-this.center.x);this.y=c+(this.y-this.center.y)};Phaser.Sprite.prototype.revive=function(){this.alive=true;this.exists=true;this.visible=true;this.events.onRevived.dispatch(this)};Phaser.Sprite.prototype.kill=function(){this.alive=false;this.exists=false;this.visible=false;this.events.onKilled.dispatch(this)};Phaser.Sprite.prototype.reset=function(b,c){this.x=b;this.y=c;this.position.x=b;this.position.y=c;this.alive=true;this.exists=true;this.visible=true;this._outOfBoundsFired=false;this.body.reset()};Phaser.Sprite.prototype.updateBounds=function(){this.offset.setTo(this._cache.a02-(this.anchor.x*this._cache.width),this._cache.a12-(this.anchor.y*this._cache.height));this.getLocalPosition(this.center,this.offset.x+this._cache.halfWidth,this.offset.y+this._cache.halfHeight);this.getLocalPosition(this.topLeft,this.offset.x,this.offset.y);this.getLocalPosition(this.topRight,this.offset.x+this._cache.width,this.offset.y);this.getLocalPosition(this.bottomLeft,this.offset.x,this.offset.y+this._cache.height);this.getLocalPosition(this.bottomRight,this.offset.x+this._cache.width,this.offset.y+this._cache.height);this._cache.left=Phaser.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);this._cache.right=Phaser.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);this._cache.top=Phaser.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);this._cache.bottom=Phaser.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);this.bounds.setTo(this._cache.left,this._cache.top,this._cache.right-this._cache.left,this._cache.bottom-this._cache.top);this._cache.boundsX=this._cache.x;this._cache.boundsY=this._cache.y;if(this.inWorld==false){this.inWorld=Phaser.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold);if(this.inWorld){this._outOfBoundsFired=false}}else{this.inWorld=Phaser.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold);if(this.inWorld==false){this.events.onOutOfBounds.dispatch(this);this._outOfBoundsFired=true}}};Phaser.Sprite.prototype.getLocalPosition=function(c,b,d){c.x=((this._cache.a11*this._cache.id*b+-this._cache.a01*this._cache.id*d+(this._cache.a12*this._cache.a01-this._cache.a02*this._cache.a11)*this._cache.id)*this._cache.scaleX)+this._cache.a02;c.y=((this._cache.a00*this._cache.id*d+-this._cache.a10*this._cache.id*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.a10)*this._cache.id)*this._cache.scaleY)+this._cache.a12;return c};Phaser.Sprite.prototype.getLocalUnmodifiedPosition=function(c,b,d){c.x=this._cache.a11*this._cache.idi*b+-this._cache.i01*this._cache.idi*d+(this._cache.a12*this._cache.i01-this._cache.a02*this._cache.a11)*this._cache.idi;c.y=this._cache.a00*this._cache.idi*d+-this._cache.i10*this._cache.idi*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.i10)*this._cache.idi;return c};Phaser.Sprite.prototype.bringToTop=function(){if(this.group){this.group.bringToTop(this)}else{this.game.world.bringToTop(this)}};Phaser.Sprite.prototype.getBounds=function(d){d=d||new Phaser.Rectangle;var f=Phaser.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);var c=Phaser.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x);var e=Phaser.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);var b=Phaser.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y);d.x=f;d.y=e;d.width=c-f;d.height=b-e;return d};Object.defineProperty(Phaser.Sprite.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.Sprite.prototype,"frame",{get:function(){return this.animations.frame},set:function(b){this.animations.frame=b}});Object.defineProperty(Phaser.Sprite.prototype,"frameName",{get:function(){return this.animations.frameName},set:function(b){this.animations.frameName=b}});Object.defineProperty(Phaser.Sprite.prototype,"inCamera",{get:function(){return this._cache.cameraVisible}});Object.defineProperty(Phaser.Sprite.prototype,"crop",{get:function(){return this._cropRect},set:function(b){if(b instanceof Phaser.Rectangle){if(this._cropUUID==null){this._cropUUID=this.game.rnd.uuid();PIXI.TextureCache[this._cropUUID]=new PIXI.Texture(PIXI.BaseTextureCache[this.key],{x:b.x,y:b.y,width:b.width,height:b.height})}else{PIXI.TextureCache[this._cropUUID].frame=b}this._cropRect=b;this.setTexture(PIXI.TextureCache[this._cropUUID])}}});Object.defineProperty(Phaser.Sprite.prototype,"inputEnabled",{get:function(){return(this.input.enabled)},set:function(b){if(b){if(this.input.enabled==false){this.input.start()}}else{if(this.input.enabled){this.input.stop()}}}});Phaser.TileSprite=function(d,c,h,f,b,e,g){c=c||0;h=h||0;f=f||256;b=b||256;e=e||null;g=g||null;Phaser.Sprite.call(this,d,c,h,e,g);this.texture=PIXI.TextureCache[e];PIXI.TilingSprite.call(this,this.texture,f,b);this.type=Phaser.TILESPRITE;this.tileScale=new Phaser.Point(1,1);this.tilePosition=new Phaser.Point(0,0)};Phaser.TileSprite.prototype=Phaser.Utils.extend(true,PIXI.TilingSprite.prototype,Phaser.Sprite.prototype);Phaser.TileSprite.prototype.constructor=Phaser.TileSprite;Phaser.Text=function(c,b,f,e,d){b=b||0;f=f||0;e=e||"";d=d||"";this.exists=true;this.alive=true;this.group=null;this.name="";this.game=c;this._text=e;this._style=d;PIXI.Text.call(this,e,d);this.type=Phaser.TEXT;this.position.x=this.x=b;this.position.y=this.y=f;this.anchor=new Phaser.Point();this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:f,id:1,x:-1,y:-1,scaleX:1,scaleY:1};this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);this.renderable=true};Phaser.Text.prototype=Object.create(PIXI.Text.prototype);Phaser.Text.prototype.constructor=Phaser.Text;Phaser.Text.prototype.update=function(){if(!this.exists){return}this._cache.dirty=false;this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);if(this.position.x!=this._cache.x||this.position.y!=this._cache.y){this.position.x=this._cache.x;this.position.y=this._cache.y;this._cache.dirty=true}};Object.defineProperty(Phaser.Text.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.Text.prototype,"text",{get:function(){return this._text},set:function(b){if(b!==this._text){this._text=b;this.dirty=true}}});Object.defineProperty(Phaser.Text.prototype,"style",{get:function(){return this._style},set:function(b){if(b!==this._style){this._style=b;this.dirty=true}}});Phaser.BitmapText=function(c,b,f,e,d){b=b||0;f=f||0;e=e||"";d=d||"";this.exists=true;this.alive=true;this.group=null;this.name="";this.game=c;PIXI.BitmapText.call(this,e,d);this.type=Phaser.BITMAPTEXT;this.position.x=b;this.position.y=f;this.anchor=new Phaser.Point();this.scale=new Phaser.Point(1,1);this.scrollFactor=new Phaser.Point(1,1);this._cache={dirty:false,a00:1,a01:0,a02:b,a10:0,a11:1,a12:f,id:1,x:-1,y:-1,scaleX:1,scaleY:1};this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);this.renderable=true};Phaser.BitmapText.prototype=Object.create(PIXI.BitmapText.prototype);Phaser.BitmapText.prototype.constructor=Phaser.BitmapText;Phaser.BitmapText.prototype.update=function(){if(!this.exists){return}this._cache.dirty=false;this._cache.x=this.x-(this.game.world.camera.x*this.scrollFactor.x);this._cache.y=this.y-(this.game.world.camera.y*this.scrollFactor.y);if(this.position.x!=this._cache.x||this.position.y!=this._cache.y){this.position.x=this._cache.x;this.position.y=this._cache.y;this._cache.dirty=true}this.pivot.x=this.anchor.x*this.width;this.pivot.y=this.anchor.y*this.height};Object.defineProperty(Phaser.BitmapText.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Object.defineProperty(Phaser.BitmapText.prototype,"x",{get:function(){return this.position.x},set:function(b){this.position.x=b}});Object.defineProperty(Phaser.BitmapText.prototype,"y",{get:function(){return this.position.y},set:function(b){this.position.y=b}});Phaser.Button=function(j,g,f,h,i,c,d,b,e){g=g||0;f=f||0;h=h||null;i=i||null;c=c||this;Phaser.Sprite.call(this,j,g,f,h,b);this.type=Phaser.BUTTON;this._onOverFrameName=null;this._onOutFrameName=null;this._onDownFrameName=null;this._onUpFrameName=null;this._onOverFrameID=null;this._onOutFrameID=null;this._onDownFrameID=null;this._onUpFrameID=null;this.onInputOver=new Phaser.Signal;this.onInputOut=new Phaser.Signal;this.onInputDown=new Phaser.Signal;this.onInputUp=new Phaser.Signal;this.setFrames(d,b,e);if(i!==null){this.onInputUp.add(i,c)}this.input.start(0,false,true);this.events.onInputOver.add(this.onInputOverHandler,this);this.events.onInputOut.add(this.onInputOutHandler,this);this.events.onInputDown.add(this.onInputDownHandler,this);this.events.onInputUp.add(this.onInputUpHandler,this)};Phaser.Button.prototype=Phaser.Utils.extend(true,Phaser.Sprite.prototype,PIXI.Sprite.prototype);Phaser.Button.prototype.constructor=Phaser.Button;Phaser.Button.prototype.setFrames=function(c,d,b){if(c!==null){if(typeof c==="string"){this._onOverFrameName=c}else{this._onOverFrameID=c}}if(d!==null){if(typeof d==="string"){this._onOutFrameName=d;this._onUpFrameName=d}else{this._onOutFrameID=d;this._onUpFrameID=d}}if(b!==null){if(typeof b==="string"){this._onDownFrameName=b}else{this._onDownFrameID=b}}};Phaser.Button.prototype.onInputOverHandler=function(b){if(this._onOverFrameName!=null){this.frameName=this._onOverFrameName}else{if(this._onOverFrameID!=null){this.frame=this._onOverFrameID}}if(this.onInputOver){this.onInputOver.dispatch(this,b)}};Phaser.Button.prototype.onInputOutHandler=function(b){if(this._onOutFrameName!=null){this.frameName=this._onOutFrameName}else{if(this._onOutFrameID!=null){this.frame=this._onOutFrameID}}if(this.onInputOut){this.onInputOut.dispatch(this,b)}};Phaser.Button.prototype.onInputDownHandler=function(b){if(this._onDownFrameName!=null){this.frameName=this._onDownFrameName}else{if(this._onDownFrameID!=null){this.frame=this._onDownFrameID}}if(this.onInputDown){this.onInputDown.dispatch(this,b)}};Phaser.Button.prototype.onInputUpHandler=function(b){if(this._onUpFrameName!=null){this.frameName=this._onUpFrameName}else{if(this._onUpFrameID!=null){this.frame=this._onUpFrameID}}if(this.onInputUp){this.onInputUp.dispatch(this,b)}};Phaser.Graphics=function(c,b,d){PIXI.Graphics.call(this);Phaser.Sprite.call(this,c,b,d);this.type=Phaser.GRAPHICS};Phaser.Graphics.prototype=Object.create(PIXI.Graphics.prototype);Phaser.Graphics.prototype.constructor=Phaser.Graphics;Phaser.Graphics.prototype=Phaser.Utils.extend(true,Phaser.Graphics.prototype,Phaser.Sprite.prototype);Object.defineProperty(Phaser.Graphics.prototype,"angle",{get:function(){return Phaser.Math.radToDeg(this.rotation)},set:function(b){this.rotation=Phaser.Math.degToRad(b)}});Phaser.RenderTexture=function(c,d,e,b){this.game=c;this.name=d;PIXI.EventTarget.call(this);this.width=e||100;this.height=b||100;this.indetityMatrix=PIXI.mat3.create();this.frame=new PIXI.Rectangle(0,0,this.width,this.height);this.type=Phaser.RENDERTEXTURE;if(PIXI.gl){this.initWebGL()}else{this.initCanvas()}};Phaser.RenderTexture.prototype=Phaser.Utils.extend(true,PIXI.RenderTexture.prototype);Phaser.RenderTexture.prototype.constructor=Phaser.RenderTexture;Phaser.Canvas={create:function(d,b){d=d||256;b=b||256;var c=document.createElement("canvas");c.width=d;c.height=b;c.style.display="block";return c},getOffset:function(c,b){b=b||new Phaser.Point;var d=c.getBoundingClientRect();var h=c.clientTop||document.body.clientTop||0;var g=c.clientLeft||document.body.clientLeft||0;var e=window.pageYOffset||c.scrollTop||document.body.scrollTop;var f=window.pageXOffset||c.scrollLeft||document.body.scrollLeft;b.x=d.left+f-g;b.y=d.top+e-h;return b},getAspectRatio:function(b){return b.width/b.height},setBackgroundColor:function(c,b){b=b||"rgb(0,0,0)";c.style.backgroundColor=b;return c},setTouchAction:function(b,c){c=c||"none";b.style.msTouchAction=c;b.style["ms-touch-action"]=c;b.style["touch-action"]=c;return b},addToDOM:function(b,c,d){c=c||"";if(typeof d==="undefined"){d=true}if(c!==""){if(document.getElementById(c)){document.getElementById(c).appendChild(b);if(d){document.getElementById(c).style.overflow="hidden"}}else{document.body.appendChild(b)}}else{document.body.appendChild(b)}return b},setTransform:function(f,h,g,d,b,e,c){f.setTransform(d,e,c,b,h,g);return f},setSmoothingEnabled:function(b,c){b.imageSmoothingEnabled=c;b.mozImageSmoothingEnabled=c;b.oImageSmoothingEnabled=c;b.webkitImageSmoothingEnabled=c;b.msImageSmoothingEnabled=c;return b},setImageRenderingCrisp:function(b){b.style["image-rendering"]="crisp-edges";b.style["image-rendering"]="-moz-crisp-edges";b.style["image-rendering"]="-webkit-optimize-contrast";b.style.msInterpolationMode="nearest-neighbor";return b},setImageRenderingBicubic:function(b){b.style["image-rendering"]="auto";b.style.msInterpolationMode="bicubic";return b}};Phaser.StageScaleMode=function(c,d,b){this._startHeight=0;this.forceLandscape=false;this.forcePortrait=false;this.incorrectOrientation=false;this.pageAlignHorizontally=false;this.pageAlignVeritcally=false;this.minWidth=null;this.maxWidth=null;this.minHeight=null;this.maxHeight=null;this.width=0;this.height=0;this.maxIterations=5;this.game=c;this.enterLandscape=new Phaser.Signal();this.enterPortrait=new Phaser.Signal();if(window.orientation){this.orientation=window.orientation}else{if(window.outerWidth>window.outerHeight){this.orientation=90}else{this.orientation=0}}this.scaleFactor=new Phaser.Point(1,1);this.aspectRatio=0;var e=this;window.addEventListener("orientationchange",function(f){return e.checkOrientation(f)},false);window.addEventListener("resize",function(f){return e.checkResize(f)},false)};Phaser.StageScaleMode.EXACT_FIT=0;Phaser.StageScaleMode.NO_SCALE=1;Phaser.StageScaleMode.SHOW_ALL=2;Phaser.StageScaleMode.prototype={startFullScreen:function(){if(this.isFullScreen){return}var b=this.game.canvas;if(b.requestFullScreen){b.requestFullScreen()}else{if(b.mozRequestFullScreen){b.mozRequestFullScreen()}else{if(b.webkitRequestFullScreen){b.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}}}this.game.stage.canvas.style.width="100%";this.game.stage.canvas.style.height="100%"},stopFullScreen:function(){if(document.cancelFullScreen){document.cancelFullScreen()}else{if(document.mozCancelFullScreen){document.mozCancelFullScreen()}else{if(document.webkitCancelFullScreen){document.webkitCancelFullScreen()}}}},checkOrientationState:function(){if(this.incorrectOrientation){if((this.forceLandscape&&window.innerWidth>window.innerHeight)||(this.forcePortrait&&window.innerHeight>window.innerWidth)){this.game.paused=false;this.incorrectOrientation=false;this.refresh()}}else{if((this.forceLandscape&&window.innerWidthwindow.outerHeight){this.orientation=90}else{this.orientation=0}if(this.isLandscape){this.enterLandscape.dispatch(this.orientation,true,false)}else{this.enterPortrait.dispatch(this.orientation,false,true)}if(this.game.stage.scaleMode!==Phaser.StageScaleMode.NO_SCALE){this.refresh()}},refresh:function(){var b=this;if(this.game.device.iPad==false&&this.game.device.webApp==false&&this.game.device.desktop==false){if(this.game.device.android&&this.game.device.chrome==false){window.scrollTo(0,1)}else{window.scrollTo(0,0)}}if(this._check==null&&this.maxIterations>0){this._iterations=this.maxIterations;this._check=window.setInterval(function(){return b.setScreenSize()},10);this.setScreenSize()}},setScreenSize:function(b){if(typeof b=="undefined"){b=false}if(this.game.device.iPad==false&&this.game.device.webApp==false&&this.game.device.desktop==false){if(this.game.device.android&&this.game.device.chrome==false){window.scrollTo(0,1)}else{window.scrollTo(0,0)}}this._iterations--;if(b||window.innerHeight>this._startHeight||this._iterations<0){document.documentElement.style.minHeight=window.innerHeight+"px";if(this.incorrectOrientation==true){this.setMaximum()}else{if(this.game.stage.scaleMode==Phaser.StageScaleMode.EXACT_FIT){this.setExactFit()}else{if(this.game.stage.scaleMode==Phaser.StageScaleMode.SHOW_ALL){this.setShowAll()}}}this.setSize();clearInterval(this._check);this._check=null}},setSize:function(){if(this.incorrectOrientation==false){if(this.maxWidth&&this.width>this.maxWidth){this.width=this.maxWidth}if(this.maxHeight&&this.height>this.maxHeight){this.height=this.maxHeight}if(this.minWidth&&this.widththis.maxWidth){this.width=this.maxWidth}else{this.width=b}if(this.maxHeight&&c>this.maxHeight){this.height=this.maxHeight}else{this.height=c}console.log("setExactFit",this.width,this.height,this.game.stage.offset)}};Object.defineProperty(Phaser.StageScaleMode.prototype,"isFullScreen",{get:function(){if(document.fullscreenElement===null||document.mozFullScreenElement===null||document.webkitFullscreenElement===null){return false}return true}});Object.defineProperty(Phaser.StageScaleMode.prototype,"isPortrait",{get:function(){return this.orientation==0||this.orientation==180}});Object.defineProperty(Phaser.StageScaleMode.prototype,"isLandscape",{get:function(){return this.orientation===90||this.orientation===-90}});Phaser.Device=function(){this.patchAndroidClearRectBug=false;this.desktop=false;this.iOS=false;this.android=false;this.chromeOS=false;this.linux=false;this.macOS=false;this.windows=false;this.canvas=false;this.file=false;this.fileSystem=false;this.localStorage=false;this.webGL=false;this.worker=false;this.touch=false;this.mspointer=false;this.css3D=false;this.pointerLock=false;this.arora=false;this.chrome=false;this.epiphany=false;this.firefox=false;this.ie=false;this.ieVersion=0;this.mobileSafari=false;this.midori=false;this.opera=false;this.safari=false;this.webApp=false;this.audioData=false;this.webAudio=false;this.ogg=false;this.opus=false;this.mp3=false;this.wav=false;this.m4a=false;this.webm=false;this.iPhone=false;this.iPhone4=false;this.iPad=false;this.pixelRatio=0;this._checkAudio();this._checkBrowser();this._checkCSS3D();this._checkDevice();this._checkFeatures();this._checkOS()};Phaser.Device.prototype={_checkOS:function(){var b=navigator.userAgent;if(/Android/.test(b)){this.android=true}else{if(/CrOS/.test(b)){this.chromeOS=true}else{if(/iP[ao]d|iPhone/i.test(b)){this.iOS=true}else{if(/Linux/.test(b)){this.linux=true}else{if(/Mac OS/.test(b)){this.macOS=true}else{if(/Windows/.test(b)){this.windows=true}}}}}}if(this.windows||this.macOS||this.linux){this.desktop=true}},_checkFeatures:function(){this.canvas=!!window.CanvasRenderingContext2D;try{this.localStorage=!!localStorage.getItem}catch(b){this.localStorage=false}this.file=!!window.File&&!!window.FileReader&&!!window.FileList&&!!window.Blob;this.fileSystem=!!window.requestFileSystem;this.webGL=(function(){try{return !!window.WebGLRenderingContext&&!!document.createElement("canvas").getContext("experimental-webgl")}catch(c){return false}})();this.worker=!!window.Worker;if("ontouchstart" in document.documentElement||window.navigator.msPointerEnabled){this.touch=true}if(window.navigator.msPointerEnabled){this.mspointer=true}this.pointerLock="pointerLockElement" in document||"mozPointerLockElement" in document||"webkitPointerLockElement" in document},_checkBrowser:function(){var b=navigator.userAgent;if(/Arora/.test(b)){this.arora=true}else{if(/Chrome/.test(b)){this.chrome=true}else{if(/Epiphany/.test(b)){this.epiphany=true}else{if(/Firefox/.test(b)){this.firefox=true}else{if(/Mobile Safari/.test(b)){this.mobileSafari=true}else{if(/MSIE (\d+\.\d+);/.test(b)){this.ie=true;this.ieVersion=parseInt(RegExp.$1)}else{if(/Midori/.test(b)){this.midori=true}else{if(/Opera/.test(b)){this.opera=true}else{if(/Safari/.test(b)){this.safari=true}}}}}}}}}if(navigator.standalone){this.webApp=true}},_checkAudio:function(){this.audioData=!!(window.Audio);this.webAudio=!!(window.webkitAudioContext||window.AudioContext);var d=document.createElement("audio");var b=false;try{if(b=!!d.canPlayType){if(d.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")){this.ogg=true}if(d.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")){this.opus=true}if(d.canPlayType("audio/mpeg;").replace(/^no$/,"")){this.mp3=true}if(d.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")){this.wav=true}if(d.canPlayType("audio/x-m4a;")||d.canPlayType("audio/aac;").replace(/^no$/,"")){this.m4a=true}if(d.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")){this.webm=true}}}catch(c){}},_checkDevice:function(){this.pixelRatio=window.devicePixelRatio||1;this.iPhone=navigator.userAgent.toLowerCase().indexOf("iphone")!=-1;this.iPhone4=(this.pixelRatio==2&&this.iPhone);this.iPad=navigator.userAgent.toLowerCase().indexOf("ipad")!=-1},_checkCSS3D:function(){var d=document.createElement("p");var e;var c={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(d,null);for(var b in c){if(d.style[b]!==undefined){d.style[b]="translate3d(1px,1px,1px)";e=window.getComputedStyle(d).getPropertyValue(c[b])}}document.body.removeChild(d);this.css3D=(e!==undefined&&e.length>0&&e!=="none")},canPlayAudio:function(b){if(b=="mp3"&&this.mp3){return true}else{if(b=="ogg"&&(this.ogg||this.opus)){return true}else{if(b=="m4a"&&this.m4a){return true}else{if(b=="wav"&&this.wav){return true}else{if(b=="webm"&&this.webm){return true}}}}}return false},isConsoleOpen:function(){if(window.console&&window.console.firebug){return true}if(window.console){console.profile();console.profileEnd();if(console.clear){console.clear()}return console.profiles.length>0}return false}};Phaser.RequestAnimationFrame=function(c){this.game=c;this._isSetTimeOut=false;this.isRunning=false;var d=["ms","moz","webkit","o"];for(var b=0;b>>0;c-=e;c*=e;e=c>>>0;c-=e;e+=c*4294967296}return(e>>>0)*2.3283064365386963e-10},integer:function(){return this.rnd.apply(this)*4294967296},frac:function(){return this.rnd.apply(this)+(this.rnd.apply(this)*2097152|0)*1.1102230246251565e-16},real:function(){return this.integer()+this.frac()},integerInRange:function(c,b){return Math.floor(this.realInRange(c,b))},realInRange:function(c,b){c=c||0;b=b||0;return this.frac()*(b-c)+c},normal:function(){return 1-2*this.frac()},uuid:function(){var d,c;for(c=d="";d++<36;c+=~d%5|d*3&4?(d^15?8^this.frac()*(d^20?16:4):4).toString(16):"-"){}return c},pick:function(b){return b[this.integerInRange(0,b.length)]},weightedPick:function(b){return b[~~(Math.pow(this.frac(),2)*b.length)]},timestamp:function(d,c){return this.realInRange(d||946684800000,c||1577862000000)},angle:function(){return this.integerInRange(-180,180)}};Phaser.Math={PI2:Math.PI*2,fuzzyEqual:function(d,c,e){if(typeof e==="undefined"){e=0.0001}return Math.abs(d-c)c-e},fuzzyCeil:function(b,c){if(typeof c==="undefined"){c=0.0001}return Math.ceil(b-c)},fuzzyFloor:function(b,c){if(typeof c==="undefined"){c=0.0001}return Math.floor(b+c)},average:function(){var b=[];for(var d=0;d<(arguments.length-0);d++){b[d]=arguments[d+0]}var e=0;for(var c=0;c0)?Math.floor(b):Math.ceil(b)},shear:function(b){return b%1},snapTo:function(b,d,c){if(typeof c==="undefined"){c=0}if(d==0){return b}b-=c;b=d*Math.round(b/d);return c+b},snapToFloor:function(b,d,c){if(typeof c==="undefined"){c=0}if(d==0){return b}b-=c;b=d*Math.floor(b/d);return c+b},snapToCeil:function(b,d,c){if(typeof c==="undefined"){c=0}if(d==0){return b}b-=c;b=d*Math.ceil(b/d);return c+b},snapToInArray:function(d,c,f){if(typeof f==="undefined"){f=true}if(f){c.sort()}if(dd/2){c+=d*2}if(b<-d/2&&c>d/2){b+=d*2}return b-c},interpolateAngles:function(c,b,d,e,f){if(typeof e==="undefined"){e=true}if(typeof f==="undefined"){f=null}c=this.normalizeAngle(c,e);b=this.normalizeAngleToAnother(b,c,e);return(typeof f==="function")?f(d,c,b-c,1):this.interpolateFloat(c,b,d)},chanceRoll:function(b){if(typeof b==="undefined"){b=50}if(b<=0){return false}else{if(b>=100){return true}else{if(Math.random()*100>=b){return false}else{return true}}}},numberArray:function(e,c){var b=[];for(var d=e;d<=c;d++){b.push(d)}return b},maxAdd:function(d,c,b){d+=c;if(d>b){d=b}return d},minSub:function(d,c,b){d-=c;if(d0.5)?1:-1},isOdd:function(b){return(b&1)},isEven:function(b){if(b&1){return false}else{return true}},max:function(){for(var d=1,c=0,b=arguments.length;d=-180&&c<=180){return c}b=(c+180)%360;if(b<0){b+=360}return b-180},angleLimit:function(e,d,c){var b=e;if(e>c){b=c}else{if(e1){return this.linear(d[b],d[b-1],b-g)}return this.linear(d[e],d[e+1>b?b:e+1],g-e)},bezierInterpolation:function(e,d){var c=0;var g=e.length-1;for(var f=0;f<=g;f++){c+=Math.pow(1-d,g-f)*Math.pow(d,f)*e[f]*this.bernstein(g,f)}return c},catmullRomInterpolation:function(d,c){var b=d.length-1;var g=b*c;var e=Math.floor(g);if(d[0]===d[b]){if(c<0){e=Math.floor(g=b*(1+c))}return this.catmullRom(d[(e-1+b)%b],d[e],d[(e+1)%b],d[(e+2)%b],g-e)}else{if(c<0){return d[0]-(this.catmullRom(d[0],d[0],d[1],d[1],-g)-d[0])}if(c>1){return d[b]-(this.catmullRom(d[b],d[b],d[b-1],d[b-1],g-b)-d[b])}return this.catmullRom(d[e?e-1:0],d[e],d[bd.length-e)){b=d.length-e}if(b>0){return d[e+Math.floor(Math.random()*b)]}}return null},floor:function(b){var c=b|0;return(b>0)?(c):((c!=b)?(c-1):(c))},ceil:function(b){var c=b|0;return(b>0)?((c!=b)?(c+1):(c)):(c)},sinCosGenerator:function(b,j,d,h){if(typeof j==="undefined"){j=1}if(typeof d==="undefined"){d=1}if(typeof h==="undefined"){h=1}var i=j;var l=d;var f=h*Math.PI/b;var e=[];var k=[];for(var g=0;g0;d--){var c=Math.floor(Math.random()*(d+1));var b=e[d];e[d]=e[c];e[c]=b}return e},distance:function(e,g,d,f){var c=e-d;var b=g-f;return Math.sqrt(c*c+b*b)},distanceRounded:function(c,e,b,d){return Math.round(Phaser.Math.distance(c,e,b,d))},clamp:function(d,e,c){return(dc)?c:d)},clampBottom:function(b,c){return b=b){return 1}c=(c-d)/(b-d);return c*c*(3-2*c)},smootherstep:function(c,d,b){if(c<=d){return 0}if(c>=b){return 1}c=(c-d)/(b-d);return c*c*c*(c*(c*6-15)+10)},sign:function(b){return(b<0)?-1:((b>0)?1:0)},degToRad:function(){var b=Math.PI/180;return function(c){return c*b}}(),radToDeg:function(){var b=180/Math.PI;return function(c){return c*b}}()};Phaser.QuadTree=function(g,c,i,f,b,e,d,h){this.physicsManager=g;this.ID=g.quadTreeID;g.quadTreeID++;this.maxObjects=e||10;this.maxLevels=d||4;this.level=h||0;this.bounds={x:Math.round(c),y:Math.round(i),width:f,height:b,subWidth:Math.floor(f/2),subHeight:Math.floor(b/2),right:Math.round(c)+Math.floor(f/2),bottom:Math.round(i)+Math.floor(b/2)};this.objects=[];this.nodes=[]};Phaser.QuadTree.prototype={split:function(){this.level++;this.nodes[0]=new Phaser.QuadTree(this.physicsManager,this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[1]=new Phaser.QuadTree(this.physicsManager,this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[2]=new Phaser.QuadTree(this.physicsManager,this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level);this.nodes[3]=new Phaser.QuadTree(this.physicsManager,this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level)},insert:function(b){var d=0;var c;if(this.nodes[0]!=null){c=this.getIndex(b);if(c!==-1){this.nodes[c].insert(b);return}}this.objects.push(b);if(this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom)){b=2}}}else{if(c.x>this.bounds.right){if((c.ythis.bounds.bottom)){b=3}}}}return b},retrieve:function(b){var c=this.objects;b.body.quadTreeIndex=this.getIndex(b.body);b.body.quadTreeIDs.push(this.ID);if(this.nodes[0]){if(b.body.quadTreeIndex!==-1){c=c.concat(this.nodes[b.body.quadTreeIndex].retrieve(b))}else{c=c.concat(this.nodes[0].retrieve(b));c=c.concat(this.nodes[1].retrieve(b));c=c.concat(this.nodes[2].retrieve(b));c=c.concat(this.nodes[3].retrieve(b))}}return c},clear:function(){this.objects=[];for(var c=0,b=this.nodes.length;c0){this._radius=c*0.5}else{this._radius=0}};Phaser.Circle.prototype={circumference:function(){return 2*(Math.PI*this._radius)},setTo:function(b,d,c){this.x=b;this.y=d;this._diameter=c;this._radius=c*0.5;return this},copyFrom:function(b){return this.setTo(b.x,b.y,b.diameter)},copyTo:function(b){b[x]=this.x;b[y]=this.y;b[diameter]=this._diameter;return b},distance:function(c,b){if(typeof b==="undefined"){b=false}if(b){return Phaser.Math.distanceRound(this.x,this.y,c.x,c.y)}else{return Phaser.Math.distance(this.x,this.y,c.x,c.y)}},clone:function(b){if(typeof b==="undefined"){b=new Phaser.Circle()}return b.setTo(a.x,a.y,a.diameter)},contains:function(b,c){return Phaser.Circle.contains(this,b,c)},circumferencePoint:function(d,c,b){return Phaser.Circle.circumferencePoint(this,d,c,b)},offset:function(c,b){this.x+=c;this.y+=b;return this},offsetPoint:function(b){return this.offset(b.x,b.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}};Object.defineProperty(Phaser.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(b){if(b>0){this._diameter=b;this._radius=b*0.5}}});Object.defineProperty(Phaser.Circle.prototype,"radius",{get:function(){return this._radius},set:function(b){if(b>0){this._radius=b;this._diameter=b*2}}});Object.defineProperty(Phaser.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(b){if(b>this.x){this._radius=0;this._diameter=0}else{this.radius=this.x-b}}});Object.defineProperty(Phaser.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(b){if(bthis.y){this._radius=0;this._diameter=0}else{this.radius=this.y-b}}});Object.defineProperty(Phaser.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(b){if(b0){return Math.PI*this._radius*this._radius}else{return 0}}});Object.defineProperty(Phaser.Circle.prototype,"empty",{get:function(){return(this._diameter==0)},set:function(b){this.setTo(0,0,0)}});Phaser.Circle.contains=function(d,b,f){if(b>=d.left&&b<=d.right&&f>=d.top&&f<=d.bottom){var e=(d.x-b)*(d.x-b);var c=(d.y-f)*(d.y-f);return(e+c)<=(d.radius*d.radius)}return false};Phaser.Circle.equals=function(d,c){return(d.x==c.x&&d.y==c.y&&d.diameter==c.diameter)};Phaser.Circle.intersects=function(d,c){return(Phaser.Math.distance(d.x,d.y,c.x,c.y)<=(d.radius+c.radius))};Phaser.Circle.circumferencePoint=function(b,e,d,c){if(typeof d==="undefined"){d=false}if(typeof c==="undefined"){c=new Phaser.Point()}if(d===true){e=Phaser.Math.radToDeg(e)}c.x=b.x+b.radius*Math.cos(e);c.y=b.y+b.radius*Math.sin(e);return c};Phaser.Circle.intersectsRectangle=function(m,d){var g=Math.abs(m.x-d.x-d.halfWidth);var l=d.halfWidth+m.radius;if(g>l){return false}var f=Math.abs(m.y-d.y-d.halfHeight);var j=d.halfHeight+m.radius;if(f>j){return false}if(g<=d.halfWidth||f<=d.halfHeight){return true}var h=g-d.halfWidth;var e=f-d.halfHeight;var k=h*h;var b=e*e;var i=m.radius*m.radius;return k+b<=i};Phaser.Point=function(b,c){b=b||0;c=c||0;this.x=b;this.y=c};Phaser.Point.prototype={copyFrom:function(b){return this.setTo(b.x,b.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(b,c){this.x=b;this.y=c;return this},add:function(b,c){this.x+=b;this.y+=c;return this},subtract:function(b,c){this.x-=b;this.y-=c;return this},multiply:function(b,c){this.x*=b;this.y*=c;return this},divide:function(b,c){this.x/=b;this.y/=c;return this},clampX:function(c,b){this.x=Phaser.Math.clamp(this.x,c,b);return this},clampY:function(c,b){this.y=Phaser.Math.clamp(this.y,c,b);return this},clamp:function(c,b){this.x=Phaser.Math.clamp(this.x,c,b);this.y=Phaser.Math.clamp(this.y,c,b);return this},clone:function(b){if(typeof b==="undefined"){b=new Phaser.Point}return b.setTo(this.x,this.y)},copyFrom:function(b){return this.setTo(b.x,b.y)},copyTo:function(b){b[x]=this.x;b[y]=this.y;return b},distance:function(c,b){return Phaser.Point.distance(this,c,b)},equals:function(b){return(b.x==this.x&&b.y==this.y)},rotate:function(b,f,d,c,e){return Phaser.Point.rotate(this,b,f,d,c,e)},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}};Phaser.Point.add=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x+c.x;e.y=d.y+c.y;return e};Phaser.Point.subtract=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x-c.x;e.y=d.y-c.y;return e};Phaser.Point.multiply=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x*c.x;e.y=d.y*c.y;return e};Phaser.Point.divide=function(d,c,e){if(typeof e==="undefined"){e=new Phaser.Point()}e.x=d.x/c.x;e.y=d.y/c.y;return e};Phaser.Point.equals=function(d,c){return(d.x==c.x&&d.y==c.y)};Phaser.Point.distance=function(d,c,e){if(typeof e==="undefined"){e=false}if(e){return Phaser.Math.distanceRound(d.x,d.y,c.x,c.y)}else{return Phaser.Math.distance(d.x,d.y,c.x,c.y)}},Phaser.Point.rotate=function(c,b,g,e,d,f){d=d||false;f=f||null;if(d){e=Phaser.Math.radToDeg(e)}if(f===null){f=Math.sqrt(((b-c.x)*(b-c.x))+((g-c.y)*(g-c.y)))}return c.setTo(b+f*Math.cos(e),g+f*Math.sin(e))};Phaser.Rectangle=function(c,e,d,b){c=c||0;e=e||0;d=d||0;b=b||0;this.x=c;this.y=e;this.width=d;this.height=b};Phaser.Rectangle.prototype={offset:function(c,b){this.x+=c;this.y+=b;return this},offsetPoint:function(b){return this.offset(b.x,b.y)},setTo:function(c,e,d,b){this.x=c;this.y=e;this.width=d;this.height=b;return this},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y)},copyFrom:function(b){return this.setTo(b.x,b.y,b.width,b.height)},copyTo:function(b){b.x=this.x;b.y=this.y;b.width=this.width;b.height=this.height;return b},inflate:function(c,b){return Phaser.Rectangle.inflate(this,c,b)},size:function(b){return Phaser.Rectangle.size(this,b)},clone:function(b){return Phaser.Rectangle.clone(this,b)},contains:function(b,c){return Phaser.Rectangle.contains(this,b,c)},containsRect:function(c){return Phaser.Rectangle.containsRect(this,c)},equals:function(c){return Phaser.Rectangle.equals(this,c)},intersection:function(c,d){return Phaser.Rectangle.intersection(this,c,output)},intersects:function(c,d){return Phaser.Rectangle.intersects(this,c,d)},intersectsRaw:function(f,d,e,c,b){return Phaser.Rectangle.intersectsRaw(this,f,d,e,c,b)},union:function(c,d){return Phaser.Rectangle.union(this,c,d)},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}};Object.defineProperty(Phaser.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}});Object.defineProperty(Phaser.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}});Object.defineProperty(Phaser.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(b){if(b<=this.y){this.height=0}else{this.height=(this.y-b)}}});Object.defineProperty(Phaser.Rectangle.prototype,"bottomRight",{get:function(){return new Phaser.Point(this.right,this.bottom)},set:function(b){this.right=b.x;this.bottom=b.y}});Object.defineProperty(Phaser.Rectangle.prototype,"left",{get:function(){return this.x},set:function(b){if(b>=this.right){this.width=0}else{this.width=this.right-b}this.x=b}});Object.defineProperty(Phaser.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(b){if(b<=this.x){this.width=0}else{this.width=this.x+b}}});Object.defineProperty(Phaser.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}});Object.defineProperty(Phaser.Rectangle.prototype,"perimeter",{get:function(){return(this.width*2)+(this.height*2)}});Object.defineProperty(Phaser.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(b){this.x=b-this.halfWidth}});Object.defineProperty(Phaser.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(b){this.y=b-this.halfHeight}});Object.defineProperty(Phaser.Rectangle.prototype,"top",{get:function(){return this.y},set:function(b){if(b>=this.bottom){this.height=0;this.y=b}else{this.height=(this.bottom-b)}}});Object.defineProperty(Phaser.Rectangle.prototype,"topLeft",{get:function(){return new Phaser.Point(this.x,this.y)},set:function(b){this.x=b.x;this.y=b.y}});Object.defineProperty(Phaser.Rectangle.prototype,"empty",{get:function(){return(!this.width||!this.height)},set:function(b){this.setTo(0,0,0,0)}});Phaser.Rectangle.inflate=function(c,d,b){c.x-=d;c.width+=2*d;c.y-=b;c.height+=2*b;return c};Phaser.Rectangle.inflatePoint=function(c,b){return Phaser.Phaser.Rectangle.inflate(c,b.x,b.y)};Phaser.Rectangle.size=function(b,c){if(typeof c==="undefined"){c=new Phaser.Point()}return c.setTo(b.width,b.height)};Phaser.Rectangle.clone=function(b,c){if(typeof c==="undefined"){c=new Phaser.Rectangle()}return c.setTo(b.x,b.y,b.width,b.height)};Phaser.Rectangle.contains=function(c,b,d){return(b>=c.x&&b<=c.right&&d>=c.y&&d<=c.bottom)};Phaser.Rectangle.containsPoint=function(c,b){return Phaser.Phaser.Rectangle.contains(c,b.x,b.y)};Phaser.Rectangle.containsRect=function(d,c){if(d.volume>c.volume){return false}return(d.x>=c.x&&d.y>=c.y&&d.right<=c.right&&d.bottom<=c.bottom)};Phaser.Rectangle.equals=function(d,c){return(d.x==c.x&&d.y==c.y&&d.width==c.width&&d.height==c.height)};Phaser.Rectangle.intersection=function(d,c,e){e=e||new Phaser.Rectangle;if(Phaser.Rectangle.intersects(d,c)){e.x=Math.max(d.x,c.x);e.y=Math.max(d.y,c.y);e.width=Math.min(d.right,c.right)-e.x;e.height=Math.min(d.bottom,c.bottom)-e.y}return e};Phaser.Rectangle.intersects=function(d,c,e){e=e||0;return !(d.x>c.right+e||d.rightc.bottom+e||d.bottomb.right+c||eb.bottom+c||d1){if(f&&f==this.decodeURI(d[0])){return this.decodeURI(d[1])}else{c[this.decodeURI(d[0])]=this.decodeURI(d[1])}}}return c},decodeURI:function(b){return decodeURIComponent(b.replace(/\+/g," "))}};Phaser.TweenManager=function(b){this.game=b;this._tweens=[];this._add=[];this.game.onPause.add(this.pauseAll,this);this.game.onResume.add(this.resumeAll,this)};Phaser.TweenManager.prototype={REVISION:"11dev",getAll:function(){return this._tweens},removeAll:function(){this._tweens=[]},add:function(b){this._add.push(b)},create:function(b){return new Phaser.Tween(b,this.game)},remove:function(c){var b=this._tweens.indexOf(c);if(b!==-1){this._tweens[b].pendingDelete=true}},update:function(){if(this._tweens.length===0&&this._add.length===0){return false}var b=0;var c=this._tweens.length;while(b0){this._tweens=this._tweens.concat(this._add);this._add.length=0}return true},pauseAll:function(){for(var b=this._tweens.length-1;b>=0;b--){this._tweens[b].pause()}},resumeAll:function(){for(var b=this._tweens.length-1;b>=0;b--){this._tweens[b].resume()}}};Phaser.Tween=function(c,b){this._object=c;this.game=b;this._manager=this.game.tweens;this._valuesStart={};this._valuesEnd={};this._valuesStartRepeat={};this._duration=1000;this._repeat=0;this._yoyo=false;this._reversed=false;this._delayTime=0;this._startTime=null;this._easingFunction=Phaser.Easing.Linear.None;this._interpolationFunction=Phaser.Math.linearInterpolation;this._chainedTweens=[];this._onStartCallback=null;this._onStartCallbackFired=false;this._onUpdateCallback=null;this._onCompleteCallback=null;this._pausedTime=0;this._parent=null;this.pendingDelete=false;for(var d in c){this._valuesStart[d]=parseFloat(c[d],10)}this.onStart=new Phaser.Signal();this.onComplete=new Phaser.Signal();this.isRunning=false};Phaser.Tween.prototype={to:function(e,h,i,d,c,g,f){h=h||1000;i=i||null;d=d||false;c=c||0;g=g||0;f=f||false;var b;if(this._parent){b=this._manager.create(this._object);b._parent=this._parent;this.chain(b)}else{b=this;b._parent=b}b._repeat=g;b._duration=h;b._valuesEnd=e;if(i!==null){b._easingFunction=i}if(c>0){b._delayTime=c}b._yoyo=f;if(d){return b.start()}else{return b}},start:function(c){if(this.game===null||this._object===null){return}this._manager.add(this);this.onStart.dispatch(this._object);this.isRunning=true;this._onStartCallbackFired=false;this._startTime=this.game.time.now+this._delayTime;for(var b in this._valuesEnd){if(this._valuesEnd[b] instanceof Array){if(this._valuesEnd[b].length===0){continue}this._valuesEnd[b]=[this._object[b]].concat(this._valuesEnd[b])}this._valuesStart[b]=this._object[b];if((this._valuesStart[b] instanceof Array)===false){this._valuesStart[b]*=1}this._valuesStartRepeat[b]=this._valuesStart[b]||0}return this},stop:function(){this._manager.remove(this);this.isRunning=false;return this},delay:function(b){this._delayTime=b;return this},repeat:function(b){this._repeat=b;return this},yoyo:function(b){this._yoyo=b;return this},easing:function(b){this._easingFunction=b;return this},interpolation:function(b){this._interpolationFunction=b;return this},chain:function(){this._chainedTweens=arguments;return this},loop:function(){if(this._parent){this.chain(this._parent)}return this},onStartCallback:function(b){this._onStartCallback=b;return this},onUpdateCallback:function(b){this._onUpdateCallback=b;return this},onCompleteCallback:function(b){this._onCompleteCallback=b;return this},pause:function(){this._paused=true},resume:function(){this._paused=false;this._startTime+=this.game.time.pauseDuration},update:function(c){if(this.pendingDelete){return false}if(this._paused||c1?1:k;var h=this._easingFunction(k);for(j in this._valuesEnd){var b=this._valuesStart[j]||0;var d=this._valuesEnd[j];if(d instanceof Array){this._object[j]=this._interpolationFunction(d,h)}else{if(typeof(d)==="string"){d=b+parseFloat(d,10)}if(typeof(d)==="number"){this._object[j]=b+(d-b)*h}}}if(this._onUpdateCallback!==null){this._onUpdateCallback.call(this._object,h)}if(k==1){if(this._repeat>0){if(isFinite(this._repeat)){this._repeat--}for(j in this._valuesStartRepeat){if(typeof(this._valuesEnd[j])==="string"){this._valuesStartRepeat[j]=this._valuesStartRepeat[j]+parseFloat(this._valuesEnd[j],10)}if(this._yoyo){var e=this._valuesStartRepeat[j];this._valuesStartRepeat[j]=this._valuesEnd[j];this._valuesEnd[j]=e;this._reversed=!this._reversed}this._valuesStart[j]=this._valuesStartRepeat[j]}this._startTime=c+this._delayTime;this.onComplete.dispatch(this._object);if(this._onCompleteCallback!==null){this._onCompleteCallback.call(this._object)}return true}else{this.onComplete.dispatch(this._object);if(this._onCompleteCallback!==null){this._onCompleteCallback.call(this._object)}for(var f=0,g=this._chainedTweens.length;fthis._timeLastSecond+1000){this.fps=Math.round((this.frames*1000)/(this.now-this._timeLastSecond));this.fpsMin=this.game.math.min(this.fpsMin,this.fps);this.fpsMax=this.game.math.max(this.fpsMax,this.fps);this._timeLastSecond=this.now;this.frames=0}this.time=this.now;this.lastTime=b+this.timeToCall;this.physicsElapsed=1*(this.elapsed/1000);if(this.game.paused){this.pausedTime=this.now-this._pauseStarted}},gamePaused:function(){this._pauseStarted=this.now},gameResumed:function(){this.time=Date.now();this.pauseDuration=this.pausedTime;this._justResumed=true},elapsedSince:function(b){return this.now-b},elapsedSecondsSince:function(b){return(this.now-b)*0.001},reset:function(){this._started=this.now}};Phaser.AnimationManager=function(b){this.sprite=b;this.game=b.game;this.currentFrame=null;this.updateIfVisible=true;this._frameData=null;this._anims={};this._outputFrames=[]};Phaser.AnimationManager.prototype={loadFrameData:function(b){this._frameData=b;this.frame=0},add:function(e,f,d,c,b){if(this._frameData==null){console.warn("No FrameData available for Phaser.Animation "+e);return}d=d||60;if(typeof c==="undefined"){c=false}if(typeof b==="undefined"){b=true}if(this.sprite.events.onAnimationStart==null){this.sprite.events.onAnimationStart=new Phaser.Signal();this.sprite.events.onAnimationComplete=new Phaser.Signal();this.sprite.events.onAnimationLoop=new Phaser.Signal()}this._outputFrames.length=0;this._frameData.getFrameIndexes(f,b,this._outputFrames);this._anims[e]=new Phaser.Animation(this.game,this.sprite,e,this._frameData,this._outputFrames,d,c);this.currentAnim=this._anims[e];this.currentFrame=this.currentAnim.currentFrame;this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);return this._anims[e]},validateFrames:function(d,b){if(typeof b=="undefined"){b=true}for(var c=0;cthis._frameData.total){return false}}else{if(this._frameData.checkFrameName(d[c])==false){return false}}}return true},play:function(d,c,b){if(this._anims[d]){if(this.currentAnim==this._anims[d]){if(this.currentAnim.isPlaying==false){return this.currentAnim.play(c,b)}}else{this.currentAnim=this._anims[d];return this.currentAnim.play(c,b)}}},stop:function(c,b){if(typeof b=="undefined"){b=false}if(typeof c=="string"){if(this._anims[c]){this.currentAnim=this._anims[c];this.currentAnim.stop(b)}}else{if(this.currentAnim){this.currentAnim.stop(b)}}},update:function(){if(this.updateIfVisible&&this.sprite.visible==false){return false}if(this.currentAnim&&this.currentAnim.update()==true){this.currentFrame=this.currentAnim.currentFrame;this.sprite.currentFrame=this.currentFrame;return true}return false},destroy:function(){this._anims={};this._frameData=null;this._frameIndex=0;this.currentAnim=null;this.currentFrame=null}};Object.defineProperty(Phaser.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}});Object.defineProperty(Phaser.AnimationManager.prototype,"frameTotal",{get:function(){if(this._frameData){return this._frameData.total}else{return -1}}});Object.defineProperty(Phaser.AnimationManager.prototype,"frame",{get:function(){if(this.currentFrame){return this._frameIndex}},set:function(b){if(this._frameData&&this._frameData.getFrame(b)!==null){this.currentFrame=this._frameData.getFrame(b);this._frameIndex=b;this.sprite.currentFrame=this.currentFrame;this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}}});Object.defineProperty(Phaser.AnimationManager.prototype,"frameName",{get:function(){if(this.currentFrame){return this.currentFrame.name}},set:function(b){if(this._frameData&&this._frameData.getFrameByName(b)!==null){this.currentFrame=this._frameData.getFrameByName(b);this._frameIndex=this.currentFrame.index;this.sprite.currentFrame=this.currentFrame;this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}else{console.warn("Cannot set frameName: "+b)}}});Phaser.Animation=function(c,g,e,f,h,d,b){this.game=c;this._parent=g;this._frameData=f;this.name=e;this._frames=[];this._frames=this._frames.concat(h);this.delay=1000/d;this.looped=b;this.isFinished=false;this.isPlaying=false;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])};Phaser.Animation.prototype={play:function(c,b){c=c||null;b=b||null;if(c!==null){this.delay=1000/c}if(b!==null){this.looped=b}this.isPlaying=true;this.isFinished=false;this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);if(this._parent.events){this._parent.events.onAnimationStart.dispatch(this._parent,this)}return this},restart:function(){this.isPlaying=true;this.isFinished=false;this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])},stop:function(b){if(typeof b==="undefined"){b=false}this.isPlaying=false;this.isFinished=true;if(b){this.currentFrame=this._frameData.getFrame(this._frames[0])}},update:function(){if(this.isPlaying==true&&this.game.time.now>=this._timeNextFrame){this._frameIndex++;if(this._frameIndex==this._frames.length){if(this.looped){this._frameIndex=0;this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);this._parent.events.onAnimationLoop.dispatch(this._parent,this)}else{this.onComplete()}}else{this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]);this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}this._timeLastFrame=this.game.time.now;this._timeNextFrame=this.game.time.now+this.delay;return true}return false},destroy:function(){this.game=null;this._parent=null;this._frames=null;this._frameData=null;this.currentFrame=null;this.isPlaying=false},onComplete:function(){this.isPlaying=false;this.isFinished=true;if(this._parent.events){this._parent.events.onAnimationComplete.dispatch(this._parent,this)}}};Object.defineProperty(Phaser.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}});Object.defineProperty(Phaser.Animation.prototype,"frame",{get:function(){if(this.currentFrame!==null){return this.currentFrame.index}else{return this._frameIndex}},set:function(b){this.currentFrame=this._frameData.getFrame(b);if(this.currentFrame!==null){this._frameIndex=b;this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid])}}});Phaser.Animation.Frame=function(e,c,h,g,b,d,f){this.index=e;this.x=c;this.y=h;this.width=g;this.height=b;this.name=d;this.uuid=f;this.centerX=Math.floor(g/2);this.centerY=Math.floor(b/2);this.distance=Phaser.Math.distance(0,0,g,b);this.rotated=false;this.rotationDirection="cw";this.trimmed=false;this.sourceSizeW=g;this.sourceSizeH=b;this.spriteSourceSizeX=0;this.spriteSourceSizeY=0;this.spriteSourceSizeW=0;this.spriteSourceSizeH=0};Phaser.Animation.Frame.prototype={setTrim:function(f,e,h,c,b,d,g){this.trimmed=f;if(f){this.width=e;this.height=h;this.sourceSizeW=e;this.sourceSizeH=h;this.centerX=Math.floor(e/2);this.centerY=Math.floor(h/2);this.spriteSourceSizeX=c;this.spriteSourceSizeY=b;this.spriteSourceSizeW=d;this.spriteSourceSizeH=g}}};Phaser.Animation.FrameData=function(){this._frames=[];this._frameNames=[]};Phaser.Animation.FrameData.prototype={addFrame:function(b){b.index=this._frames.length;this._frames.push(b);if(b.name!==""){this._frameNames[b.name]=b.index}return b},getFrame:function(b){if(this._frames[b]){return this._frames[b]}return null},getFrameByName:function(b){if(typeof this._frameNames[b]==="number"){return this._frames[this._frameNames[b]]}return null},checkFrameName:function(b){if(this._frameNames[b]==null){return false}return true},getFrameRange:function(e,b,c){if(typeof c==="undefined"){c=[]}for(var d=e;d<=b;d++){c.push(this._frames[d])}return c},getFrames:function(f,c,d){if(typeof c==="undefined"){c=true}if(typeof d==="undefined"){d=[]}if(typeof f==="undefined"||f.length==0){for(var e=0;e tag");return}var d=new Phaser.Animation.FrameData();var j=g.getElementsByTagName("SubTexture");var f;for(var e=0;e0){this._progressChunk=100/this._keys.length;this.loadFile()}else{this.progress=100;this.hasLoaded=true;this.onLoadComplete.dispatch()}},loadFile:function(){var b=this._fileList[this._keys.shift()];var c=this;switch(b.type){case"image":case"spritesheet":case"textureatlas":case"bitmapfont":case"tilemap":b.data=new Image();b.data.name=b.key;b.data.onload=function(){return c.fileComplete(b.key)};b.data.onerror=function(){return c.fileError(b.key)};b.data.crossOrigin=this.crossOrigin;b.data.src=this.baseURL+b.url;break;case"audio":b.url=this.getAudioURL(b.url);if(b.url!==null){if(this.game.sound.usingWebAudio){this._xhr.open("GET",this.baseURL+b.url,true);this._xhr.responseType="arraybuffer";this._xhr.onload=function(){return c.fileComplete(b.key)};this._xhr.onerror=function(){return c.fileError(b.key)};this._xhr.send()}else{if(this.game.sound.usingAudioTag){if(this.game.sound.touchLocked){b.data=new Audio();b.data.name=b.key;b.data.preload="auto";b.data.src=this.baseURL+b.url;this.fileComplete(b.key)}else{b.data=new Audio();b.data.name=b.key;b.data.onerror=function(){return c.fileError(b.key)};b.data.preload="auto";b.data.src=this.baseURL+b.url;b.data.addEventListener("canplaythrough",Phaser.GAMES[this.game.id].load.fileComplete(b.key),false);b.data.load()}}}}else{this.fileError(b.key)}break;case"text":this._xhr.open("GET",this.baseURL+b.url,true);this._xhr.responseType="text";this._xhr.onload=function(){return c.fileComplete(b.key)};this._xhr.onerror=function(){return c.fileError(b.key)};this._xhr.send();break}},getAudioURL:function(c){var d;for(var b=0;b100){this.progress=100}if(this.preloadSprite!==null){if(this.preloadSprite.direction==0){this.preloadSprite.crop.width=(this.preloadSprite.width/100)*this.progress}else{this.preloadSprite.crop.height=(this.preloadSprite.height/100)*this.progress}this.preloadSprite.sprite.crop=this.preloadSprite.crop}this.onFileComplete.dispatch(this.progress,b,c,this.queueSize-this._keys.length,this.queueSize);if(this._keys.length>0){this.loadFile()}else{this.hasLoaded=true;this.isLoading=false;this.removeAll();this.onLoadComplete.dispatch()}}};Phaser.Loader.Parser={bitmapFont:function(q,h,l){if(!h.getElementsByTagName("font")){console.warn("Phaser.Loader.Parser.bitmapFont: Invalid XML given, missing tag");return}var m=PIXI.TextureCache[l];var e={};var c=h.getElementsByTagName("info")[0];var j=h.getElementsByTagName("common")[0];e.font=c.attributes.getNamedItem("face").nodeValue;e.size=parseInt(c.attributes.getNamedItem("size").nodeValue,10);e.lineHeight=parseInt(j.attributes.getNamedItem("lineHeight").nodeValue,10);e.chars={};var k=h.getElementsByTagName("char");for(var d=0;d=this.duration){if(this.usingWebAudio){if(this.loop){this.onLoop.dispatch(this);if(this.currentMarker==""){this.currentTime=0;this.startTime=this.game.time.now}else{this.play(this.currentMarker,0,this.volume,true,true)}}else{this.stop()}}else{if(this.loop){this.onLoop.dispatch(this);this.play(this.currentMarker,0,this.volume,true,true)}else{this.stop()}}}}},play:function(d,b,f,c,e){d=d||"";b=b||0;f=f||1;if(typeof c=="undefined"){c=false}if(typeof e=="undefined"){e=false}console.log(this.name+" play "+d+" position "+b+" volume "+f+" loop "+c);if(this.isPlaying==true&&e==false&&this.override==false){return}if(this.isPlaying&&this.override){if(this.usingWebAudio){if(typeof this._sound.stop==="undefined"){this._sound.noteOff(0)}else{this._sound.stop(0)}}else{if(this.usingAudioTag){this._sound.pause();this._sound.currentTime=0}}}this.currentMarker=d;if(d!==""&&this.markers[d]){this.position=this.markers[d].start;this.volume=this.markers[d].volume;this.loop=this.markers[d].loop;this.duration=this.markers[d].duration*1000;this._tempMarker=d;this._tempPosition=this.position;this._tempVolume=this.volume;this._tempLoop=this.loop}else{this.position=b;this.volume=f;this.loop=c;this.duration=0;this._tempMarker=d;this._tempPosition=b;this._tempVolume=f;this._tempLoop=c}if(this.usingWebAudio){if(this.game.cache.isSoundDecoded(this.key)){if(this._buffer==null){this._buffer=this.game.cache.getSoundData(this.key)}this._sound=this.context.createBufferSource();this._sound.buffer=this._buffer;this._sound.connect(this.gainNode);this.totalDuration=this._sound.buffer.duration;if(this.duration==0){this.duration=this.totalDuration*1000}if(this.loop&&d==""){this._sound.loop=true}if(typeof this._sound.start==="undefined"){this._sound.noteGrainOn(0,this.position,this.duration/1000)}else{this._sound.start(0,this.position,this.duration/1000)}this.isPlaying=true;this.startTime=this.game.time.now;this.currentTime=0;this.stopTime=this.startTime+this.duration;this.onPlay.dispatch(this)}else{this.pendingPlayback=true;if(this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).isDecoding==false){this.game.sound.decode(this.key,this)}}}else{if(this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked){this.game.cache.reloadSound(this.key);this.pendingPlayback=true}else{if(this._sound&&this._sound.readyState==4){this._sound.play();this.totalDuration=this._sound.duration;if(this.duration==0){this.duration=this.totalDuration*1000}this._sound.currentTime=this.position;this._sound.muted=this._muted;if(this._muted){this._sound.volume=0}else{this._sound.volume=this._volume}this.isPlaying=true;this.startTime=this.game.time.now;this.currentTime=0;this.stopTime=this.startTime+this.duration;this.onPlay.dispatch(this)}else{this.pendingPlayback=true}}}},restart:function(d,b,e,c){d=d||"";b=b||0;e=e||1;if(typeof c=="undefined"){c=false}this.play(d,b,e,c,true)},pause:function(){if(this.isPlaying&&this._sound){this.stop();this.isPlaying=false;this.paused=true;this.onPause.dispatch(this)}},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){if(typeof this._sound.start==="undefined"){this._sound.noteGrainOn(0,this.position,this.duration)}else{this._sound.start(0,this.position,this.duration)}}else{this._sound.play()}this.isPlaying=true;this.paused=false;this.onResume.dispatch(this)}},stop:function(){if(this.isPlaying&&this._sound){if(this.usingWebAudio){if(typeof this._sound.stop==="undefined"){this._sound.noteOff(0)}else{this._sound.stop(0)}}else{if(this.usingAudioTag){this._sound.pause();this._sound.currentTime=0}}}this.isPlaying=false;var b=this.currentMarker;this.currentMarker="";this.onStop.dispatch(this,b)}};Object.defineProperty(Phaser.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}});Object.defineProperty(Phaser.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}});Object.defineProperty(Phaser.Sound.prototype,"mute",{get:function(){return this._muted},set:function(b){b=b||null;if(b){this._muted=true;if(this.usingWebAudio){this._muteVolume=this.gainNode.gain.value;this.gainNode.gain.value=0}else{if(this.usingAudioTag&&this._sound){this._muteVolume=this._sound.volume;this._sound.volume=0}}}else{this._muted=false;if(this.usingWebAudio){this.gainNode.gain.value=this._muteVolume}else{if(this.usingAudioTag&&this._sound){this._sound.volume=this._muteVolume}}}this.onMute.dispatch(this)}});Object.defineProperty(Phaser.Sound.prototype,"volume",{get:function(){return this._volume},set:function(b){if(this.usingWebAudio){this._volume=b;this.gainNode.gain.value=b}else{if(this.usingAudioTag&&this._sound){if(b>=0&&b<=1){this._volume=b;this._sound.volume=b}}}}});Phaser.SoundManager=function(b){this.game=b;this.onSoundDecode=new Phaser.Signal;this._muted=false;this._unlockSource=null;this._volume=1;this._sounds=[];this.context=null;this.usingWebAudio=true;this.usingAudioTag=false;this.noAudio=false;this.touchLocked=false;this.channels=32};Phaser.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&this.game.device.webAudio==false){this.channels=1}if(this.game.device.iOS||(window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)){this.game.input.touch.callbackContext=this;this.game.input.touch.touchStartCallback=this.unlock;this.game.input.mouse.callbackContext=this;this.game.input.mouse.mouseDownCallback=this.unlock;this.touchLocked=true}else{this.touchLocked=false}if(window.PhaserGlobal){if(window.PhaserGlobal.disableAudio==true){this.usingWebAudio=false;this.noAudio=true;return}if(window.PhaserGlobal.disableWebAudio==true){this.usingWebAudio=false;this.usingAudioTag=true;this.noAudio=false;return}}if(!!window.AudioContext){this.context=new window.AudioContext()}else{if(!!window.webkitAudioContext){this.context=new window.webkitAudioContext()}else{if(!!window.Audio){this.usingWebAudio=false;this.usingAudioTag=true}else{this.usingWebAudio=false;this.noAudio=true}}}if(this.context!==null){if(typeof this.context.createGain==="undefined"){this.masterGain=this.context.createGainNode()}else{this.masterGain=this.context.createGain()}this.masterGain.gain.value=1;this.masterGain.connect(this.context.destination)}},unlock:function(){if(this.touchLocked==false){return}if(this.game.device.webAudio==false||(window.PhaserGlobal&&window.PhaserGlobal.disableWebAudio==true)){this.touchLocked=false;this._unlockSource=null;this.game.input.touch.callbackContext=null;this.game.input.touch.touchStartCallback=null;this.game.input.mouse.callbackContext=null;this.game.input.mouse.mouseDownCallback=null}else{var b=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource();this._unlockSource.buffer=b;this._unlockSource.connect(this.context.destination);this._unlockSource.noteOn(0)}},stopAll:function(){for(var b=0;b255){return Phaser.Color.getColor(255,255,255)}if(d>c){return Phaser.Color.getColor(255,255,255)}var f=d+Math.round(Math.random()*(c-d));var e=d+Math.round(Math.random()*(c-d));var b=d+Math.round(Math.random()*(c-d));return Phaser.Color.getColor32(g,f,e,b)},getRGB:function(b){return{alpha:b>>>24,red:b>>16&255,green:b>>8&255,blue:b&255}},getWebRGB:function(c){var f=(c>>>24)/255;var e=c>>16&255;var d=c>>8&255;var b=c&255;return"rgba("+e.toString()+","+d.toString()+","+b.toString()+","+f.toString()+")"},getAlpha:function(b){return b>>>24},getAlphaFloat:function(b){return(b>>>24)/255},getRed:function(b){return b>>16&255},getGreen:function(b){return b>>8&255},getBlue:function(b){return b&255}};Phaser.Physics={};Phaser.Physics.Arcade=function(b){this.game=b;this.gravity=new Phaser.Point;this.bounds=new Phaser.Rectangle(0,0,b.world.width,b.world.height);this.maxObjects=10;this.maxLevels=4;this.OVERLAP_BIAS=4;this.TILE_OVERLAP=false;this.quadTree=new Phaser.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels);this.quadTreeID=0;this._bounds1=new Phaser.Rectangle;this._bounds2=new Phaser.Rectangle;this._overlap=0;this._maxOverlap=0;this._velocity1=0;this._velocity2=0;this._newVelocity1=0;this._newVelocity2=0;this._average=0;this._mapData=[];this._result=false;this._total=0};Phaser.Physics.Arcade.prototype={updateMotion:function(b){this._velocityDelta=(this.computeVelocity(0,false,b.angularVelocity,b.angularAcceleration,b.angularDrag,b.maxAngular)-b.angularVelocity)/2;b.angularVelocity+=this._velocityDelta;b.rotation+=b.angularVelocity*this.game.time.physicsElapsed;this._velocityDelta=(this.computeVelocity(1,b,b.velocity.x,b.acceleration.x,b.drag.x)-b.velocity.x)/2;b.velocity.x+=this._velocityDelta;this._delta=b.velocity.x*this.game.time.physicsElapsed;b.x+=this._delta;this._velocityDelta=(this.computeVelocity(2,b,b.velocity.y,b.acceleration.y,b.drag.y)-b.velocity.y)/2;b.velocity.y+=this._velocityDelta;this._delta=b.velocity.y*this.game.time.physicsElapsed;b.y+=this._delta},computeVelocity:function(e,c,g,f,d,b){b=b||10000;if(e==1&&c.allowGravity){g+=this.gravity.x+c.gravity.x}else{if(e==2&&c.allowGravity){g+=this.gravity.y+c.gravity.y}}if(f!==0){g+=f*this.game.time.physicsElapsed}else{if(d!==0){this._drag=d*this.game.time.physicsElapsed;if(g-this._drag>0){g=g-this._drag}else{if(g+this._drag<0){g+=this._drag}else{g=0}}}}if(g!=0){if(g>b){g=b}else{if(g<-b){g=-b}}}return g},preUpdate:function(){this.quadTree.clear();this.quadTreeID=0;this.quadTree=new Phaser.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels)},postUpdate:function(){this.quadTree.clear()},collide:function(f,e,d,c,b){d=d||null;c=c||null;b=b||d;this._result=false;this._total=0;if(f&&e&&f.exists&&e.exists){if(f.type==Phaser.SPRITE){if(e.type==Phaser.SPRITE){this.collideSpriteVsSprite(f,e,d,c,b)}else{if(e.type==Phaser.GROUP||e.type==Phaser.EMITTER){this.collideSpriteVsGroup(f,e,d,c,b)}else{if(e.type==Phaser.TILEMAP){this.collideSpriteVsTilemap(f,e,d,c,b)}}}}else{if(f.type==Phaser.GROUP){if(e.type==Phaser.SPRITE){this.collideSpriteVsGroup(e,f,d,c,b)}else{if(e.type==Phaser.GROUP||e.type==Phaser.EMITTER){this.collideGroupVsGroup(f,e,d,c,b)}else{if(e.type==Phaser.TILEMAP){this.collideGroupVsTilemap(f,e,d,c,b)}}}}else{if(f.type==Phaser.TILEMAP){if(e.type==Phaser.SPRITE){this.collideSpriteVsTilemap(e,f,d,c,b)}else{if(e.type==Phaser.GROUP||e.type==Phaser.EMITTER){this.collideGroupVsTilemap(e,f,d,c,b)}}}else{if(f.type==Phaser.EMITTER){if(e.type==Phaser.SPRITE){this.collideSpriteVsGroup(e,f,d,c,b)}else{if(e.type==Phaser.GROUP||e.type==Phaser.EMITTER){this.collideGroupVsGroup(f,e,d,c,b)}else{if(e.type==Phaser.TILEMAP){this.collideGroupVsTilemap(f,e,d,c,b)}}}}}}}}return(this._total>0)},collideSpriteVsSprite:function(f,e,d,c,b){this.separate(f.body,e.body);if(this._result){if(c){if(c.call(b,f,e)){this._total++;if(d){d.call(b,f,e)}}}else{this._total++;if(d){d.call(b,f,e)}}}},collideGroupVsTilemap:function(g,f,e,d,b){if(g.length==0){return}if(g._container.first._iNext){var c=g._container.first._iNext;do{if(c.exists){this.collideSpriteVsTilemap(c,f,e,d,b)}c=c._iNext}while(c!=g._container.last._iNext)}},collideSpriteVsTilemap:function(d,g,f,e,b){this._mapData=g.collisionLayer.getTileOverlaps(d);var c=this._mapData.length;while(c--){if(e){if(e.call(b,d,this._mapData[c].tile)){this._total++;if(f){f.call(b,d,this._mapData[c].tile)}}}else{this._total++;if(f){f.call(b,d,this._mapData[c].tile)}}}},collideSpriteVsGroup:function(e,h,g,f,c){if(h.length==0){return}this._potentials=this.quadTree.retrieve(e);for(var d=0,b=this._potentials.length;d0)?c.deltaX():0),c.lastY,c.width+((c.deltaX()>0)?c.deltaX():-c.deltaX()),c.height);this._bounds2.setTo(b.x-((b.deltaX()>0)?b.deltaX():0),b.lastY,b.width+((b.deltaX()>0)?b.deltaX():-b.deltaX()),b.height);if((this._bounds1.right>this._bounds2.x)&&(this._bounds1.xthis._bounds2.y)&&(this._bounds1.yb.deltaX()){this._overlap=c.x+c.width-b.x;if((this._overlap>this._maxOverlap)||c.allowCollision.right==false||b.allowCollision.left==false){this._overlap=0}else{c.touching.right=true;b.touching.left=true}}else{if(c.deltaX()this._maxOverlap)||c.allowCollision.left==false||b.allowCollision.right==false){this._overlap=0}else{c.touching.left=true;b.touching.right=true}}}}}if(this._overlap!=0){c.overlapX=this._overlap;b.overlapX=this._overlap;if(c.customSeparateX||b.customSeparateX){return true}this._velocity1=c.velocity.x;this._velocity2=b.velocity.x;if(!c.immovable&&!b.immovable){this._overlap*=0.5;c.x=c.x-this._overlap;b.x+=this._overlap;this._newVelocity1=Math.sqrt((this._velocity2*this._velocity2*b.mass)/c.mass)*((this._velocity2>0)?1:-1);this._newVelocity2=Math.sqrt((this._velocity1*this._velocity1*c.mass)/b.mass)*((this._velocity1>0)?1:-1);this._average=(this._newVelocity1+this._newVelocity2)*0.5;this._newVelocity1-=this._average;this._newVelocity2-=this._average;c.velocity.x=this._average+this._newVelocity1*c.bounce.x;b.velocity.x=this._average+this._newVelocity2*b.bounce.x}else{if(!c.immovable){c.x=c.x-this._overlap;c.velocity.x=this._velocity2-this._velocity1*c.bounce.x}else{if(!b.immovable){b.x+=this._overlap;b.velocity.x=this._velocity1-this._velocity2*b.bounce.x}}}return true}else{return false}},separateY:function(c,b){if(c.immovable&&b.immovable){return false}this._overlap=0;if(c.deltaY()!=b.deltaY()){this._bounds1.setTo(c.x,c.y-((c.deltaY()>0)?c.deltaY():0),c.width,c.height+c.deltaAbsY());this._bounds2.setTo(b.x,b.y-((b.deltaY()>0)?b.deltaY():0),b.width,b.height+b.deltaAbsY());if((this._bounds1.right>this._bounds2.x)&&(this._bounds1.xthis._bounds2.y)&&(this._bounds1.yb.deltaY()){this._overlap=c.y+c.height-b.y;if((this._overlap>this._maxOverlap)||c.allowCollision.down==false||b.allowCollision.up==false){this._overlap=0}else{c.touching.down=true;b.touching.up=true}}else{if(c.deltaY()this._maxOverlap)||c.allowCollision.up==false||b.allowCollision.down==false){this._overlap=0}else{c.touching.up=true;b.touching.down=true}}}}}if(this._overlap!=0){c.overlapY=this._overlap;b.overlapY=this._overlap;if(c.customSeparateY||b.customSeparateY){return true}this._velocity1=c.velocity.y;this._velocity2=b.velocity.y;if(!c.immovable&&!b.immovable){this._overlap*=0.5;c.y=c.y-this._overlap;b.y+=this._overlap;this._newVelocity1=Math.sqrt((this._velocity2*this._velocity2*b.mass)/c.mass)*((this._velocity2>0)?1:-1);this._newVelocity2=Math.sqrt((this._velocity1*this._velocity1*c.mass)/b.mass)*((this._velocity1>0)?1:-1);this._average=(this._newVelocity1+this._newVelocity2)*0.5;this._newVelocity1-=this._average;this._newVelocity2-=this._average;c.velocity.y=this._average+this._newVelocity1*c.bounce.y;b.velocity.y=this._average+this._newVelocity2*b.bounce.y}else{if(!c.immovable){c.y=c.y-this._overlap;c.velocity.y=this._velocity2-this._velocity1*c.bounce.y;if(b.active&&b.moves&&(c.deltaY()>b.deltaY())){c.x+=b.x-b.lastX}}else{if(!b.immovable){b.y+=this._overlap;b.velocity.y=this._velocity1-this._velocity2*b.bounce.y;if(c.sprite.active&&c.moves&&(c.deltaY()h)&&(this._bounds1.xg)&&(this._bounds1.y0){this._overlap=c.x+c.width-h;if((this._overlap>this._maxOverlap)||!c.allowCollision.right||!d){this._overlap=0}else{c.touching.right=true}}else{if(c.deltaX()<0){this._overlap=c.x-b-h;if((-this._overlap>this._maxOverlap)||!c.allowCollision.left||!i){this._overlap=0}else{c.touching.left=true}}}}}if(this._overlap!=0){if(e){c.x=c.x-this._overlap;if(c.bounce.x==0){c.velocity.x=0}else{c.velocity.x=-c.velocity.x*c.bounce.x}}return true}else{return false}},separateTileY:function(d,h,g,c,j,f,i,b,e){if(d.immovable){return false}this._overlap=0;if(d.deltaY()!=0){this._bounds1.setTo(d.x,d.y,d.width,d.height);if((this._bounds1.right>h)&&(this._bounds1.xg)&&(this._bounds1.y0){this._overlap=d.bottom-g;if((this._overlap>this._maxOverlap)||!d.allowCollision.down||!b){this._overlap=0}else{d.touching.down=true}}else{this._overlap=d.y-j-g;if((-this._overlap>this._maxOverlap)||!d.allowCollision.up||!i){this._overlap=0}else{d.touching.up=true}}}}if(this._overlap!=0){if(e){d.y=d.y-this._overlap;if(d.bounce.y==0){d.velocity.y=0}else{d.velocity.y=-d.velocity.y*d.bounce.y}}return true}else{return false}},velocityFromAngle:function(e,d,b){d=d||0;b=b||new Phaser.Point;var c=this.game.math.degToRad(e);return b.setTo((Math.cos(c)*d),(Math.sin(c)*d))},moveTowardsObject:function(g,e,f,c){f=f||60;c=c||0;var b=this.angleBetween(g,e);if(c>0){var h=this.distanceBetween(g,e);f=h/(c/1000)}g.body.velocity.x=Math.cos(b)*f;g.body.velocity.y=Math.sin(b)*f},accelerateTowardsObject:function(f,d,e,b,g){b=b||1000;g=g||1000;var c=this.angleBetween(f,d);f.body.velocity.x=0;f.body.velocity.y=0;f.body.acceleration.x=Math.cos(c)*e;f.body.acceleration.y=Math.sin(c)*e;f.body.maxVelocity.x=b;f.body.maxVelocity.y=g},moveTowardsMouse:function(f,e,c){e=e||60;c=c||0;var b=this.angleBetweenMouse(f);if(c>0){var g=this.distanceToMouse(f);e=g/(c/1000)}f.body.velocity.x=Math.cos(b)*e;f.body.velocity.y=Math.sin(b)*e},accelerateTowardsMouse:function(e,d,b,f){b=b||1000;f=f||1000;var c=this.angleBetweenMouse(e);e.body.velocity.x=0;e.body.velocity.y=0;e.body.acceleration.x=Math.cos(c)*d;e.body.acceleration.y=Math.sin(c)*d;e.body.maxVelocity.x=b;e.body.maxVelocity.y=f},moveTowardsPoint:function(f,g,e,c){e=e||60;c=c||0;var b=this.angleBetweenPoint(f,g);if(c>0){var h=this.distanceToPoint(f,g);e=h/(c/1000)}f.body.velocity.x=Math.cos(b)*e;f.body.velocity.y=Math.sin(b)*e},accelerateTowardsPoint:function(e,f,d,b,g){b=b||1000;g=g||1000;var c=this.angleBetweenPoint(e,f);e.body.velocity.x=0;e.body.velocity.y=0;e.body.acceleration.x=Math.cos(c)*d;e.body.acceleration.y=Math.sin(c)*d;e.body.maxVelocity.x=b;e.body.maxVelocity.y=g},distanceBetween:function(e,c){var f=e.center.x-c.center.x;var d=e.center.y-c.center.y;return Math.sqrt(f*f+d*d)},distanceToPoint:function(c,e){var d=c.center.x-e.x;var b=c.center.y-e.y;return Math.sqrt(d*d+b*b)},distanceToMouse:function(c){var d=c.center.x-this.game.input.x;var b=c.center.y-this.game.input.y;return Math.sqrt(d*d+b*b)},angleBetweenPoint:function(c,f,e){e=e||false;var d=f.x-c.center.x;var b=f.y-c.center.y;if(e){return this.game.math.radToDeg(Math.atan2(b,d))}else{return Math.atan2(b,d)}},angleBetween:function(e,c,g){g=g||false;var f=c.center.x-e.center.x;var d=c.center.y-e.center.y;if(g){return this.game.math.radToDeg(Math.atan2(d,f))}else{return Math.atan2(d,f)}},velocityFromFacing:function(b,c){},angleBetweenMouse:function(c,e){e=e||false;var d=this.game.input.x-c.bounds.x;var b=this.game.input.y-c.bounds.y;if(e){return this.game.math.radToDeg(Math.atan2(b,d))}else{return Math.atan2(b,d)}}};Phaser.Physics.Arcade.Body=function(b){this.sprite=b;this.game=b.game;this.offset=new Phaser.Point;this.x=b.x;this.y=b.y;this.lastX=b.x;this.lastY=b.y;this.sourceWidth=b.currentFrame.sourceSizeW;this.sourceHeight=b.currentFrame.sourceSizeH;this.width=b.currentFrame.sourceSizeW;this.height=b.currentFrame.sourceSizeH;this.halfWidth=Math.floor(b.currentFrame.sourceSizeW/2);this.halfHeight=Math.floor(b.currentFrame.sourceSizeH/2);this._sx=b.scale.x;this._sy=b.scale.y;this.velocity=new Phaser.Point;this.acceleration=new Phaser.Point;this.drag=new Phaser.Point;this.gravity=new Phaser.Point;this.bounce=new Phaser.Point;this.maxVelocity=new Phaser.Point(10000,10000);this.angularVelocity=0;this.angularAcceleration=0;this.angularDrag=0;this.maxAngular=1000;this.mass=1;this.quadTreeIDs=[];this.quadTreeIndex=-1;this.allowCollision={none:false,any:true,up:true,down:true,left:true,right:true};this.touching={none:true,up:false,down:false,left:false,right:false};this.wasTouching={none:true,up:false,down:false,left:false,right:false};this.immovable=false;this.moves=true;this.rotation=0;this.allowRotation=true;this.allowGravity=true;this.customSeparateX=false;this.customSeparateY=false;this.overlapX=0;this.overlapY=0;this.collideWorldBounds=false};Phaser.Physics.Arcade.Body.prototype={updateBounds:function(e,d,c,b){if(c!=this._sx||b!=this._sy){this.width=this.sourceWidth*c;this.height=this.sourceHeight*b;this.halfWidth=Math.floor(this.width/2);this.halfHeight=Math.floor(this.height/2);this._sx=c;this._sy=b}},update:function(){this.wasTouching.none=this.touching.none;this.wasTouching.up=this.touching.up;this.wasTouching.down=this.touching.down;this.wasTouching.left=this.touching.left;this.wasTouching.right=this.touching.right;this.touching.none=true;this.touching.up=false;this.touching.down=false;this.touching.left=false;this.touching.right=false;this.lastX=this.x;this.lastY=this.y;this.rotation=this.sprite.angle;this.x=(this.sprite.x-(this.sprite.anchor.x*this.width))+this.offset.x;this.y=(this.sprite.y-(this.sprite.anchor.y*this.height))+this.offset.y;if(this.moves){this.game.physics.updateMotion(this)}if(this.collideWorldBounds){this.checkWorldBounds()}if(this.allowCollision.none==false&&this.sprite.visible&&this.sprite.alive){this.quadTreeIDs=[];this.quadTreeIndex=-1;this.game.physics.quadTree.insert(this)}if(this.deltaX()!=0){this.sprite.x-=this.deltaX()}if(this.deltaY()!=0){this.sprite.y-=this.deltaY()}this.sprite.x=this.x-this.offset.x+(this.sprite.anchor.x*this.width);this.sprite.y=this.y-this.offset.y+(this.sprite.anchor.y*this.height);if(this.allowRotation){this.sprite.angle=this.rotation}},postUpdate:function(){this.sprite.x=this.x-this.offset.x+(this.sprite.anchor.x*this.width);this.sprite.y=this.y-this.offset.y+(this.sprite.anchor.y*this.height);if(this.allowRotation){this.sprite.angle=this.rotation}},checkWorldBounds:function(){if(this.xthis.game.world.bounds.right){this.x=this.game.world.bounds.right-this.width;this.velocity.x*=-this.bounce.x}}if(this.ythis.game.world.bounds.bottom){this.y=this.game.world.bounds.bottom-this.height;this.velocity.y*=-this.bounce.y}}},setSize:function(d,c,b,e){b=b||this.offset.x;e=e||this.offset.y;this.sourceWidth=d;this.sourceHeight=c;this.width=this.sourceWidth*this._sx;this.height=this.sourceHeight*this._sy;this.halfWidth=Math.floor(this.width/2);this.halfHeight=Math.floor(this.height/2);this.offset.setTo(b,e)},reset:function(){this.velocity.setTo(0,0);this.acceleration.setTo(0,0);this.angularVelocity=0;this.angularAcceleration=0;this.x=(this.sprite.x-(this.sprite.anchor.x*this.width))+this.offset.x;this.y=(this.sprite.y-(this.sprite.anchor.y*this.height))+this.offset.y;this.lastX=this.x;this.lastY=this.y},deltaAbsX:function(){return(this.deltaX()>0?this.deltaX():-this.deltaX())},deltaAbsY:function(){return(this.deltaY()>0?this.deltaY():-this.deltaY())},deltaX:function(){return this.x-this.lastX},deltaY:function(){return this.y-this.lastY}};Object.defineProperty(Phaser.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.y+this.height},set:function(b){if(b<=this.y){this.height=0}else{this.height=(this.y-b)}}});Object.defineProperty(Phaser.Physics.Arcade.Body.prototype,"right",{get:function(){return this.x+this.width},set:function(b){if(b<=this.x){this.width=0}else{this.width=this.x+b}}});Phaser.Particles=function(b){this.emitters={};this.ID=0};Phaser.Particles.prototype={emitters:null,add:function(b){this.emitters[b.name]=b;return b},remove:function(b){delete this.emitters[b.name]},update:function(){for(var b in this.emitters){if(this.emitters[b].exists){this.emitters[b].update()}}}};Phaser.Particles.Arcade={};Phaser.Particles.Arcade.Emitter=function(c,b,e,d){d=d||50;Phaser.Group.call(this,c);this.name="emitter"+this.game.particles.ID++;this.type=Phaser.EMITTER;this.x=0;this.y=0;this.width=1;this.height=1;this.minParticleSpeed=new Phaser.Point(-100,-100);this.maxParticleSpeed=new Phaser.Point(100,100);this.minParticleScale=1;this.maxParticleScale=1;this.minRotation=-360;this.maxRotation=360;this.gravity=2;this.particleClass=null;this.particleDrag=new Phaser.Point();this.angularDrag=0;this.frequency=100;this.maxParticles=d;this.lifespan=2000;this.bounce=new Phaser.Point();this._quantity=0;this._timer=0;this._counter=0;this._explode=true;this.on=false;this.exists=true;this.emitX=b;this.emitY=e};Phaser.Particles.Arcade.Emitter.prototype=Object.create(Phaser.Group.prototype);Phaser.Particles.Arcade.Emitter.prototype.constructor=Phaser.Particles.Arcade.Emitter;Phaser.Particles.Arcade.Emitter.prototype.update=function(){if(this.on){if(this._explode){this._counter=0;do{this.emitParticle();this._counter++}while(this._counter=this._timer){this.emitParticle();this._counter++;if(this._quantity>0){if(this._counter>=this._quantity){this.on=false}}this._timer=this.game.time.now+this.frequency}}}};Phaser.Particles.Arcade.Emitter.prototype.makeParticles=function(j,f,c,h,k){if(typeof f=="undefined"){f=0}c=c||this.maxParticles;h=h||0;if(typeof k=="undefined"){k=false}var e;var d=0;var b=j;var g=0;while(d0){e.body.allowCollision.any=true;e.body.allowCollision.none=false}else{e.body.allowCollision.none=true}e.body.collideWorldBounds=k;e.exists=false;e.visible=false;e.anchor.setTo(0.5,0.5);this.add(e);d++}return this};Phaser.Particles.Arcade.Emitter.prototype.kill=function(){this.on=false;this.alive=false;this.exists=false};Phaser.Particles.Arcade.Emitter.prototype.revive=function(){this.alive=true;this.exists=true};Phaser.Particles.Arcade.Emitter.prototype.start=function(b,e,d,c){if(typeof b!=="boolean"){b=true}e=e||0;d=d||250;c=c||0;this.revive();this.visible=true;this.on=true;this._explode=b;this.lifespan=e;this.frequency=d;if(b){this._quantity=c}else{this._quantity+=c}this._counter=0;this._timer=this.game.time.now+d};Phaser.Particles.Arcade.Emitter.prototype.emitParticle=function(){var c=this.getFirstExists(false);if(c==null){return}if(this.width>1||this.height>1){c.reset(this.emiteX-this.game.rnd.integerInRange(this.left,this.right),this.emiteY-this.game.rnd.integerInRange(this.top,this.bottom))}else{c.reset(this.emitX,this.emitY)}c.lifespan=this.lifespan;c.body.bounce.setTo(this.bounce.x,this.bounce.y);if(this.minParticleSpeed.x!=this.maxParticleSpeed.x){c.body.velocity.x=this.game.rnd.integerInRange(this.minParticleSpeed.x,this.maxParticleSpeed.x)}else{c.body.velocity.x=this.minParticleSpeed.x}if(this.minParticleSpeed.y!=this.maxParticleSpeed.y){c.body.velocity.y=this.game.rnd.integerInRange(this.minParticleSpeed.y,this.maxParticleSpeed.y)}else{c.body.velocity.y=this.minParticleSpeed.y}c.body.gravity.y=this.gravity;if(this.minRotation!=this.maxRotation){c.body.angularVelocity=this.game.rnd.integerInRange(this.minRotation,this.maxRotation)}else{c.body.angularVelocity=this.minRotation}if(this.minParticleScale!==1||this.maxParticleScale!==1){var b=this.game.rnd.realInRange(this.minParticleScale,this.maxParticleScale);c.scale.setTo(b,b)}c.body.drag.x=this.particleDrag.x;c.body.drag.y=this.particleDrag.y;c.body.angularDrag=this.angularDrag};Phaser.Particles.Arcade.Emitter.prototype.setSize=function(c,b){this.width=c;this.height=b};Phaser.Particles.Arcade.Emitter.prototype.setXSpeed=function(c,b){c=c||0;b=b||0;this.minParticleSpeed.x=c;this.maxParticleSpeed.x=b};Phaser.Particles.Arcade.Emitter.prototype.setYSpeed=function(c,b){c=c||0;b=b||0;this.minParticleSpeed.y=c;this.maxParticleSpeed.y=b};Phaser.Particles.Arcade.Emitter.prototype.setRotation=function(c,b){c=c||0;b=b||0;this.minRotation=c;this.maxRotation=b};Phaser.Particles.Arcade.Emitter.prototype.at=function(b){this.emitX=b.center.x;this.emitY=b.center.y};Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"alpha",{get:function(){return this._container.alpha},set:function(b){this._container.alpha=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"visible",{get:function(){return this._container.visible},set:function(b){this._container.visible=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(b){this.emitX=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(b){this.emitY=b}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-(this.width/2))}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+(this.width/2))}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-(this.height/2))}});Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+(this.height/2))}});Phaser.Tilemap=function(d,e,b,i,g,h,c){if(typeof g==="undefined"){g=true}if(typeof h==="undefined"){h=0}if(typeof c==="undefined"){c=0}this.game=d;this.group=null;this.name="";this.key=e;this.renderOrderID=0;this.collisionCallback=null;this.exists=true;this.visible=true;this.tiles=[];this.layers=[];var f=this.game.cache.getTilemap(e);PIXI.DisplayObjectContainer.call(this);this.position.x=b;this.position.y=i;this.type=Phaser.TILEMAP;this.renderer=new Phaser.TilemapRenderer(this.game);this.mapFormat=f.format;switch(this.mapFormat){case Phaser.Tilemap.CSV:this.parseCSV(f.mapData,e,h,c);break;case Phaser.Tilemap.JSON:this.parseTiledJSON(f.mapData,e);break}if(this.currentLayer&&g){this.game.world.setSize(this.currentLayer.widthInPixels,this.currentLayer.heightInPixels,true)}};Phaser.Tilemap.prototype=Object.create(PIXI.DisplayObjectContainer.prototype);Phaser.Tilemap.prototype.constructor=Phaser.Tilemap;Phaser.Tilemap.CSV=0;Phaser.Tilemap.JSON=1;Phaser.Tilemap.prototype.parseCSV=function(d,j,h,g){var f=new Phaser.TilemapLayer(this,0,j,Phaser.Tilemap.CSV,"TileLayerCSV"+this.layers.length.toString(),h,g);d=d.trim();var k=d.split("\n");for(var e=0;e0){f.addColumn(c)}}f.updateBounds();f.createCanvas();var b=f.parseTileOffsets();this.currentLayer=f;this.collisionLayer=f;this.layers.push(f);this.generateTiles(b)};Phaser.Tilemap.prototype.parseTiledJSON=function(g,f){for(var e=0;e0){this.collisionCallback.call(this.collisionCallbackContext,b,this._tempCollisionData)}return true}else{return false}};Phaser.Tilemap.prototype.putTile=function(b,e,c,d){if(typeof d==="undefined"){d=this.currentLayer.ID}this.layers[d].putTile(b,e,c)};Phaser.Tilemap.prototype.update=function(){this.renderer.render(this)};Phaser.Tilemap.prototype.destroy=function(){this.tiles.length=0;this.layers.length=0};Object.defineProperty(Phaser.Tilemap.prototype,"widthInPixels",{get:function(){return this.currentLayer.widthInPixels}});Object.defineProperty(Phaser.Tilemap.prototype,"heightInPixels",{get:function(){return this.currentLayer.heightInPixels}});Phaser.TilemapLayer=function(f,i,e,d,c,h,b){this.exists=true;this.visible=true;this.widthInTiles=0;this.heightInTiles=0;this.widthInPixels=0;this.heightInPixels=0;this.tileMargin=0;this.tileSpacing=0;this.parent=f;this.game=f.game;this.ID=i;this.name=c;this.key=e;this.type=Phaser.TILEMAPLAYER;this.mapFormat=d;this.tileWidth=h;this.tileHeight=b;this.boundsInTiles=new Phaser.Rectangle();var g=this.game.cache.getTilemap(e);this.tileset=g.data;this._alpha=1;this.canvas=null;this.context=null;this.baseTexture=null;this.texture=null;this.sprite=null;this.mapData=[];this._tempTileBlock=[];this._tempBlockResults=[]};Phaser.TilemapLayer.prototype={putTileWorldXY:function(b,d,c){b=this.game.math.snapToFloor(b,this.tileWidth)/this.tileWidth;d=this.game.math.snapToFloor(d,this.tileHeight)/this.tileHeight;if(d>=0&&d=0&&b=0&&d=0&&bthis.widthInPixels||b.body.y<0||b.body.bottom>this.heightInPixels){return this._tempBlockResults}this._tempTileX=this.game.math.snapToFloor(b.body.x,this.tileWidth)/this.tileWidth;this._tempTileY=this.game.math.snapToFloor(b.body.y,this.tileHeight)/this.tileHeight;this._tempTileW=(this.game.math.snapToCeil(b.body.width,this.tileWidth)+this.tileWidth)/this.tileWidth;this._tempTileH=(this.game.math.snapToCeil(b.body.height,this.tileHeight)+this.tileHeight)/this.tileHeight;this.getTempBlock(this._tempTileX,this._tempTileY,this._tempTileW,this._tempTileH,true);for(var c=0;cthis.widthInTiles){g=this.widthInTiles}if(c>this.heightInTiles){c=this.heightInTiles}this._tempTileBlock=[];for(var b=h;b=0&&c=0&&bb.widthInTiles){this._maxX=b.widthInTiles}if(this._maxY>b.heightInTiles){this._maxY=b.heightInTiles}if(this._startX+this._maxX>b.widthInTiles){this._startX=b.widthInTiles-this._maxX}if(this._startY+this._maxY>b.heightInTiles){this._startY=b.heightInTiles-this._maxY}this._dx=-(this.game.camera.x-(this._startX*b.tileWidth));this._dy=-(this.game.camera.y-(this._startY*b.tileHeight));this._tx=this._dx;this._ty=this._dy;if(b.alpha!==1){this._ga=b.context.globalAlpha;b.context.globalAlpha=b.alpha}b.context.clearRect(0,0,b.canvas.width,b.canvas.height);for(var f=this._startY;f-1){b.context.globalAlpha=this._ga}if(this.game.renderType==Phaser.WEBGL){PIXI.texturesToUpdate.push(b.baseTexture)}}return true}}; \ No newline at end of file +/*! Phaser v1.1.0 | (c) 2013 Photon Storm Ltd. */ +!function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.Phaser=b()}(this,function(){function b(a){return[(255&a>>16)/255,(255&a>>8)/255,(255&a)/255]}function c(){return d.Matrix="undefined"!=typeof Float32Array?Float32Array:Array,d.Matrix}function b(a){return[(255&a>>16)/255,(255&a>>8)/255,(255&a)/255]}var d=d||{},e=e||{VERSION:"1.1.0",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,SPRITE:0,BUTTON:1,BULLET:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4};return d.InteractionManager=function(){},e.Utils={shuffle:function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},pad:function(a,b,c,d){if("undefined"==typeof b)var b=0;if("undefined"==typeof c)var c=" ";if("undefined"==typeof d)var d=3;if(b+1>=a.length)switch(d){case 1:a=Array(b+1-a.length).join(c)+a;break;case 3:var e=Math.ceil((padlen=b-a.length)/2),f=padlen-e;a=Array(f+1).join(c)+a+Array(e+1).join(c);break;default:a+=Array(b+1-a.length).join(c)}return a},isPlainObject:function(a){if("object"!=typeof a||a.nodeType||a===a.window)return!1;try{if(a.constructor&&!hasOwn.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!0},extend:function(){var a,b,c,d,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;for("boolean"==typeof h&&(k=h,h=arguments[1]||{},i=2),j===i&&(h=this,--i);j>i;i++)if(null!=(a=arguments[i]))for(b in a)c=h[b],d=a[b],h!==d&&(k&&d&&(e.Utils.isPlainObject(d)||(f=Array.isArray(d)))?(f?(f=!1,g=c&&Array.isArray(c)?c:[]):g=c&&e.Utils.isPlainObject(c)?c:{},h[b]=e.Utils.extend(k,g,d)):void 0!==d&&(h[b]=d));return h}},"function"!=typeof Function.prototype.bind&&(Function.prototype.bind=function(){var a=Array.prototype.slice;return function(b){function c(){var f=e.concat(a.call(arguments));d.apply(this instanceof c?this:b,f)}var d=this,e=a.call(arguments,1);if("function"!=typeof d)throw new TypeError;return c.prototype=function f(a){return a&&(f.prototype=a),this instanceof f?void 0:new f}(d.prototype),c}}()),c(),d.mat3={},d.mat3.create=function(){var a=new d.Matrix(9);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},d.mat3.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},d.mat4={},d.mat4.create=function(){var a=new d.Matrix(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},d.mat3.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=b[0],n=b[1],o=b[2],p=b[3],q=b[4],r=b[5],s=b[6],t=b[7],u=b[8];return c[0]=m*d+n*g+o*j,c[1]=m*e+n*h+o*k,c[2]=m*f+n*i+o*l,c[3]=p*d+q*g+r*j,c[4]=p*e+q*h+r*k,c[5]=p*f+q*i+r*l,c[6]=s*d+t*g+u*j,c[7]=s*e+t*h+u*k,c[8]=s*f+t*i+u*l,c},d.mat3.clone=function(a){var b=new d.Matrix(9);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b},d.mat3.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[5];return a[1]=a[3],a[2]=a[6],a[3]=c,a[5]=a[7],a[6]=d,a[7]=e,a}return b[0]=a[0],b[1]=a[3],b[2]=a[6],b[3]=a[1],b[4]=a[4],b[5]=a[7],b[6]=a[2],b[7]=a[5],b[8]=a[8],b},d.mat3.toMat4=function(a,b){return b||(b=d.mat4.create()),b[15]=1,b[14]=0,b[13]=0,b[12]=0,b[11]=0,b[10]=a[8],b[9]=a[7],b[8]=a[6],b[7]=0,b[6]=a[5],b[5]=a[4],b[4]=a[3],b[3]=0,b[2]=a[2],b[1]=a[1],b[0]=a[0],b},d.mat4.create=function(){var a=new d.Matrix(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},d.mat4.transpose=function(a,b){if(!b||a===b){var c=a[1],d=a[2],e=a[3],f=a[6],g=a[7],h=a[11];return a[1]=a[4],a[2]=a[8],a[3]=a[12],a[4]=c,a[6]=a[9],a[7]=a[13],a[8]=d,a[9]=f,a[11]=a[14],a[12]=e,a[13]=g,a[14]=h,a}return b[0]=a[0],b[1]=a[4],b[2]=a[8],b[3]=a[12],b[4]=a[1],b[5]=a[5],b[6]=a[9],b[7]=a[13],b[8]=a[2],b[9]=a[6],b[10]=a[10],b[11]=a[14],b[12]=a[3],b[13]=a[7],b[14]=a[11],b[15]=a[15],b},d.mat4.multiply=function(a,b,c){c||(c=a);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=a[9],n=a[10],o=a[11],p=a[12],q=a[13],r=a[14],s=a[15],t=b[0],u=b[1],v=b[2],w=b[3];return c[0]=t*d+u*h+v*l+w*p,c[1]=t*e+u*i+v*m+w*q,c[2]=t*f+u*j+v*n+w*r,c[3]=t*g+u*k+v*o+w*s,t=b[4],u=b[5],v=b[6],w=b[7],c[4]=t*d+u*h+v*l+w*p,c[5]=t*e+u*i+v*m+w*q,c[6]=t*f+u*j+v*n+w*r,c[7]=t*g+u*k+v*o+w*s,t=b[8],u=b[9],v=b[10],w=b[11],c[8]=t*d+u*h+v*l+w*p,c[9]=t*e+u*i+v*m+w*q,c[10]=t*f+u*j+v*n+w*r,c[11]=t*g+u*k+v*o+w*s,t=b[12],u=b[13],v=b[14],w=b[15],c[12]=t*d+u*h+v*l+w*p,c[13]=t*e+u*i+v*m+w*q,c[14]=t*f+u*j+v*n+w*r,c[15]=t*g+u*k+v*o+w*s,c},d.Point=function(a,b){this.x=a||0,this.y=b||0},d.Point.prototype.clone=function(){return new d.Point(this.x,this.y)},d.Point.prototype.constructor=d.Point,d.Rectangle=function(a,b,c,d){this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0},d.Rectangle.prototype.clone=function(){return new d.Rectangle(this.x,this.y,this.width,this.height)},d.Rectangle.prototype.contains=function(a,b){if(this.width<=0||this.height<=0)return!1;var c=this.x;if(a>=c&&a<=c+this.width){var d=this.y;if(b>=d&&b<=d+this.height)return!0}return!1},d.Rectangle.prototype.constructor=d.Rectangle,d.DisplayObject=function(){this.last=this,this.first=this,this.position=new d.Point,this.scale=new d.Point(1,1),this.pivot=new d.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.buttonMode=!1,this.renderable=!1,this.parent=null,this.stage=null,this.worldAlpha=1,this._interactive=!1,this.worldTransform=d.mat3.create(),this.localTransform=d.mat3.create(),this.color=[],this.dynamic=!0,this._sr=0,this._cr=1},d.DisplayObject.prototype.constructor=d.DisplayObject,d.DisplayObject.prototype.setInteractive=function(a){this.interactive=a},Object.defineProperty(d.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(a){this._interactive=a,this.stage&&(this.stage.dirty=!0)}}),Object.defineProperty(d.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(a){this._mask=a,a?this.addFilter(a):this.removeFilter()}}),d.DisplayObject.prototype.addFilter=function(a){if(!this.filter){this.filter=!0;var b=new d.FilterBlock,c=new d.FilterBlock;b.mask=a,c.mask=a,b.first=b.last=this,c.first=c.last=this,b.open=!0;var e,f,g=b,h=b;f=this.first._iPrev,f?(e=f._iNext,g._iPrev=f,f._iNext=g):e=this,e&&(e._iPrev=h,h._iNext=e);var g=c,h=c,e=null,f=null;f=this.last,e=f._iNext,e&&(e._iPrev=h,h._iNext=e),g._iPrev=f,f._iNext=g;for(var i=this,j=this.last;i;)i.last==j&&(i.last=c),i=i.parent;this.first=b,this.__renderGroup&&this.__renderGroup.addFilterBlocks(b,c),a.renderable=!1}},d.DisplayObject.prototype.removeFilter=function(){if(this.filter){this.filter=!1;var a=this.first,b=a._iNext,c=a._iPrev;b&&(b._iPrev=c),c&&(c._iNext=b),this.first=a._iNext;var d=this.last,b=d._iNext,c=d._iPrev;b&&(b._iPrev=c),c._iNext=b;for(var e=d._iPrev,f=this;f.last==d&&(f.last=e,f=f.parent););var g=a.mask;g.renderable=!0,this.__renderGroup&&this.__renderGroup.removeFilterBlocks(a,d)}},d.DisplayObject.prototype.updateTransform=function(){this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation));var a=this.localTransform,b=this.parent.worldTransform,c=this.worldTransform;a[0]=this._cr*this.scale.x,a[1]=-this._sr*this.scale.y,a[3]=this._sr*this.scale.x,a[4]=this._cr*this.scale.y;var e=this.pivot.x,f=this.pivot.y,g=a[0],h=a[1],i=this.position.x-a[0]*e-f*a[1],j=a[3],k=a[4],l=this.position.y-a[4]*f-e*a[3],m=b[0],n=b[1],o=b[2],p=b[3],q=b[4],r=b[5];a[2]=i,a[5]=l,c[0]=m*g+n*j,c[1]=m*h+n*k,c[2]=m*i+n*l+o,c[3]=p*g+q*j,c[4]=p*h+q*k,c[5]=p*i+q*l+r,this.worldAlpha=this.alpha*this.parent.worldAlpha,this.vcount=d.visibleCount},d.visibleCount=0,d.DisplayObjectContainer=function(){d.DisplayObject.call(this),this.children=[]},d.DisplayObjectContainer.prototype=Object.create(d.DisplayObject.prototype),d.DisplayObjectContainer.prototype.constructor=d.DisplayObjectContainer,d.DisplayObjectContainer.prototype.addChild=function(a){if(void 0!=a.parent&&a.parent.removeChild(a),a.parent=this,this.children.push(a),this.stage){var b=a;do b.interactive&&(this.stage.dirty=!0),b.stage=this.stage,b=b._iNext;while(b)}var c,d,e=a.first,f=a.last;d=this.filter?this.last._iPrev:this.last,c=d._iNext;for(var g=this,h=d;g;)g.last==h&&(g.last=a.last),g=g.parent;c&&(c._iPrev=f,f._iNext=c),e._iPrev=d,d._iNext=e,this.__renderGroup&&(a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a),this.__renderGroup.addDisplayObjectAndChildren(a))},d.DisplayObjectContainer.prototype.addChildAt=function(a,b){if(!(b>=0&&b<=this.children.length))throw new Error(a+" The index "+b+" supplied is out of bounds "+this.children.length);if(void 0!=a.parent&&a.parent.removeChild(a),a.parent=this,this.stage){var c=a;do c.interactive&&(this.stage.dirty=!0),c.stage=this.stage,c=c._iNext;while(c)}var d,e,f=a.first,g=a.last;if(b==this.children.length){e=this.last;for(var h=this,i=this.last;h;)h.last==i&&(h.last=a.last),h=h.parent}else e=0==b?this:this.children[b-1].last;d=e._iNext,d&&(d._iPrev=g,g._iNext=d),f._iPrev=e,e._iNext=f,this.children.splice(b,0,a),this.__renderGroup&&(a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a),this.__renderGroup.addDisplayObjectAndChildren(a))},d.DisplayObjectContainer.prototype.swapChildren=function(){},d.DisplayObjectContainer.prototype.getChildAt=function(a){if(a>=0&&aa;a++)this.children[a].updateTransform()}},d.blendModes={},d.blendModes.NORMAL=0,d.blendModes.SCREEN=1,d.Sprite=function(a){d.DisplayObjectContainer.call(this),this.anchor=new d.Point,this.texture=a,this.blendMode=d.blendModes.NORMAL,this._width=0,this._height=0,a.baseTexture.hasLoaded?this.updateFrame=!0:(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},d.Sprite.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Sprite.prototype.constructor=d.Sprite,Object.defineProperty(d.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(a){this.scale.x=a/this.texture.frame.width,this._width=a}}),Object.defineProperty(d.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(a){this.scale.y=a/this.texture.frame.height,this._height=a}}),d.Sprite.prototype.setTexture=function(a){this.texture.baseTexture!=a.baseTexture?(this.textureChange=!0,this.texture=a,this.__renderGroup&&this.__renderGroup.updateTexture(this)):this.texture=a,this.updateFrame=!0},d.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height),this.updateFrame=!0},d.Sprite.fromFrame=function(a){var b=d.TextureCache[a];if(!b)throw new Error("The frameId '"+a+"' does not exist in the texture cache"+this);return new d.Sprite(b)},d.Sprite.fromImage=function(a){var b=d.Texture.fromImage(a);return new d.Sprite(b)},d.Stage=function(a,b){d.DisplayObjectContainer.call(this),this.worldTransform=d.mat3.create(),this.interactive=b,this.interactionManager=new d.InteractionManager(this),this.dirty=!0,this.__childrenAdded=[],this.__childrenRemoved=[],this.stage=this,this.stage.hitArea=new d.Rectangle(0,0,1e5,1e5),this.setBackgroundColor(a),this.worldVisible=!0},d.Stage.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Stage.prototype.constructor=d.Stage,d.Stage.prototype.updateTransform=function(){this.worldAlpha=1,this.vcount=d.visibleCount;for(var a=0,b=this.children.length;b>a;a++)this.children[a].updateTransform();this.dirty&&(this.dirty=!1,this.interactionManager.dirty=!0),this.interactive&&this.interactionManager.update()},d.Stage.prototype.setBackgroundColor=function(a){this.backgroundColor=a||0,this.backgroundColorSplit=b(this.backgroundColor);var c=this.backgroundColor.toString(16);c="000000".substr(0,6-c.length)+c,this.backgroundColorString="#"+c},d.Stage.prototype.getMousePosition=function(){return this.interactionManager.mouse.global},d.CustomRenderable=function(){d.DisplayObject.call(this)},d.CustomRenderable.prototype=Object.create(d.DisplayObject.prototype),d.CustomRenderable.prototype.constructor=d.CustomRenderable,d.CustomRenderable.prototype.renderCanvas=function(){},d.CustomRenderable.prototype.initWebGL=function(){},d.CustomRenderable.prototype.renderWebGL=function(){},d.Strip=function(a,b,c){d.DisplayObjectContainer.call(this),this.texture=a,this.blendMode=d.blendModes.NORMAL;try{this.uvs=new Float32Array([0,1,1,1,1,0,0,1]),this.verticies=new Float32Array([0,0,0,0,0,0,0,0,0]),this.colors=new Float32Array([1,1,1,1]),this.indices=new Uint16Array([0,1,2,3])}catch(e){this.uvs=[0,1,1,1,1,0,0,1],this.verticies=[0,0,0,0,0,0,0,0,0],this.colors=[1,1,1,1],this.indices=[0,1,2,3]}this.width=b,this.height=c,a.baseTexture.hasLoaded?(this.width=this.texture.frame.width,this.height=this.texture.frame.height,this.updateFrame=!0):(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},d.Strip.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Strip.prototype.constructor=d.Strip,d.Strip.prototype.setTexture=function(a){this.texture=a,this.width=a.frame.width,this.height=a.frame.height,this.updateFrame=!0},d.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},d.Rope=function(a,b){d.Strip.call(this,a),this.points=b;try{this.verticies=new Float32Array(4*b.length),this.uvs=new Float32Array(4*b.length),this.colors=new Float32Array(2*b.length),this.indices=new Uint16Array(2*b.length)}catch(c){this.verticies=verticies,this.uvs=uvs,this.colors=colors,this.indices=indices}this.refresh()},d.Rope.prototype=Object.create(d.Strip.prototype),d.Rope.prototype.constructor=d.Rope,d.Rope.prototype.refresh=function(){var a=this.points;if(!(a.length<1)){var b=this.uvs,c=this.indices,d=this.colors,e=a[0],f=a[0];this.count-=.2,b[0]=0,b[1]=1,b[2]=0,b[3]=1,d[0]=1,d[1]=1,c[0]=0,c[1]=1;for(var g=a.length,h=1;g>h;h++){var f=a[h],i=4*h,j=h/(g-1);h%2?(b[i]=j,b[i+1]=0,b[i+2]=j,b[i+3]=1):(b[i]=j,b[i+1]=0,b[i+2]=j,b[i+3]=1),i=2*h,d[i]=1,d[i+1]=1,i=2*h,c[i]=i,c[i+1]=i+1,e=f}}},d.Rope.prototype.updateTransform=function(){var a=this.points;if(!(a.length<1)){var b,c=this.verticies,e=a[0],f={x:0,y:0},g=a[0];this.count-=.2,c[0]=g.x+f.x,c[1]=g.y+f.y,c[2]=g.x-f.x,c[3]=g.y-f.y;for(var h=a.length,i=1;h>i;i++){var g=a[i],j=4*i;b=i1&&(k=1);var l=Math.sqrt(f.x*f.x+f.y*f.y),m=this.texture.height/2;f.x/=l,f.y/=l,f.x*=m,f.y*=m,c[j]=g.x+f.x,c[j+1]=g.y+f.y,c[j+2]=g.x-f.x,c[j+3]=g.y-f.y,e=g}d.DisplayObjectContainer.prototype.updateTransform.call(this)}},d.Rope.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},d.TilingSprite=function(a,b,c){d.DisplayObjectContainer.call(this),this.texture=a,this.width=b,this.height=c,this.tileScale=new d.Point(1,1),this.tilePosition=new d.Point(0,0),this.renderable=!0,this.blendMode=d.blendModes.NORMAL},d.TilingSprite.prototype=Object.create(d.DisplayObjectContainer.prototype),d.TilingSprite.prototype.constructor=d.TilingSprite,d.TilingSprite.prototype.setTexture=function(a){this.texture=a,this.updateFrame=!0},d.TilingSprite.prototype.onTextureUpdate=function(){this.updateFrame=!0},d.FilterBlock=function(a){this.graphics=a,this.visible=!0,this.renderable=!0},d.MaskFilter=function(){this.graphics},d.Graphics=function(){d.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor="black",this.graphicsData=[],this.currentPath={points:[]}},d.Graphics.prototype=Object.create(d.DisplayObjectContainer.prototype),d.Graphics.prototype.constructor=d.Graphics,d.Graphics.prototype.lineStyle=function(a,b,c){0==this.currentPath.points.length&&this.graphicsData.pop(),this.lineWidth=a||0,this.lineColor=b||0,this.lineAlpha=void 0==c?1:c,this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:d.Graphics.POLY},this.graphicsData.push(this.currentPath)},d.Graphics.prototype.moveTo=function(a,b){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath=this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:d.Graphics.POLY},this.currentPath.points.push(a,b),this.graphicsData.push(this.currentPath)},d.Graphics.prototype.lineTo=function(a,b){this.currentPath.points.push(a,b),this.dirty=!0},d.Graphics.prototype.beginFill=function(a,b){this.filling=!0,this.fillColor=a||0,this.fillAlpha=void 0==b?1:b},d.Graphics.prototype.endFill=function(){this.filling=!1,this.fillColor=null,this.fillAlpha=1},d.Graphics.prototype.drawRect=function(a,b,c,e){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[a,b,c,e],type:d.Graphics.RECT},this.graphicsData.push(this.currentPath),this.dirty=!0},d.Graphics.prototype.drawCircle=function(a,b,c){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[a,b,c,c],type:d.Graphics.CIRC},this.graphicsData.push(this.currentPath),this.dirty=!0},d.Graphics.prototype.drawElipse=function(a,b,c,e){0==this.currentPath.points.length&&this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[a,b,c,e],type:d.Graphics.ELIP},this.graphicsData.push(this.currentPath),this.dirty=!0},d.Graphics.prototype.clear=function(){this.lineWidth=0,this.filling=!1,this.dirty=!0,this.clearDirty=!0,this.graphicsData=[]},d.Graphics.POLY=0,d.Graphics.RECT=1,d.Graphics.CIRC=2,d.Graphics.ELIP=3,d.CanvasGraphics=function(){},d.CanvasGraphics.renderGraphics=function(a,b){for(var c=a.worldAlpha,e=0;e1&&(c=1,console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));for(var e=0;1>e;e++){var f=a.graphicsData[e],g=f.points;if(f.type==d.Graphics.POLY){b.beginPath(),b.moveTo(g[0],g[1]);for(var h=1;h0&&(d.Texture.frameUpdates=[])},d.CanvasRenderer.prototype.resize=function(a,b){this.width=a,this.height=b,this.view.width=a,this.view.height=b},d.CanvasRenderer.prototype.renderDisplayObject=function(a){var b,c=this.context;c.globalCompositeOperation="source-over";var e=a.last._iNext;a=a.first;do if(b=a.worldTransform,a.visible)if(a.renderable){if(a instanceof d.Sprite){var f=a.texture.frame;f&&(c.globalAlpha=a.worldAlpha,c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),c.drawImage(a.texture.baseTexture.source,f.x,f.y,f.width,f.height,a.anchor.x*-f.width,a.anchor.y*-f.height,f.width,f.height))}else if(a instanceof d.Strip)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderStrip(a);else if(a instanceof d.TilingSprite)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderTilingSprite(a);else if(a instanceof d.CustomRenderable)a.renderCanvas(this);else if(a instanceof d.Graphics)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),d.CanvasGraphics.renderGraphics(a,c);else if(a instanceof d.FilterBlock)if(a.open){c.save();var g=a.mask.alpha,h=a.mask.worldTransform;c.setTransform(h[0],h[3],h[1],h[4],h[2],h[5]),a.mask.worldAlpha=.5,c.worldAlpha=0,d.CanvasGraphics.renderGraphicsMask(a.mask,c),c.clip(),a.mask.worldAlpha=g}else c.restore();a=a._iNext}else a=a._iNext;else a=a.last._iNext;while(a!=e)},d.CanvasRenderer.prototype.renderStripFlat=function(a){var b=this.context,c=a.verticies;a.uvs;var d=c.length/2;this.count++,b.beginPath();for(var e=1;d-2>e;e++){var f=2*e,g=c[f],h=c[f+2],i=c[f+4],j=c[f+1],k=c[f+3],l=c[f+5];b.moveTo(g,j),b.lineTo(h,k),b.lineTo(i,l)}b.fillStyle="#FF0000",b.fill(),b.closePath()},d.CanvasRenderer.prototype.renderTilingSprite=function(a){var b=this.context;b.globalAlpha=a.worldAlpha,a.__tilePattern||(a.__tilePattern=b.createPattern(a.texture.baseTexture.source,"repeat")),b.beginPath();var c=a.tilePosition,d=a.tileScale;b.scale(d.x,d.y),b.translate(c.x,c.y),b.fillStyle=a.__tilePattern,b.fillRect(-c.x,-c.y,a.width/d.x,a.height/d.y),b.scale(1/d.x,1/d.y),b.translate(-c.x,-c.y),b.closePath()},d.CanvasRenderer.prototype.renderStrip=function(a){var b=this.context,c=a.verticies,d=a.uvs,e=c.length/2;this.count++;for(var f=1;e-2>f;f++){var g=2*f,h=c[g],i=c[g+2],j=c[g+4],k=c[g+1],l=c[g+3],m=c[g+5],n=d[g]*a.texture.width,o=d[g+2]*a.texture.width,p=d[g+4]*a.texture.width,q=d[g+1]*a.texture.height,r=d[g+3]*a.texture.height,s=d[g+5]*a.texture.height;b.save(),b.beginPath(),b.moveTo(h,k),b.lineTo(i,l),b.lineTo(j,m),b.closePath(),b.clip();var t=n*r+q*p+o*s-r*p-q*o-n*s,u=h*r+q*j+i*s-r*j-q*i-h*s,v=n*i+h*p+o*j-i*p-h*o-n*j,w=n*r*j+q*i*p+h*o*s-h*r*p-q*o*j-n*i*s,x=k*r+q*m+l*s-r*m-q*l-k*s,y=n*l+k*p+o*m-l*p-k*o-n*m,z=n*r*m+q*l*p+k*o*s-k*r*p-q*o*m-n*l*s;b.transform(u/t,x/t,v/t,y/t,w/t,z/t),b.drawImage(a.texture.baseTexture.source,0,0),b.restore()}},d._batchs=[],d._getBatch=function(a){return 0==d._batchs.length?new d.WebGLBatch(a):d._batchs.pop()},d._returnBatch=function(a){a.clean(),d._batchs.push(a)},d._restoreBatchs=function(a){for(var b=0;bc;c++){var d=6*c,e=4*c;this.indices[d+0]=e+0,this.indices[d+1]=e+1,this.indices[d+2]=e+2,this.indices[d+3]=e+0,this.indices[d+4]=e+2,this.indices[d+5]=e+3}a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW)},d.WebGLBatch.prototype.refresh=function(){this.gl,this.dynamicSize3&&d.WebGLGraphics.buildPoly(c,a._webGL),c.lineWidth>0&&d.WebGLGraphics.buildLine(c,a._webGL)):c.type==d.Graphics.RECT?d.WebGLGraphics.buildRectangle(c,a._webGL):(c.type==d.Graphics.CIRC||c.type==d.Graphics.ELIP)&&d.WebGLGraphics.buildCircle(c,a._webGL)}a._webGL.lastIndex=a.graphicsData.length;var e=d.gl;a._webGL.glPoints=new Float32Array(a._webGL.points),e.bindBuffer(e.ARRAY_BUFFER,a._webGL.buffer),e.bufferData(e.ARRAY_BUFFER,a._webGL.glPoints,e.STATIC_DRAW),a._webGL.glIndicies=new Uint16Array(a._webGL.indices),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a._webGL.indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,a._webGL.glIndicies,e.STATIC_DRAW)},d.WebGLGraphics.buildRectangle=function(a,c){var e=a.points,f=e[0],g=e[1],h=e[2],i=e[3];if(a.fill){var j=b(a.fillColor),k=a.fillAlpha,l=j[0]*k,m=j[1]*k,n=j[2]*k,o=c.points,p=c.indices,q=o.length/6;o.push(f,g),o.push(l,m,n,k),o.push(f+h,g),o.push(l,m,n,k),o.push(f,g+i),o.push(l,m,n,k),o.push(f+h,g+i),o.push(l,m,n,k),p.push(q,q,q+1,q+2,q+3,q+3)}a.lineWidth&&(a.points=[f,g,f+h,g,f+h,g+i,f,g+i,f,g],d.WebGLGraphics.buildLine(a,c))},d.WebGLGraphics.buildCircle=function(a,c){var e=a.points,f=e[0],g=e[1],h=e[2],i=e[3],j=40,k=2*Math.PI/j;if(a.fill){var l=b(a.fillColor),m=a.fillAlpha,n=l[0]*m,o=l[1]*m,p=l[2]*m,q=c.points,r=c.indices,s=q.length/6;r.push(s);for(var t=0;j+1>t;t++)q.push(f,g,n,o,p,m),q.push(f+Math.sin(k*t)*h,g+Math.cos(k*t)*i,n,o,p,m),r.push(s++,s++);r.push(s-1)}if(a.lineWidth){a.points=[];for(var t=0;j+1>t;t++)a.points.push(f+Math.sin(k*t)*h,g+Math.cos(k*t)*i);d.WebGLGraphics.buildLine(a,c)}},d.WebGLGraphics.buildLine=function(a,c){var e=a.points;if(0!=e.length){var f=new d.Point(e[0],e[1]),g=new d.Point(e[e.length-2],e[e.length-1]);if(f.x==g.x&&f.y==g.y){e.pop(),e.pop(),g=new d.Point(e[e.length-2],e[e.length-1]);var h=g.x+.5*(f.x-g.x),i=g.y+.5*(f.y-g.y);e.unshift(h,i),e.push(h,i)}var j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E=c.points,F=c.indices,G=e.length/2,H=e.length,I=E.length/6,J=a.lineWidth/2,K=b(a.lineColor),L=a.lineAlpha,M=K[0]*L,N=K[1]*L,O=K[2]*L;j=e[0],k=e[1],l=e[2],m=e[3],p=-(k-m),q=j-l,D=Math.sqrt(p*p+q*q),p/=D,q/=D,p*=J,q*=J,E.push(j-p,k-q,M,N,O,L),E.push(j+p,k+q,M,N,O,L);for(var P=1;G-1>P;P++)j=e[2*(P-1)],k=e[2*(P-1)+1],l=e[2*P],m=e[2*P+1],n=e[2*(P+1)],o=e[2*(P+1)+1],p=-(k-m),q=j-l,D=Math.sqrt(p*p+q*q),p/=D,q/=D,p*=J,q*=J,r=-(m-o),s=l-n,D=Math.sqrt(r*r+s*s),r/=D,s/=D,r*=J,s*=J,v=-q+k-(-q+m),w=-p+l-(-p+j),x=(-p+j)*(-q+m)-(-p+l)*(-q+k),y=-s+o-(-s+m),z=-r+l-(-r+n),A=(-r+n)*(-s+m)-(-r+l)*(-s+o),B=v*z-y*w,0==B&&(B+=1),px=(w*A-z*x)/B,py=(y*x-v*A)/B,C=(px-l)*(px-l)+(py-m)+(py-m),C>19600?(t=p-r,u=q-s,D=Math.sqrt(t*t+u*u),t/=D,u/=D,t*=J,u*=J,E.push(l-t,m-u),E.push(M,N,O,L),E.push(l+t,m+u),E.push(M,N,O,L),E.push(l-t,m-u),E.push(M,N,O,L),H++):(E.push(px,py),E.push(M,N,O,L),E.push(l-(px-l),m-(py-m)),E.push(M,N,O,L));j=e[2*(G-2)],k=e[2*(G-2)+1],l=e[2*(G-1)],m=e[2*(G-1)+1],p=-(k-m),q=j-l,D=Math.sqrt(p*p+q*q),p/=D,q/=D,p*=J,q*=J,E.push(l-p,m-q),E.push(M,N,O,L),E.push(l+p,m+q),E.push(M,N,O,L),F.push(I);for(var P=0;H>P;P++)F.push(I++);F.push(I-1)}},d.WebGLGraphics.buildPoly=function(a,c){var e=a.points;if(!(e.length<6)){for(var f=c.points,g=c.indices,h=e.length/2,i=b(a.fillColor),j=a.fillAlpha,k=i[0]*j,l=i[1]*j,m=i[2]*j,n=d.PolyK.Triangulate(e),o=f.length/6,p=0;pp;p++)f.push(e[2*p],e[2*p+1],k,l,m,j)}},d._defaultFrame=new d.Rectangle(0,0,1,1),d.gl,d.WebGLRenderer=function(a,b,c,e,f){this.transparent=!!e,this.width=a||800,this.height=b||600,this.view=c||document.createElement("canvas"),this.view.width=this.width,this.view.height=this.height;var g=this;this.view.addEventListener("webglcontextlost",function(a){g.handleContextLost(a)},!1),this.view.addEventListener("webglcontextrestored",function(a){g.handleContextRestored(a)},!1),this.batchs=[];try{d.gl=this.gl=this.view.getContext("experimental-webgl",{alpha:this.transparent,antialias:!!f,premultipliedAlpha:!1,stencil:!0})}catch(h){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}d.initPrimitiveShader(),d.initDefaultShader(),d.initDefaultStripShader(),d.activateDefaultShader();var i=this.gl;d.WebGLRenderer.gl=i,this.batch=new d.WebGLBatch(i),i.disable(i.DEPTH_TEST),i.disable(i.CULL_FACE),i.enable(i.BLEND),i.colorMask(!0,!0,!0,this.transparent),d.projection=new d.Point(400,300),this.resize(this.width,this.height),this.contextLost=!1,this.stageRenderGroup=new d.WebGLRenderGroup(this.gl)},d.WebGLRenderer.prototype.constructor=d.WebGLRenderer,d.WebGLRenderer.getBatch=function(){return 0==d._batchs.length?new d.WebGLBatch(d.WebGLRenderer.gl):d._batchs.pop()},d.WebGLRenderer.returnBatch=function(a){a.clean(),d._batchs.push(a)},d.WebGLRenderer.prototype.render=function(a){if(!this.contextLost){this.__stage!==a&&(this.__stage=a,this.stageRenderGroup.setRenderable(a)),d.WebGLRenderer.updateTextures(),d.visibleCount++,a.updateTransform();var b=this.gl;if(b.colorMask(!0,!0,!0,this.transparent),b.viewport(0,0,this.width,this.height),b.bindFramebuffer(b.FRAMEBUFFER,null),b.clearColor(a.backgroundColorSplit[0],a.backgroundColorSplit[1],a.backgroundColorSplit[2],!this.transparent),b.clear(b.COLOR_BUFFER_BIT),this.stageRenderGroup.backgroundColor=a.backgroundColorSplit,this.stageRenderGroup.render(d.projection),a.interactive&&(a._interactiveEventsAdded||(a._interactiveEventsAdded=!0,a.interactionManager.setTarget(this))),d.Texture.frameUpdates.length>0){for(var c=0;c0;)n=n.children[n.children.length-1],n.renderable&&(m=n);if(m instanceof d.Sprite){l=m.batch;var k=l.head;if(k==m)g=0;else for(g=1;k.__next!=m;)g++,k=k.__next}else l=m;if(j==l)return j instanceof d.WebGLBatch?j.render(e,g+1):this.renderSpecial(j,b),void 0;f=this.batchs.indexOf(j),h=this.batchs.indexOf(l),j instanceof d.WebGLBatch?j.render(e):this.renderSpecial(j,b);for(var o=f+1;h>o;o++)renderable=this.batchs[o],renderable instanceof d.WebGLBatch?this.batchs[o].render():this.renderSpecial(renderable,b);l instanceof d.WebGLBatch?l.render(0,g+1):this.renderSpecial(l,b)},d.WebGLRenderGroup.prototype.renderSpecial=function(a,b){var c=a.vcount===d.visibleCount;if(a instanceof d.TilingSprite)c&&this.renderTilingSprite(a,b);else if(a instanceof d.Strip)c&&this.renderStrip(a,b);else if(a instanceof d.CustomRenderable)c&&a.renderWebGL(this,b);else if(a instanceof d.Graphics)c&&a.renderable&&d.WebGLGraphics.renderGraphics(a,b);else if(a instanceof d.FilterBlock){var e=d.gl;a.open?(e.enable(e.STENCIL_TEST),e.colorMask(!1,!1,!1,!1),e.stencilFunc(e.ALWAYS,1,255),e.stencilOp(e.KEEP,e.KEEP,e.REPLACE),d.WebGLGraphics.renderGraphics(a.mask,b),e.colorMask(!0,!0,!0,!0),e.stencilFunc(e.NOTEQUAL,0,255),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)):e.disable(e.STENCIL_TEST)}},d.WebGLRenderGroup.prototype.updateTexture=function(a){this.removeObject(a);for(var b=a.first;b!=this.root&&(b=b._iPrev,!b.renderable||!b.__renderGroup););for(var c=a.last;c._iNext&&(c=c._iNext,!c.renderable||!c.__renderGroup););this.insertObject(a,b,c)},d.WebGLRenderGroup.prototype.addFilterBlocks=function(a,b){a.__renderGroup=this,b.__renderGroup=this;for(var c=a;c!=this.root&&(c=c._iPrev,!c.renderable||!c.__renderGroup););this.insertAfter(a,c);for(var d=b;d!=this.root&&(d=d._iPrev,!d.renderable||!d.__renderGroup););this.insertAfter(b,d)},d.WebGLRenderGroup.prototype.removeFilterBlocks=function(a,b){this.removeObject(a),this.removeObject(b)},d.WebGLRenderGroup.prototype.addDisplayObjectAndChildren=function(a){a.__renderGroup&&a.__renderGroup.removeDisplayObjectAndChildren(a);for(var b=a.first;b!=this.root.first&&(b=b._iPrev,!b.renderable||!b.__renderGroup););for(var c=a.last;c._iNext&&(c=c._iNext,!c.renderable||!c.__renderGroup););var d=a.first,e=a.last._iNext;do d.__renderGroup=this,d.renderable&&(this.insertObject(d,b,c),b=d),d=d._iNext;while(d!=e)},d.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren=function(a){if(a.__renderGroup==this){a.last;do a.__renderGroup=null,a.renderable&&this.removeObject(a),a=a._iNext;while(a)}},d.WebGLRenderGroup.prototype.insertObject=function(a,b,c){var e=b,f=c;if(a instanceof d.Sprite){var g,h;if(e instanceof d.Sprite){if(g=e.batch,g&&g.texture==a.texture.baseTexture&&g.blendMode==a.blendMode)return g.insertAfter(a,e),void 0}else g=e;if(f)if(f instanceof d.Sprite){if(h=f.batch){if(h.texture==a.texture.baseTexture&&h.blendMode==a.blendMode)return h.insertBefore(a,f),void 0;if(h==g){var i=g.split(f),j=d.WebGLRenderer.getBatch(),k=this.batchs.indexOf(g);return j.init(a),this.batchs.splice(k+1,0,j,i),void 0}}}else h=f;var j=d.WebGLRenderer.getBatch();if(j.init(a),g){var k=this.batchs.indexOf(g);this.batchs.splice(k+1,0,j)}else this.batchs.push(j)}else a instanceof d.TilingSprite?this.initTilingSprite(a):a instanceof d.Strip&&this.initStrip(a),this.insertAfter(a,e)},d.WebGLRenderGroup.prototype.insertAfter=function(a,b){if(b instanceof d.Sprite){var c=b.batch;if(c)if(c.tail==b){var e=this.batchs.indexOf(c);this.batchs.splice(e+1,0,a)}else{var f=c.split(b.__next),e=this.batchs.indexOf(c);this.batchs.splice(e+1,0,a,f)}else this.batchs.push(a)}else{var e=this.batchs.indexOf(b);this.batchs.splice(e+1,0,a)}},d.WebGLRenderGroup.prototype.removeObject=function(a){var b;if(a instanceof d.Sprite){var c=a.batch;if(!c)return;c.remove(a),0==c.size&&(b=c)}else b=a;if(b){var e=this.batchs.indexOf(b);if(-1==e)return;if(0==e||e==this.batchs.length-1)return this.batchs.splice(e,1),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b),void 0;if(this.batchs[e-1]instanceof d.WebGLBatch&&this.batchs[e+1]instanceof d.WebGLBatch&&this.batchs[e-1].texture==this.batchs[e+1].texture&&this.batchs[e-1].blendMode==this.batchs[e+1].blendMode)return this.batchs[e-1].merge(this.batchs[e+1]),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b),d.WebGLRenderer.returnBatch(this.batchs[e+1]),this.batchs.splice(e,2),void 0;this.batchs.splice(e,1),b instanceof d.WebGLBatch&&d.WebGLRenderer.returnBatch(b)}},d.WebGLRenderGroup.prototype.initTilingSprite=function(a){var b=this.gl;a.verticies=new Float32Array([0,0,a.width,0,a.width,a.height,0,a.height]),a.uvs=new Float32Array([0,0,1,0,1,1,0,1]),a.colors=new Float32Array([1,1,1,1]),a.indices=new Uint16Array([0,1,3,2]),a._vertexBuffer=b.createBuffer(),a._indexBuffer=b.createBuffer(),a._uvBuffer=b.createBuffer(),a._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,a._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,a.verticies,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._uvBuffer),b.bufferData(b.ARRAY_BUFFER,a.uvs,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._colorBuffer),b.bufferData(b.ARRAY_BUFFER,a.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,a.indices,b.STATIC_DRAW),a.texture.baseTexture._glTexture?(b.bindTexture(b.TEXTURE_2D,a.texture.baseTexture._glTexture),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.REPEAT),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.REPEAT),a.texture.baseTexture._powerOf2=!0):a.texture.baseTexture._powerOf2=!0},d.WebGLRenderGroup.prototype.renderStrip=function(a,b){var c=this.gl,e=d.shaderProgram;c.useProgram(d.stripShaderProgram);var f=d.mat3.clone(a.worldTransform);d.mat3.transpose(f),c.uniformMatrix3fv(d.stripShaderProgram.translationMatrix,!1,f),c.uniform2f(d.stripShaderProgram.projectionVector,b.x,b.y),c.uniform1f(d.stripShaderProgram.alpha,a.worldAlpha),a.dirty?(a.dirty=!1,c.bindBuffer(c.ARRAY_BUFFER,a._vertexBuffer),c.bufferData(c.ARRAY_BUFFER,a.verticies,c.STATIC_DRAW),c.vertexAttribPointer(e.vertexPositionAttribute,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.bufferData(c.ARRAY_BUFFER,a.uvs,c.STATIC_DRAW),c.vertexAttribPointer(e.textureCoordAttribute,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,a.texture.baseTexture._glTexture),c.bindBuffer(c.ARRAY_BUFFER,a._colorBuffer),c.bufferData(c.ARRAY_BUFFER,a.colors,c.STATIC_DRAW),c.vertexAttribPointer(e.colorAttribute,1,c.FLOAT,!1,0,0),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,a._indexBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,a.indices,c.STATIC_DRAW)):(c.bindBuffer(c.ARRAY_BUFFER,a._vertexBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,a.verticies),c.vertexAttribPointer(e.vertexPositionAttribute,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.vertexAttribPointer(e.textureCoordAttribute,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,a.texture.baseTexture._glTexture),c.bindBuffer(c.ARRAY_BUFFER,a._colorBuffer),c.vertexAttribPointer(e.colorAttribute,1,c.FLOAT,!1,0,0),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,a._indexBuffer)),c.drawElements(c.TRIANGLE_STRIP,a.indices.length,c.UNSIGNED_SHORT,0),c.useProgram(d.shaderProgram)},d.WebGLRenderGroup.prototype.renderTilingSprite=function(a,b){var c=this.gl;d.shaderProgram;var e=a.tilePosition,f=a.tileScale,g=e.x/a.texture.baseTexture.width,h=e.y/a.texture.baseTexture.height,i=a.width/a.texture.baseTexture.width/f.x,j=a.height/a.texture.baseTexture.height/f.y;a.uvs[0]=0-g,a.uvs[1]=0-h,a.uvs[2]=1*i-g,a.uvs[3]=0-h,a.uvs[4]=1*i-g,a.uvs[5]=1*j-h,a.uvs[6]=0-g,a.uvs[7]=1*j-h,c.bindBuffer(c.ARRAY_BUFFER,a._uvBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,a.uvs),this.renderStrip(a,b)},d.WebGLRenderGroup.prototype.initStrip=function(a){var b=this.gl;this.shaderProgram,a._vertexBuffer=b.createBuffer(),a._indexBuffer=b.createBuffer(),a._uvBuffer=b.createBuffer(),a._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,a._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,a.verticies,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._uvBuffer),b.bufferData(b.ARRAY_BUFFER,a.uvs,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,a._colorBuffer),b.bufferData(b.ARRAY_BUFFER,a.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,a.indices,b.STATIC_DRAW)},d.shaderFragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","gl_FragColor = gl_FragColor * vColor;","}"],d.shaderVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","varying vec2 vTextureCoord;","varying float vColor;","void main(void) {","gl_Position = vec4( aVertexPosition.x / projectionVector.x -1.0, aVertexPosition.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vTextureCoord = aTextureCoord;","vColor = aColor;","}"],d.stripShaderFragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","gl_FragColor = gl_FragColor * alpha;","}"],d.stripShaderVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","varying vec2 vTextureCoord;","varying float vColor;","void main(void) {","vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);","gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vTextureCoord = aTextureCoord;","vColor = aColor;","}"],d.primitiveShaderFragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {","gl_FragColor = vColor;","}"],d.primitiveShaderVertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform float alpha;","varying vec4 vColor;","void main(void) {","vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);","gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vColor = aColor * alpha;","}"],d.initPrimitiveShader=function(){var a=d.gl,b=d.compileProgram(d.primitiveShaderVertexSrc,d.primitiveShaderFragmentSrc);a.useProgram(b),b.vertexPositionAttribute=a.getAttribLocation(b,"aVertexPosition"),b.colorAttribute=a.getAttribLocation(b,"aColor"),b.projectionVector=a.getUniformLocation(b,"projectionVector"),b.translationMatrix=a.getUniformLocation(b,"translationMatrix"),b.alpha=a.getUniformLocation(b,"alpha"),d.primitiveProgram=b},d.initDefaultShader=function(){var a=this.gl,b=d.compileProgram(d.shaderVertexSrc,d.shaderFragmentSrc);a.useProgram(b),b.vertexPositionAttribute=a.getAttribLocation(b,"aVertexPosition"),b.projectionVector=a.getUniformLocation(b,"projectionVector"),b.textureCoordAttribute=a.getAttribLocation(b,"aTextureCoord"),b.colorAttribute=a.getAttribLocation(b,"aColor"),b.samplerUniform=a.getUniformLocation(b,"uSampler"),d.shaderProgram=b},d.initDefaultStripShader=function(){var a=this.gl,b=d.compileProgram(d.stripShaderVertexSrc,d.stripShaderFragmentSrc);a.useProgram(b),b.vertexPositionAttribute=a.getAttribLocation(b,"aVertexPosition"),b.projectionVector=a.getUniformLocation(b,"projectionVector"),b.textureCoordAttribute=a.getAttribLocation(b,"aTextureCoord"),b.translationMatrix=a.getUniformLocation(b,"translationMatrix"),b.alpha=a.getUniformLocation(b,"alpha"),b.colorAttribute=a.getAttribLocation(b,"aColor"),b.projectionVector=a.getUniformLocation(b,"projectionVector"),b.samplerUniform=a.getUniformLocation(b,"uSampler"),d.stripShaderProgram=b},d.CompileVertexShader=function(a,b){return d._CompileShader(a,b,a.VERTEX_SHADER)},d.CompileFragmentShader=function(a,b){return d._CompileShader(a,b,a.FRAGMENT_SHADER)},d._CompileShader=function(a,b,c){var d=b.join("\n"),e=a.createShader(c);return a.shaderSource(e,d),a.compileShader(e),a.getShaderParameter(e,a.COMPILE_STATUS)?e:(alert(a.getShaderInfoLog(e)),null)},d.compileProgram=function(a,b){var c=d.gl,e=d.CompileFragmentShader(c,b),f=d.CompileVertexShader(c,a),g=c.createProgram();return c.attachShader(g,f),c.attachShader(g,e),c.linkProgram(g),c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders"),g},d.activateDefaultShader=function(){var a=d.gl,b=d.shaderProgram;a.useProgram(b),a.enableVertexAttribArray(b.vertexPositionAttribute),a.enableVertexAttribArray(b.textureCoordAttribute),a.enableVertexAttribArray(b.colorAttribute)},d.activatePrimitiveShader=function(){var a=d.gl;a.disableVertexAttribArray(d.shaderProgram.textureCoordAttribute),a.disableVertexAttribArray(d.shaderProgram.colorAttribute),a.useProgram(d.primitiveProgram),a.enableVertexAttribArray(d.primitiveProgram.vertexPositionAttribute),a.enableVertexAttribArray(d.primitiveProgram.colorAttribute)},d.BitmapText=function(a,b){d.DisplayObjectContainer.call(this),this.setText(a),this.setStyle(b),this.updateText(),this.dirty=!1},d.BitmapText.prototype=Object.create(d.DisplayObjectContainer.prototype),d.BitmapText.prototype.constructor=d.BitmapText,d.BitmapText.prototype.setText=function(a){this.text=a||" ",this.dirty=!0},d.BitmapText.prototype.setStyle=function(a){a=a||{},a.align=a.align||"left",this.style=a;var b=a.font.split(" ");this.fontName=b[b.length-1],this.fontSize=b.length>=2?parseInt(b[b.length-2],10):d.BitmapText.fonts[this.fontName].size,this.dirty=!0},d.BitmapText.prototype.updateText=function(){for(var a=d.BitmapText.fonts[this.fontName],b=new d.Point,c=null,e=[],f=0,g=[],h=0,i=this.fontSize/a.size,j=0;j=j;j++){var n=0;"right"==this.style.align?n=f-g[j]:"center"==this.style.align&&(n=(f-g[j])/2),m.push(n)}for(j=0;j0;)this.removeChild(this.getChildAt(0));this.updateText(),this.dirty=!1}d.DisplayObjectContainer.prototype.updateTransform.call(this)},d.BitmapText.fonts={},d.Text=function(a,b){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),d.Sprite.call(this,d.Texture.fromCanvas(this.canvas)),this.setText(a),this.setStyle(b),this.updateText(),this.dirty=!1},d.Text.prototype=Object.create(d.Sprite.prototype),d.Text.prototype.constructor=d.Text,d.Text.prototype.setStyle=function(a){a=a||{},a.font=a.font||"bold 20pt Arial",a.fill=a.fill||"black",a.align=a.align||"left",a.stroke=a.stroke||"black",a.strokeThickness=a.strokeThickness||0,a.wordWrap=a.wordWrap||!1,a.wordWrapWidth=a.wordWrapWidth||100,this.style=a,this.dirty=!0},d.Sprite.prototype.setText=function(a){this.text=a.toString()||" ",this.dirty=!0},d.Text.prototype.updateText=function(){this.context.font=this.style.font;var a=this.text;this.style.wordWrap&&(a=this.wordWrap(this.text));for(var b=a.split(/(?:\r\n|\r|\n)/),c=[],e=0,f=0;fe?f:arguments.callee(a,b,f,d,e):arguments.callee(a,b,c,f,e)},c=function(a,c,d){if(a.measureText(c).width<=d||c.length<1)return c;var e=b(a,c,0,c.length,d);return c.substring(0,e)+"\n"+arguments.callee(a,c.substring(e),d)},d="",e=a.split("\n"),f=0;fthis.baseTexture.width||a.y+a.height>this.baseTexture.height)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.updateFrame=!0,d.Texture.frameUpdates.push(this)},d.Texture.fromImage=function(a,b){var c=d.TextureCache[a];return c||(c=new d.Texture(d.BaseTexture.fromImage(a,b)),d.TextureCache[a]=c),c},d.Texture.fromFrame=function(a){var b=d.TextureCache[a];if(!b)throw new Error("The frameId '"+a+"' does not exist in the texture cache "+this);return b},d.Texture.fromCanvas=function(a){var b=new d.BaseTexture(a);return new d.Texture(b)},d.Texture.addTextureToCache=function(a,b){d.TextureCache[b]=a},d.Texture.removeTextureFromCache=function(a){var b=d.TextureCache[a];return d.TextureCache[a]=null,b},d.Texture.frameUpdates=[],d.RenderTexture=function(a,b){d.EventTarget.call(this),this.width=a||100,this.height=b||100,this.indetityMatrix=d.mat3.create(),this.frame=new d.Rectangle(0,0,this.width,this.height),d.gl?this.initWebGL():this.initCanvas()},d.RenderTexture.prototype=Object.create(d.Texture.prototype),d.RenderTexture.prototype.constructor=d.RenderTexture,d.RenderTexture.prototype.initWebGL=function(){var a=d.gl;this.glFramebuffer=a.createFramebuffer(),a.bindFramebuffer(a.FRAMEBUFFER,this.glFramebuffer),this.glFramebuffer.width=this.width,this.glFramebuffer.height=this.height,this.baseTexture=new d.BaseTexture,this.baseTexture.width=this.width,this.baseTexture.height=this.height,this.baseTexture._glTexture=a.createTexture(),a.bindTexture(a.TEXTURE_2D,this.baseTexture._glTexture),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,this.width,this.height,0,a.RGBA,a.UNSIGNED_BYTE,null),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),this.baseTexture.isRender=!0,a.bindFramebuffer(a.FRAMEBUFFER,this.glFramebuffer),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,this.baseTexture._glTexture,0),this.projection=new d.Point(this.width/2,this.height/2),this.render=this.renderWebGL},d.RenderTexture.prototype.resize=function(a,b){if(this.width=a,this.height=b,d.gl){this.projection.x=this.width/2,this.projection.y=this.height/2;var c=d.gl;c.bindTexture(c.TEXTURE_2D,this.baseTexture._glTexture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,this.width,this.height,0,c.RGBA,c.UNSIGNED_BYTE,null)}else this.frame.width=this.width,this.frame.height=this.height,this.renderer.resize(this.width,this.height)},d.RenderTexture.prototype.initCanvas=function(){this.renderer=new d.CanvasRenderer(this.width,this.height,null,0),this.baseTexture=new d.BaseTexture(this.renderer.view),this.frame=new d.Rectangle(0,0,this.width,this.height),this.render=this.renderCanvas},d.RenderTexture.prototype.renderWebGL=function(a,b,c){var e=d.gl;e.colorMask(!0,!0,!0,!0),e.viewport(0,0,this.width,this.height),e.bindFramebuffer(e.FRAMEBUFFER,this.glFramebuffer),c&&(e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)); +var f=a.children,g=a.worldTransform;a.worldTransform=d.mat3.create(),a.worldTransform[4]=-1,a.worldTransform[5]=2*this.projection.y,b&&(a.worldTransform[2]=b.x,a.worldTransform[5]-=b.y),d.visibleCount++,a.vcount=d.visibleCount;for(var h=0,i=f.length;i>h;h++)f[h].updateTransform();var j=a.__renderGroup;j?a==j.root?j.render(this.projection):j.renderSpecific(a,this.projection):(this.renderGroup||(this.renderGroup=new d.WebGLRenderGroup(e)),this.renderGroup.setRenderable(a),this.renderGroup.render(this.projection)),a.worldTransform=g},d.RenderTexture.prototype.renderCanvas=function(a,b,c){var e=a.children;a.worldTransform=d.mat3.create(),b&&(a.worldTransform[2]=b.x,a.worldTransform[5]=b.y);for(var f=0,g=e.length;g>f;f++)e[f].updateTransform();c&&this.renderer.context.clearRect(0,0,this.width,this.height),this.renderer.renderDisplayObject(a),this.renderer.context.setTransform(1,0,0,1,0,0)},d.EventTarget=function(){var a={};this.addEventListener=this.on=function(b,c){void 0===a[b]&&(a[b]=[]),-1===a[b].indexOf(c)&&a[b].push(c)},this.dispatchEvent=this.emit=function(b){for(var c in a[b.type])a[b.type][c](b)},this.removeEventListener=this.off=function(b,c){var d=a[b].indexOf(c);-1!==d&&a[b].splice(d,1)}},d.PolyK={},d.PolyK.Triangulate=function(a){var b=!0,c=a.length>>1;if(3>c)return[];for(var e=[],f=[],g=0;c>g;g++)f.push(g);for(var g=0,h=c;h>3;){var i=f[(g+0)%h],j=f[(g+1)%h],k=f[(g+2)%h],l=a[2*i],m=a[2*i+1],n=a[2*j],o=a[2*j+1],p=a[2*k],q=a[2*k+1],r=!1;if(d.PolyK._convex(l,m,n,o,p,q,b)){r=!0;for(var s=0;h>s;s++){var t=f[s];if(t!=i&&t!=j&&t!=k&&d.PolyK._PointInTriangle(a[2*t],a[2*t+1],l,m,n,o,p,q)){r=!1;break}}}if(r)e.push(i,j,k),f.splice((g+1)%h,1),h--,g=0;else if(g++>3*h){if(!b)return console.log("PIXI Warning: shape too complex to fill"),[];var e=[];f=[];for(var g=0;c>g;g++)f.push(g);g=0,h=c,b=!1}}return e.push(f[0],f[1],f[2]),e},d.PolyK._PointInTriangle=function(a,b,c,d,e,f,g,h){var i=g-c,j=h-d,k=e-c,l=f-d,m=a-c,n=b-d,o=i*i+j*j,p=i*k+j*l,q=i*m+j*n,r=k*k+l*l,s=k*m+l*n,t=1/(o*r-p*p),u=(r*q-p*s)*t,v=(o*s-p*q)*t;return u>=0&&v>=0&&1>u+v},d.PolyK._convex=function(a,b,c,d,e,f,g){return(b-d)*(e-c)+(c-a)*(f-d)>=0==g},e.Camera=function(a,b,c,d,f,g){this.game=a,this.world=a.world,this.id=0,this.view=new e.Rectangle(c,d,f,g),this.screenView=new e.Rectangle(c,d,f,g),this.bounds=new e.Rectangle(c,d,f,g),this.deadzone=null,this.visible=!0,this.atLimit={x:!1,y:!1},this.target=null,this._edge=0,this.displayObject=null},e.Camera.FOLLOW_LOCKON=0,e.Camera.FOLLOW_PLATFORMER=1,e.Camera.FOLLOW_TOPDOWN=2,e.Camera.FOLLOW_TOPDOWN_TIGHT=3,e.Camera.prototype={follow:function(a,b){"undefined"==typeof b&&(b=e.Camera.FOLLOW_LOCKON),this.target=a;var c;switch(b){case e.Camera.FOLLOW_PLATFORMER:var d=this.width/8,f=this.height/3;this.deadzone=new e.Rectangle((this.width-d)/2,(this.height-f)/2-.25*f,d,f);break;case e.Camera.FOLLOW_TOPDOWN:c=Math.max(this.width,this.height)/4,this.deadzone=new e.Rectangle((this.width-c)/2,(this.height-c)/2,c,c);break;case e.Camera.FOLLOW_TOPDOWN_TIGHT:c=Math.max(this.width,this.height)/8,this.deadzone=new e.Rectangle((this.width-c)/2,(this.height-c)/2,c,c);break;case e.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},focusOn:function(a){this.setPosition(Math.round(a.x-this.view.halfWidth),Math.round(a.y-this.view.halfHeight))},focusOnXY:function(a,b){this.setPosition(Math.round(a-this.view.halfWidth),Math.round(b-this.view.halfHeight))},update:function(){this.target&&this.updateTarget(),this.bounds&&this.checkBounds(),this.view.x!==-this.displayObject.position.x&&(this.displayObject.position.x=-this.view.x),this.view.y!==-this.displayObject.position.y&&(this.displayObject.position.y=-this.view.y)},updateTarget:function(){this.deadzone?(this._edge=this.target.x-this.deadzone.x,this.view.x>this._edge&&(this.view.x=this._edge),this._edge=this.target.x+this.target.width-this.deadzone.x-this.deadzone.width,this.view.xthis._edge&&(this.view.y=this._edge),this._edge=this.target.y+this.target.height-this.deadzone.y-this.deadzone.height,this.view.ythis.bounds.right-this.width&&(this.atLimit.x=!0,this.view.x=this.bounds.right-this.width+1),this.view.ythis.bounds.bottom-this.height&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom-this.height+1),this.view.floor()},setPosition:function(a,b){this.view.x=a,this.view.y=b,this.bounds&&this.checkBounds()},setSize:function(a,b){this.view.width=a,this.view.height=b}},Object.defineProperty(e.Camera.prototype,"x",{get:function(){return this.view.x},set:function(a){this.view.x=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"y",{get:function(){return this.view.y},set:function(a){this.view.y=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(e.Camera.prototype,"width",{get:function(){return this.view.width},set:function(a){this.view.width=a}}),Object.defineProperty(e.Camera.prototype,"height",{get:function(){return this.view.height},set:function(a){this.view.height=a}}),e.State=function(){this.game=null,this.add=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null},e.State.prototype={preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},render:function(){},paused:function(){},destroy:function(){}},e.StateManager=function(a,b){this.game=a,this.states={},null!==b&&(this._pendingState=b)},e.StateManager.prototype={game:null,_pendingState:null,_created:!1,states:{},current:"",onInitCallback:null,onPreloadCallback:null,onCreateCallback:null,onUpdateCallback:null,onRenderCallback:null,onPreRenderCallback:null,onLoadUpdateCallback:null,onLoadRenderCallback:null,onPausedCallback:null,onShutDownCallback:null,boot:function(){null!==this._pendingState&&("string"==typeof this._pendingState?this.start(this._pendingState,!1,!1):this.add("default",this._pendingState,!0))},add:function(a,b,c){"undefined"==typeof c&&(c=!1);var d;return b instanceof e.State?d=b:"object"==typeof b?(d=b,d.game=this.game):"function"==typeof b&&(d=new b(this.game)),this.states[a]=d,c&&(this.game.isBooted?this.start(a):this._pendingState=a),d},remove:function(a){this.current==a&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onDestroyCallback=null),delete this.states[a]},start:function(a,b,c){return"undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=!1),0==this.game.isBooted?(this._pendingState=a,void 0):(0!=this.checkState(a)&&(this.current&&this.onShutDownCallback.call(this.callbackContext),b&&(this.game.tweens.removeAll(),this.game.world.destroy(),1==c&&this.game.cache.destroy()),this.setCurrentState(a),this.onPreloadCallback?(this.game.load.reset(),this.onPreloadCallback.call(this.callbackContext),0==this.game.load.queueSize?this.game.loadComplete():this.game.load.start()):this.game.loadComplete()),void 0)},dummy:function(){},checkState:function(a){if(this.states[a]){var b=!1;return this.states[a].preload&&(b=!0),0==b&&this.states[a].loadRender&&(b=!0),0==b&&this.states[a].loadUpdate&&(b=!0),0==b&&this.states[a].create&&(b=!0),0==b&&this.states[a].update&&(b=!0),0==b&&this.states[a].preRender&&(b=!0),0==b&&this.states[a].render&&(b=!0),0==b&&this.states[a].paused&&(b=!0),0==b?(console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions."),!1):!0}return console.warn("Phaser.StateManager - No state found with the key: "+a),!1},link:function(a){this.states[a].game=this.game,this.states[a].add=this.game.add,this.states[a].camera=this.game.camera,this.states[a].cache=this.game.cache,this.states[a].input=this.game.input,this.states[a].load=this.game.load,this.states[a].math=this.game.math,this.states[a].sound=this.game.sound,this.states[a].stage=this.game.stage,this.states[a].time=this.game.time,this.states[a].tweens=this.game.tweens,this.states[a].world=this.game.world,this.states[a].particles=this.game.particles,this.states[a].physics=this.game.physics,this.states[a].rnd=this.game.rnd},setCurrentState:function(a){this.callbackContext=this.states[a],this.link(a),this.onInitCallback=this.states[a].init||this.dummy,this.onPreloadCallback=this.states[a].preload||null,this.onLoadRenderCallback=this.states[a].loadRender||null,this.onLoadUpdateCallback=this.states[a].loadUpdate||null,this.onCreateCallback=this.states[a].create||null,this.onUpdateCallback=this.states[a].update||null,this.onPreRenderCallback=this.states[a].preRender||null,this.onRenderCallback=this.states[a].render||null,this.onPausedCallback=this.states[a].paused||null,this.onShutDownCallback=this.states[a].shutdown||this.dummy,this.current=a,this._created=!1,this.onInitCallback.call(this.callbackContext)},loadComplete:function(){0==this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext)):this._created=!0},update:function(){this._created&&this.onUpdateCallback?this.onUpdateCallback.call(this.callbackContext):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext)},preRender:function(){this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext)},render:function(){this._created&&this.onRenderCallback?this.onRenderCallback.call(this.callbackContext):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext)},destroy:function(){this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onDestroyCallback=null,this.game=null,this.states={},this._pendingState=null}},e.LinkedList=function(){this.next=null,this.prev=null,this.first=null,this.last=null,this.total=0},e.LinkedList.prototype={add:function(a){return 0==this.total&&null==this.first&&null==this.last?(this.first=a,this.last=a,this.next=a,a.prev=this,this.total++,a):(this.last.next=a,a.prev=this.last,this.last=a,this.total++,a)},remove:function(a){a==this.first?this.first=this.first.next:a==this.last&&(this.last=this.last.prev),a.prev&&(a.prev.next=a.next),a.next&&(a.next.prev=a.prev),a.next=a.prev=null,null==this.first&&(this.last=null),this.total--},callAll:function(a){if(this.first&&this.last){var b=this.first;do b&&b[a]&&b[a].call(b),b=b.next;while(b!=this.last.next)}}},e.Signal=function(){this._bindings=[],this._prevParams=null;var a=this;this.dispatch=function(){e.Signal.prototype.dispatch.apply(a,arguments)}},e.Signal.prototype={memorize:!1,_shouldPropagate:!0,active:!0,validateListener:function(a,b){if("function"!=typeof a)throw new Error("listener is a required param of {fn}() and should be a Function.".replace("{fn}",b))},_registerListener:function(a,b,c,d){var f,g=this._indexOfListener(a,c);if(-1!==g){if(f=this._bindings[g],f.isOnce()!==b)throw new Error("You cannot add"+(b?"":"Once")+"() then add"+(b?"Once":"")+"() the same listener without removing the relationship first.")}else f=new e.SignalBinding(this,a,b,c,d),this._addBinding(f);return this.memorize&&this._prevParams&&f.execute(this._prevParams),f},_addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b]&&a._priority<=this._bindings[b]._priority);this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){for(var c,d=this._bindings.length;d--;)if(c=this._bindings[d],c._listener===a&&c.context===b)return d;return-1},has:function(a,b){return-1!==this._indexOfListener(a,b)},add:function(a,b,c){return this.validateListener(a,"add"),this._registerListener(a,!1,b,c)},addOnce:function(a,b,c){return this.validateListener(a,"addOnce"),this._registerListener(a,!0,b,c)},remove:function(a,b){this.validateListener(a,"remove");var c=this._indexOfListener(a,b);return-1!==c&&(this._bindings[c]._destroy(),this._bindings.splice(c,1)),a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active){var a,b=Array.prototype.slice.call(arguments),c=this._bindings.length;if(this.memorize&&(this._prevParams=b),c){a=this._bindings.slice(),this._shouldPropagate=!0;do c--;while(a[c]&&this._shouldPropagate&&a[c].execute(b)!==!1)}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll(),delete this._bindings,delete this._prevParams},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}},e.SignalBinding=function(a,b,c,d,e){this._listener=b,this._isOnce=c,this.context=d,this._signal=a,this._priority=e||0},e.SignalBinding.prototype={active:!0,params:null,execute:function(a){var b,c;return this.active&&this._listener&&(c=this.params?this.params.concat(a):a,b=this._listener.apply(this.context,c),this._isOnce&&this.detach()),b},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},e.Plugin=function(a,b){"undefined"==typeof b&&(b=null),this.game=a,this.parent=b,this.active=!1,this.visible=!1,this.hasPreUpdate=!1,this.hasUpdate=!1,this.hasRender=!1,this.hasPostRender=!1},e.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null,this.parent=null,this.active=!1,this.visible=!1}},e.PluginManager=function(a,b){this.game=a,this._parent=b,this.plugins=[],this._pluginsLength=0},e.PluginManager.prototype={add:function(a){var b=!1;return"function"==typeof a?a=new a(this.game,this._parent):(a.game=this.game,a.parent=this._parent),"function"==typeof a.preUpdate&&(a.hasPreUpdate=!0,b=!0),"function"==typeof a.update&&(a.hasUpdate=!0,b=!0),"function"==typeof a.render&&(a.hasRender=!0,b=!0),"function"==typeof a.postRender&&(a.hasPostRender=!0,b=!0),b?((a.hasPreUpdate||a.hasUpdate)&&(a.active=!0),(a.hasRender||a.hasPostRender)&&(a.visible=!0),this._pluginsLength=this.plugins.push(a),a):null},remove:function(){this._pluginsLength--},preUpdate:function(){if(0!=this._pluginsLength)for(this._p=0;this._pthis._nextOffsetCheck&&(e.Canvas.getOffset(this.canvas,this.offset),this._nextOffsetCheck=this.game.time.now+this.checkOffsetInterval)},visibilityChange:function(a){this.disableVisibilityChange||(this.game.paused="pagehide"==a.type||"blur"==a.type||1==document.hidden||1==document.webkitHidden?!0:!1)}},Object.defineProperty(e.Stage.prototype,"backgroundColor",{get:function(){return this._backgroundColor},set:function(a){this._backgroundColor=a,"string"==typeof a&&(a=e.Color.hexToRGB(a)),this._stage.setBackgroundColor(a)}}),e.Group=function(a,b,c,f){"undefined"==typeof b&&(b=a.world),"undefined"==typeof f&&(f=!1),this.game=a,this.name=c||"group",f?this._container=this.game.stage._stage:(this._container=new d.DisplayObjectContainer,this._container.name=this.name,b?b instanceof e.Group?(b._container.addChild(this._container),b._container.updateTransform()):(b.addChild(this._container),b.updateTransform()):(this.game.stage._stage.addChild(this._container),this.game.stage._stage.updateTransform())),this.type=e.GROUP,this.exists=!0,this.scale=new e.Point(1,1)},e.Group.prototype={add:function(a){return a.group!==this&&(a.group=this,a.events&&a.events.onAddedToGroup.dispatch(a,this),this._container.addChild(a),a.updateTransform()),a},addAt:function(a,b){return a.group!==this&&(a.group=this,a.events&&a.events.onAddedToGroup.dispatch(a,this),this._container.addChildAt(a,b),a.updateTransform()),a},getAt:function(a){return this._container.getChildAt(a)},create:function(a,b,c,d,f){"undefined"==typeof f&&(f=!0);var g=new e.Sprite(this.game,a,b,c,d);return g.group=this,g.exists=f,g.visible=f,g.alive=f,g.events&&g.events.onAddedToGroup.dispatch(g,this),this._container.addChild(g),g.updateTransform(),g},createMultiple:function(a,b,c,d){"undefined"==typeof d&&(d=!1);for(var f=0;a>f;f++){var g=new e.Sprite(this.game,0,0,b,c);g.group=this,g.exists=d,g.visible=d,g.alive=d,g.events&&g.events.onAddedToGroup.dispatch(g,this),this._container.addChild(g),g.updateTransform()}},swap:function(a,b){if(a===b||!a.parent||!b.parent)return console.warn("You cannot swap a child with itself or swap un-parented children"),!1;var c=a._iPrev,d=a._iNext,e=b._iPrev,f=b._iNext,g=this._container.last._iNext,h=this.game.stage._stage;do h!==a&&h!==b&&(h.first===a?h.first=b:h.first===b&&(h.first=a),h.last===a?h.last=b:h.last===b&&(h.last=a)),h=h._iNext;while(h!=g);return a._iNext==b?(a._iNext=f,a._iPrev=b,b._iNext=a,b._iPrev=c,c&&(c._iNext=b),f&&(f._iPrev=a),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0):b._iNext==a?(a._iNext=b,a._iPrev=e,b._iNext=d,b._iPrev=a,e&&(e._iNext=a),d&&(f._iPrev=b),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0):(a._iNext=f,a._iPrev=e,b._iNext=d,b._iPrev=c,c&&(c._iNext=b),d&&(d._iPrev=b),e&&(e._iNext=a),f&&(f._iPrev=a),a.__renderGroup&&a.__renderGroup.updateTexture(a),b.__renderGroup&&b.__renderGroup.updateTexture(b),!0)},bringToTop:function(a){return a.group===this&&(this.remove(a),this.add(a)),a},getIndex:function(a){return this._container.children.indexOf(a)},replace:function(a,b){if(this._container.first._iNext){var c=this.getIndex(a);-1!=c&&(void 0!=b.parent&&(b.events.onRemovedFromGroup.dispatch(b,this),b.parent.removeChild(b)),this._container.removeChild(a),this._container.addChildAt(b,c),b.events.onAddedToGroup.dispatch(b,this),b.updateTransform())}},setProperty:function(a,b,c,d){d=d||0,1==b.length?0==d?a[b[0]]=c:1==d?a[b[0]]+=c:2==d?a[b[0]]-=c:3==d?a[b[0]]*=c:4==d&&(a[b[0]]/=c):2==b.length?0==d?a[b[0]][b[1]]=c:1==d?a[b[0]][b[1]]+=c:2==d?a[b[0]][b[1]]-=c:3==d?a[b[0]][b[1]]*=c:4==d&&(a[b[0]][b[1]]/=c):3==b.length?0==d?a[b[0]][b[1]][b[2]]=c:1==d?a[b[0]][b[1]][b[2]]+=c:2==d?a[b[0]][b[1]][b[2]]-=c:3==d?a[b[0]][b[1]][b[2]]*=c:4==d&&(a[b[0]][b[1]][b[2]]/=c):4==b.length&&(0==d?a[b[0]][b[1]][b[2]][b[3]]=c:1==d?a[b[0]][b[1]][b[2]][b[3]]+=c:2==d?a[b[0]][b[1]][b[2]][b[3]]-=c:3==d?a[b[0]][b[1]][b[2]][b[3]]*=c:4==d&&(a[b[0]][b[1]][b[2]][b[3]]/=c))},setAll:function(a,b,c,d,e){if(a=a.split("."),"undefined"==typeof c&&(c=!1),"undefined"==typeof d&&(d=!1),e=e||0,this._container.children.length>0&&this._container.first._iNext){var f=this._container.first._iNext;do(0==c||c&&f.alive)&&(0==d||d&&f.visible)&&this.setProperty(f,a,b,e),f=f._iNext;while(f!=this._container.last._iNext)}},addAll:function(a,b,c,d){this.setAll(a,b,c,d,1)},subAll:function(a,b,c,d){this.setAll(a,b,c,d,2)},multiplyAll:function(a,b,c,d){this.setAll(a,b,c,d,3)},divideAll:function(a,b,c,d){this.setAll(a,b,c,d,4)},callAllExists:function(a,b){var c=Array.prototype.splice.call(arguments,2);if(this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do d.exists==b&&d[a]&&d[a].apply(d,c),d=d._iNext;while(d!=this._container.last._iNext)}},callAll:function(a){var b=Array.prototype.splice.call(arguments,1);if(this._container.children.length>0&&this._container.first._iNext){var c=this._container.first._iNext;do c[a]&&c[a].apply(c,b),c=c._iNext;while(c!=this._container.last._iNext)}},forEach:function(a,b,c){"undefined"==typeof c&&(c=!1);var d=Array.prototype.splice.call(arguments,3);if(d.unshift(null),this._container.children.length>0&&this._container.first._iNext){var e=this._container.first._iNext;do(0==c||c&&e.exists)&&(d[0]=e,a.apply(b,d)),e=e._iNext;while(e!=this._container.last._iNext)}},forEachAlive:function(a,b){var c=Array.prototype.splice.call(arguments,2);if(c.unshift(null),this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do d.alive&&(c[0]=d,a.apply(b,c)),d=d._iNext;while(d!=this._container.last._iNext)}},forEachDead:function(a,b){var c=Array.prototype.splice.call(arguments,2);if(c.unshift(null),this._container.children.length>0&&this._container.first._iNext){var d=this._container.first._iNext;do 0==d.alive&&(c[0]=d,a.apply(b,c)),d=d._iNext;while(d!=this._container.last._iNext)}},getFirstExists:function(a){if("boolean"!=typeof a&&(a=!0),this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do{if(b.exists===a)return b;b=b._iNext}while(b!=this._container.last._iNext)}return null},getFirstAlive:function(){if(this._container.children.length>0&&this._container.first._iNext){var a=this._container.first._iNext;do{if(a.alive)return a;a=a._iNext}while(a!=this._container.last._iNext)}return null},getFirstDead:function(){if(this._container.children.length>0&&this._container.first._iNext){var a=this._container.first._iNext;do{if(!a.alive)return a;a=a._iNext}while(a!=this._container.last._iNext)}return null},countLiving:function(){var a=0;if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do b.alive&&a++,b=b._iNext;while(b!=this._container.last._iNext)}else a=-1;return a},countDead:function(){var a=0;if(this._container.children.length>0&&this._container.first._iNext){var b=this._container.first._iNext;do b.alive||a++,b=b._iNext;while(b!=this._container.last._iNext)}else a=-1;return a},getRandom:function(a,b){return 0==this._container.children.length?null:(a=a||0,b=b||this._container.children.length,this.game.math.getRandom(this._container.children,a,b))},remove:function(a){a.events&&a.events.onRemovedFromGroup.dispatch(a,this),this._container.removeChild(a),a.group=null},removeAll:function(){if(0!=this._container.children.length)do this._container.children[0].events&&this._container.children[0].events.onRemovedFromGroup.dispatch(this._container.children[0],this),this._container.removeChild(this._container.children[0]);while(this._container.children.length>0)},removeBetween:function(a,b){if(0!=this._container.children.length){if(a>b||0>a||b>this._container.children.length)return!1;for(var c=a;b>c;c++){var d=this._container.children[c];d.events.onRemovedFromGroup.dispatch(d,this),this._container.removeChild(d)}}},destroy:function(){this.removeAll(),this._container.parent.removeChild(this._container),this._container=null,this.game=null,this.exists=!1},dump:function(a){"undefined"==typeof a&&(a=!1);var b=20,c="\n"+e.Utils.pad("Node",b)+"|"+e.Utils.pad("Next",b)+"|"+e.Utils.pad("Previous",b)+"|"+e.Utils.pad("First",b)+"|"+e.Utils.pad("Last",b);console.log(c);var c=e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b)+"|"+e.Utils.pad("----------",b);if(console.log(c),a)var d=this.game.stage._stage.last._iNext,f=this.game.stage._stage;else var d=this._container.last._iNext,f=this._container;do{var g=f.name||"*",h="-",i="-",j="-",k="-";f._iNext&&(h=f._iNext.name),f._iPrev&&(i=f._iPrev.name),f.first&&(j=f.first.name),f.last&&(k=f.last.name),"undefined"==typeof h&&(h="-"),"undefined"==typeof i&&(i="-"),"undefined"==typeof j&&(j="-"),"undefined"==typeof k&&(k="-");var c=e.Utils.pad(g,b)+"|"+e.Utils.pad(h,b)+"|"+e.Utils.pad(i,b)+"|"+e.Utils.pad(j,b)+"|"+e.Utils.pad(k,b);console.log(c),f=f._iNext}while(f!=d)}},Object.defineProperty(e.Group.prototype,"total",{get:function(){return this._container.children.length}}),Object.defineProperty(e.Group.prototype,"length",{get:function(){return this._container.children.length}}),Object.defineProperty(e.Group.prototype,"x",{get:function(){return this._container.position.x},set:function(a){this._container.position.x=a}}),Object.defineProperty(e.Group.prototype,"y",{get:function(){return this._container.position.y},set:function(a){this._container.position.y=a}}),Object.defineProperty(e.Group.prototype,"angle",{get:function(){return e.Math.radToDeg(this._container.rotation)},set:function(a){this._container.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.Group.prototype,"rotation",{get:function(){return this._container.rotation},set:function(a){this._container.rotation=a}}),Object.defineProperty(e.Group.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),Object.defineProperty(e.Group.prototype,"alpha",{get:function(){return this._container.alpha},set:function(a){this._container.alpha=a}}),e.World=function(a){e.Group.call(this,a,null,"__world",!1),this.scale=new e.Point(1,1),this.bounds=new e.Rectangle(0,0,a.width,a.height),this.camera=null,this.currentRenderOrderID=0},e.World.prototype=Object.create(e.Group.prototype),e.World.prototype.constructor=e.World,e.World.prototype.boot=function(){this.camera=new e.Camera(this.game,0,0,0,this.game.width,this.game.height),this.camera.displayObject=this._container,this.game.camera=this.camera},e.World.prototype.update=function(){if(this.currentRenderOrderID=0,this.game.stage._stage.first._iNext){var a=this.game.stage._stage.first._iNext;do a.preUpdate&&a.preUpdate(),a.update&&a.update(),a=a._iNext;while(a!=this.game.stage._stage.last._iNext)}},e.World.prototype.postUpdate=function(){if(this.camera.update(),this.game.stage._stage.first._iNext){var a=this.game.stage._stage.first._iNext;do a.postUpdate&&a.postUpdate(),a=a._iNext;while(a!=this.game.stage._stage.last._iNext)}},e.World.prototype.setBounds=function(a,b,c,d){this.bounds.setTo(a,b,c,d),this.camera.bounds&&this.camera.bounds.setTo(a,b,c,d)},e.World.prototype.destroy=function(){this.camera.x=0,this.camera.y=0,this.game.input.reset(!0),this.removeAll()},Object.defineProperty(e.World.prototype,"width",{get:function(){return this.bounds.width},set:function(a){this.bounds.width=a}}),Object.defineProperty(e.World.prototype,"height",{get:function(){return this.bounds.height},set:function(a){this.bounds.height=a}}),Object.defineProperty(e.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth}}),Object.defineProperty(e.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight}}),Object.defineProperty(e.World.prototype,"randomX",{get:function(){return this.bounds.x<0?this.game.rnd.integerInRange(this.bounds.x,this.bounds.width-Math.abs(this.bounds.x)):this.game.rnd.integerInRange(this.bounds.x,this.bounds.width)}}),Object.defineProperty(e.World.prototype,"randomY",{get:function(){return this.bounds.y<0?this.game.rnd.integerInRange(this.bounds.y,this.bounds.height-Math.abs(this.bounds.y)):this.game.rnd.integerInRange(this.bounds.y,this.bounds.height)}}),e.Game=function(a,b,c,d,f,g,h){a=a||800,b=b||600,c=c||e.AUTO,d=d||"",f=f||null,"undefined"==typeof g&&(g=!1),"undefined"==typeof h&&(h=!0),this.id=e.GAMES.push(this)-1,this.parent=d,this.width=a,this.height=b,this.transparent=g,this.antialias=h,this.renderer=null,this.state=new e.StateManager(this,f),this._paused=!1,this.renderType=c,this._loadComplete=!1,this.isBooted=!1,this.isRunning=!1,this.raf=null,this.add=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.net=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.physics=null,this.rnd=null,this.device=null,this.camera=null,this.canvas=null,this.context=null,this.debug=null,this.particles=null;var i=this;return this._onBoot=function(){return i.boot()},"complete"===document.readyState||"interactive"===document.readyState?window.setTimeout(this._onBoot,0):(document.addEventListener("DOMContentLoaded",this._onBoot,!1),window.addEventListener("load",this._onBoot,!1)),this},e.Game.prototype={boot:function(){if(!this.isBooted)if(document.body){document.removeEventListener("DOMContentLoaded",this._onBoot),window.removeEventListener("load",this._onBoot),this.onPause=new e.Signal,this.onResume=new e.Signal,this.isBooted=!0,this.device=new e.Device,this.math=e.Math,this.rnd=new e.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.stage=new e.Stage(this,this.width,this.height),this.setUpRenderer(),this.world=new e.World(this),this.add=new e.GameObjectFactory(this),this.cache=new e.Cache(this),this.load=new e.Loader(this),this.time=new e.Time(this),this.tweens=new e.TweenManager(this),this.input=new e.Input(this),this.sound=new e.SoundManager(this),this.physics=new e.Physics.Arcade(this),this.particles=new e.Particles(this),this.plugins=new e.PluginManager(this,this),this.net=new e.Net(this),this.debug=new e.Utils.Debug(this),this.stage.boot(),this.world.boot(),this.input.boot(),this.sound.boot(),this.state.boot(),this.load.onLoadComplete.add(this.loadComplete,this),this.renderType==e.CANVAS?console.log("%cPhaser "+e.VERSION+" initialized. Rendering to Canvas","color: #ffff33; background: #000000"):console.log("%cPhaser "+e.VERSION+" initialized. Rendering to WebGL","color: #ffff33; background: #000000");var a=e.VERSION.indexOf("-"),b=a>=0?e.VERSION.substr(a+1):null;if(b){var c=["a","e","i","o","u","y"].indexOf(b.charAt(0))>=0?"an":"a";console.warn("You are using %s %s version of Phaser. Some things may not work.",c,b)}this.isRunning=!0,this._loadComplete=!1,this.raf=new e.RequestAnimationFrame(this),this.raf.start()}else window.setTimeout(this._onBoot,20)},setUpRenderer:function(){if(this.renderType===e.CANVAS||this.renderType===e.AUTO&&0==this.device.webGL){if(!this.device.canvas)throw new Error("Phaser.Game - cannot create Canvas or WebGL context, aborting."); +this.renderType=e.CANVAS,this.renderer=new d.CanvasRenderer(this.width,this.height,this.stage.canvas,this.transparent),e.Canvas.setSmoothingEnabled(this.renderer.context,this.antialias),this.canvas=this.renderer.view,this.context=this.renderer.context}else this.renderType=e.WEBGL,this.renderer=new d.WebGLRenderer(this.width,this.height,this.stage.canvas,this.transparent,this.antialias),this.canvas=this.renderer.view,this.context=null;e.Canvas.addToDOM(this.renderer.view,this.parent,!0),e.Canvas.setTouchAction(this.renderer.view)},loadComplete:function(){this._loadComplete=!0,this.state.loadComplete()},update:function(a){this.time.update(a),this._paused||(this.plugins.preUpdate(),this.physics.preUpdate(),this.stage.update(),this.input.update(),this.tweens.update(),this.sound.update(),this.world.update(),this.particles.update(),this.state.update(),this.plugins.update(),this.world.postUpdate(),this.renderer.render(this.stage._stage),this.plugins.render(),this.state.render(),this.plugins.postRender())},destroy:function(){this.raf.stop(),this.input.destroy(),this.state.destroy(),this.state=null,this.cache=null,this.input=null,this.load=null,this.sound=null,this.stage=null,this.time=null,this.world=null,this.isBooted=!1}},Object.defineProperty(e.Game.prototype,"paused",{get:function(){return this._paused},set:function(a){a===!0?0==this._paused&&(this._paused=!0,this.onPause.dispatch(this)):this._paused&&(this._paused=!1,this.onResume.dispatch(this))}}),e.Input=function(a){this.game=a,this.hitCanvas=null,this.hitContext=null},e.Input.MOUSE_OVERRIDES_TOUCH=0,e.Input.TOUCH_OVERRIDES_MOUSE=1,e.Input.MOUSE_TOUCH_COMBINE=2,e.Input.prototype={game:null,pollRate:0,_pollCounter:0,_oldPosition:null,_x:0,_y:0,disabled:!1,multiInputOverride:e.Input.MOUSE_TOUCH_COMBINE,position:null,speed:null,circle:null,scale:null,maxPointers:10,currentPointers:0,tapRate:200,doubleTapRate:300,holdRate:2e3,justPressedRate:200,justReleasedRate:200,recordPointerHistory:!1,recordRate:100,recordLimit:100,pointer1:null,pointer2:null,pointer3:null,pointer4:null,pointer5:null,pointer6:null,pointer7:null,pointer8:null,pointer9:null,pointer10:null,activePointer:null,mousePointer:null,mouse:null,keyboard:null,touch:null,mspointer:null,onDown:null,onUp:null,onTap:null,onHold:null,interactiveItems:new e.LinkedList,boot:function(){this.mousePointer=new e.Pointer(this.game,0),this.pointer1=new e.Pointer(this.game,1),this.pointer2=new e.Pointer(this.game,2),this.mouse=new e.Mouse(this.game),this.keyboard=new e.Keyboard(this.game),this.touch=new e.Touch(this.game),this.mspointer=new e.MSPointer(this.game),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.scale=new e.Point(1,1),this.speed=new e.Point,this.position=new e.Point,this._oldPosition=new e.Point,this.circle=new e.Circle(0,0,44),this.activePointer=this.mousePointer,this.currentPointers=0,this.hitCanvas=document.createElement("canvas"),this.hitCanvas.width=1,this.hitCanvas.height=1,this.hitContext=this.hitCanvas.getContext("2d"),this.mouse.start(),this.keyboard.start(),this.touch.start(),this.mspointer.start(),this.mousePointer.active=!0},destroy:function(){this.mouse.stop(),this.keyboard.stop(),this.touch.stop(),this.mspointer.stop()},addPointer:function(){for(var a=0,b=10;b>0;b--)null===this["pointer"+b]&&(a=b);return 0==a?(console.warn("You can only have 10 Pointer objects"),null):(this["pointer"+a]=new e.Pointer(this.game,a),this["pointer"+a])},update:function(){return this.pollRate>0&&this._pollCounter=b;b++)this["pointer"+b]&&this["pointer"+b].reset();this.currentPointers=0,this.game.stage.canvas.style.cursor="default",1==a&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new e.Signal,this.onUp=new e.Signal,this.onTap=new e.Signal,this.onHold=new e.Signal,this.interactiveItems.callAll("reset")),this._pollCounter=0}},resetSpeed:function(a,b){this._oldPosition.setTo(a,b),this.speed.setTo(0,0)},startPointer:function(a){if(this.maxPointers<10&&this.totalActivePointers==this.maxPointers)return null;if(0==this.pointer1.active)return this.pointer1.start(a);if(0==this.pointer2.active)return this.pointer2.start(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&0==this["pointer"+b].active)return this["pointer"+b].start(a);return null},updatePointer:function(a){if(this.pointer1.active&&this.pointer1.identifier==a.identifier)return this.pointer1.move(a);if(this.pointer2.active&&this.pointer2.identifier==a.identifier)return this.pointer2.move(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active&&this["pointer"+b].identifier==a.identifier)return this["pointer"+b].move(a);return null},stopPointer:function(a){if(this.pointer1.active&&this.pointer1.identifier==a.identifier)return this.pointer1.stop(a);if(this.pointer2.active&&this.pointer2.identifier==a.identifier)return this.pointer2.stop(a);for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active&&this["pointer"+b].identifier==a.identifier)return this["pointer"+b].stop(a);return null},getPointer:function(a){if(a=a||!1,this.pointer1.active==a)return this.pointer1;if(this.pointer2.active==a)return this.pointer2;for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].active==a)return this["pointer"+b];return null},getPointerFromIdentifier:function(a){if(this.pointer1.identifier==a)return this.pointer1;if(this.pointer2.identifier==a)return this.pointer2;for(var b=3;10>=b;b++)if(this["pointer"+b]&&this["pointer"+b].identifier==a)return this["pointer"+b];return null}},Object.defineProperty(e.Input.prototype,"x",{get:function(){return this._x},set:function(a){this._x=Math.floor(a)}}),Object.defineProperty(e.Input.prototype,"y",{get:function(){return this._y},set:function(a){this._y=Math.floor(a)}}),Object.defineProperty(e.Input.prototype,"pollLocked",{get:function(){return this.pollRate>0&&this._pollCounter=a;a++)this["pointer"+a]&&this["pointer"+a].active&&this.currentPointers++;return this.currentPointers}}),Object.defineProperty(e.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}}),Object.defineProperty(e.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}}),e.Key=function(a,b){this.game=a,this.isDown=!1,this.isUp=!1,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.duration=0,this.timeUp=0,this.repeats=0,this.keyCode=b,this.onDown=new e.Signal,this.onUp=new e.Signal},e.Key.prototype={processKeyDown:function(a){this.altKey=a.altKey,this.ctrlKey=a.ctrlKey,this.shiftKey=a.shiftKey,this.isDown?(this.duration=a.timeStamp-this.timeDown,this.repeats++):(this.isDown=!0,this.isUp=!1,this.timeDown=a.timeStamp,this.duration=0,this.repeats=0,this.onDown.dispatch(this))},processKeyUp:function(a){this.isDown=!1,this.isUp=!0,this.timeUp=a.timeStamp,this.onUp.dispatch(this)},justPressed:function(a){return"undefined"==typeof a&&(a=250),this.isDown&&this.duration=this.game.input.holdRate&&((this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&this.game.input.onHold.dispatch(this),this._holdSent=!0),this.game.input.recordPointerHistory&&this.game.time.now>=this._nextDrop&&(this._nextDrop=this.game.time.now+this.game.input.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>this.game.input.recordLimit&&this._history.shift()))},move:function(a){if(!this.game.input.pollLocked){if("undefined"!=typeof a.button&&(this.button=a.button),this.clientX=a.clientX,this.clientY=a.clientY,this.pageX=a.pageX,this.pageY=a.pageY,this.screenX=a.screenX,this.screenY=a.screenY,this.x=(this.pageX-this.game.stage.offset.x)*this.game.input.scale.x,this.y=(this.pageY-this.game.stage.offset.y)*this.game.input.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&(this.game.input.activePointer=this,this.game.input.x=this.x,this.game.input.y=this.y,this.game.input.position.setTo(this.game.input.x,this.game.input.y),this.game.input.circle.x=this.game.input.x,this.game.input.circle.y=this.game.input.y),this.game.paused)return this;if(null!==this.targetObject&&1==this.targetObject.isDragged)return 0==this.targetObject.update(this)&&(this.targetObject=null),this;if(this._highestRenderOrderID=-1,this._highestRenderObject=null,this._highestInputPriorityID=-1,this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do(b.pixelPerfect||b.priorityID>this._highestInputPriorityID||b.priorityID==this._highestInputPriorityID&&b.sprite.renderOrderID>this._highestRenderOrderID)&&b.checkPointerOver(this)&&(this._highestRenderOrderID=b.sprite.renderOrderID,this._highestInputPriorityID=b.priorityID,this._highestRenderObject=b),b=b.next;while(null!=b)}return null==this._highestRenderObject?this.targetObject&&(this.targetObject._pointerOutHandler(this),this.targetObject=null):null==this.targetObject?(this.targetObject=this._highestRenderObject,this._highestRenderObject._pointerOverHandler(this)):this.targetObject==this._highestRenderObject?0==this._highestRenderObject.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this),this.targetObject=this._highestRenderObject,this.targetObject._pointerOverHandler(this)),this}},leave:function(a){this.withinGame=!1,this.move(a)},stop:function(a){if(this._stateReset)return a.preventDefault(),void 0;if(this.timeUp=this.game.time.now,(this.game.input.multiInputOverride==e.Input.MOUSE_OVERRIDES_TOUCH||this.game.input.multiInputOverride==e.Input.MOUSE_TOUCH_COMBINE||this.game.input.multiInputOverride==e.Input.TOUCH_OVERRIDES_MOUSE&&0==this.game.input.currentPointers)&&(this.game.input.onUp.dispatch(this,a),this.duration>=0&&this.duration<=this.game.input.tapRate&&(this.timeUp-this.previousTapTime0&&(this.active=!1),this.withinGame=!1,this.isDown=!1,this.isUp=!0,0==this.isMouse&&this.game.input.currentPointers--,this.game.input.interactiveItems.total>0){var b=this.game.input.interactiveItems.next;do b&&b._releasedHandler(this),b=b.next;while(null!=b)}return this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null,this},justPressed:function(a){return a=a||this.game.input.justPressedRate,this.isDown===!0&&this.timeDown+a>this.game.time.now},justReleased:function(a){return a=a||this.game.input.justReleasedRate,this.isUp===!0&&this.timeUp+a>this.game.time.now},reset:function(){0==this.isMouse&&(this.active=!1),this.identifier=null,this.isDown=!1,this.isUp=!0,this.totalTouches=0,this._holdSent=!1,this._history.length=0,this._stateReset=!0,this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null},toString:function(){return"[{Pointer (id="+this.id+" identifer="+this.identifier+" active="+this.active+" duration="+this.duration+" withinGame="+this.withinGame+" x="+this.x+" y="+this.y+" clientX="+this.clientX+" clientY="+this.clientY+" screenX="+this.screenX+" screenY="+this.screenY+" pageX="+this.pageX+" pageY="+this.pageY+")}]"}},Object.defineProperty(e.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.now-this.timeDown}}),Object.defineProperty(e.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}}),Object.defineProperty(e.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}}),e.Touch=function(a){this.game=a,this.disabled=!1,this.callbackContext=this.game,this.touchStartCallback=null,this.touchMoveCallback=null,this.touchEndCallback=null,this.touchEnterCallback=null,this.touchLeaveCallback=null,this.touchCancelCallback=null,this.preventDefault=!0,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null},e.Touch.prototype={start:function(){var a=this;this.game.device.touch&&(this._onTouchStart=function(b){return a.onTouchStart(b)},this._onTouchMove=function(b){return a.onTouchMove(b)},this._onTouchEnd=function(b){return a.onTouchEnd(b)},this._onTouchEnter=function(b){return a.onTouchEnter(b)},this._onTouchLeave=function(b){return a.onTouchLeave(b)},this._onTouchCancel=function(b){return a.onTouchCancel(b)},this.game.renderer.view.addEventListener("touchstart",this._onTouchStart,!1),this.game.renderer.view.addEventListener("touchmove",this._onTouchMove,!1),this.game.renderer.view.addEventListener("touchend",this._onTouchEnd,!1),this.game.renderer.view.addEventListener("touchenter",this._onTouchEnter,!1),this.game.renderer.view.addEventListener("touchleave",this._onTouchLeave,!1),this.game.renderer.view.addEventListener("touchcancel",this._onTouchCancel,!1))},consumeDocumentTouches:function(){this._documentTouchMove=function(a){a.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)},onTouchStart:function(a){if(this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,a),!this.game.input.disabled&&!this.disabled){this.preventDefault&&a.preventDefault();for(var b=0;bc;c++)this._pointerData[c]={id:c,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new e.Point,this.enabled=!0,this.sprite.events&&null==this.sprite.events.onInputOver&&(this.sprite.events.onInputOver=new e.Signal,this.sprite.events.onInputOut=new e.Signal,this.sprite.events.onInputDown=new e.Signal,this.sprite.events.onInputUp=new e.Signal,this.sprite.events.onDragStart=new e.Signal,this.sprite.events.onDragStop=new e.Signal)}return this.sprite},reset:function(){this.enabled=!1;for(var a=0;10>a;a++)this._pointerData[a]={id:a,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}},stop:function(){0!=this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))},destroy:function(){this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this),this.stop(),this.sprite=null)},pointerX:function(a){return a=a||0,this._pointerData[a].x},pointerY:function(a){return a=a||0,this._pointerData[a].y},pointerDown:function(a){return a=a||0,this._pointerData[a].isDown},pointerUp:function(a){return a=a||0,this._pointerData[a].isUp},pointerTimeDown:function(a){return a=a||0,this._pointerData[a].timeDown},pointerTimeUp:function(a){return a=a||0,this._pointerData[a].timeUp},pointerOver:function(a){return a=a||0,this._pointerData[a].isOver},pointerOut:function(a){return a=a||0,this._pointerData[a].isOut},pointerTimeOver:function(a){return a=a||0,this._pointerData[a].timeOver},pointerTimeOut:function(a){return a=a||0,this._pointerData[a].timeOut},pointerDragged:function(a){return a=a||0,this._pointerData[a].isDragged},checkPointerOver:function(a){return this.enabled&&this.sprite.visible&&(this.sprite.getLocalUnmodifiedPosition(this._tempPoint,a.x,a.y),this._tempPoint.x>=0&&this._tempPoint.x<=this.sprite.currentFrame.width&&this._tempPoint.y>=0&&this._tempPoint.y<=this.sprite.currentFrame.height)?this.pixelPerfect?this.checkPixel(this._tempPoint.x,this._tempPoint.y):!0:!1},checkPixel:function(a,b){if(this.sprite.texture.baseTexture.source){this.game.input.hitContext.clearRect(0,0,1,1),a+=this.sprite.texture.frame.x,b+=this.sprite.texture.frame.y,this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,a,b,1,1,0,0,1,1);var c=this.game.input.hitContext.getImageData(0,0,1,1);if(c.data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(a){return 0==this.enabled||0==this.sprite.visible||this.sprite.group&&0==this.sprite.group.visible?(this._pointerOutHandler(a),!1):this.draggable&&this._draggedPointerID==a.id?this.updateDrag(a):1==this._pointerData[a.id].isOver?this.checkPointerOver(a)?(this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,!0):(this._pointerOutHandler(a),!1):void 0},_pointerOverHandler:function(a){0==this._pointerData[a.id].isOver&&(this._pointerData[a.id].isOver=!0,this._pointerData[a.id].isOut=!1,this._pointerData[a.id].timeOver=this.game.time.now,this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,this.useHandCursor&&0==this._pointerData[a.id].isDragged&&(this.game.stage.canvas.style.cursor="pointer"),this.sprite.events.onInputOver.dispatch(this.sprite,a))},_pointerOutHandler:function(a){this._pointerData[a.id].isOver=!1,this._pointerData[a.id].isOut=!0,this._pointerData[a.id].timeOut=this.game.time.now,this.useHandCursor&&0==this._pointerData[a.id].isDragged&&(this.game.stage.canvas.style.cursor="default"),this.sprite&&this.sprite.events&&this.sprite.events.onInputOut.dispatch(this.sprite,a) +},_touchedHandler:function(a){return 0==this._pointerData[a.id].isDown&&1==this._pointerData[a.id].isOver&&(this._pointerData[a.id].isDown=!0,this._pointerData[a.id].isUp=!1,this._pointerData[a.id].timeDown=this.game.time.now,this.sprite.events.onInputDown.dispatch(this.sprite,a),this.draggable&&0==this.isDragged&&this.startDrag(a),this.bringToTop&&this.sprite.bringToTop()),this.consumePointerEvent},_releasedHandler:function(a){this._pointerData[a.id].isDown&&a.isUp&&(this._pointerData[a.id].isDown=!1,this._pointerData[a.id].isUp=!0,this._pointerData[a.id].timeUp=this.game.time.now,this._pointerData[a.id].downDuration=this._pointerData[a.id].timeUp-this._pointerData[a.id].timeDown,this.checkPointerOver(a)?this.sprite.events.onInputUp.dispatch(this.sprite,a):this.useHandCursor&&(this.game.stage.canvas.style.cursor="default"),this.draggable&&this.isDragged&&this._draggedPointerID==a.id&&this.stopDrag(a))},updateDrag:function(a){return a.isUp?(this.stopDrag(a),!1):(this.allowHorizontalDrag&&(this.sprite.x=a.x+this._dragPoint.x+this.dragOffset.x),this.allowVerticalDrag&&(this.sprite.y=a.y+this._dragPoint.y+this.dragOffset.y),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.x=Math.round(this.sprite.x/this.snapX)*this.snapX,this.sprite.y=Math.round(this.sprite.y/this.snapY)*this.snapY),!0)},justOver:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isOver&&this.overDuration(a)a;a++)this._pointerData[a].isDragged=!1;this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1},startDrag:function(a){this.isDragged=!0,this._draggedPointerID=a.id,this._pointerData[a.id].isDragged=!0,this.dragFromCenter?(this.sprite.centerOn(a.x,a.y),this._dragPoint.setTo(this.sprite.x-a.x,this.sprite.y-a.y)):this._dragPoint.setTo(this.sprite.x-a.x,this.sprite.y-a.y),this.updateDrag(a),this.bringToTop&&this.sprite.bringToTop(),this.sprite.events.onDragStart.dispatch(this.sprite,a)},stopDrag:function(a){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[a.id].isDragged=!1,this.snapOnRelease&&(this.sprite.x=Math.round(this.sprite.x/this.snapX)*this.snapX,this.sprite.y=Math.round(this.sprite.y/this.snapY)*this.snapY),this.sprite.events.onDragStop.dispatch(this.sprite,a),this.sprite.events.onInputUp.dispatch(this.sprite,a)},setDragLock:function(a,b){"undefined"==typeof a&&(a=!0),"undefined"==typeof b&&(b=!0),this.allowHorizontalDrag=a,this.allowVerticalDrag=b},enableSnap:function(a,b,c,d){"undefined"==typeof c&&(c=!0),"undefined"==typeof d&&(d=!1),this.snapX=a,this.snapY=b,this.snapOnDrag=c,this.snapOnRelease=d},disableSnap:function(){this.snapOnDrag=!1,this.snapOnRelease=!1},checkBoundsRect:function(){this.sprite.xthis.boundsRect.right&&(this.sprite.x=this.boundsRect.right-this.sprite.width),this.sprite.ythis.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-this.sprite.height)},checkBoundsSprite:function(){this.sprite.xthis.boundsSprite.x+this.boundsSprite.width&&(this.sprite.x=this.boundsSprite.x+this.boundsSprite.width-this.sprite.width),this.sprite.ythis.boundsSprite.y+this.boundsSprite.height&&(this.sprite.y=this.boundsSprite.y+this.boundsSprite.height-this.sprite.height)}},e.Events=function(a){this.parent=a,this.onAddedToGroup=new e.Signal,this.onRemovedFromGroup=new e.Signal,this.onKilled=new e.Signal,this.onRevived=new e.Signal,this.onOutOfBounds=new e.Signal,this.onInputOver=null,this.onInputOut=null,this.onInputDown=null,this.onInputUp=null,this.onDragStart=null,this.onDragStop=null,this.onAnimationStart=null,this.onAnimationComplete=null,this.onAnimationLoop=null},e.Events.prototype={destroy:function(){this.parent=null,this.onAddedToGroup.dispose(),this.onRemovedFromGroup.dispose(),this.onKilled.dispose(),this.onRevived.dispose(),this.onOutOfBounds.dispose(),this.onInputOver&&(this.onInputOver.dispose(),this.onInputOut.dispose(),this.onInputDown.dispose(),this.onInputUp.dispose(),this.onDragStart.dispose(),this.onDragStop.dispose()),this.onAnimationStart&&(this.onAnimationStart.dispose(),this.onAnimationComplete.dispose(),this.onAnimationLoop.dispose())}},e.GameObjectFactory=function(a){this.game=a,this.world=this.game.world},e.GameObjectFactory.prototype={existing:function(a){return this.world.add(a)},sprite:function(a,b,c,d){return this.world.create(a,b,c,d)},child:function(a,b,c,d,e){return a.create(b,c,d,e)},tween:function(a){return this.game.tweens.create(a)},group:function(a,b){return new e.Group(this.game,a,b)},audio:function(a,b,c){return this.game.sound.add(a,b,c)},tileSprite:function(a,b,c,d,f,g){return this.world.add(new e.TileSprite(this.game,a,b,c,d,f,g))},text:function(a,b,c,d){return this.world.add(new e.Text(this.game,a,b,c,d))},button:function(a,b,c,d,f,g,h,i){return this.world.add(new e.Button(this.game,a,b,c,d,f,g,h,i))},graphics:function(a,b){return this.world.add(new e.Graphics(this.game,a,b))},emitter:function(a,b,c){return this.game.particles.add(new e.Particles.Arcade.Emitter(this.game,a,b,c))},bitmapText:function(a,b,c,d){return this.world.add(new e.BitmapText(this.game,a,b,c,d))},tilemap:function(a){return new e.Tilemap(this.game,a)},tileset:function(a){return this.game.cache.getTileset(a)},tilemapLayer:function(a,b,c,d,f,g,h){return this.world.add(new e.TilemapLayer(this.game,a,b,c,d,f,g,h))},renderTexture:function(a,b,c){var d=new e.RenderTexture(this.game,a,b,c);return this.game.cache.addRenderTexture(a,d),d}},e.Sprite=function(a,b,c,f,g){b=b||0,c=c||0,f=f||null,g=g||null,this.game=a,this.exists=!0,this.alive=!0,this.group=null,this.name="",this.type=e.SPRITE,this.renderOrderID=-1,this.lifespan=0,this.events=new e.Events(this),this.animations=new e.AnimationManager(this),this.input=new e.InputHandler(this),this.key=f,this.currentFrame=null,f instanceof e.RenderTexture?(d.Sprite.call(this,f),this.currentFrame=this.game.cache.getTextureFrame(f.name)):f instanceof d.Texture?(d.Sprite.call(this,f),this.currentFrame=g):((null==f||0==this.game.cache.checkImageKey(f))&&(f="__default",this.key=f),d.Sprite.call(this,d.TextureCache[f]),this.game.cache.isSpriteSheet(f)?(this.animations.loadFrameData(this.game.cache.getFrameData(f)),null!==g&&("string"==typeof g?this.frameName=g:this.frame=g)):this.currentFrame=this.game.cache.getFrame(f)),this.anchor=new e.Point,this.x=b,this.y=c,this.position.x=b,this.position.y=c,this.autoCull=!1,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:-1,a01:-1,a02:-1,a10:-1,a11:-1,a12:-1,id:-1,i01:-1,i10:-1,idi:-1,left:null,right:null,top:null,bottom:null,x:-1,y:-1,scaleX:1,scaleY:1,realScaleX:1,realScaleY:1,width:this.currentFrame.sourceSizeW,height:this.currentFrame.sourceSizeH,halfWidth:Math.floor(this.currentFrame.sourceSizeW/2),halfHeight:Math.floor(this.currentFrame.sourceSizeH/2),calcWidth:-1,calcHeight:-1,frameID:-1,frameWidth:this.currentFrame.width,frameHeight:this.currentFrame.height,boundsX:0,boundsY:0,cameraVisible:!0,cropX:0,cropY:0,cropWidth:this.currentFrame.sourceSizeW,cropHeight:this.currentFrame.sourceSizeH},this.offset=new e.Point,this.center=new e.Point(b+Math.floor(this._cache.width/2),c+Math.floor(this._cache.height/2)),this.topLeft=new e.Point(b,c),this.topRight=new e.Point(b+this._cache.width,c),this.bottomRight=new e.Point(b+this._cache.width,c+this._cache.height),this.bottomLeft=new e.Point(b,c+this._cache.height),this.bounds=new e.Rectangle(b,c,this._cache.width,this._cache.height),this.body=new e.Physics.Arcade.Body(this),this.health=1,this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds),this.inWorldThreshold=0,this.outOfBoundsKill=!1,this._outOfBoundsFired=!1,this.fixedToCamera=!1,this.crop=new e.Rectangle(0,0,this._cache.width,this._cache.height),this.cropEnabled=!1},e.Sprite.prototype=Object.create(d.Sprite.prototype),e.Sprite.prototype.constructor=e.Sprite,e.Sprite.prototype.preUpdate=function(){return this.exists?this.lifespan>0&&(this.lifespan-=this.game.time.elapsed,this.lifespan<=0)?(this.kill(),void 0):(this._cache.dirty=!1,this.animations.update()&&(this._cache.dirty=!0),this.visible&&(this.renderOrderID=this.game.world.currentRenderOrderID++),this.prevX=this.x,this.prevY=this.y,this.updateCache(),this.updateAnimation(),this.cropEnabled&&this.updateCrop(),this._cache.dirty&&(this.updateBounds(),this._cache.cameraVisible=e.Rectangle.intersects(this.game.world.camera.screenView,this.bounds,0),1==this.autoCull&&(this.renderable=this._cache.cameraVisible),this.body&&this.body.updateBounds(this.center.x,this.center.y,this._cache.scaleX,this._cache.scaleY)),this.body&&this.body.preUpdate(),void 0):(this.renderOrderID=-1,void 0)},e.Sprite.prototype.updateCache=function(){(this.worldTransform[1]!=this._cache.i01||this.worldTransform[3]!=this._cache.i10)&&(this._cache.a00=this.worldTransform[0],this._cache.a01=this.worldTransform[1],this._cache.a10=this.worldTransform[3],this._cache.a11=this.worldTransform[4],this._cache.i01=this.worldTransform[1],this._cache.i10=this.worldTransform[3],this._cache.scaleX=Math.sqrt(this._cache.a00*this._cache.a00+this._cache.a01*this._cache.a01),this._cache.scaleY=Math.sqrt(this._cache.a10*this._cache.a10+this._cache.a11*this._cache.a11),this._cache.a01*=-1,this._cache.a10*=-1,this._cache.dirty=!0),(this.worldTransform[2]!=this._cache.a02||this.worldTransform[5]!=this._cache.a12)&&(this._cache.a02=this.worldTransform[2],this._cache.a12=this.worldTransform[5],this._cache.dirty=!0)},e.Sprite.prototype.updateAnimation=function(){this.currentFrame&&this.currentFrame.uuid!=this._cache.frameID&&(this._cache.frameWidth=this.texture.frame.width,this._cache.frameHeight=this.texture.frame.height,this._cache.frameID=this.currentFrame.uuid,this._cache.dirty=!0),this._cache.dirty&&this.currentFrame&&(this._cache.width=this.currentFrame.width,this._cache.height=this.currentFrame.height,this._cache.halfWidth=Math.floor(this._cache.width/2),this._cache.halfHeight=Math.floor(this._cache.height/2),this._cache.id=1/(this._cache.a00*this._cache.a11+this._cache.a01*-this._cache.a10),this._cache.idi=1/(this._cache.a00*this._cache.a11+this._cache.i01*-this._cache.i10))},e.Sprite.prototype.updateBounds=function(){var a=1,b=1;(0!==this.worldTransform[3]||0!==this.worldTransform[1])&&(a=this.scale.x,b=this.scale.y),this.offset.setTo(this._cache.a02-this.anchor.x*this.width,this._cache.a12-this.anchor.y*this.height),this.getLocalPosition(this.center,this.offset.x+this.width/2,this.offset.y+this.height/2,a,b),this.getLocalPosition(this.topLeft,this.offset.x,this.offset.y,a,b),this.getLocalPosition(this.topRight,this.offset.x+this.width,this.offset.y,a,b),this.getLocalPosition(this.bottomLeft,this.offset.x,this.offset.y+this.height,a,b),this.getLocalPosition(this.bottomRight,this.offset.x+this.width,this.offset.y+this.height,a,b),this._cache.left=e.Math.min(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x),this._cache.right=e.Math.max(this.topLeft.x,this.topRight.x,this.bottomLeft.x,this.bottomRight.x),this._cache.top=e.Math.min(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y),this._cache.bottom=e.Math.max(this.topLeft.y,this.topRight.y,this.bottomLeft.y,this.bottomRight.y),this.bounds.setTo(this._cache.left,this._cache.top,this._cache.right-this._cache.left,this._cache.bottom-this._cache.top),this._cache.boundsX=this._cache.x,this._cache.boundsY=this._cache.y,this.updateFrame=!0,0==this.inWorld?(this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold),this.inWorld&&(this._outOfBoundsFired=!1)):(this.inWorld=e.Rectangle.intersects(this.bounds,this.game.world.bounds,this.inWorldThreshold),0==this.inWorld&&(this.events.onOutOfBounds.dispatch(this),this._outOfBoundsFired=!0,this.outOfBoundsKill&&this.kill()))},e.Sprite.prototype.getLocalPosition=function(a,b,c,d,e){return a.x=(this._cache.a11*this._cache.id*b+-this._cache.a01*this._cache.id*c+(this._cache.a12*this._cache.a01-this._cache.a02*this._cache.a11)*this._cache.id)*d+this._cache.a02,a.y=(this._cache.a00*this._cache.id*c+-this._cache.a10*this._cache.id*b+(-this._cache.a12*this._cache.a00+this._cache.a02*this._cache.a10)*this._cache.id)*e+this._cache.a12,a},e.Sprite.prototype.getLocalUnmodifiedPosition=function(a,b,c){var d=this.worldTransform[0],e=this.worldTransform[1],f=this.worldTransform[2],g=this.worldTransform[3],h=this.worldTransform[4],i=this.worldTransform[5],j=1/(d*h+e*-g),k=h*j*b+-e*j*c+(i*e-f*h)*j,l=d*j*c+-g*j*b+(-i*d+f*g)*j;return a.x=k+this.anchor.x*this._cache.width,a.y=l+this.anchor.y*this._cache.height,a},e.Sprite.prototype.updateCrop=function(){(this.crop.width!=this._cache.cropWidth||this.crop.height!=this._cache.cropHeight||this.crop.x!=this._cache.cropX||this.crop.y!=this._cache.cropY)&&(this.crop.floorAll(),this._cache.cropX=this.crop.x,this._cache.cropY=this.crop.y,this._cache.cropWidth=this.crop.width,this._cache.cropHeight=this.crop.height,this.texture.frame=this.crop,this.texture.width=this.crop.width,this.texture.height=this.crop.height,this.texture.updateFrame=!0,d.Texture.frameUpdates.push(this.texture))},e.Sprite.prototype.resetCrop=function(){this.crop=new e.Rectangle(0,0,this._cache.width,this._cache.height),this.texture.setFrame(this.crop),this.cropEnabled=!1},e.Sprite.prototype.postUpdate=function(){this.exists&&(this.body&&this.body.postUpdate(),this.fixedToCamera?(this._cache.x=this.game.camera.view.x+this.x,this._cache.y=this.game.camera.view.y+this.y):(this._cache.x=this.x,this._cache.y=this.y),(this.position.x!=this._cache.x||this.position.y!=this._cache.y)&&(this.position.x=this._cache.x,this.position.y=this._cache.y))},e.Sprite.prototype.loadTexture=function(a,b){this.key=a,a instanceof e.RenderTexture?this.currentFrame=this.game.cache.getTextureFrame(a.name):a instanceof d.Texture?this.currentFrame=b:(("undefined"==typeof a||this.game.cache.checkImageKey(a)===!1)&&(a="__default",this.key=a),this.game.cache.isSpriteSheet(a)?(this.animations.loadFrameData(this.game.cache.getFrameData(a)),"undefined"!=typeof b&&("string"==typeof b?this.frameName=b:this.frame=b)):(this.currentFrame=this.game.cache.getFrame(a),this.setTexture(d.TextureCache[a])))},e.Sprite.prototype.deltaAbsX=function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},e.Sprite.prototype.deltaAbsY=function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},e.Sprite.prototype.deltaX=function(){return this.x-this.prevX},e.Sprite.prototype.deltaY=function(){return this.y-this.prevY},e.Sprite.prototype.centerOn=function(a,b){return this.x=a+(this.x-this.center.x),this.y=b+(this.y-this.center.y),this},e.Sprite.prototype.revive=function(a){return"undefined"==typeof a&&(a=1),this.alive=!0,this.exists=!0,this.visible=!0,this.health=a,this.events&&this.events.onRevived.dispatch(this),this},e.Sprite.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled.dispatch(this),this},e.Sprite.prototype.destroy=function(){this.group&&this.group.remove(this),this.input&&this.input.destroy(),this.events&&this.events.destroy(),this.animations&&this.animations.destroy(),this.alive=!1,this.exists=!1,this.visible=!1,this.game=null},e.Sprite.prototype.damage=function(a){return this.alive&&(this.health-=a,this.health<0&&this.kill()),this},e.Sprite.prototype.reset=function(a,b,c){return"undefined"==typeof c&&(c=1),this.x=a,this.y=b,this.position.x=this.x,this.position.y=this.y,this.alive=!0,this.exists=!0,this.visible=!0,this.renderable=!0,this._outOfBoundsFired=!1,this.health=c,this.body&&this.body.reset(),this},e.Sprite.prototype.bringToTop=function(){return this.group?this.group.bringToTop(this):this.game.world.bringToTop(this),this},e.Sprite.prototype.play=function(a,b,c,d){return this.animations?this.animations.play(a,b,c,d):void 0},Object.defineProperty(e.Sprite.prototype,"angle",{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.rotation))},set:function(a){this.rotation=e.Math.degToRad(e.Math.wrapAngle(a))}}),Object.defineProperty(e.Sprite.prototype,"frame",{get:function(){return this.animations.frame},set:function(a){this.animations.frame=a}}),Object.defineProperty(e.Sprite.prototype,"frameName",{get:function(){return this.animations.frameName},set:function(a){this.animations.frameName=a}}),Object.defineProperty(e.Sprite.prototype,"inCamera",{get:function(){return this._cache.cameraVisible}}),Object.defineProperty(e.Sprite.prototype,"width",{get:function(){return this.scale.x*this.currentFrame.width},set:function(a){this.scale.x=a/this.currentFrame.width,this._cache.scaleX=a/this.currentFrame.width,this._width=a}}),Object.defineProperty(e.Sprite.prototype,"height",{get:function(){return this.scale.y*this.currentFrame.height},set:function(a){this.scale.y=a/this.currentFrame.height,this._cache.scaleY=a/this.currentFrame.height,this._height=a}}),Object.defineProperty(e.Sprite.prototype,"inputEnabled",{get:function(){return this.input.enabled},set:function(a){a?0==this.input.enabled&&this.input.start():this.input.enabled&&this.input.stop()}}),e.TileSprite=function(a,b,c,f,g,h,i){b=b||0,c=c||0,f=f||256,g=g||256,h=h||null,i=i||null,e.Sprite.call(this,a,b,c,h,i),this.texture=d.TextureCache[h],d.TilingSprite.call(this,this.texture,f,g),this.type=e.TILESPRITE,this.tileScale=new e.Point(1,1),this.tilePosition=new e.Point(0,0)},e.TileSprite.prototype=e.Utils.extend(!0,d.TilingSprite.prototype,e.Sprite.prototype),e.TileSprite.prototype.constructor=e.TileSprite,e.Text=function(a,b,c,f,g){b=b||0,c=c||0,f=f||"",g=g||"",this.exists=!0,this.alive=!0,this.group=null,this.name="",this.game=a,this._text=f,this._style=g,d.Text.call(this,f,g),this.type=e.TEXT,this.position.x=this.x=b,this.position.y=this.y=c,this.anchor=new e.Point,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:1,a01:0,a02:b,a10:0,a11:1,a12:c,id:1,x:-1,y:-1,scaleX:1,scaleY:1},this._cache.x=this.x,this._cache.y=this.y,this.renderable=!0},e.Text.prototype=Object.create(d.Text.prototype),e.Text.prototype.constructor=e.Text,e.Text.prototype.update=function(){this.exists&&(this._cache.dirty=!1,this._cache.x=this.x,this._cache.y=this.y,(this.position.x!=this._cache.x||this.position.y!=this._cache.y)&&(this.position.x=this._cache.x,this.position.y=this._cache.y,this._cache.dirty=!0))},e.Text.prototype.destroy=function(){this.group&&this.group.remove(this),this.canvas.parentNode?this.canvas.parentNode.removeChild(this.canvas):(this.canvas=null,this.context=null),this.exists=!1,this.group=null},Object.defineProperty(e.Text.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(a){this.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.Text.prototype,"content",{get:function(){return this._text},set:function(a){a!==this._text&&(this._text=a,this.setText(a))}}),Object.defineProperty(e.Text.prototype,"font",{get:function(){return this._style},set:function(a){a!==this._style&&(this._style=a,this.setStyle(a))}}),e.BitmapText=function(a,b,c,f,g){b=b||0,c=c||0,f=f||"",g=g||"",this.exists=!0,this.alive=!0,this.group=null,this.name="",this.game=a,d.BitmapText.call(this,f,g),this.type=e.BITMAPTEXT,this.position.x=b,this.position.y=c,this.anchor=new e.Point,this.scale=new e.Point(1,1),this._cache={dirty:!1,a00:1,a01:0,a02:b,a10:0,a11:1,a12:c,id:1,x:-1,y:-1,scaleX:1,scaleY:1},this._cache.x=this.x,this._cache.y=this.y,this.renderable=!0},e.BitmapText.prototype=Object.create(d.BitmapText.prototype),e.BitmapText.prototype.constructor=e.BitmapText,e.BitmapText.prototype.update=function(){this.exists&&(this._cache.dirty=!1,this._cache.x=this.x,this._cache.y=this.y,(this.position.x!=this._cache.x||this.position.y!=this._cache.y)&&(this.position.x=this._cache.x,this.position.y=this._cache.y,this._cache.dirty=!0),this.pivot.x=this.anchor.x*this.width,this.pivot.y=this.anchor.y*this.height)},e.BitmapText.prototype.destroy=function(){this.group&&this.group.remove(this),this.canvas.parentNode?this.canvas.parentNode.removeChild(this.canvas):(this.canvas=null,this.context=null),this.exists=!1,this.group=null},Object.defineProperty(e.BitmapText.prototype,"angle",{get:function(){return e.Math.radToDeg(this.rotation)},set:function(a){this.rotation=e.Math.degToRad(a)}}),Object.defineProperty(e.BitmapText.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(e.BitmapText.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),e.Button=function(a,b,c,d,f,g,h,i,j){b=b||0,c=c||0,d=d||null,f=f||null,g=g||this,e.Sprite.call(this,a,b,c,d,i),this.type=e.BUTTON,this._onOverFrameName=null,this._onOutFrameName=null,this._onDownFrameName=null,this._onUpFrameName=null,this._onOverFrameID=null,this._onOutFrameID=null,this._onDownFrameID=null,this._onUpFrameID=null,this.onInputOver=new e.Signal,this.onInputOut=new e.Signal,this.onInputDown=new e.Signal,this.onInputUp=new e.Signal,this.setFrames(h,i,j),null!==f&&this.onInputUp.add(f,g),this.freezeFrames=!1,this.input.start(0,!0),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this)},e.Button.prototype=e.Utils.extend(!0,e.Sprite.prototype,d.Sprite.prototype),e.Button.prototype.constructor=e.Button,e.Button.prototype.setFrames=function(a,b,c){null!==a&&("string"==typeof a?(this._onOverFrameName=a,this.input.pointerOver()&&(this.frameName=a)):(this._onOverFrameID=a,this.input.pointerOver()&&(this.frame=a))),null!==b&&("string"==typeof b?(this._onOutFrameName=b,this._onUpFrameName=b,0==this.input.pointerOver()&&(this.frameName=b)):(this._onOutFrameID=b,this._onUpFrameID=b,0==this.input.pointerOver()&&(this.frame=b))),null!==c&&("string"==typeof c?(this._onDownFrameName=c,this.input.pointerOver()&&(this.frameName=c)):(this._onDownFrameID=c,this.input.pointerOver()&&(this.frame=c)))},e.Button.prototype.onInputOverHandler=function(a){0==this.freezeFrames&&(null!=this._onOverFrameName?this.frameName=this._onOverFrameName:null!=this._onOverFrameID&&(this.frame=this._onOverFrameID)),this.onInputOver&&this.onInputOver.dispatch(this,a)},e.Button.prototype.onInputOutHandler=function(a){0==this.freezeFrames&&(null!=this._onOutFrameName?this.frameName=this._onOutFrameName:null!=this._onOutFrameID&&(this.frame=this._onOutFrameID)),this.onInputOut&&this.onInputOut.dispatch(this,a)},e.Button.prototype.onInputDownHandler=function(a){0==this.freezeFrames&&(null!=this._onDownFrameName?this.frameName=this._onDownFrameName:null!=this._onDownFrameID&&(this.frame=this._onDownFrameID)),this.onInputDown&&this.onInputDown.dispatch(this,a)},e.Button.prototype.onInputUpHandler=function(a){0==this.freezeFrames&&(null!=this._onUpFrameName?this.frameName=this._onUpFrameName:null!=this._onUpFrameID&&(this.frame=this._onUpFrameID)),this.onInputUp&&this.onInputUp.dispatch(this,a)},e.Graphics=function(a){this.game=a,d.Graphics.call(this),this.type=e.GRAPHICS},e.Graphics.prototype=Object.create(d.Graphics.prototype),e.Graphics.prototype.constructor=e.Graphics,e.Graphics.prototype.destroy=function(){this.clear(),this.group&&this.group.remove(this),this.game=null},Object.defineProperty(e.Graphics.prototype,"angle",{get:function(){return e.Math.wrapAngle(e.Math.radToDeg(this.rotation))},set:function(a){this.rotation=e.Math.degToRad(e.Math.wrapAngle(a))}}),Object.defineProperty(e.Graphics.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(e.Graphics.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),e.RenderTexture=function(a,b,c,f){this.game=a,this.name=b,d.EventTarget.call(this),this.width=c||100,this.height=f||100,this.indetityMatrix=d.mat3.create(),this.frame=new d.Rectangle(0,0,this.width,this.height),this.type=e.RENDERTEXTURE,d.gl?this.initWebGL():this.initCanvas()},e.RenderTexture.prototype=e.Utils.extend(!0,d.RenderTexture.prototype),e.RenderTexture.prototype.constructor=e.RenderTexture,e.Canvas={create:function(a,b){a=a||256,b=b||256;var c=document.createElement("canvas");return c.width=a,c.height=b,c.style.display="block",c},getOffset:function(a,b){b=b||new e.Point;var c=a.getBoundingClientRect(),d=a.clientTop||document.body.clientTop||0,f=a.clientLeft||document.body.clientLeft||0,g=window.pageYOffset||a.scrollTop||document.body.scrollTop,h=window.pageXOffset||a.scrollLeft||document.body.scrollLeft;return b.x=c.left+h-f,b.y=c.top+g-d,b},getAspectRatio:function(a){return a.width/a.height},setBackgroundColor:function(a,b){return b=b||"rgb(0,0,0)",a.style.backgroundColor=b,a},setTouchAction:function(a,b){return b=b||"none",a.style.msTouchAction=b,a.style["ms-touch-action"]=b,a.style["touch-action"]=b,a},setUserSelect:function(a,b){return b=b||"none",a.style["-webkit-touch-callout"]=b,a.style["-webkit-user-select"]=b,a.style["-khtml-user-select"]=b,a.style["-moz-user-select"]=b,a.style["-ms-user-select"]=b,a.style["user-select"]=b,a.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",a},addToDOM:function(a,b,c){return b=b||"","undefined"==typeof c&&(c=!0),""!==b?document.getElementById(b)?(document.getElementById(b).appendChild(a),c&&(document.getElementById(b).style.overflow="hidden")):document.body.appendChild(a):document.body.appendChild(a),a},setTransform:function(a,b,c,d,e,f,g){return a.setTransform(d,f,g,e,b,c),a},setSmoothingEnabled:function(a,b){return a.imageSmoothingEnabled=b,a.mozImageSmoothingEnabled=b,a.oImageSmoothingEnabled=b,a.webkitImageSmoothingEnabled=b,a.msImageSmoothingEnabled=b,a},setImageRenderingCrisp:function(a){return a.style["image-rendering"]="crisp-edges",a.style["image-rendering"]="-moz-crisp-edges",a.style["image-rendering"]="-webkit-optimize-contrast",a.style.msInterpolationMode="nearest-neighbor",a},setImageRenderingBicubic:function(a){return a.style["image-rendering"]="auto",a.style.msInterpolationMode="bicubic",a}},e.StageScaleMode=function(a){this._startHeight=0,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this.pageAlignHorizontally=!1,this.pageAlignVertically=!1,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this.width=0,this.height=0,this.maxIterations=5,this.game=a,this.enterLandscape=new e.Signal,this.enterPortrait=new e.Signal,this.orientation=window.orientation?window.orientation:window.outerWidth>window.outerHeight?90:0,this.scaleFactor=new e.Point(1,1),this.aspectRatio=0;var b=this;window.addEventListener("orientationchange",function(a){return b.checkOrientation(a)},!1),window.addEventListener("resize",function(a){return b.checkResize(a)},!1)},e.StageScaleMode.EXACT_FIT=0,e.StageScaleMode.NO_SCALE=1,e.StageScaleMode.SHOW_ALL=2,e.StageScaleMode.prototype={startFullScreen:function(){if(!this.isFullScreen){var a=this.game.canvas;a.requestFullScreen?a.requestFullScreen():a.mozRequestFullScreen?a.mozRequestFullScreen():a.webkitRequestFullScreen&&a.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT),this.game.stage.canvas.style.width="100%",this.game.stage.canvas.style.height="100%"}},stopFullScreen:function(){document.cancelFullScreen?document.cancelFullScreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen()},checkOrientationState:function(){this.incorrectOrientation?(this.forceLandscape&&window.innerWidth>window.innerHeight||this.forcePortrait&&window.innerHeight>window.innerWidth)&&(this.game.paused=!1,this.incorrectOrientation=!1,this.refresh()):(this.forceLandscape&&window.innerWidthwindow.outerHeight?90:0,this.isLandscape?this.enterLandscape.dispatch(this.orientation,!0,!1):this.enterPortrait.dispatch(this.orientation,!1,!0),this.game.stage.scaleMode!==e.StageScaleMode.NO_SCALE&&this.refresh()},refresh:function(){var a=this;0==this.game.device.iPad&&0==this.game.device.webApp&&0==this.game.device.desktop&&(this.game.device.android&&0==this.game.device.chrome?window.scrollTo(0,1):window.scrollTo(0,0)),null==this._check&&this.maxIterations>0&&(this._iterations=this.maxIterations,this._check=window.setInterval(function(){return a.setScreenSize()},10),this.setScreenSize())},setScreenSize:function(a){"undefined"==typeof a&&(a=!1),0==this.game.device.iPad&&0==this.game.device.webApp&&0==this.game.device.desktop&&(this.game.device.android&&0==this.game.device.chrome?window.scrollTo(0,1):window.scrollTo(0,0)),this._iterations--,(a||window.innerHeight>this._startHeight||this._iterations<0)&&(document.documentElement.style.minHeight=window.innerHeight+"px",1==this.incorrectOrientation?this.setMaximum():this.game.stage.scaleMode==e.StageScaleMode.EXACT_FIT?this.setExactFit():this.game.stage.scaleMode==e.StageScaleMode.SHOW_ALL&&this.setShowAll(),this.setSize(),clearInterval(this._check),this._check=null)},setSize:function(){0==this.incorrectOrientation&&(this.maxWidth&&this.width>this.maxWidth&&(this.width=this.maxWidth),this.maxHeight&&this.height>this.maxHeight&&(this.height=this.maxHeight),this.minWidth&&this.widththis.maxWidth?this.maxWidth:a,this.height=this.maxHeight&&b>this.maxHeight?this.maxHeight:b,console.log("setExactFit",this.width,this.height,this.game.stage.offset) +}},Object.defineProperty(e.StageScaleMode.prototype,"isFullScreen",{get:function(){return null===document.fullscreenElement||null===document.mozFullScreenElement||null===document.webkitFullscreenElement?!1:!0}}),Object.defineProperty(e.StageScaleMode.prototype,"isPortrait",{get:function(){return 0==this.orientation||180==this.orientation}}),Object.defineProperty(e.StageScaleMode.prototype,"isLandscape",{get:function(){return 90===this.orientation||-90===this.orientation}}),e.Device=function(){this.patchAndroidClearRectBug=!1,this.desktop=!1,this.iOS=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.canvas=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.webGL=!1,this.worker=!1,this.touch=!1,this.mspointer=!1,this.css3D=!1,this.pointerLock=!1,this.arora=!1,this.chrome=!1,this.epiphany=!1,this.firefox=!1,this.ie=!1,this.ieVersion=0,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.webApp=!1,this.audioData=!1,this.webAudio=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this._checkAudio(),this._checkBrowser(),this._checkCSS3D(),this._checkDevice(),this._checkFeatures(),this._checkOS()},e.Device.prototype={_checkOS:function(){var a=navigator.userAgent;/Android/.test(a)?this.android=!0:/CrOS/.test(a)?this.chromeOS=!0:/iP[ao]d|iPhone/i.test(a)?this.iOS=!0:/Linux/.test(a)?this.linux=!0:/Mac OS/.test(a)?this.macOS=!0:/Windows/.test(a)&&(this.windows=!0),(this.windows||this.macOS||this.linux)&&(this.desktop=!0)},_checkFeatures:function(){this.canvas=!!window.CanvasRenderingContext2D;try{this.localStorage=!!localStorage.getItem}catch(a){this.localStorage=!1}this.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),this.fileSystem=!!window.requestFileSystem,this.webGL=function(){try{var a=document.createElement("canvas");return!!window.WebGLRenderingContext&&(a.getContext("webgl")||a.getContext("experimental-webgl"))}catch(b){return!1}}(),this.webGL=null===this.webGL?!1:!0,this.worker=!!window.Worker,("ontouchstart"in document.documentElement||window.navigator.msPointerEnabled)&&(this.touch=!0),window.navigator.msPointerEnabled&&(this.mspointer=!0),this.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document},_checkBrowser:function(){var a=navigator.userAgent;/Arora/.test(a)?this.arora=!0:/Chrome/.test(a)?this.chrome=!0:/Epiphany/.test(a)?this.epiphany=!0:/Firefox/.test(a)?this.firefox=!0:/Mobile Safari/.test(a)?this.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(a)?(this.ie=!0,this.ieVersion=parseInt(RegExp.$1)):/Midori/.test(a)?this.midori=!0:/Opera/.test(a)?this.opera=!0:/Safari/.test(a)&&(this.safari=!0),navigator.standalone&&(this.webApp=!0)},_checkAudio:function(){this.audioData=!!window.Audio,this.webAudio=!(!window.webkitAudioContext&&!window.AudioContext);var a=document.createElement("audio"),b=!1;try{(b=!!a.canPlayType)&&(a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.ogg=!0),a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")&&(this.opus=!0),a.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(this.mp3=!0),a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(this.wav=!0),(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;").replace(/^no$/,""))&&(this.m4a=!0),a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(this.webm=!0))}catch(c){}},_checkDevice:function(){this.pixelRatio=window.devicePixelRatio||1,this.iPhone=-1!=navigator.userAgent.toLowerCase().indexOf("iphone"),this.iPhone4=2==this.pixelRatio&&this.iPhone,this.iPad=-1!=navigator.userAgent.toLowerCase().indexOf("ipad")},_checkCSS3D:function(){var a,b=document.createElement("p"),c={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};document.body.insertBefore(b,null);for(var d in c)void 0!==b.style[d]&&(b.style[d]="translate3d(1px,1px,1px)",a=window.getComputedStyle(b).getPropertyValue(c[d]));document.body.removeChild(b),this.css3D=void 0!==a&&a.length>0&&"none"!==a},canPlayAudio:function(a){return"mp3"==a&&this.mp3?!0:"ogg"==a&&(this.ogg||this.opus)?!0:"m4a"==a&&this.m4a?!0:"wav"==a&&this.wav?!0:"webm"==a&&this.webm?!0:!1},isConsoleOpen:function(){return window.console&&window.console.firebug?!0:window.console?(console.profile(),console.profileEnd(),console.clear&&console.clear(),console.profiles.length>0):!1}},e.RequestAnimationFrame=function(a){this.game=a,this._isSetTimeOut=!1,this.isRunning=!1;for(var b=["ms","moz","webkit","o"],c=0;c>>0,b-=d,b*=d,d=b>>>0,b-=d,d+=4294967296*b;return 2.3283064365386963e-10*(d>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+1.1102230246251565e-16*(0|2097152*this.rnd.apply(this))},real:function(){return this.integer()+this.frac()},integerInRange:function(a,b){return Math.floor(this.realInRange(a,b))},realInRange:function(a,b){return this.frac()*(b-a)+a},normal:function(){return 1-2*this.frac()},uuid:function(){var a,b;for(b=a="";a++<36;b+=~a%5|4&3*a?(15^a?8^this.frac()*(20^a?16:4):4).toString(16):"-");return b},pick:function(a){return a[this.integerInRange(0,a.length)]},weightedPick:function(a){return a[~~(Math.pow(this.frac(),2)*a.length)]},timestamp:function(a,b){return this.realInRange(a||9466848e5,b||1577862e6)},angle:function(){return this.integerInRange(-180,180)}},e.Math={PI2:2*Math.PI,fuzzyEqual:function(a,b,c){return"undefined"==typeof c&&(c=1e-4),Math.abs(a-b)a},fuzzyGreaterThan:function(a,b,c){return"undefined"==typeof c&&(c=1e-4),a>b-c},fuzzyCeil:function(a,b){return"undefined"==typeof b&&(b=1e-4),Math.ceil(a-b)},fuzzyFloor:function(a,b){return"undefined"==typeof b&&(b=1e-4),Math.floor(a+b)},average:function(){for(var a=[],b=0;b0?Math.floor(a):Math.ceil(a)},shear:function(a){return a%1},snapTo:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.round(a/b),c+a)},snapToFloor:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.floor(a/b),c+a)},snapToCeil:function(a,b,c){return"undefined"==typeof c&&(c=0),0==b?a:(a-=c,a=b*Math.ceil(a/b),c+a)},snapToInArray:function(a,b,c){if("undefined"==typeof c&&(c=!0),c&&b.sort(),a=f-a?f:e},roundTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.round(a*d)/d},floorTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.floor(a*d)/d},ceilTo:function(a,b,c){"undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=10);var d=Math.pow(c,-b);return Math.ceil(a*d)/d},interpolateFloat:function(a,b,c){return(b-a)*c+a},angleBetween:function(a,b,c,d){return Math.atan2(d-b,c-a)},normalizeAngle:function(a,b){"undefined"==typeof b&&(b=!0);var c=b?GameMath.PI:180;return this.wrap(a,c,-c)},nearestAngleBetween:function(a,b,c){"undefined"==typeof c&&(c=!0);var d=c?Math.PI:180;return a=this.normalizeAngle(a,c),b=this.normalizeAngle(b,c),-d/2>a&&b>d/2&&(a+=2*d),-d/2>b&&a>d/2&&(b+=2*d),b-a},interpolateAngles:function(a,b,c,d,e){return"undefined"==typeof d&&(d=!0),"undefined"==typeof e&&(e=null),a=this.normalizeAngle(a,d),b=this.normalizeAngleToAnother(b,a,d),"function"==typeof e?e(c,a,b-a,1):this.interpolateFloat(a,b,c)},chanceRoll:function(a){return"undefined"==typeof a&&(a=50),0>=a?!1:a>=100?!0:100*Math.random()>=a?!1:!0},numberArray:function(a,b){for(var c=[],d=a;b>=d;d++)c.push(d);return c},maxAdd:function(a,b,c){return a+=b,a>c&&(a=c),a},minSub:function(a,b,c){return a-=b,c>a&&(a=c),a},wrap:function(a,b,c){var d=c-b;if(0>=d)return 0;var e=(a-b)%d;return 0>e&&(e+=d),e+b},wrapValue:function(a,b,c){var d;return a=Math.abs(a),b=Math.abs(b),c=Math.abs(c),d=(a+b)%c},randomSign:function(){return Math.random()>.5?1:-1},isOdd:function(a){return 1&a},isEven:function(a){return 1&a?!1:!0},max:function(){for(var a=1,b=0,c=arguments.length;c>a;a++)arguments[b]a;a++)arguments[a]=-180&&180>=a?a:(b=(a+180)%360,0>b&&(b+=360),b-180)},angleLimit:function(a,b,c){var d=a;return a>c?d=c:b>a&&(d=b),d},linearInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return 0>b?this.linear(a[0],a[1],d):b>1?this.linear(a[c],a[c-1],c-d):this.linear(a[e],a[e+1>c?c:e+1],d-e)},bezierInterpolation:function(a,b){for(var c=0,d=a.length-1,e=0;d>=e;e++)c+=Math.pow(1-b,d-e)*Math.pow(b,e)*a[e]*this.bernstein(d,e);return c},catmullRomInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return a[0]===a[c]?(0>b&&(e=Math.floor(d=c*(1+b))),this.catmullRom(a[(e-1+c)%c],a[e],a[(e+1)%c],a[(e+2)%c],d-e)):0>b?a[0]-(this.catmullRom(a[0],a[0],a[1],a[1],-d)-a[0]):b>1?a[c]-(this.catmullRom(a[c],a[c],a[c-1],a[c-1],d-c)-a[c]):this.catmullRom(a[e?e-1:0],a[e],a[e+1>c?c:e+1],a[e+2>c?c:e+2],d-e)},linear:function(a,b,c){return(b-a)*c+a},bernstein:function(a,b){return this.factorial(a)/this.factorial(b)/this.factorial(a-b)},catmullRom:function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b},difference:function(a,b){return Math.abs(a-b)},getRandom:function(a,b,c){if("undefined"==typeof b&&(b=0),"undefined"==typeof c&&(c=0),null!=a){var d=c;if((0==d||d>a.length-b)&&(d=a.length-b),d>0)return a[b+Math.floor(Math.random()*d)]}return null},floor:function(a){var b=0|a;return a>0?b:b!=a?b-1:b},ceil:function(a){var b=0|a;return a>0?b!=a?b+1:b:b},sinCosGenerator:function(a,b,c,d){"undefined"==typeof b&&(b=1),"undefined"==typeof c&&(c=1),"undefined"==typeof d&&(d=1);for(var e=b,f=c,g=d*Math.PI/a,h=[],i=[],j=0;a>j;j++)f-=e*g,e+=f*g,h[j]=f,i[j]=e;return{sin:i,cos:h}},shift:function(a){var b=a.shift();return a.push(b),b},shuffleArray:function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},distance:function(a,b,c,d){var e=a-c,f=b-d;return Math.sqrt(e*e+f*f)},distanceRounded:function(a,b,c,d){return Math.round(e.Math.distance(a,b,c,d))},clamp:function(a,b,c){return b>a?b:a>c?c:a},clampBottom:function(a,b){return b>a?b:a},within:function(a,b,c){return Math.abs(a-b)<=c},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},smoothstep:function(a,b,c){return b>=a?0:a>=c?1:(a=(a-b)/(c-b),a*a*(3-2*a))},smootherstep:function(a,b,c){return b>=a?0:a>=c?1:(a=(a-b)/(c-b),a*a*a*(a*(6*a-15)+10))},sign:function(a){return 0>a?-1:a>0?1:0},degToRad:function(){var a=Math.PI/180;return function(b){return b*a}}(),radToDeg:function(){var a=180/Math.PI;return function(b){return b*a}}()},e.QuadTree=function(a,b,c,d,e,f,g,h){this.physicsManager=a,this.ID=a.quadTreeID,a.quadTreeID++,this.maxObjects=f||10,this.maxLevels=g||4,this.level=h||0,this.bounds={x:Math.round(b),y:Math.round(c),width:d,height:e,subWidth:Math.floor(d/2),subHeight:Math.floor(e/2),right:Math.round(b)+Math.floor(d/2),bottom:Math.round(c)+Math.floor(e/2)},this.objects=[],this.nodes=[]},e.QuadTree.prototype={split:function(){this.level++,this.nodes[0]=new e.QuadTree(this.physicsManager,this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[1]=new e.QuadTree(this.physicsManager,this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[2]=new e.QuadTree(this.physicsManager,this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level),this.nodes[3]=new e.QuadTree(this.physicsManager,this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level)},insert:function(a){var b,c=0;if(null!=this.nodes[0]&&(b=this.getIndex(a),-1!==b))return this.nodes[b].insert(a),void 0;if(this.objects.push(a),this.objects.length>this.maxObjects&&this.levelthis.bounds.bottom&&(b=2):a.x>this.bounds.right&&(a.ythis.bounds.bottom&&(b=3)),b},retrieve:function(a){var b=this.objects;return a.body.quadTreeIndex=this.getIndex(a.body),a.body.quadTreeIDs.push(this.ID),this.nodes[0]&&(-1!==a.body.quadTreeIndex?b=b.concat(this.nodes[a.body.quadTreeIndex].retrieve(a)):(b=b.concat(this.nodes[0].retrieve(a)),b=b.concat(this.nodes[1].retrieve(a)),b=b.concat(this.nodes[2].retrieve(a)),b=b.concat(this.nodes[3].retrieve(a)))),b},clear:function(){this.objects=[];for(var a=0,b=this.nodes.length;b>a;a++)this.nodes[a]&&(this.nodes[a].clear(),delete this.nodes[a])}},e.Circle=function(a,b,c){a=a||0,b=b||0,c=c||0,this.x=a,this.y=b,this._diameter=c,this._radius=c>0?.5*c:0},e.Circle.prototype={circumference:function(){return 2*Math.PI*this._radius},setTo:function(a,b,c){return this.x=a,this.y=b,this._diameter=c,this._radius=.5*c,this},copyFrom:function(a){return this.setTo(a.x,a.y,a.diameter)},copyTo:function(a){return a[x]=this.x,a[y]=this.y,a[diameter]=this._diameter,a},distance:function(a,b){return"undefined"==typeof b&&(b=!1),b?e.Math.distanceRound(this.x,this.y,a.x,a.y):e.Math.distance(this.x,this.y,a.x,a.y)},clone:function(b){return"undefined"==typeof b&&(b=new e.Circle),b.setTo(a.x,a.y,a.diameter)},contains:function(a,b){return e.Circle.contains(this,a,b)},circumferencePoint:function(a,b,c){return e.Circle.circumferencePoint(this,a,b,c)},offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},Object.defineProperty(e.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(a){a>0&&(this._diameter=a,this._radius=.5*a)}}),Object.defineProperty(e.Circle.prototype,"radius",{get:function(){return this._radius},set:function(a){a>0&&(this._radius=a,this._diameter=2*a)}}),Object.defineProperty(e.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(a){a>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-a}}),Object.defineProperty(e.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(a){athis.y?(this._radius=0,this._diameter=0):this.radius=this.y-a}}),Object.defineProperty(e.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){a0?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(e.Circle.prototype,"empty",{get:function(){return 0==this._diameter},set:function(){this.setTo(0,0,0)}}),e.Circle.contains=function(a,b,c){if(b>=a.left&&b<=a.right&&c>=a.top&&c<=a.bottom){var d=(a.x-b)*(a.x-b),e=(a.y-c)*(a.y-c);return d+e<=a.radius*a.radius}return!1},e.Circle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.diameter==b.diameter},e.Circle.intersects=function(a,b){return e.Math.distance(a.x,a.y,b.x,b.y)<=a.radius+b.radius},e.Circle.circumferencePoint=function(a,b,c,d){return"undefined"==typeof c&&(c=!1),"undefined"==typeof d&&(d=new e.Point),c===!0&&(b=e.Math.radToDeg(b)),d.x=a.x+a.radius*Math.cos(b),d.y=a.y+a.radius*Math.sin(b),d},e.Circle.intersectsRectangle=function(a,b){var c=Math.abs(a.x-b.x-b.halfWidth),d=b.halfWidth+a.radius;if(c>d)return!1;var e=Math.abs(a.y-b.y-b.halfHeight),f=b.halfHeight+a.radius;if(e>f)return!1;if(c<=b.halfWidth||e<=b.halfHeight)return!0;var g=c-b.halfWidth,h=e-b.halfHeight,i=g*g,j=h*h,k=a.radius*a.radius;return k>=i+j},e.Point=function(a,b){a=a||0,b=b||0,this.x=a,this.y=b},e.Point.prototype={copyFrom:function(a){return this.setTo(a.x,a.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(a,b){return this.x=a,this.y=b,this},add:function(a,b){return this.x+=a,this.y+=b,this},subtract:function(a,b){return this.x-=a,this.y-=b,this},multiply:function(a,b){return this.x*=a,this.y*=b,this},divide:function(a,b){return this.x/=a,this.y/=b,this},clampX:function(a,b){return this.x=e.Math.clamp(this.x,a,b),this},clampY:function(a,b){return this.y=e.Math.clamp(this.y,a,b),this},clamp:function(a,b){return this.x=e.Math.clamp(this.x,a,b),this.y=e.Math.clamp(this.y,a,b),this},clone:function(a){return"undefined"==typeof a&&(a=new e.Point),a.setTo(this.x,this.y)},copyFrom:function(a){return this.setTo(a.x,a.y)},copyTo:function(a){return a[x]=this.x,a[y]=this.y,a},distance:function(a,b){return e.Point.distance(this,a,b)},equals:function(a){return a.x==this.x&&a.y==this.y},rotate:function(a,b,c,d,f){return e.Point.rotate(this,a,b,c,d,f)},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}},e.Point.add=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x+b.x,c.y=a.y+b.y,c},e.Point.subtract=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x-b.x,c.y=a.y-b.y,c},e.Point.multiply=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x*b.x,c.y=a.y*b.y,c},e.Point.divide=function(a,b,c){return"undefined"==typeof c&&(c=new e.Point),c.x=a.x/b.x,c.y=a.y/b.y,c},e.Point.equals=function(a,b){return a.x==b.x&&a.y==b.y},e.Point.distance=function(a,b,c){return"undefined"==typeof c&&(c=!1),c?e.Math.distanceRound(a.x,a.y,b.x,b.y):e.Math.distance(a.x,a.y,b.x,b.y)},e.Point.rotate=function(a,b,c,d,f,g){return f=f||!1,g=g||null,f&&(d=e.Math.radToDeg(d)),null===g&&(g=Math.sqrt((b-a.x)*(b-a.x)+(c-a.y)*(c-a.y))),a.setTo(b+g*Math.cos(d),c+g*Math.sin(d))},e.Rectangle=function(a,b,c,d){a=a||0,b=b||0,c=c||0,d=d||0,this.x=a,this.y=b,this.width=c,this.height=d},e.Rectangle.prototype={offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},setTo:function(a,b,c,d){return this.x=a,this.y=b,this.width=c,this.height=d,this},floor:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y)},floorAll:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.width=Math.floor(this.width),this.height=Math.floor(this.height)},copyFrom:function(a){return this.setTo(a.x,a.y,a.width,a.height)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.width=this.width,a.height=this.height,a},inflate:function(a,b){return e.Rectangle.inflate(this,a,b)},size:function(a){return e.Rectangle.size(this,a)},clone:function(a){return e.Rectangle.clone(this,a)},contains:function(a,b){return e.Rectangle.contains(this,a,b)},containsRect:function(a){return e.Rectangle.containsRect(this,a)},equals:function(a){return e.Rectangle.equals(this,a)},intersection:function(a){return e.Rectangle.intersection(this,a,output)},intersects:function(a,b){return e.Rectangle.intersects(this,a,b)},intersectsRaw:function(a,b,c,d,f){return e.Rectangle.intersectsRaw(this,a,b,c,d,f)},union:function(a,b){return e.Rectangle.union(this,a,b)},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(e.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}}),Object.defineProperty(e.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}}),Object.defineProperty(e.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){this.height=a<=this.y?0:this.y-a}}),Object.defineProperty(e.Rectangle.prototype,"bottomRight",{get:function(){return new e.Point(this.right,this.bottom)},set:function(a){this.right=a.x,this.bottom=a.y}}),Object.defineProperty(e.Rectangle.prototype,"left",{get:function(){return this.x},set:function(a){this.width=a>=this.right?0:this.right-a,this.x=a}}),Object.defineProperty(e.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:this.x+a}}),Object.defineProperty(e.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(e.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(e.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(a){this.x=a-this.halfWidth}}),Object.defineProperty(e.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(a){this.y=a-this.halfHeight}}),Object.defineProperty(e.Rectangle.prototype,"top",{get:function(){return this.y},set:function(a){a>=this.bottom?(this.height=0,this.y=a):this.height=this.bottom-a}}),Object.defineProperty(e.Rectangle.prototype,"topLeft",{get:function(){return new e.Point(this.x,this.y)},set:function(a){this.x=a.x,this.y=a.y}}),Object.defineProperty(e.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(){this.setTo(0,0,0,0)}}),e.Rectangle.inflate=function(a,b,c){return a.x-=b,a.width+=2*b,a.y-=c,a.height+=2*c,a},e.Rectangle.inflatePoint=function(a,b){return e.Rectangle.inflate(a,b.x,b.y)},e.Rectangle.size=function(a,b){return"undefined"==typeof b&&(b=new e.Point),b.setTo(a.width,a.height)},e.Rectangle.clone=function(a,b){return"undefined"==typeof b&&(b=new e.Rectangle),b.setTo(a.x,a.y,a.width,a.height)},e.Rectangle.contains=function(a,b,c){return b>=a.x&&b<=a.right&&c>=a.y&&c<=a.bottom},e.Rectangle.containsRaw=function(a,b,c,d,e,f){return e>=a&&a+c>=e&&f>=b&&b+d>=f},e.Rectangle.containsPoint=function(a,b){return e.Rectangle.contains(a,b.x,b.y)},e.Rectangle.containsRect=function(a,b){return a.volume>b.volume?!1:a.x>=b.x&&a.y>=b.y&&a.right<=b.right&&a.bottom<=b.bottom},e.Rectangle.equals=function(a,b){return a.x==b.x&&a.y==b.y&&a.width==b.width&&a.height==b.height},e.Rectangle.intersection=function(a,b,c){return c=c||new e.Rectangle,e.Rectangle.intersects(a,b)&&(c.x=Math.max(a.x,b.x),c.y=Math.max(a.y,b.y),c.width=Math.min(a.right,b.right)-c.x,c.height=Math.min(a.bottom,b.bottom)-c.y),c},e.Rectangle.intersects=function(a,b){return a.xa.right+f||ca.bottom+f||e1){if(a&&a==this.decodeURI(e[0]))return this.decodeURI(e[1]);b[this.decodeURI(e[0])]=this.decodeURI(e[1])}}return b},decodeURI:function(a){return decodeURIComponent(a.replace(/\+/g," "))}},e.TweenManager=function(a){this.game=a,this._tweens=[],this._add=[],this.game.onPause.add(this.pauseAll,this),this.game.onResume.add(this.resumeAll,this)},e.TweenManager.prototype={REVISION:"11dev",getAll:function(){return this._tweens},removeAll:function(){this._tweens=[]},add:function(a){this._add.push(a)},create:function(a){return new e.Tween(a,this.game)},remove:function(a){var b=this._tweens.indexOf(a);-1!==b&&(this._tweens[b].pendingDelete=!0)},update:function(){if(0===this._tweens.length&&0===this._add.length)return!1;for(var a=0,b=this._tweens.length;b>a;)this._tweens[a].update(this.game.time.now)?a++:(this._tweens.splice(a,1),b--);return this._add.length>0&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},pauseAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a].pause()},resumeAll:function(){for(var a=this._tweens.length-1;a>=0;a--)this._tweens[a].resume()}},e.Tween=function(a,b){this._object=a,this.game=b,this._manager=this.game.tweens,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._repeat=0,this._yoyo=!1,this._reversed=!1,this._delayTime=0,this._startTime=null,this._easingFunction=e.Easing.Linear.None,this._interpolationFunction=e.Math.linearInterpolation,this._chainedTweens=[],this._onStartCallback=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onCompleteCallback=null,this._pausedTime=0,this.pendingDelete=!1;for(var c in a)this._valuesStart[c]=parseFloat(a[c],10);this.onStart=new e.Signal,this.onComplete=new e.Signal,this.isRunning=!1},e.Tween.prototype={to:function(a,b,c,d,e,f,g){b=b||1e3,c=c||null,d=d||!1,e=e||0,f=f||0,g=g||!1;var h;return this._parent?(h=this._manager.create(this._object),this._lastChild.chain(h),this._lastChild=h):(h=this,this._parent=this,this._lastChild=this),h._repeat=f,h._duration=b,h._valuesEnd=a,null!==c&&(h._easingFunction=c),e>0&&(h._delayTime=e),h._yoyo=g,d?this.start():this},start:function(){if(null!==this.game&&null!==this._object){this._manager.add(this),this.onStart.dispatch(this._object),this.isRunning=!0,this._onStartCallbackFired=!1,this._startTime=this.game.time.now+this._delayTime;for(var a in this._valuesEnd){if(this._valuesEnd[a]instanceof Array){if(0===this._valuesEnd[a].length)continue;this._valuesEnd[a]=[this._object[a]].concat(this._valuesEnd[a])}this._valuesStart[a]=this._object[a],this._valuesStart[a]instanceof Array==!1&&(this._valuesStart[a]*=1),this._valuesStartRepeat[a]=this._valuesStart[a]||0}return this}},stop:function(){return this._manager.remove(this),this.isRunning=!1,this},delay:function(a){return this._delayTime=a,this},repeat:function(a){return this._repeat=a,this},yoyo:function(a){return this._yoyo=a,this},easing:function(a){return this._easingFunction=a,this},interpolation:function(a){return this._interpolationFunction=a,this},chain:function(){return this._chainedTweens=arguments,this},loop:function(){return this._lastChild.chain(this),this},onStartCallback:function(a){return this._onStartCallback=a,this},onUpdateCallback:function(a){return this._onUpdateCallback=a,this},onCompleteCallback:function(a){return this._onCompleteCallback=a,this},pause:function(){this._paused=!0,this._pausedTime=this.game.time.now},resume:function(){this._paused=!1,this._startTime+=this.game.time.now-this._pausedTime},update:function(a){if(this.pendingDelete)return!1;if(this._paused||a1?1:c;var d=this._easingFunction(c);for(b in this._valuesEnd){var e=this._valuesStart[b]||0,f=this._valuesEnd[b];f instanceof Array?this._object[b]=this._interpolationFunction(f,d):("string"==typeof f&&(f=e+parseFloat(f,10)),"number"==typeof f&&(this._object[b]=e+(f-e)*d))}if(null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._object,d),1==c){if(this._repeat>0){isFinite(this._repeat)&&this._repeat--;for(b in this._valuesStartRepeat){if("string"==typeof this._valuesEnd[b]&&(this._valuesStartRepeat[b]=this._valuesStartRepeat[b]+parseFloat(this._valuesEnd[b],10)),this._yoyo){var g=this._valuesStartRepeat[b];this._valuesStartRepeat[b]=this._valuesEnd[b],this._valuesEnd[b]=g,this._reversed=!this._reversed}this._valuesStart[b]=this._valuesStartRepeat[b]}return this._startTime=a+this._delayTime,this.onComplete.dispatch(this._object),null!==this._onCompleteCallback&&this._onCompleteCallback.call(this._object),!0}this.onComplete.dispatch(this._object),null!==this._onCompleteCallback&&this._onCompleteCallback.call(this._object);for(var h=0,i=this._chainedTweens.length;i>h;h++)this._chainedTweens[h].start(a);return!1}return!0}},e.Easing={Linear:{None:function(a){return a}},Quadratic:{In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 1-Math.cos(a*Math.PI/2)},Out:function(a){return Math.sin(a*Math.PI/2)},InOut:function(a){return.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)}},Circular:{In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),-(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*2*Math.PI/d)))},Out:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin((a-b)*2*Math.PI/d)+1) +},InOut:function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?-.5*c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*2*Math.PI/d):.5*c*Math.pow(2,-10*(a-=1))*Math.sin((a-b)*2*Math.PI/d)+1)}},Back:{In:function(a){var b=1.70158;return a*a*((b+1)*a-b)},Out:function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},InOut:function(a){var b=2.5949095;return(a*=2)<1?.5*a*a*((b+1)*a-b):.5*((a-=2)*a*((b+1)*a+b)+2)}},Bounce:{In:function(a){return 1-e.Easing.Bounce.Out(1-a)},Out:function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return.5>a?.5*e.Easing.Bounce.In(2*a):.5*e.Easing.Bounce.Out(2*a-1)+.5}}},e.Time=function(a){this.game=a,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this.physicsElapsed=0,this.time=0,this.pausedTime=0,this.now=0,this.elapsed=0,this.fps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.frames=0,this.pauseDuration=0,this.timeToCall=0,this.lastTime=0,this.game.onPause.add(this.gamePaused,this),this.game.onResume.add(this.gameResumed,this),this._justResumed=!1},e.Time.prototype={totalElapsedSeconds:function(){return.001*(this.now-this._started)},update:function(a){this.now=a,this._justResumed&&(this.time=this.now,this._justResumed=!1),this.timeToCall=this.game.math.max(0,16-(a-this.lastTime)),this.elapsed=this.now-this.time,this.msMin=this.game.math.min(this.msMin,this.elapsed),this.msMax=this.game.math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3&&(this.fps=Math.round(1e3*this.frames/(this.now-this._timeLastSecond)),this.fpsMin=this.game.math.min(this.fpsMin,this.fps),this.fpsMax=this.game.math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0),this.time=this.now,this.lastTime=a+this.timeToCall,this.physicsElapsed=1*(this.elapsed/1e3),this.physicsElapsed>1&&(this.physicsElapsed=1),this.game.paused&&(this.pausedTime=this.now-this._pauseStarted)},gamePaused:function(){this._pauseStarted=this.now},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.pausedTime,this._justResumed=!0},elapsedSince:function(a){return this.now-a},elapsedSecondsSince:function(a){return.001*(this.now-a)},reset:function(){this._started=this.now}},e.AnimationManager=function(a){this.sprite=a,this.game=a.game,this.currentFrame=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},e.AnimationManager.prototype={loadFrameData:function(a){this._frameData=a,this.frame=0,this.isLoaded=!0},add:function(a,b,c,f,g){return null==this._frameData?(console.warn("No FrameData available for Phaser.Animation "+a),void 0):(c=c||60,"undefined"==typeof f&&(f=!1),"undefined"==typeof g&&(g=b&&"number"==typeof b[0]?!0:!1),null==this.sprite.events.onAnimationStart&&(this.sprite.events.onAnimationStart=new e.Signal,this.sprite.events.onAnimationComplete=new e.Signal,this.sprite.events.onAnimationLoop=new e.Signal),this._outputFrames.length=0,this._frameData.getFrameIndexes(b,g,this._outputFrames),this._anims[a]=new e.Animation(this.game,this.sprite,a,this._frameData,this._outputFrames,c,f),this.currentAnim=this._anims[a],this.currentFrame=this.currentAnim.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid]),this._anims[a])},validateFrames:function(a,b){"undefined"==typeof b&&(b=!0);for(var c=0;cthis._frameData.total)return!1}else if(0==this._frameData.checkFrameName(a[c]))return!1;return!0},play:function(a,b,c,d){if(this._anims[a]){if(this.currentAnim!=this._anims[a])return this.currentAnim=this._anims[a],this.currentAnim.play(b,c,d);if(0==this.currentAnim.isPlaying)return this.currentAnim.play(b,c,d)}},stop:function(a,b){"undefined"==typeof b&&(b=!1),"string"==typeof a?this._anims[a]&&(this.currentAnim=this._anims[a],this.currentAnim.stop(b)):this.currentAnim&&this.currentAnim.stop(b)},update:function(){return this.updateIfVisible&&0==this.sprite.visible?!1:this.currentAnim&&1==this.currentAnim.update()?(this.currentFrame=this.currentAnim.currentFrame,this.sprite.currentFrame=this.currentFrame,!0):!1},refreshFrame:function(){this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid])},destroy:function(){this._anims={},this._frameData=null,this._frameIndex=0,this.currentAnim=null,this.currentFrame=null}},Object.defineProperty(e.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(e.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData?this._frameData.total:-1}}),Object.defineProperty(e.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(a){this.currentAnim.paused=a}}),Object.defineProperty(e.AnimationManager.prototype,"frame",{get:function(){return this.currentFrame?this._frameIndex:void 0},set:function(a){"number"==typeof a&&this._frameData&&null!==this._frameData.getFrame(a)&&(this.currentFrame=this._frameData.getFrame(a),this._frameIndex=a,this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid]))}}),Object.defineProperty(e.AnimationManager.prototype,"frameName",{get:function(){return this.currentFrame?this.currentFrame.name:void 0},set:function(a){"string"==typeof a&&this._frameData&&null!==this._frameData.getFrameByName(a)?(this.currentFrame=this._frameData.getFrameByName(a),this._frameIndex=this.currentFrame.index,this.sprite.currentFrame=this.currentFrame,this.sprite.setTexture(d.TextureCache[this.currentFrame.uuid])):console.warn("Cannot set frameName: "+a)}}),e.Animation=function(a,b,c,d,e,f,g){this.game=a,this._parent=b,this._frameData=d,this.name=c,this._frames=[],this._frames=this._frames.concat(e),this.delay=1e3/f,this.looped=g,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])},e.Animation.prototype={play:function(a,b,c){return"number"==typeof a&&(this.delay=1e3/a),"boolean"==typeof b&&(this.looped=b),"undefined"!=typeof c&&(this.killOnComplete=c),this.isPlaying=!0,this.isFinished=!1,this._timeLastFrame=this.game.time.now,this._timeNextFrame=this.game.time.now+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]),this._parent.events&&this._parent.events.onAnimationStart.dispatch(this._parent,this),this},restart:function(){this.isPlaying=!0,this.isFinished=!1,this._timeLastFrame=this.game.time.now,this._timeNextFrame=this.game.time.now+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex])},stop:function(a){"undefined"==typeof a&&(a=!1),this.isPlaying=!1,this.isFinished=!0,a&&(this.currentFrame=this._frameData.getFrame(this._frames[0]))},update:function(){return this.isPaused?!1:1==this.isPlaying&&this.game.time.now>=this._timeNextFrame?(this._frameSkip=1,this._frameDiff=this.game.time.now-this._timeNextFrame,this._timeLastFrame=this.game.time.now,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=this.game.time.now+(this.delay-this._frameDiff),this._frameIndex+=this._frameSkip,this._frameIndex>=this._frames.length?this.looped?(this._frameIndex%=this._frames.length,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]),this._parent.events.onAnimationLoop.dispatch(this._parent,this)):this.onComplete():(this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setTexture(d.TextureCache[this.currentFrame.uuid])),!0):!1},destroy:function(){this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1},onComplete:function(){this.isPlaying=!1,this.isFinished=!0,this._parent.events&&this._parent.events.onAnimationComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}},Object.defineProperty(e.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(a){this.isPaused=a,a?this._pauseStartTime=this.game.time.now:this.isPlaying&&(this._timeNextFrame=this.game.time.now+this.delay)}}),Object.defineProperty(e.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(e.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(a){this.currentFrame=this._frameData.getFrame(a),null!==this.currentFrame&&(this._frameIndex=a,this._parent.setTexture(d.TextureCache[this.currentFrame.uuid]))}}),e.Animation.generateFrameNames=function(a,b,c,d,f){"undefined"==typeof d&&(d="");var g=[],h="";if(c>b)for(var i=b;c>=i;i++)h="number"==typeof f?e.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+d,g.push(h);else for(var i=b;i>=c;i--)h="number"==typeof f?e.Utils.pad(i.toString(),f,"0",1):i.toString(),h=a+h+d,g.push(h);return g},e.Frame=function(a,b,c,d,f,g,h){this.index=a,this.x=b,this.y=c,this.width=d,this.height=f,this.name=g,this.uuid=h,this.centerX=Math.floor(d/2),this.centerY=Math.floor(f/2),this.distance=e.Math.distance(0,0,d,f),this.rotated=!1,this.rotationDirection="cw",this.trimmed=!1,this.sourceSizeW=d,this.sourceSizeH=f,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0},e.Frame.prototype={setTrim:function(a,b,c,d,e,f,g){this.trimmed=a,a&&(this.width=b,this.height=c,this.sourceSizeW=b,this.sourceSizeH=c,this.centerX=Math.floor(b/2),this.centerY=Math.floor(c/2),this.spriteSourceSizeX=d,this.spriteSourceSizeY=e,this.spriteSourceSizeW=f,this.spriteSourceSizeH=g)}},e.FrameData=function(){this._frames=[],this._frameNames=[]},e.FrameData.prototype={addFrame:function(a){return a.index=this._frames.length,this._frames.push(a),""!==a.name&&(this._frameNames[a.name]=a.index),a},getFrame:function(a){return this._frames.length>a?this._frames[a]:null},getFrameByName:function(a){return"number"==typeof this._frameNames[a]?this._frames[this._frameNames[a]]:null},checkFrameName:function(a){return null==this._frameNames[a]?!1:!0},getFrameRange:function(a,b,c){"undefined"==typeof c&&(c=[]);for(var d=a;b>=d;d++)c.push(this._frames[d]);return c},getFrames:function(a,b,c){if("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=[]),"undefined"==typeof a||0==a.length)for(var d=0;dd;d++)b?c.push(this.getFrame(a[d])):c.push(this.getFrameByName(a[d]));return c},getFrameIndexes:function(a,b,c){if("undefined"==typeof b&&(b=!0),"undefined"==typeof c&&(c=[]),"undefined"==typeof a||0==a.length)for(var d=0,e=this._frames.length;e>d;d++)c.push(this._frames[d].index);else for(var d=0,e=a.length;e>d;d++)b?c.push(a[d]):this.getFrameByName(a[d])&&c.push(this.getFrameByName(a[d]).index);return c}},Object.defineProperty(e.FrameData.prototype,"total",{get:function(){return this._frames.length}}),e.AnimationParser={spriteSheet:function(a,b,c,f,g){var h=a.cache.getImage(b);if(null==h)return null;var i=h.width,j=h.height;0>=c&&(c=Math.floor(-i/Math.min(-1,c))),0>=f&&(f=Math.floor(-j/Math.min(-1,f)));var k=Math.round(i/c),l=Math.round(j/f),m=k*l;if(-1!==g&&(m=g),0==i||0==j||c>i||f>j||0===m)return console.warn("Phaser.AnimationParser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight"),null;for(var n=new e.FrameData,o=0,p=0,q=0;m>q;q++){var r=a.rnd.uuid();n.addFrame(new e.Frame(q,o,p,c,f,"",r)),d.TextureCache[r]=new d.Texture(d.BaseTextureCache[b],{x:o,y:p,width:c,height:f}),o+=c,o===i&&(o=0,p+=f)}return n},JSONData:function(a,b,c){if(!b.frames)return console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"),console.log(b),void 0;for(var f,g=new e.FrameData,h=b.frames,i=0;i tag"),void 0;for(var f,g=new e.FrameData,h=b.getElementsByTagName("SubTexture"),i=0;i0?(this._progressChunk=100/this._keys.length,this.loadFile()):(this.progress=100,this.hasLoaded=!0,this.onLoadComplete.dispatch()))},loadFile:function(){var a=this._fileList[this._keys.shift()],b=this;switch(a.type){case"image":case"spritesheet":case"textureatlas":case"bitmapfont":case"tileset":a.data=new Image,a.data.name=a.key,a.data.onload=function(){return b.fileComplete(a.key)},a.data.onerror=function(){return b.fileError(a.key)},a.data.crossOrigin=this.crossOrigin,a.data.src=this.baseURL+a.url;break;case"audio":a.url=this.getAudioURL(a.url),null!==a.url?this.game.sound.usingWebAudio?(this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="arraybuffer",this._xhr.onload=function(){return b.fileComplete(a.key)},this._xhr.onerror=function(){return b.fileError(a.key)},this._xhr.send()):this.game.sound.usingAudioTag&&(this.game.sound.touchLocked?(a.data=new Audio,a.data.name=a.key,a.data.preload="auto",a.data.src=this.baseURL+a.url,this.fileComplete(a.key)):(a.data=new Audio,a.data.name=a.key,a.data.onerror=function(){return b.fileError(a.key)},a.data.preload="auto",a.data.src=this.baseURL+a.url,a.data.addEventListener("canplaythrough",e.GAMES[this.game.id].load.fileComplete(a.key),!1),a.data.load())):this.fileError(a.key);break;case"tilemap":this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="text",a.format==e.Tilemap.TILED_JSON?this._xhr.onload=function(){return b.jsonLoadComplete(a.key)}:a.format==e.Tilemap.CSV&&(this._xhr.onload=function(){return b.csvLoadComplete(a.key)}),this._xhr.onerror=function(){return b.dataLoadError(a.key)},this._xhr.send();break;case"text":this._xhr.open("GET",this.baseURL+a.url,!0),this._xhr.responseType="text",this._xhr.onload=function(){return b.fileComplete(a.key)},this._xhr.onerror=function(){return b.fileError(a.key)},this._xhr.send()}},getAudioURL:function(a){for(var b,c=0;c100&&(this.progress=100),null!==this.preloadSprite&&(0==this.preloadSprite.direction?this.preloadSprite.crop.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.crop.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite.crop=this.preloadSprite.crop),this.onFileComplete.dispatch(this.progress,a,b,this.queueSize-this._keys.length,this.queueSize),this._keys.length>0?this.loadFile():(this.hasLoaded=!0,this.isLoading=!1,this.removeAll(),this.onLoadComplete.dispatch())}},e.LoaderParser={bitmapFont:function(a,b,c){if(!b.getElementsByTagName("font"))return console.warn("Phaser.LoaderParser.bitmapFont: Invalid XML given, missing tag"),void 0;var e=d.TextureCache[c],f={},g=b.getElementsByTagName("info")[0],h=b.getElementsByTagName("common")[0];f.font=g.attributes.getNamedItem("face").nodeValue,f.size=parseInt(g.attributes.getNamedItem("size").nodeValue,10),f.lineHeight=parseInt(h.attributes.getNamedItem("lineHeight").nodeValue,10),f.chars={};for(var i=b.getElementsByTagName("char"),j=0;j=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),""==this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.now):this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop():this.loop?(this.onLoop.dispatch(this),this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop()))},play:function(a,b,c,d,e){if(a=a||"",b=b||0,c=c||1,"undefined"==typeof d&&(d=!1),"undefined"==typeof e&&(e=!0),1!=this.isPlaying||0!=e||0!=this.override){if(this.isPlaying&&this.override&&(this.usingWebAudio?"undefined"==typeof this._sound.stop?this._sound.noteOff(0):this._sound.stop(0):this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.currentMarker=a,""!==a){if(!this.markers[a])return console.warn("Phaser.Sound.play: audio marker "+a+" doesn't exist"),void 0;this.position=this.markers[a].start,this.volume=this.markers[a].volume,this.loop=this.markers[a].loop,this.duration=this.markers[a].duration,this.durationMS=this.markers[a].durationMS,this._tempMarker=a,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else this.position=b,this.volume=c,this.loop=d,this.duration=0,this.durationMS=0,this._tempMarker=a,this._tempPosition=b,this._tempVolume=c,this._tempLoop=d;this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(null==this._buffer&&(this._buffer=this.game.cache.getSoundData(this.key)),this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.gainNode),this.totalDuration=this._sound.buffer.duration,0==this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this.loop&&""==a&&(this._sound.loop=!0),"undefined"==typeof this._sound.start?this._sound.noteGrainOn(0,this.position,this.duration):this._sound.start(0,this.position,this.duration),this.isPlaying=!0,this.startTime=this.game.time.now,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&0==this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)):this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&4==this._sound.readyState?(this._sound.play(),this.totalDuration=this._sound.duration,0==this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._sound.currentTime=this.position,this._sound.muted=this._muted,this._sound.volume=this._muted?0:this._volume,this.isPlaying=!0,this.startTime=this.game.time.now,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!0}},restart:function(a,b,c,d){a=a||"",b=b||0,c=c||1,"undefined"==typeof d&&(d=!1),this.play(a,b,c,d,!0)},pause:function(){this.isPlaying&&this._sound&&(this.stop(),this.isPlaying=!1,this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.now,this.onPause.dispatch(this))},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){var a=this.position+this.pausedPosition/1e3;this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this._sound.connect(this.gainNode),"undefined"==typeof this._sound.start?this._sound.noteGrainOn(0,a,this.duration):this._sound.start(0,a,this.duration)}else this._sound.play();this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.now-this.pausedTime,this.onResume.dispatch(this)}},stop:function(){this.isPlaying&&this._sound&&(this.usingWebAudio?"undefined"==typeof this._sound.stop?this._sound.noteOff(0):this._sound.stop(0):this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0)),this.isPlaying=!1;var a=this.currentMarker;this.currentMarker="",this.onStop.dispatch(this,a)}},Object.defineProperty(e.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(e.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(e.Sound.prototype,"mute",{get:function(){return this._muted},set:function(a){a=a||null,a?(this._muted=!0,this.usingWebAudio?(this._muteVolume=this.gainNode.gain.value,this.gainNode.gain.value=0):this.usingAudioTag&&this._sound&&(this._muteVolume=this._sound.volume,this._sound.volume=0)):(this._muted=!1,this.usingWebAudio?this.gainNode.gain.value=this._muteVolume:this.usingAudioTag&&this._sound&&(this._sound.volume=this._muteVolume)),this.onMute.dispatch(this)}}),Object.defineProperty(e.Sound.prototype,"volume",{get:function(){return this._volume},set:function(a){this.usingWebAudio?(this._volume=a,this.gainNode.gain.value=a):this.usingAudioTag&&this._sound&&a>=0&&1>=a&&(this._volume=a,this._sound.volume=a)}}),e.SoundManager=function(a){this.game=a,this.onSoundDecode=new e.Signal,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this.context=null,this.usingWebAudio=!0,this.usingAudioTag=!1,this.noAudio=!1,this.touchLocked=!1,this.channels=32},e.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&0==this.game.device.webAudio&&(this.channels=1),this.game.device.iOS||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock?(this.game.input.touch.callbackContext=this,this.game.input.touch.touchStartCallback=this.unlock,this.game.input.mouse.callbackContext=this,this.game.input.mouse.mouseDownCallback=this.unlock,this.touchLocked=!0):this.touchLocked=!1,window.PhaserGlobal){if(1==window.PhaserGlobal.disableAudio)return this.usingWebAudio=!1,this.noAudio=!0,void 0;if(1==window.PhaserGlobal.disableWebAudio)return this.usingWebAudio=!1,this.usingAudioTag=!0,this.noAudio=!1,void 0}window.AudioContext?this.context=new window.AudioContext:window.webkitAudioContext?this.context=new window.webkitAudioContext:window.Audio?(this.usingWebAudio=!1,this.usingAudioTag=!0):(this.usingWebAudio=!1,this.noAudio=!0),null!==this.context&&(this.masterGain="undefined"==typeof this.context.createGain?this.context.createGainNode():this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination))},unlock:function(){if(0!=this.touchLocked)if(0==this.game.device.webAudio||window.PhaserGlobal&&1==window.PhaserGlobal.disableWebAudio)this.touchLocked=!1,this._unlockSource=null,this.game.input.touch.callbackContext=null,this.game.input.touch.touchStartCallback=null,this.game.input.mouse.callbackContext=null,this.game.input.mouse.mouseDownCallback=null;else{var a=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=a,this._unlockSource.connect(this.context.destination),this._unlockSource.noteOn(0)}},stopAll:function(){for(var a=0;a255)return e.Color.getColor(255,255,255);if(a>b)return e.Color.getColor(255,255,255);var d=a+Math.round(Math.random()*(b-a)),f=a+Math.round(Math.random()*(b-a)),g=a+Math.round(Math.random()*(b-a));return e.Color.getColor32(c,d,f,g)},getRGB:function(a){return{alpha:a>>>24,red:255&a>>16,green:255&a>>8,blue:255&a}},getWebRGB:function(a){var b=(a>>>24)/255,c=255&a>>16,d=255&a>>8,e=255&a;return"rgba("+c.toString()+","+d.toString()+","+e.toString()+","+b.toString()+")"},getAlpha:function(a){return a>>>24},getAlphaFloat:function(a){return(a>>>24)/255},getRed:function(a){return 255&a>>16},getGreen:function(a){return 255&a>>8},getBlue:function(a){return 255&a}},e.Physics={},e.Physics.Arcade=function(a){this.game=a,this.gravity=new e.Point,this.bounds=new e.Rectangle(0,0,a.world.width,a.world.height),this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.quadTree=new e.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTreeID=0,this._bounds1=new e.Rectangle,this._bounds2=new e.Rectangle,this._overlap=0,this._maxOverlap=0,this._velocity1=0,this._velocity2=0,this._newVelocity1=0,this._newVelocity2=0,this._average=0,this._mapData=[],this._mapTiles=0,this._result=!1,this._total=0,this._angle=0,this._dx=0,this._dy=0},e.Physics.Arcade.prototype={updateMotion:function(a){this._velocityDelta=(this.computeVelocity(0,a,a.angularVelocity,a.angularAcceleration,a.angularDrag,a.maxAngular)-a.angularVelocity)/2,a.angularVelocity+=this._velocityDelta,a.rotation+=a.angularVelocity*this.game.time.physicsElapsed,a.angularVelocity+=this._velocityDelta,this._velocityDelta=(this.computeVelocity(1,a,a.velocity.x,a.acceleration.x,a.drag.x,a.maxVelocity.x)-a.velocity.x)/2,a.velocity.x+=this._velocityDelta,a.x+=a.velocity.x*this.game.time.physicsElapsed,a.velocity.x+=this._velocityDelta,this._velocityDelta=(this.computeVelocity(2,a,a.velocity.y,a.acceleration.y,a.drag.y,a.maxVelocity.y)-a.velocity.y)/2,a.velocity.y+=this._velocityDelta,a.y+=a.velocity.y*this.game.time.physicsElapsed,a.velocity.y+=this._velocityDelta},computeVelocity:function(a,b,c,d,e,f){return f=f||1e4,1==a&&b.allowGravity?c+=this.gravity.x+b.gravity.x:2==a&&b.allowGravity&&(c+=this.gravity.y+b.gravity.y),0!==d?c+=d*this.game.time.physicsElapsed:0!==e&&(this._drag=e*this.game.time.physicsElapsed,c-this._drag>0?c-=this._drag:c+this._drag<0?c+=this._drag:c=0),c>f?c=f:-f>c&&(c=-f),c},preUpdate:function(){this.quadTree.clear(),this.quadTreeID=0,this.quadTree=new e.QuadTree(this,this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels)},postUpdate:function(){this.quadTree.clear()},overlap:function(a,b){return a&&b&&a.exists&&b.exists?e.Rectangle.intersects(a.body,b.body):!1},collide:function(a,b,c,d,f){return c=c||null,d=d||null,f=f||c,this._result=!1,this._total=0,a&&b&&a.exists&&b.exists&&(a.type==e.SPRITE?b.type==e.SPRITE?this.collideSpriteVsSprite(a,b,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideSpriteVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(a,b,c,d,f):a.type==e.GROUP?b.type==e.SPRITE?this.collideSpriteVsGroup(b,a,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideGroupVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,c,d,f):a.type==e.TILEMAPLAYER?b.type==e.SPRITE?this.collideSpriteVsTilemapLayer(b,a,c,d,f):(b.type==e.GROUP||b.type==e.EMITTER)&&this.collideGroupVsTilemapLayer(b,a,c,d,f):a.type==e.EMITTER&&(b.type==e.SPRITE?this.collideSpriteVsGroup(b,a,c,d,f):b.type==e.GROUP||b.type==e.EMITTER?this.collideGroupVsGroup(a,b,c,d,f):b.type==e.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,c,d,f))),this._total>0},collideSpriteVsTilemapLayer:function(a,b,c,d,e){if(this._mapData=b.getTiles(a.body.x,a.body.y,a.body.width,a.body.height,!0),this._mapData.length>1)for(var f=1;ff;f++)this._potentials[f].sprite.group==b&&(this.separate(a.body,this._potentials[f]),this._result&&d&&(this._result=d.call(e,a,this._potentials[f].sprite)),this._result&&(this._total++,c&&c.call(e,a,this._potentials[f].sprite)))}},collideGroupVsGroup:function(a,b,c,d,e){if(0!=a.length&&0!=b.length&&a._container.first._iNext){var f=a._container.first._iNext;do f.exists&&this.collideSpriteVsGroup(f,b,c,d,e),f=f._iNext;while(f!=a._container.last._iNext)}},separate:function(a,b){this._result=this.separateX(a,b)||this.separateY(a,b)},separateX:function(a,b){return a.immovable&&b.immovable?!1:(this._overlap=0,e.Rectangle.intersects(a,b)&&(this._maxOverlap=a.deltaAbsX()+b.deltaAbsX()+this.OVERLAP_BIAS,0==a.deltaX()&&0==b.deltaX()?(a.embedded=!0,b.embedded=!0):a.deltaX()>b.deltaX()?(this._overlap=a.x+a.width-b.x,this._overlap>this._maxOverlap||0==a.allowCollision.right||0==b.allowCollision.left?this._overlap=0:(a.touching.right=!0,b.touching.left=!0)):a.deltaX()this._maxOverlap||0==a.allowCollision.left||0==b.allowCollision.right?this._overlap=0:(a.touching.left=!0,b.touching.right=!0)),0!=this._overlap)?(a.overlapX=this._overlap,b.overlapX=this._overlap,a.customSeparateX||b.customSeparateX?!0:(this._velocity1=a.velocity.x,this._velocity2=b.velocity.x,a.immovable||b.immovable?a.immovable?b.immovable||(b.x+=this._overlap,b.velocity.x=this._velocity1-this._velocity2*b.bounce.x):(a.x=a.x-this._overlap,a.velocity.x=this._velocity2-this._velocity1*a.bounce.x):(this._overlap*=.5,a.x=a.x-this._overlap,b.x+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.x=this._average+this._newVelocity1*a.bounce.x,b.velocity.x=this._average+this._newVelocity2*b.bounce.x),!0)):!1)},separateY:function(a,b){return a.immovable&&b.immovable?!1:(this._overlap=0,e.Rectangle.intersects(a,b)&&(this._maxOverlap=a.deltaAbsY()+b.deltaAbsY()+this.OVERLAP_BIAS,0==a.deltaY()&&0==b.deltaY()?(a.embedded=!0,b.embedded=!0):a.deltaY()>b.deltaY()?(this._overlap=a.y+a.height-b.y,this._overlap>this._maxOverlap||0==a.allowCollision.down||0==b.allowCollision.up?this._overlap=0:(a.touching.down=!0,b.touching.up=!0)):a.deltaY()this._maxOverlap||0==a.allowCollision.up||0==b.allowCollision.down?this._overlap=0:(a.touching.up=!0,b.touching.down=!0)),0!=this._overlap)?(a.overlapY=this._overlap,b.overlapY=this._overlap,a.customSeparateY||b.customSeparateY?!0:(this._velocity1=a.velocity.y,this._velocity2=b.velocity.y,a.immovable||b.immovable?a.immovable?b.immovable||(b.y+=this._overlap,b.velocity.y=this._velocity1-this._velocity2*b.bounce.y,a.sprite.active&&a.moves&&a.deltaY()b.deltaY()&&(a.x+=b.x-b.lastX)):(this._overlap*=.5,a.y=a.y-this._overlap,b.y+=this._overlap,this._newVelocity1=Math.sqrt(this._velocity2*this._velocity2*b.mass/a.mass)*(this._velocity2>0?1:-1),this._newVelocity2=Math.sqrt(this._velocity1*this._velocity1*a.mass/b.mass)*(this._velocity1>0?1:-1),this._average=.5*(this._newVelocity1+this._newVelocity2),this._newVelocity1-=this._average,this._newVelocity2-=this._average,a.velocity.y=this._average+this._newVelocity1*a.bounce.y,b.velocity.y=this._average+this._newVelocity2*b.bounce.y),!0)):!1)},separateTile:function(a,b){this._result=this.separateTileX(a,b,!0)||this.separateTileY(a,b,!0)},separateTileX:function(a,b,c){return a.immovable||0==a.deltaX()||0==e.Rectangle.intersects(a.hullX,b)?!1:(this._overlap=0,this._maxOverlap=a.deltaAbsX()+this.OVERLAP_BIAS,a.deltaX()<0?(this._overlap=b.right-a.hullX.x,this._overlap>this._maxOverlap||0==a.allowCollision.left||0==b.tile.collideRight?this._overlap=0:a.touching.left=!0):(this._overlap=a.hullX.right-b.x,this._overlap>this._maxOverlap||0==a.allowCollision.right||0==b.tile.collideLeft?this._overlap=0:a.touching.right=!0),0!=this._overlap?(c&&(a.x=a.deltaX()<0?a.x+this._overlap:a.x-this._overlap,a.velocity.x=0==a.bounce.x?0:-a.velocity.x*a.bounce.x,a.updateHulls()),!0):!1)},separateTileY:function(a,b,c){return a.immovable||0==a.deltaY()||0==e.Rectangle.intersects(a.hullY,b)?!1:(this._overlap=0,this._maxOverlap=a.deltaAbsY()+this.OVERLAP_BIAS,a.deltaY()<0?(this._overlap=b.bottom-a.hullY.y,this._overlap>this._maxOverlap||0==a.allowCollision.up||0==b.tile.collideDown?this._overlap=0:a.touching.up=!0):(this._overlap=a.hullY.bottom-b.y,this._overlap>this._maxOverlap||0==a.allowCollision.down||0==b.tile.collideUp?this._overlap=0:a.touching.down=!0),0!=this._overlap?(c&&(a.y=a.deltaY()<0?a.y+this._overlap:a.y-this._overlap,a.velocity.y=0==a.bounce.y?0:-a.velocity.y*a.bounce.y,a.updateHulls()),!0):!1)},moveToObject:function(a,b,c,d){return c=c||60,d=d||0,this._angle=Math.atan2(b.y-a.y,b.x-a.x),d>0&&(c=this.distanceBetween(a,b)/(d/1e3)),a.body.velocity.x=Math.cos(this._angle)*c,a.body.velocity.y=Math.sin(this._angle)*c,this._angle},moveToPointer:function(a,b,c,d){return b=b||60,c=c||this.game.input.activePointer,d=d||0,this._angle=this.angleToPointer(a,c),d>0&&(b=this.distanceToPointer(a,c)/(d/1e3)),a.body.velocity.x=Math.cos(this._angle)*b,a.body.velocity.y=Math.sin(this._angle)*b,this._angle},moveToXY:function(a,b,c,d,e){return d=d||60,e=e||0,this._angle=Math.atan2(c-a.y,b-a.x),e>0&&(d=this.distanceToXY(a,b,c)/(e/1e3)),a.body.velocity.x=Math.cos(this._angle)*d,a.body.velocity.y=Math.sin(this._angle)*d,this._angle +},velocityFromAngle:function(a,b,c){return b=b||60,c=c||new e.Point,c.setTo(Math.cos(this.game.math.degToRad(a))*b,Math.sin(this.game.math.degToRad(a))*b)},velocityFromRotation:function(a,b,c){return b=b||60,c=c||new e.Point,c.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerationFromRotation:function(a,b,c){return b=b||60,c=c||new e.Point,c.setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerateToObject:function(a,b,c,d,e){return"undefined"==typeof c&&(c=60),"undefined"==typeof d&&(d=1e3),"undefined"==typeof e&&(e=1e3),this._angle=this.angleBetween(a,b),a.body.acceleration.setTo(Math.cos(this._angle)*c,Math.sin(this._angle)*c),a.body.maxVelocity.setTo(d,e),this._angle},accelerateToPointer:function(a,b,c,d,e){return"undefined"==typeof c&&(c=60),"undefined"==typeof b&&(b=this.game.input.activePointer),"undefined"==typeof d&&(d=1e3),"undefined"==typeof e&&(e=1e3),this._angle=this.angleToPointer(a,b),a.body.acceleration.setTo(Math.cos(this._angle)*c,Math.sin(this._angle)*c),a.body.maxVelocity.setTo(d,e),this._angle},accelerateToXY:function(a,b,c,d,e,f){return"undefined"==typeof d&&(d=60),"undefined"==typeof e&&(e=1e3),"undefined"==typeof f&&(f=1e3),this._angle=this.angleToXY(a,b,c),a.body.acceleration.setTo(Math.cos(this._angle)*d,Math.sin(this._angle)*d),a.body.maxVelocity.setTo(e,f),this._angle},distanceBetween:function(a,b){return this._dx=a.x-b.x,this._dy=a.y-b.y,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToXY:function(a,b,c){return this._dx=a.x-b,this._dy=a.y-c,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},distanceToPointer:function(a,b){return b=b||this.game.input.activePointer,this._dx=a.worldX-b.x,this._dy=a.worldY-b.y,Math.sqrt(this._dx*this._dx+this._dy*this._dy)},angleBetween:function(a,b){return this._dx=b.x-a.x,this._dy=b.y-a.y,Math.atan2(this._dy,this._dx)},angleToXY:function(a,b,c){return this._dx=b-a.x,this._dy=c-a.y,Math.atan2(this._dy,this._dx)},angleToPointer:function(a,b){return b=b||this.game.input.activePointer,this._dx=b.worldX-a.x,this._dy=b.worldY-a.y,Math.atan2(this._dy,this._dx)}},e.Physics.Arcade.Body=function(a){this.sprite=a,this.game=a.game,this.offset=new e.Point,this.x=a.x,this.y=a.y,this.preX=a.x,this.preY=a.y,this.preRotation=a.angle,this.screenX=a.x,this.screenY=a.y,this.sourceWidth=a.currentFrame.sourceSizeW,this.sourceHeight=a.currentFrame.sourceSizeH,this.width=a.currentFrame.sourceSizeW,this.height=a.currentFrame.sourceSizeH,this.halfWidth=Math.floor(a.currentFrame.sourceSizeW/2),this.halfHeight=Math.floor(a.currentFrame.sourceSizeH/2),this._sx=a.scale.x,this._sy=a.scale.y,this.velocity=new e.Point,this.acceleration=new e.Point,this.drag=new e.Point,this.gravity=new e.Point,this.bounce=new e.Point,this.maxVelocity=new e.Point(1e4,1e4),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.skipQuadTree=!1,this.quadTreeIDs=[],this.quadTreeIndex=-1,this.allowCollision={none:!1,any:!0,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.facing=e.NONE,this.immovable=!1,this.moves=!0,this.rotation=0,this.allowRotation=!0,this.allowGravity=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.hullX=new e.Rectangle,this.hullY=new e.Rectangle,this.embedded=!1,this.collideWorldBounds=!1},e.Physics.Arcade.Body.prototype={updateBounds:function(a,b,c,d){(c!=this._sx||d!=this._sy)&&(this.width=this.sourceWidth*c,this.height=this.sourceHeight*d,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this._sx=c,this._sy=d)},preUpdate:function(){this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.embedded=!1,this.screenX=this.sprite.worldTransform[2]-this.sprite.anchor.x*this.width+this.offset.x,this.screenY=this.sprite.worldTransform[5]-this.sprite.anchor.y*this.height+this.offset.y,this.preX=this.sprite.worldTransform[2]-this.sprite.anchor.x*this.width+this.offset.x,this.preY=this.sprite.worldTransform[5]-this.sprite.anchor.y*this.height+this.offset.y,this.preRotation=this.sprite.angle,this.x=this.preX,this.y=this.preY,this.rotation=this.preRotation,this.moves&&(this.game.physics.updateMotion(this),this.collideWorldBounds&&this.checkWorldBounds(),this.updateHulls()),0==this.skipQuadTree&&0==this.allowCollision.none&&this.sprite.visible&&this.sprite.alive&&(this.quadTreeIDs=[],this.quadTreeIndex=-1,this.game.physics.quadTree.insert(this))},postUpdate:function(){0==this.deltaX()&&0==this.deltaY()&&0==this.sprite.deltaX()&&0==this.sprite.deltaY(),this.deltaX()<0?this.facing=e.LEFT:this.deltaX()>0&&(this.facing=e.RIGHT),this.deltaY()<0?this.facing=e.UP:this.deltaY()>0&&(this.facing=e.DOWN),this.sprite.x+=this.deltaX(),this.sprite.y+=this.deltaY(),this.allowRotation&&(this.sprite.angle+=this.deltaZ())},updateHulls:function(){this.hullX.setTo(this.x,this.preY,this.width,this.height),this.hullY.setTo(this.preX,this.y,this.width,this.height)},checkWorldBounds:function(){this.xthis.game.world.bounds.right&&(this.x=this.game.world.bounds.right-this.width,this.velocity.x*=-this.bounce.x),this.ythis.game.world.bounds.bottom&&(this.y=this.game.world.bounds.bottom-this.height,this.velocity.y*=-this.bounce.y)},setSize:function(a,b,c,d){c=c||this.offset.x,d=d||this.offset.y,this.sourceWidth=a,this.sourceHeight=b,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(c,d)},reset:function(){this.velocity.setTo(0,0),this.acceleration.setTo(0,0),this.angularVelocity=0,this.angularAcceleration=0,this.preX=this.sprite.worldTransform[2]-this.sprite.anchor.x*this.width+this.offset.x,this.preY=this.sprite.worldTransform[5]-this.sprite.anchor.y*this.height+this.offset.y,this.preRotation=this.sprite.angle,this.x=this.preX,this.y=this.preY,this.rotation=this.preRotation},deltaAbsX:function(){return this.deltaX()>0?this.deltaX():-this.deltaX()},deltaAbsY:function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},deltaX:function(){return this.x-this.preX},deltaY:function(){return this.y-this.preY},deltaZ:function(){return this.rotation-this.preRotation}},Object.defineProperty(e.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){this.height=a<=this.y?0:this.y-a}}),Object.defineProperty(e.Physics.Arcade.Body.prototype,"right",{get:function(){return this.x+this.width},set:function(a){this.width=a<=this.x?0:this.x+a}}),e.Particles=function(){this.emitters={},this.ID=0},e.Particles.prototype={add:function(a){return this.emitters[a.name]=a,a},remove:function(a){delete this.emitters[a.name]},update:function(){for(var a in this.emitters)this.emitters[a].exists&&this.emitters[a].update()}},e.Particles.Arcade={},e.Particles.Arcade.Emitter=function(a,b,c,d){this.maxParticles=d||50,e.Group.call(this,a),this.name="emitter"+this.game.particles.ID++,this.type=e.EMITTER,this.x=0,this.y=0,this.width=1,this.height=1,this.minParticleSpeed=new e.Point(-100,-100),this.maxParticleSpeed=new e.Point(100,100),this.minParticleScale=1,this.maxParticleScale=1,this.minRotation=-360,this.maxRotation=360,this.gravity=2,this.particleClass=null,this.particleDrag=new e.Point,this.angularDrag=0,this.frequency=100,this.lifespan=2e3,this.bounce=new e.Point,this._quantity=0,this._timer=0,this._counter=0,this._explode=!0,this.on=!1,this.exists=!0,this.emitX=b,this.emitY=c},e.Particles.Arcade.Emitter.prototype=Object.create(e.Group.prototype),e.Particles.Arcade.Emitter.prototype.constructor=e.Particles.Arcade.Emitter,e.Particles.Arcade.Emitter.prototype.update=function(){if(this.on)if(this._explode){this._counter=0;do this.emitParticle(),this._counter++;while(this._counter=this._timer&&(this.emitParticle(),this._counter++,this._quantity>0&&this._counter>=this._quantity&&(this.on=!1),this._timer=this.game.time.now+this.frequency)},e.Particles.Arcade.Emitter.prototype.makeParticles=function(a,b,c,d,f){"undefined"==typeof b&&(b=0),c=c||this.maxParticles,d=d||0,"undefined"==typeof f&&(f=!1);for(var g,h=0,i=a,j=0;c>h;)null==this.particleClass&&("object"==typeof a&&(i=this.game.rnd.pick(a)),"object"==typeof b&&(j=this.game.rnd.pick(b)),g=new e.Sprite(this.game,0,0,i,j)),d>0?(g.body.allowCollision.any=!0,g.body.allowCollision.none=!1):g.body.allowCollision.none=!0,g.body.collideWorldBounds=f,g.exists=!1,g.visible=!1,g.anchor.setTo(.5,.5),this.add(g),h++;return this},e.Particles.Arcade.Emitter.prototype.kill=function(){this.on=!1,this.alive=!1,this.exists=!1},e.Particles.Arcade.Emitter.prototype.revive=function(){this.alive=!0,this.exists=!0},e.Particles.Arcade.Emitter.prototype.start=function(a,b,c,d){"boolean"!=typeof a&&(a=!0),b=b||0,c=c||250,d=d||0,this.revive(),this.visible=!0,this.on=!0,this._explode=a,this.lifespan=b,this.frequency=c,a?this._quantity=d:this._quantity+=d,this._counter=0,this._timer=this.game.time.now+c},e.Particles.Arcade.Emitter.prototype.emitParticle=function(){var a=this.getFirstExists(!1);if(null!=a){if(this.width>1||this.height>1?a.reset(this.game.rnd.integerInRange(this.left,this.right),this.game.rnd.integerInRange(this.top,this.bottom)):a.reset(this.emitX,this.emitY),a.lifespan=this.lifespan,a.body.bounce.setTo(this.bounce.x,this.bounce.y),a.body.velocity.x=this.minParticleSpeed.x!=this.maxParticleSpeed.x?this.game.rnd.integerInRange(this.minParticleSpeed.x,this.maxParticleSpeed.x):this.minParticleSpeed.x,a.body.velocity.y=this.minParticleSpeed.y!=this.maxParticleSpeed.y?this.game.rnd.integerInRange(this.minParticleSpeed.y,this.maxParticleSpeed.y):this.minParticleSpeed.y,a.body.gravity.y=this.gravity,a.body.angularVelocity=this.minRotation!=this.maxRotation?this.game.rnd.integerInRange(this.minRotation,this.maxRotation):this.minRotation,1!==this.minParticleScale||1!==this.maxParticleScale){var b=this.game.rnd.realInRange(this.minParticleScale,this.maxParticleScale);a.scale.setTo(b,b)}a.body.drag.x=this.particleDrag.x,a.body.drag.y=this.particleDrag.y,a.body.angularDrag=this.angularDrag}},e.Particles.Arcade.Emitter.prototype.setSize=function(a,b){this.width=a,this.height=b},e.Particles.Arcade.Emitter.prototype.setXSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.x=a,this.maxParticleSpeed.x=b},e.Particles.Arcade.Emitter.prototype.setYSpeed=function(a,b){a=a||0,b=b||0,this.minParticleSpeed.y=a,this.maxParticleSpeed.y=b},e.Particles.Arcade.Emitter.prototype.setRotation=function(a,b){a=a||0,b=b||0,this.minRotation=a,this.maxRotation=b},e.Particles.Arcade.Emitter.prototype.at=function(a){this.emitX=a.center.x,this.emitY=a.center.y},Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"alpha",{get:function(){return this._container.alpha},set:function(a){this._container.alpha=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"visible",{get:function(){return this._container.visible},set:function(a){this._container.visible=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(a){this.emitX=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(a){this.emitY=a}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.width/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.height/2)}}),Object.defineProperty(e.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.height/2)}}),e.Tile=function(a,b,c,d,e,f){this.tileset=a,this.index=b,this.width=e,this.height=f,this.x=c,this.y=d,this.mass=1,this.collideNone=!0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.separateX=!0,this.separateY=!0,this.collisionCallback=null,this.collisionCallbackContext=this},e.Tile.prototype={setCollisionCallback:function(a,b){this.collisionCallbackContext=b,this.collisionCallback=a},destroy:function(){this.tileset=null},setCollision:function(a,b,c,d){this.collideLeft=a,this.collideRight=b,this.collideUp=c,this.collideDown=d,this.collideNone=a||b||c||d?!1:!0},resetCollision:function(){this.collideNone=!0,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1}},Object.defineProperty(e.Tile.prototype,"bottom",{get:function(){return this.y+this.height}}),Object.defineProperty(e.Tile.prototype,"right",{get:function(){return this.x+this.width}}),e.Tilemap=function(a,b){this.game=a,this.layers,"string"==typeof b?(this.key=b,this.layers=a.cache.getTilemapData(b).layers,this.calculateIndexes()):this.layers=[],this.currentLayer=0,this.debugMap=[],this.dirty=!1,this._results=[],this._tempA=0,this._tempB=0},e.Tilemap.CSV=0,e.Tilemap.TILED_JSON=1,e.Tilemap.prototype={create:function(a,b,c){for(var d=[],f=0;c>f;f++){d[f]=[];for(var g=0;b>g;g++)d[f][g]=0}this.currentLayer=this.layers.push({name:a,width:b,height:c,alpha:1,visible:!0,tileMargin:0,tileSpacing:0,format:e.Tilemap.CSV,data:d,indexes:[]}),this.dirty=!0},calculateIndexes:function(){for(var a=0;a=0&&b=0&&c=0&&a=0&&b=0&&a=0&&b=0&&b=0&&ca&&(a=0),0>b&&(b=0),c>this.layers[e].width&&(c=this.layers[e].width),d>this.layers[e].height&&(d=this.layers[e].height),this._results.length=0,this._results.push({x:a,y:b,width:c,height:d,layer:e});for(var f=b;b+d>f;f++)for(var g=a;a+c>g;g++)this._results.push({x:g,y:f,index:this.layers[e].data[f][g]});return this._results},paste:function(a,b,c,d){if("undefined"==typeof a&&(a=0),"undefined"==typeof b&&(b=0),"undefined"==typeof d&&(d=this.currentLayer),c&&!(c.length<2)){for(var e=c[1].x-a,f=c[1].y-b,g=1;g1?this.debugMap[this.layers[this.currentLayer].data[c][d]]?b.push("background: "+this.debugMap[this.layers[this.currentLayer].data[c][d]]):b.push("background: #ffffff"):b.push("background: rgb(0, 0, 0)");a+="\n"}b[0]=a,console.log.apply(console,b)},destroy:function(){this.removeAllLayers(),this.game=null}},e.TilemapLayer=function(a,b,c,f,g,h,i,j){this.game=a,this.canvas=e.Canvas.create(f,g),this.context=this.canvas.getContext("2d"),this.baseTexture=new d.BaseTexture(this.canvas),this.texture=new d.Texture(this.baseTexture),this.textureFrame=new e.Frame(0,0,0,f,g,"tilemaplayer",a.rnd.uuid()),e.Sprite.call(this,this.game,b,c,this.texture,this.textureFrame),this.type=e.TILEMAPLAYER,this.fixedToCamera=!0,this.tileset=null,this.tileWidth=0,this.tileHeight=0,this.tileMargin=0,this.tileSpacing=0,this.widthInPixels=0,this.heightInPixels=0,this.renderWidth=f,this.renderHeight=g,this._ga=1,this._dx=0,this._dy=0,this._dw=0,this._dh=0,this._tx=0,this._ty=0,this._results=[],this._tw=0,this._th=0,this._tl=0,this._maxX=0,this._maxY=0,this._startX=0,this._startY=0,this.tilemap=null,this.layer=null,this.index=0,this._x=0,this._y=0,this._prevX=0,this._prevY=0,this.dirty=!0,(h instanceof e.Tileset||"string"==typeof h)&&this.updateTileset(h),i instanceof e.Tilemap&&this.updateMapData(i,j)},e.TilemapLayer.prototype=e.Utils.extend(!0,e.Sprite.prototype,d.Sprite.prototype),e.TilemapLayer.prototype.constructor=e.TilemapLayer,e.TilemapLayer.prototype.update=function(){this.scrollX=this.game.camera.x,this.scrollY=this.game.camera.y,this.render()},e.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.widthInPixels,this.heightInPixels)},e.TilemapLayer.prototype.updateTileset=function(a){if(a instanceof e.Tileset)this.tileset=a;else{if("string"!=typeof a)return;this.tileset=this.game.cache.getTileset("tiles")}this.tileWidth=this.tileset.tileWidth,this.tileHeight=this.tileset.tileHeight,this.tileMargin=this.tileset.tileMargin,this.tileSpacing=this.tileset.tileSpacing,this.updateMax()},e.TilemapLayer.prototype.updateMapData=function(a,b){"undefined"==typeof b&&(b=0),a instanceof e.Tilemap&&(this.tilemap=a,this.layer=this.tilemap.layers[b],this.index=b,this.updateMax(),this.tilemap.dirty=!0)},e.TilemapLayer.prototype.getTileX=function(a){var b=this.tileWidth*this.scale.x;return this.game.math.snapToFloor(a,b)/b},e.TilemapLayer.prototype.getTileY=function(a){var b=this.tileHeight*this.scale.y;return this.game.math.snapToFloor(a,b)/b},e.TilemapLayer.prototype.getTileXY=function(a,b,c){return c.x=this.getTileX(a),c.y=this.getTileY(b),c},e.TilemapLayer.prototype.getTiles=function(a,b,c,d,e){if(null!==this.tilemap){"undefined"==typeof e&&(e=!1),0>a&&(a=0),0>b&&(b=0),c>this.widthInPixels&&(c=this.widthInPixels),d>this.heightInPixels&&(d=this.heightInPixels);var f=this.tileWidth*this.scale.x,g=this.tileHeight*this.scale.y;this._tx=this.game.math.snapToFloor(a,f)/f,this._ty=this.game.math.snapToFloor(b,g)/g,this._tw=(this.game.math.snapToCeil(c,f)+f)/f,this._th=(this.game.math.snapToCeil(d,g)+g)/g,this._results.length=0,this._results.push({x:a,y:b,width:c,height:d,tx:this._tx,ty:this._ty,tw:this._tw,th:this._th});for(var h=0,i=null,j=0,k=0,l=this._ty;lthis.layer.width&&(this._maxX=this.layer.width),this._maxY>this.layer.height&&(this._maxY=this.layer.height),this.widthInPixels=this.layer.width*this.tileWidth,this.heightInPixels=this.layer.height*this.tileHeight),this.dirty=!0},e.TilemapLayer.prototype.render=function(){if(this.tilemap&&this.tilemap.dirty&&(this.dirty=!0),this.dirty&&this.tileset&&this.tilemap&&this.visible){this._prevX=this._dx,this._prevY=this._dy,this._dx=-(this._x-this._startX*this.tileWidth),this._dy=-(this._y-this._startY*this.tileHeight),this._tx=this._dx,this._ty=this._dy,this.context.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=this._startY;a0?this.deltaX():-this.deltaX()},e.TilemapLayer.prototype.deltaAbsY=function(){return this.deltaY()>0?this.deltaY():-this.deltaY()},e.TilemapLayer.prototype.deltaX=function(){return this._dx-this._prevX},e.TilemapLayer.prototype.deltaY=function(){return this._dy-this._prevY},Object.defineProperty(e.TilemapLayer.prototype,"scrollX",{get:function(){return this._x},set:function(a){a!==this._x&&a>=0&&this.layer&&(this._x=a,this._x>this.widthInPixels-this.renderWidth&&(this._x=this.widthInPixels-this.renderWidth),this._startX=this.game.math.floor(this._x/this.tileWidth),this._startX<0&&(this._startX=0),this._startX+this._maxX>this.layer.width&&(this._startX=this.layer.width-this._maxX),this.dirty=!0)}}),Object.defineProperty(e.TilemapLayer.prototype,"scrollY",{get:function(){return this._y},set:function(a){a!==this._y&&a>=0&&this.layer&&(this._y=a,this._y>this.heightInPixels-this.renderHeight&&(this._y=this.heightInPixels-this.renderHeight),this._startY=this.game.math.floor(this._y/this.tileHeight),this._startY<0&&(this._startY=0),this._startY+this._maxY>this.layer.height&&(this._startY=this.layer.height-this._maxY),this.dirty=!0)}}),e.TilemapParser={tileset:function(a,b,c,d,f,g,h){var i=a.cache.getTilesetImage(b);if(null==i)return null;var j=i.width,k=i.height;0>=c&&(c=Math.floor(-j/Math.min(-1,c))),0>=d&&(d=Math.floor(-k/Math.min(-1,d)));var l=Math.round(j/c),m=Math.round(k/d),n=l*m;if(-1!==f&&(n=f),0==j||0==k||c>j||d>k||0===n)return console.warn("Phaser.TilemapParser.tileSet: width/height zero or width/height < given tileWidth/tileHeight"),null;for(var o=g,p=g,q=new e.Tileset(i,b,c,d,g,h),r=0;n>r;r++)q.addTile(new e.Tile(q,r,o,p,c,d)),o+=c+h,o===j&&(o=g,p+=d+h);return q},parse:function(a,b,c){return c===e.Tilemap.CSV?this.parseCSV(b):c===e.Tilemap.TILED_JSON?this.parseTiledJSON(b):void 0},parseCSV:function(a){a=a.trim();for(var b=[],c=a.split("\n"),d=c.length,e=0,f=0;fa)for(var g=a;b>=g;g++)this.tiles[g].setCollision(c,d,e,f)},setCollision:function(a,b,c,d,e){this.tiles[a]&&this.tiles[a].setCollision(b,c,d,e)}},Object.defineProperty(e.Tileset.prototype,"total",{get:function(){return this.tiles.length}}),d.CanvasRenderer.prototype.renderDisplayObject=function(a){var b,c=this.context;c.globalCompositeOperation="source-over";var e=a.last._iNext;a=a.first;do if(b=a.worldTransform,a.visible)if(a.renderable&&0!=a.alpha){if(a instanceof d.Sprite){var f=a.texture.frame;f&&(c.globalAlpha=a.worldAlpha,a.texture.trimmed?c.setTransform(b[0],b[3],b[1],b[4],b[2]+a.texture.trim.x,b[5]+a.texture.trim.y):c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),c.drawImage(a.texture.baseTexture.source,f.x,f.y,f.width,f.height,a.anchor.x*-f.width,a.anchor.y*-f.height,f.width,f.height))}else if(a instanceof d.Strip)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderStrip(a);else if(a instanceof d.TilingSprite)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),this.renderTilingSprite(a);else if(a instanceof d.CustomRenderable)a.renderCanvas(this);else if(a instanceof d.Graphics)c.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]),d.CanvasGraphics.renderGraphics(a,c);else if(a instanceof d.FilterBlock)if(a.open){c.save();var g=a.mask.alpha,h=a.mask.worldTransform;c.setTransform(h[0],h[3],h[1],h[4],h[2],h[5]),a.mask.worldAlpha=.5,c.worldAlpha=0,d.CanvasGraphics.renderGraphicsMask(a.mask,c),c.clip(),a.mask.worldAlpha=g}else c.restore();a=a._iNext}else a=a._iNext;else a=a.last._iNext;while(a!=e)},d.WebGLBatch.prototype.update=function(){this.gl;for(var a,b,c,e,f,g,h,i,j,k,l,m,n,o,p,q,r=0,s=this.head;s;){if(s.vcount===d.visibleCount){if(b=s.texture.frame.width,c=s.texture.frame.height,e=s.anchor.x,f=s.anchor.y,g=b*(1-e),h=b*-e,i=c*(1-f),j=c*-f,k=8*r,a=s.worldTransform,l=a[0],m=a[3],n=a[1],o=a[4],p=a[2],q=a[5],s.texture.trimmed&&(p+=s.texture.trim.x,q+=s.texture.trim.y),this.verticies[k+0]=l*h+n*j+p,this.verticies[k+1]=o*j+m*h+q,this.verticies[k+2]=l*g+n*j+p,this.verticies[k+3]=o*j+m*g+q,this.verticies[k+4]=l*g+n*i+p,this.verticies[k+5]=o*i+m*g+q,this.verticies[k+6]=l*h+n*i+p,this.verticies[k+7]=o*i+m*h+q,s.updateFrame||s.texture.updateFrame){this.dirtyUVS=!0;var t=s.texture,u=t.frame,v=t.baseTexture.width,w=t.baseTexture.height;this.uvs[k+0]=u.x/v,this.uvs[k+1]=u.y/w,this.uvs[k+2]=(u.x+u.width)/v,this.uvs[k+3]=u.y/w,this.uvs[k+4]=(u.x+u.width)/v,this.uvs[k+5]=(u.y+u.height)/w,this.uvs[k+6]=u.x/v,this.uvs[k+7]=(u.y+u.height)/w,s.updateFrame=!1}if(s.cacheAlpha!=s.worldAlpha){s.cacheAlpha=s.worldAlpha;var x=4*r;this.colors[x]=this.colors[x+1]=this.colors[x+2]=this.colors[x+3]=s.worldAlpha,this.dirtyColors=!0}}else k=8*r,this.verticies[k+0]=0,this.verticies[k+1]=0,this.verticies[k+2]=0,this.verticies[k+3]=0,this.verticies[k+4]=0,this.verticies[k+5]=0,this.verticies[k+6]=0,this.verticies[k+7]=0;r++,s=s.__next}},e}); \ No newline at end of file diff --git a/build/ts.bat b/build/ts.bat new file mode 100644 index 00000000..7b415531 --- /dev/null +++ b/build/ts.bat @@ -0,0 +1 @@ +jsdocts -d:phaser.d.ts phaser.js \ No newline at end of file diff --git a/changelog.md b/changelog.md index e8e555a7..1b6612d0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,81 @@ Change Log ---------- -V0.9.8 +Version 1.0.6 (September 24th 2013) + +* Added check into Pointer.move to always consider a Sprite that has pixelPerfect enabled, regardless of render ID. +* BUG: The pixel perfect click check doesn't work if the sprite is part of a texture atlas yet. +* Fixed issue with anti-alias in the Game constructor not being set correctly (thanks luizbills) +* Added support for the Graphics game object back in and two examples (thanks earok for spotting) +* New: Tweens can now be chained via multiple to() calls + example created (thanks to powerfear for adding) +* Fixed Math.wrap (thanks TheJare) +* New: When loading a Sprite Sheet you can now pass negative values for the frame sizes which specifies the number of rows/columns to load instead (thanks TheJare) +* New: BitmapText now supports anchor and has fixed box dimensions (thanks TheJare) +* Fixed bug where if a State contains an empty Preloader the Update will not be called (thanks TheJare) +* Several new examples added (cameras, tweens, etc) +* Added in extra checks to halt collision if it involves an empty Group (thanks cang) +* Added time smoothing to Animation update to help frames hopefully not get too out of sync during long animations with high frame rates. +* Added frame skip to Animation.update. If it gets too far behind it will now skip frames to try and catch up. + +Version 1.0.5 (September 20th 2013) + +* Fixed issue in FrameData.getFrameIndexes where the input array was being ignored. +* Added Math.numberArray - Returns an Array containing the numbers from min to max (inclusive), useful for animation frame construction. +* Fixed a horrendously sneaky bug: If a new tween was created in the onComplete callback of a tween about to be deleted, it would get automatically spliced. +* Added a pendingDelete property to Tween to stop tweens that were removed during a callback from causing update errors during the TweenManager loop. +* Added Group.length property. +* Added explicit x/y attributes to Phaser.Text to make it work with the camera system (thanks cocoademon). +* Fixed issue stopping multiple animations from playing, only the most recent would play (frames array was being overwritten, thanks Legrandk) +* Updated Debug.renderSpriteBounds() so it doesn't use the deprecated Sprite.worldView any more (thanks MikeMnD) +* Added 2 new properties to the Text object: Text.text and Text.style, both are getter/setters and don't flag dirty unless changed, so safe for core loop use. +* Removed the exists check from Group.callAll, it now runs on all children (as the name implies) +* Added Group.callAllExists - you can now call a function on all children who have exists = the provided boolean. +* Finished off the Breakout example game - now fully playable, proper rebound, scoring, lives, etc. +* Removed Group.sort dummy entry until it's working. +* Removed ArcadePhysics.postUpdate. +* Updated Sprite.update to set renderable to false when the object goes out of Camera, not 'visible' false, otherwise it stops the transform being updated by Pixi. +* BUG: There is a known issue where the wrong rect coordinates are given to the QuadTree if the Sprite is a child of a Group or another Sprite which has an x/y offset. + +Version 1.0.4 (September 18th 2013) + +* Small fix to Phaser.Canvas to stop it from setting overflow hidden if the parent DOM element doesn't exist. +* Added Loader.setPreloadSprite(sprite, direction) - this will automatically apply a crop rect to the Sprite which is updated in line with the load progress. +* A lot of changes inside the StateManager. State functions are now passed through link() which automatically creates the key Game properties (load, input, etc) +* Fixed a bug in getFrameByName that wouldn't return the first frame in the array. +* Updated Phaser.Rectangle.intersects to use x and y instead of left and top so it can be used to check Physics bodies overlapping. +* Fixed issue in Cache where the Frame index wasn't being set correctly (thanks Cameron) +* Fixed issue in Sprite where boundsY wasn't set (thanks Cameron) +* For some reason there were 2 copies of the Canvas class in the build file - fixed, a few KB saved :) + +Version 1.0.3 (September 17th 2013) + +* FrameData.getFrameIndexes and getFrameIndexesByName refactored into a more versatile getFrames function. +* Various fixes to looping parameters in the Sound system. +* Documentation started across most classes. Keep track of progress in the Docs folder. +* Optimised AnimationManager.add so it will only get the required frames rather than all of them and is now faster at parsing the frame data. +* Fixed Phaser.Text and Phaser.BitmapText so they now render correctly and added several Text examples. + +Version 1.0.2 (September 16th 2013) + +* Added optional parameter to Animation.stop: resetFrame. If true the animation will be stopped and then the current frame reset to the first frame in the animation. +* Fixed an issue causing 'explode' particle bursts to ignore the quantity parameter. +* Added 'collideWorldBounds' to Emitter.makeParticles function. +* Added Emitter.angularDrag +* Changed Emitter.bounce from a number to a Point, so now set its x/y properties to control different amounts of bounce per axis. +* Fixed a bug in the AnimationManager where useNumericIndex was always set to true +* Added in lots of Particle examples +* Added in the start of a Breakout game +* Added in the start of a Platformer game + +Version 1.0.1 (September 15th 2013) + +* Added checks into every Group function to ensure that the Group has children before running them. +* Added optional flag to Group.create which allows you to set the default exists state of the Sprites. +* Sprite.animation.stop no longer needs an animation name parameter, will default to stopping the current animation. +* Fixed the license in package.json +* Fixed a logic bug in the separateTileX function that would sometimes cause tunneling of big sprites through small tiles. + +Version 0.9.8 * Massive refactoring across the entire codebase. * Removed Basic and GameObject and put Sprite on a diet. 127 properties and methods cut down to 32. @@ -109,7 +183,7 @@ V0.9.8 * Added CanvasUtils class, including ability to set image rendering, add a canvas to the dom and other handy things. -V0.9.6 +Version 0.9.6 * Virtually every class now has documentation - if you spot a typo or something missing please shout (thanks pixelpicosean). * Grunt file updated to produce the new Special FX JS file (thanks HackManiac). @@ -197,7 +271,7 @@ V0.9.6 * Added the GameObjectFactory to Phaser.State * Added new format parameter to Loader.addTextureAtlas defining the format. Currently supported: JSON Array and Starling/Sparrow XML. -V0.9.5 +Version 0.9.5 * Moved the BootScreen and PauseScreen out of Stage into their own classes (system/screens/BootScreen and PauseScreen). * Updated the PauseScreen to show a subtle animation effect, making it easier to create your own interesting pause screens. @@ -231,7 +305,7 @@ V0.9.5 * Added fun new "map draw" test - rebound those carrots! :) * Changed SoundManager class to respect volume on first play (thanks initials and hackmaniac) -V0.9.4 +Version 0.9.4 * Added Tilemap.getTile, getTileFromWorldXY, getTileFromInputXY * Added Tilemap.setCollisionByIndex and setCollisionByRange @@ -261,7 +335,7 @@ V0.9.3 * Removed the need for DynamicTextures to require a key property and updated test cases. * You can now pass an array or a single value to Input.Keyboard.addKeyCapture(). -V0.9.2 +Version 0.9.2 * Fixed issue with create not being called if there was an empty init method. * Added ability to flip a sprite (Sprite.flipped = true) + a test case for it. @@ -269,7 +343,7 @@ V0.9.2 * Sprite animations don't restart if you call play on them when they are already running. * Added Stage.disablePauseScreen. Set to true to stop your game pausing when the tab loses focus. -V0.9.1 +Version 0.9.1 * Added the new align property to GameObjects that controls placement when rendering. * Added an align example to the Sprites test group (click the mouse to change alignment position) @@ -279,7 +353,7 @@ for new collision system. * Game.Input now has 2 signals you can subscribe to for down/up events, see the Sprite align example for use. * Updated the States examples to bring in-line with 0.9 release. -V0.9 +Version 0.9 * Large refactoring. Everything now lives inside the Phaser module, so all code and all tests have been updated to reflect this. Makes coding a tiny bit more verbose but stops the framework from globbing up the global namespace. Also should make code-insight work in WebStorm and similar editors. * Added the new GeomSprite object. This is a sprite that uses a geometry class for display (Circle, Rectangle, Point, Line). It's extremely flexible! @@ -290,27 +364,27 @@ V0.9 * Added new Motion class which contains lots of handy functions like 'moveTowardsObject', 'velocityFromAngle' and more. * Tween Manager added. You can now create tweens via Game.createTween (or for more control game.tweens). All the usual suspects are here: Bounce, * Elastic, Quintic, etc and it's hooked into the core game clock, so if your game pauses and resumes your tweens adjust accordingly. -V0.8 +Version 0.8 * Added ability to set Sprite frame by name (sprite.frameName), useful when you've loaded a Texture Atlas with filename values set rather than using frame indexes. * Updated texture atlas 4 demo to show this. * Fixed a bug that would cause a run-time error if you tried to create a sprite using an invalid texture key. * Added in DynamicTexture support and a test case for it. -V0.7 +Version 0.7 * Renamed FullScreen to StageScaleMode as it's much more fitting. Tested across Android and iOS with the various scale modes. * Added in world x/y coordinates to the input class, and the ability to get world x/y input coordinates from any Camera. * Added the RandomDataGenerator for seeded random number generation. * Setting the game world size now resizes the default camera (optional bool flag) -V0.6 +Version 0.6 * Added in Touch support for mobile devices (and desktops that enable it) and populated x/y coords in Input with common values from touch and mouse. * Added new Circle geometry class (used by Touch) and moved them into a Geom folder. * Added in Device class for device inspection. * Added FullScreen class to enable full-screen support on mobile devices (scrolls URL bar out of the way on iOS and Android) -V0.5 +Version 0.5 * Initial release diff --git a/docs/Animation.js.html b/docs/Animation.js.html new file mode 100644 index 00000000..eb175def --- /dev/null +++ b/docs/Animation.js.html @@ -0,0 +1,907 @@ + + + + + + Phaser Source: animation/Animation.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: animation/Animation.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* An Animation instance contains a single animation and the controls to play it.
    +* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
    +*
    +* @class Phaser.Animation
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +* @param {Phaser.Sprite} parent - A reference to the owner of this Animation.
    +* @param {string} name - The unique name for this animation, used in playback commands.
    +* @param {Phaser.FrameData} frameData - The FrameData object that contains all frames used by this Animation.
    +* @param {(Array.<number>|Array.<string>)} frames - An array of numbers or strings indicating which frames to play in which order.
    +* @param {number} delay - The time between each frame of the animation, given in ms.
    +* @param {boolean} looped - Should this animation loop or play through once.
    +*/
    +Phaser.Animation = function (game, parent, name, frameData, frames, delay, looped) {
    +
    +    /**
    +    * @property {Phaser.Game} game - A reference to the currently running Game.
    +    */
    +	this.game = game;
    +
    +    /**
    +    * @property {Phaser.Sprite} _parent - A reference to the parent Sprite that owns this Animation.
    +    * @private
    +    */
    +	this._parent = parent;
    +
    +    /**
    +    * @property {Phaser.FrameData} _frameData - The FrameData the Animation uses.
    +    * @private
    +    */
    +    this._frameData = frameData;
    +
    +    /**
    +    * @property {string} name - The user defined name given to this Animation.
    +    */
    +    this.name = name;
    +
    +    /**
    +    * @property {object} _frames
    +    * @private
    +    */
    +	this._frames = [];
    +    this._frames = this._frames.concat(frames);
    +
    +    /**
    +    * @property {number} delay - The delay in ms between each frame of the Animation.
    +    */
    +	this.delay = 1000 / delay;
    +
    +    /**
    +    * @property {boolean} looped - The loop state of the Animation.
    +    */
    +	this.looped = looped;
    +
    +    /**
    +    * @property {boolean} looped - The loop state of the Animation.
    +    */
    +    this.killOnComplete = false;
    +
    +    /**
    +    * @property {boolean} isFinished - The finished state of the Animation. Set to true once playback completes, false during playback.
    +    * @default
    +    */
    +	this.isFinished = false;
    +
    +    /**
    +    * @property {boolean} isPlaying - The playing state of the Animation. Set to false once playback completes, true during playback.
    +    * @default
    +    */
    +	this.isPlaying = false;
    +
    +    /**
    +    * @property {boolean} isPaused - The paused state of the Animation.
    +    * @default
    +    */
    +    this.isPaused = false;
    +
    +    /**
    +    * @property {boolean} _pauseStartTime - The time the animation paused.
    +    * @private
    +    * @default
    +    */
    +    this._pauseStartTime = 0;
    +
    +    /**
    +    * @property {number} _frameIndex
    +    * @private
    +    * @default
    +    */
    +	this._frameIndex = 0;
    +
    +    /**
    +    * @property {number} _frameDiff
    +    * @private
    +    * @default
    +    */
    +    this._frameDiff = 0;
    +
    +    /**
    +    * @property {number} _frameSkip
    +    * @private
    +    * @default
    +    */
    +    this._frameSkip = 1;
    +
    +    /**
    +    * @property {Phaser.Frame} currentFrame - The currently displayed frame of the Animation.
    +    */
    +	this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
    +	
    +};
    +
    +Phaser.Animation.prototype = {
    +
    +    /**
    +    * Plays this animation.
    +    *
    +    * @method Phaser.Animation#play
    +    * @memberof Phaser.Animation
    +    * @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
    +    * @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
    +    * @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed.
    +    * @return {Phaser.Animation} - A reference to this Animation instance.
    +    */
    +    play: function (frameRate, loop, killOnComplete) {
    +
    +        if (typeof frameRate === 'number')
    +        {
    +            //  If they set a new frame rate then use it, otherwise use the one set on creation
    +            this.delay = 1000 / frameRate;
    +        }
    +
    +        if (typeof loop === 'boolean')
    +        {
    +            //  If they set a new loop value then use it, otherwise use the one set on creation
    +            this.looped = loop;
    +        }
    +
    +        if (typeof killOnComplete !== 'undefined')
    +        {
    +            //  Remove the parent sprite once the animation has finished?
    +            this.killOnComplete = killOnComplete;
    +        }
    +
    +        this.isPlaying = true;
    +        this.isFinished = false;
    +
    +        this._timeLastFrame = this.game.time.now;
    +        this._timeNextFrame = this.game.time.now + this.delay;
    +
    +        this._frameIndex = 0;
    +
    +        this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
    +		this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
    +
    +        if (this._parent.events)
    +        {
    +            this._parent.events.onAnimationStart.dispatch(this._parent, this);
    +        }
    +
    +        return this;
    +
    +    },
    +
    +    /**
    +    * Sets this animation back to the first frame and restarts the animation.
    +    *
    +    * @method Phaser.Animation#restart
    +    * @memberof Phaser.Animation
    +    */
    +    restart: function () {
    +
    +        this.isPlaying = true;
    +        this.isFinished = false;
    +
    +        this._timeLastFrame = this.game.time.now;
    +        this._timeNextFrame = this.game.time.now + this.delay;
    +
    +        this._frameIndex = 0;
    +
    +        this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
    +
    +    },
    +
    +    /**
    +    * Stops playback of this animation and set it to a finished state. If a resetFrame is provided it will stop playback and set frame to the first in the animation.
    +    *
    +    * @method Phaser.Animation#stop
    +    * @memberof Phaser.Animation
    +    * @param {boolean} [resetFrame=false] - If true after the animation stops the currentFrame value will be set to the first frame in this animation.
    +    */
    +    stop: function (resetFrame) {
    +
    +        if (typeof resetFrame === 'undefined') { resetFrame = false; }
    +
    +        this.isPlaying = false;
    +        this.isFinished = true;
    +
    +        if (resetFrame)
    +        {
    +            this.currentFrame = this._frameData.getFrame(this._frames[0]);
    +        }
    +
    +    },
    +
    +    /**
    +    * Updates this animation. Called automatically by the AnimationManager.
    +    *
    +    * @method Phaser.Animation#update
    +    * @memberof Phaser.Animation
    +    */
    +    update: function () {
    +
    +        if (this.isPaused)
    +        {
    +            return false;
    +        }
    +
    +        if (this.isPlaying == true && this.game.time.now >= this._timeNextFrame)
    +        {
    +            this._frameSkip = 1;
    +
    +            //  Lagging?
    +            this._frameDiff = this.game.time.now - this._timeNextFrame;
    +
    +            this._timeLastFrame = this.game.time.now;
    +
    +            if (this._frameDiff > this.delay)
    +            {
    +                //  We need to skip a frame, work out how many
    +                this._frameSkip = Math.floor(this._frameDiff / this.delay);
    +
    +                this._frameDiff -= (this._frameSkip * this.delay);
    +            }
    +
    +            //  And what's left now?
    +            this._timeNextFrame = this.game.time.now + (this.delay - this._frameDiff);
    +
    +            this._frameIndex += this._frameSkip;
    +
    +            if (this._frameIndex >= this._frames.length)
    +            {
    +                if (this.looped)
    +                {
    +                    this._frameIndex %= this._frames.length;
    +                    this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
    +
    +                    if (this.currentFrame)
    +                    {
    +                        this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
    +                    }
    +                    
    +                    this._parent.events.onAnimationLoop.dispatch(this._parent, this);
    +                }
    +                else
    +                {
    +                    this.onComplete();
    +                }
    +            }
    +            else
    +            {
    +                this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
    +				this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
    +            }
    +
    +            return true;
    +        }
    +
    +        return false;
    +
    +    },
    +
    +    /**
    +    * Cleans up this animation ready for deletion. Nulls all values and references.
    +    *
    +    * @method Phaser.Animation#destroy
    +    * @memberof Phaser.Animation
    +    */
    +    destroy: function () {
    +
    +        this.game = null;
    +        this._parent = null;
    +        this._frames = null;
    +        this._frameData = null;
    +        this.currentFrame = null;
    +        this.isPlaying = false;
    +
    +    },
    +
    +    /**
    +    * Called internally when the animation finishes playback. Sets the isPlaying and isFinished states and dispatches the onAnimationComplete event if it exists on the parent.
    +    *
    +    * @method Phaser.Animation#onComplete
    +    * @memberof Phaser.Animation
    +    */
    +    onComplete: function () {
    +
    +        this.isPlaying = false;
    +        this.isFinished = true;
    +
    +        if (this._parent.events)
    +        {
    +            this._parent.events.onAnimationComplete.dispatch(this._parent, this);
    +        }
    +
    +        if (this.killOnComplete)
    +        {
    +            this._parent.kill();
    +        }
    +
    +    }
    +
    +};
    +
    +/**
    +* @name Phaser.Animation#paused
    +* @property {boolean} paused - Gets and sets the paused state of this Animation.
    +*/
    +Object.defineProperty(Phaser.Animation.prototype, "paused", {
    +
    +    get: function () {
    +
    +        return this.isPaused;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        this.isPaused = value;
    +
    +        if (value)
    +        {
    +            //  Paused
    +            this._pauseStartTime = this.game.time.now;
    +        }
    +        else
    +        {
    +            //  Un-paused
    +            if (this.isPlaying)
    +            {
    +                this._timeNextFrame = this.game.time.now + this.delay;
    +            }
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Animation#frameTotal
    +* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Animation.prototype, "frameTotal", {
    +
    +    get: function () {
    +        return this._frames.length;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Animation#frame
    +* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display.
    +*/
    +Object.defineProperty(Phaser.Animation.prototype, "frame", {
    +
    +    get: function () {
    +
    +        if (this.currentFrame !== null)
    +        {
    +            return this.currentFrame.index;
    +        }
    +        else
    +        {
    +            return this._frameIndex;
    +        }
    +
    +    },
    +
    +    set: function (value) {
    +
    +        this.currentFrame = this._frameData.getFrame(value);
    +
    +        if (this.currentFrame !== null)
    +        {
    +            this._frameIndex = value;
    +			this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* Really handy function for when you are creating arrays of animation data but it's using frame names and not numbers.
    +* For example imagine you've got 30 frames named: 'explosion_0001-large' to 'explosion_0030-large'
    +* You could use this function to generate those by doing: Phaser.Animation.generateFrameNames('explosion_', 1, 30, '-large', 4);
    +*
    +* @method Phaser.Animation.generateFrameNames
    +* @param {string} prefix - The start of the filename. If the filename was 'explosion_0001-large' the prefix would be 'explosion_'.
    +* @param {number} start - The number to start sequentially counting from. If your frames are named 'explosion_0001' to 'explosion_0034' the start is 1.
    +* @param {number} stop - The number to count to. If your frames are named 'explosion_0001' to 'explosion_0034' the stop value is 34.
    +* @param {string} [suffix=''] - The end of the filename. If the filename was 'explosion_0001-large' the prefix would be '-large'.
    +* @param {number} [zeroPad=0] - The number of zeroes to pad the min and max values with. If your frames are named 'explosion_0001' to 'explosion_0034' then the zeroPad is 4.
    +*/
    +Phaser.Animation.generateFrameNames = function (prefix, start, stop, suffix, zeroPad) {
    +
    +    if (typeof suffix == 'undefined') { suffix = ''; }
    +
    +    var output = [];
    +    var frame = '';
    +
    +    if (start < stop)
    +    {
    +        for (var i = start; i <= stop; i++)
    +        {
    +            if (typeof zeroPad == 'number')
    +            {
    +                //  str, len, pad, dir
    +                frame = Phaser.Utils.pad(i.toString(), zeroPad, '0', 1);
    +            }
    +            else
    +            {
    +                frame = i.toString();
    +            }
    +
    +            frame = prefix + frame + suffix;
    +
    +            output.push(frame);
    +        }
    +    }
    +    else
    +    {
    +        for (var i = start; i >= stop; i--)
    +        {
    +            if (typeof zeroPad == 'number')
    +            {
    +                //  str, len, pad, dir
    +                frame = Phaser.Utils.pad(i.toString(), zeroPad, '0', 1);
    +            }
    +            else
    +            {
    +                frame = i.toString();
    +            }
    +
    +            frame = prefix + frame + suffix;
    +
    +            output.push(frame);
    +        }
    +    }
    +
    +    return output;
    +
    +}
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/AnimationManager.js.html b/docs/AnimationManager.js.html new file mode 100644 index 00000000..f7d9a825 --- /dev/null +++ b/docs/AnimationManager.js.html @@ -0,0 +1,849 @@ + + + + + + Phaser Source: animation/AnimationManager.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: animation/AnimationManager.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* The Animation Manager is used to add, play and update Phaser Animations.
    +* Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance.
    +*
    +* @class Phaser.AnimationManager
    +* @constructor
    +* @param {Phaser.Sprite} sprite - A reference to the Game Object that owns this AnimationManager.
    +*/
    +Phaser.AnimationManager = function (sprite) {
    +
    +    /**
    +    * @property {Phaser.Sprite} sprite - A reference to the parent Sprite that owns this AnimationManager.
    +    */
    +	this.sprite = sprite;
    +
    +    /**
    +    * @property {Phaser.Game} game - A reference to the currently running Game.
    +    */
    +	this.game = sprite.game;
    +
    +	/**
    +	* @property {Phaser.Frame} currentFrame - The currently displayed Frame of animation, if any.
    +	* @default
    +	*/
    +	this.currentFrame = null;
    +	
    +	/**
    +	* @property {boolean} updateIfVisible - Should the animation data continue to update even if the Sprite.visible is set to false.
    +	* @default
    +	*/
    +	this.updateIfVisible = true;
    +
    +	/**
    +	* @property {boolean} isLoaded - Set to true once animation data has been loaded.
    +	* @default
    +	*/
    +	this.isLoaded = false;
    +
    +	/**
    +	* @property {Phaser.FrameData} _frameData - A temp. var for holding the currently playing Animations FrameData.
    +	* @private
    +	* @default
    +	*/
    +	this._frameData = null;
    +
    +	/**
    +	* @property {object} _anims - An internal object that stores all of the Animation instances.
    +	* @private
    +	*/   
    +	this._anims = {};
    +
    +	/**
    +	* @property {object} _outputFrames - An internal object to help avoid gc.
    +	* @private
    +	*/
    +	this._outputFrames = [];
    +
    +};
    +
    +Phaser.AnimationManager.prototype = {
    +
    +    /**
    +    * Loads FrameData into the internal temporary vars and resets the frame index to zero.
    +    * This is called automatically when a new Sprite is created.
    +    *
    +    * @method Phaser.AnimationManager#loadFrameData
    +    * @private
    +    * @param {Phaser.FrameData} frameData - The FrameData set to load.
    +    */
    +	loadFrameData: function (frameData) {
    +
    +		this._frameData = frameData;
    +		this.frame = 0;
    +		this.isLoaded = true;
    +
    +	},
    +
    +	/**
    +	* Adds a new animation under the given key. Optionally set the frames, frame rate and loop.
    +	* Animations added in this way are played back with the play function.
    +	*
    +    * @method Phaser.AnimationManager#add
    +	* @param {string} name - The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk".
    +	* @param {Array} [frames=null] - An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used.
    +	* @param {number} [frameRate=60] - The speed at which the animation should play. The speed is given in frames per second.
    +	* @param {boolean} [loop=false] - Whether or not the animation is looped or just plays once.
    +	* @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings?
    +	* @return {Phaser.Animation} The Animation object that was created.
    +	*/
    +	add: function (name, frames, frameRate, loop, useNumericIndex) {
    +
    +		if (this._frameData == null)
    +		{
    +			console.warn('No FrameData available for Phaser.Animation ' + name);
    +			return;
    +		}
    +
    +		frameRate = frameRate || 60;
    +
    +		if (typeof loop === 'undefined') { loop = false; }
    +
    +		//	If they didn't set the useNumericIndex then let's at least try and guess it
    +		if (typeof useNumericIndex === 'undefined')
    +		{
    +			if (frames && typeof frames[0] === 'number')
    +			{
    +				useNumericIndex = true;
    +			}
    +			else
    +			{
    +				useNumericIndex = false;
    +			}
    +		}
    +
    +		//  Create the signals the AnimationManager will emit
    +		if (this.sprite.events.onAnimationStart == null)
    +		{
    +			this.sprite.events.onAnimationStart = new Phaser.Signal();
    +			this.sprite.events.onAnimationComplete = new Phaser.Signal();
    +			this.sprite.events.onAnimationLoop = new Phaser.Signal();
    +		}
    +
    +    	this._outputFrames.length = 0;
    +
    +		this._frameData.getFrameIndexes(frames, useNumericIndex, this._outputFrames);
    +
    +		this._anims[name] = new Phaser.Animation(this.game, this.sprite, name, this._frameData, this._outputFrames, frameRate, loop);
    +		this.currentAnim = this._anims[name];
    +		this.currentFrame = this.currentAnim.currentFrame;
    +		this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
    +
    +		return this._anims[name];
    +
    +	},
    +
    +	/**
    +	* Check whether the frames in the given array are valid and exist.
    +	*
    +    * @method Phaser.AnimationManager#validateFrames
    +	* @param {Array} frames - An array of frames to be validated.
    +	* @param {boolean} [useNumericIndex=true] - Validate the frames based on their numeric index (true) or string index (false)
    +	* @return {boolean} True if all given Frames are valid, otherwise false.
    +	*/
    +	validateFrames: function (frames, useNumericIndex) {
    +
    +		if (typeof useNumericIndex == 'undefined') { useNumericIndex = true; }
    +
    +		for (var i = 0; i < frames.length; i++)
    +		{
    +			if (useNumericIndex == true)
    +			{
    +				if (frames[i] > this._frameData.total)
    +				{
    +					return false;
    +				}
    +			}
    +			else
    +			{
    +				if (this._frameData.checkFrameName(frames[i]) == false)
    +				{
    +					return false;
    +				}
    +			}
    +		}
    +
    +		return true;
    +
    +	},
    +
    +	/**
    +	* Play an animation based on the given key. The animation should previously have been added via sprite.animations.add()
    +	* If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself.
    +	* 
    +	* @method Phaser.AnimationManager#play
    +	* @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump".
    +    * @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
    +    * @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
    +    * @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed.
    +    * @return {Phaser.Animation} A reference to playing Animation instance.
    +	*/
    +	play: function (name, frameRate, loop, killOnComplete) {
    +
    +		if (this._anims[name])
    +		{
    +			if (this.currentAnim == this._anims[name])
    +			{
    +				if (this.currentAnim.isPlaying == false)
    +				{
    +					return this.currentAnim.play(frameRate, loop, killOnComplete);
    +				}
    +			}
    +			else
    +			{
    +				this.currentAnim = this._anims[name];
    +				return this.currentAnim.play(frameRate, loop, killOnComplete);
    +			}
    +		}
    +
    +	},
    +
    +	/**
    +	* Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the current animation is stopped.
    +	* The currentAnim property of the AnimationManager is automatically set to the animation given.
    +	*
    +	* @method Phaser.AnimationManager#stop
    +	* @param {string} [name=null] - The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped.
    +	* @param {boolean} [resetFrame=false] - When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false)
    +	*/
    +	stop: function (name, resetFrame) {
    +
    +		if (typeof resetFrame == 'undefined') { resetFrame = false; }
    +
    +		if (typeof name == 'string')
    +		{
    +			if (this._anims[name])
    +			{
    +				this.currentAnim = this._anims[name];
    +				this.currentAnim.stop(resetFrame);
    +			}
    +		}
    +		else
    +		{
    +			if (this.currentAnim)
    +			{
    +				this.currentAnim.stop(resetFrame);
    +			}
    +		}
    +
    +	},
    +
    +	/**
    +	* The main update function is called by the Sprites update loop. It's responsible for updating animation frames and firing related events.
    +	* 
    +	* @method Phaser.AnimationManager#update
    +	* @protected
    +    * @return {boolean} True if a new animation frame has been set, otherwise false.
    +	*/
    +	update: function () {
    +
    +		if (this.updateIfVisible && this.sprite.visible == false)
    +		{
    +			return false;
    +		}
    +
    +		if (this.currentAnim && this.currentAnim.update() == true)
    +		{
    +			this.currentFrame = this.currentAnim.currentFrame;
    +			this.sprite.currentFrame = this.currentFrame;
    +			return true;
    +		}
    +
    +		return false;
    +
    +	},
    +
    +    /**
    +    * Refreshes the current frame data back to the parent Sprite and also resets the texture data.
    +    *
    +    * @method Phaser.AnimationManager#refreshFrame
    +    */
    +	refreshFrame: function () {
    +
    +        this.sprite.currentFrame = this.currentFrame;
    +		this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
    +
    +	},
    +
    +    /**
    +    * Destroys all references this AnimationManager contains. Sets the _anims to a new object and nulls the current animation.
    +    *
    +    * @method Phaser.AnimationManager#destroy
    +    */
    +    destroy: function () {
    +
    +        this._anims = {};
    +        this._frameData = null;
    +        this._frameIndex = 0;
    +        this.currentAnim = null;
    +        this.currentFrame = null;
    +
    +    }
    +
    +};
    +
    +/**
    +* @name Phaser.AnimationManager#frameData
    +* @property {Phaser.FrameData} frameData - The current animations FrameData.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", {
    +
    +    get: function () {
    +        return this._frameData;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.AnimationManager#frameTotal
    +* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", {
    + 
    +    get: function () {
    +
    +        if (this._frameData)
    +        {
    +            return this._frameData.total;
    +        }
    +        else
    +        {
    +            return -1;
    +        }
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.AnimationManager#paused
    +* @property {boolean} paused - Gets and sets the paused state of the current animation.
    +*/
    +Object.defineProperty(Phaser.AnimationManager.prototype, "paused", {
    +
    +    get: function () {
    +
    +        return this.currentAnim.isPaused;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        this.currentAnim.paused = value;
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.AnimationManager#frame
    +* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display.
    +*/
    +Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
    +
    +    get: function () {
    +
    +    	if (this.currentFrame)
    +    	{
    +	        return this._frameIndex;
    +	    }
    +	    
    +    },
    +
    +    set: function (value) {
    +
    +        if (typeof value === 'number' && this._frameData && this._frameData.getFrame(value) !== null)
    +        {
    +            this.currentFrame = this._frameData.getFrame(value);
    +            this._frameIndex = value;
    +            this.sprite.currentFrame = this.currentFrame;
    +			this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.AnimationManager#frameName
    +* @property {string} frameName - Gets or sets the current frame name and updates the Texture Cache for display.
    +*/
    +Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
    +
    +    get: function () {
    +
    +    	if (this.currentFrame)
    +    	{
    +	        return this.currentFrame.name;
    +    	}
    +
    +    },
    +
    +    set: function (value) {
    +
    +        if (typeof value === 'string' && this._frameData && this._frameData.getFrameByName(value) !== null)
    +        {
    +            this.currentFrame = this._frameData.getFrameByName(value);
    +            this._frameIndex = this.currentFrame.index;
    +            this.sprite.currentFrame = this.currentFrame;
    +			this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
    +        }
    +        else
    +        {
    +            console.warn("Cannot set frameName: " + value);
    +        }
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/AnimationParser.js.html b/docs/AnimationParser.js.html new file mode 100644 index 00000000..d52e7908 --- /dev/null +++ b/docs/AnimationParser.js.html @@ -0,0 +1,763 @@ + + + + + + Phaser Source: animation/AnimationParser.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: animation/AnimationParser.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations.
    +*
    +* @class Phaser.AnimationParser
    +*/
    +Phaser.AnimationParser = {
    +
    +    /**
    +    * Parse a Sprite Sheet and extract the animation frame data from it.
    +    *
    +    * @method Phaser.AnimationParser.spriteSheet
    +    * @param {Phaser.Game} game - A reference to the currently running game.
    +    * @param {string} key - The Game.Cache asset key of the Sprite Sheet image.
    +    * @param {number} frameWidth - The fixed width of each frame of the animation.
    +    * @param {number} frameHeight - The fixed height of each frame of the animation.
    +    * @param {number} [frameMax=-1] - The total number of animation frames to extact from the Sprite Sheet. The default value of -1 means "extract all frames".
    +    * @return {Phaser.FrameData} A FrameData object containing the parsed frames.
    +    */
    +    spriteSheet: function (game, key, frameWidth, frameHeight, frameMax) {
    +
    +        //  How big is our image?
    +        var img = game.cache.getImage(key);
    +
    +        if (img == null)
    +        {
    +            return null;
    +        }
    +
    +        var width = img.width;
    +        var height = img.height;
    +
    +        if (frameWidth <= 0)
    +        {
    +            frameWidth = Math.floor(-width / Math.min(-1, frameWidth));
    +        }
    +
    +        if (frameHeight <= 0)
    +        {
    +            frameHeight = Math.floor(-height / Math.min(-1, frameHeight));
    +        }
    +
    +        var row = Math.round(width / frameWidth);
    +        var column = Math.round(height / frameHeight);
    +        var total = row * column;
    +        
    +        if (frameMax !== -1)
    +        {
    +            total = frameMax;
    +        }
    +
    +        //  Zero or smaller than frame sizes?
    +        if (width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0)
    +        {
    +            console.warn("Phaser.AnimationParser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight");
    +            return null;
    +        }
    +
    +        //  Let's create some frames then
    +        var data = new Phaser.FrameData();
    +        var x = 0;
    +        var y = 0;
    +
    +        for (var i = 0; i < total; i++)
    +        {
    +            var uuid = game.rnd.uuid();
    +
    +            data.addFrame(new Phaser.Frame(i, x, y, frameWidth, frameHeight, '', uuid));
    +
    +            PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[key], {
    +                x: x,
    +                y: y,
    +                width: frameWidth,
    +                height: frameHeight
    +            });
    +
    +            x += frameWidth;
    +
    +            if (x === width)
    +            {
    +                x = 0;
    +                y += frameHeight;
    +            }
    +        }
    +
    +        return data;
    +
    +    },
    +
    +    /**
    +    * Parse the JSON data and extract the animation frame data from it.
    +    *
    +    * @method Phaser.AnimationParser.JSONData
    +    * @param {Phaser.Game} game - A reference to the currently running game.
    +    * @param {Object} json - The JSON data from the Texture Atlas. Must be in Array format.
    +    * @param {string} cacheKey - The Game.Cache asset key of the texture image.
    +    * @return {Phaser.FrameData} A FrameData object containing the parsed frames.
    +    */
    +    JSONData: function (game, json, cacheKey) {
    +
    +        //  Malformed?
    +        if (!json['frames'])
    +        {
    +            console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array");
    +            console.log(json);
    +            return;
    +        }
    +
    +        //  Let's create some frames then
    +        var data = new Phaser.FrameData();
    +        
    +        //  By this stage frames is a fully parsed array
    +        var frames = json['frames'];
    +        var newFrame;
    +        
    +        for (var i = 0; i < frames.length; i++)
    +        {
    +            var uuid = game.rnd.uuid();
    +
    +            newFrame = data.addFrame(new Phaser.Frame(
    +                i,
    +            	frames[i].frame.x, 
    +            	frames[i].frame.y, 
    +            	frames[i].frame.w, 
    +            	frames[i].frame.h, 
    +            	frames[i].filename,
    +                uuid
    +			));
    +
    +            PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[cacheKey], {
    +                x: frames[i].frame.x,
    +                y: frames[i].frame.y,
    +                width: frames[i].frame.w,
    +                height: frames[i].frame.h
    +            });
    +
    +            if (frames[i].trimmed)
    +            {
    +                newFrame.setTrim(
    +                    frames[i].trimmed, 
    +                    frames[i].sourceSize.w, 
    +                    frames[i].sourceSize.h, 
    +                    frames[i].spriteSourceSize.x, 
    +                    frames[i].spriteSourceSize.y, 
    +                    frames[i].spriteSourceSize.w, 
    +                    frames[i].spriteSourceSize.h
    +                );
    +
    +                //  We had to hack Pixi to get this to work :(
    +                PIXI.TextureCache[uuid].trimmed = true;
    +                PIXI.TextureCache[uuid].trim.x = frames[i].spriteSourceSize.x;
    +                PIXI.TextureCache[uuid].trim.y = frames[i].spriteSourceSize.y;
    +
    +            }
    +        }
    +
    +        return data;
    +
    +    },
    +
    +    /**
    +    * Parse the JSON data and extract the animation frame data from it.
    +    *
    +    * @method Phaser.AnimationParser.JSONDataHash
    +    * @param {Phaser.Game} game - A reference to the currently running game.
    +    * @param {Object} json - The JSON data from the Texture Atlas. Must be in JSON Hash format.
    +    * @param {string} cacheKey - The Game.Cache asset key of the texture image.
    +    * @return {Phaser.FrameData} A FrameData object containing the parsed frames.
    +    */
    +    JSONDataHash: function (game, json, cacheKey) {
    +
    +        //  Malformed?
    +        if (!json['frames'])
    +        {
    +            console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object");
    +            console.log(json);
    +            return;
    +        }
    +            
    +        //  Let's create some frames then
    +        var data = new Phaser.FrameData();
    +
    +        //  By this stage frames is a fully parsed array
    +        var frames = json['frames'];
    +        var newFrame;
    +        var i = 0;
    +        
    +        for (var key in frames)
    +        {
    +            var uuid = game.rnd.uuid();
    +
    +            newFrame = data.addFrame(new Phaser.Frame(
    +                i,
    +                frames[key].frame.x, 
    +                frames[key].frame.y, 
    +                frames[key].frame.w, 
    +                frames[key].frame.h, 
    +                key,
    +                uuid
    +            ));
    +
    +            PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[cacheKey], {
    +                x: frames[key].frame.x,
    +                y: frames[key].frame.y,
    +                width: frames[key].frame.w,
    +                height: frames[key].frame.h
    +            });
    +
    +            if (frames[key].trimmed)
    +            {
    +                newFrame.setTrim(
    +                    frames[key].trimmed, 
    +                    frames[key].sourceSize.w, 
    +                    frames[key].sourceSize.h, 
    +                    frames[key].spriteSourceSize.x, 
    +                    frames[key].spriteSourceSize.y, 
    +                    frames[key].spriteSourceSize.w, 
    +                    frames[key].spriteSourceSize.h
    +                );
    +
    +                //  We had to hack Pixi to get this to work :(
    +                PIXI.TextureCache[uuid].trimmed = true;
    +                PIXI.TextureCache[uuid].trim.x = frames[key].spriteSourceSize.x;
    +                PIXI.TextureCache[uuid].trim.y = frames[key].spriteSourceSize.y;
    +
    +            }
    +
    +            i++;
    +        }
    +
    +        return data;
    +
    +    },
    +
    +    /**
    +    * Parse the XML data and extract the animation frame data from it.
    +    *
    +    * @method Phaser.AnimationParser.XMLData
    +    * @param {Phaser.Game} game - A reference to the currently running game.
    +    * @param {Object} xml - The XML data from the Texture Atlas. Must be in Starling XML format.
    +    * @param {string} cacheKey - The Game.Cache asset key of the texture image.
    +    * @return {Phaser.FrameData} A FrameData object containing the parsed frames.
    +    */
    +    XMLData: function (game, xml, cacheKey) {
    +
    +        //  Malformed?
    +        if (!xml.getElementsByTagName('TextureAtlas'))
    +        {
    +            console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing <TextureAtlas> tag");
    +            return;
    +        }
    +
    +        //  Let's create some frames then
    +        var data = new Phaser.FrameData();
    +        var frames = xml.getElementsByTagName('SubTexture');
    +        var newFrame;
    +        
    +        for (var i = 0; i < frames.length; i++)
    +        {
    +            var uuid = game.rnd.uuid();
    +
    +            var frame = frames[i].attributes;
    +
    +            newFrame = data.addFrame(new Phaser.Frame(
    +                i,
    +            	frame.x.nodeValue, 
    +            	frame.y.nodeValue, 
    +            	frame.width.nodeValue, 
    +            	frame.height.nodeValue, 
    +            	frame.name.nodeValue,
    +                uuid
    +            ));
    +
    +            PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[cacheKey], {
    +                x: frame.x.nodeValue,
    +                y: frame.y.nodeValue,
    +                width: frame.width.nodeValue,
    +                height: frame.height.nodeValue
    +            });
    +
    +            //  Trimmed?
    +            if (frame.frameX.nodeValue != '-0' || frame.frameY.nodeValue != '-0')
    +            {
    +                newFrame.setTrim(
    +                	true, 
    +                	frame.width.nodeValue, 
    +                	frame.height.nodeValue, 
    +                	Math.abs(frame.frameX.nodeValue), 
    +                	Math.abs(frame.frameY.nodeValue), 
    +                	frame.frameWidth.nodeValue, 
    +                	frame.frameHeight.nodeValue
    +                );
    +
    +                PIXI.TextureCache[uuid].realSize = {
    +                    x: Math.abs(frame.frameX.nodeValue),
    +                    y: Math.abs(frame.frameY.nodeValue),
    +                    w: frame.frameWidth.nodeValue,
    +                    h: frame.frameHeight.nodeValue
    +                };
    +
    +                //  We had to hack Pixi to get this to work :(
    +                PIXI.TextureCache[uuid].trimmed = true;
    +                PIXI.TextureCache[uuid].trim.x = Math.abs(frame.frameX.nodeValue);
    +                PIXI.TextureCache[uuid].trim.y = Math.abs(frame.frameY.nodeValue);
    +
    +            }
    +        }
    +
    +        return data;
    +
    +    }
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/ArcadePhysics.js.html b/docs/ArcadePhysics.js.html new file mode 100644 index 00000000..ded02953 --- /dev/null +++ b/docs/ArcadePhysics.js.html @@ -0,0 +1,1815 @@ + + + + + + Phaser Source: physics/arcade/ArcadePhysics.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: physics/arcade/ArcadePhysics.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* @class Phaser.Physics
    +*/
    +Phaser.Physics = {};
    +
    +/**
    +* Arcade Physics constructor.
    +*
    +* @class Phaser.Physics.Arcade
    +* @classdesc Arcade Physics Constructor
    +* @constructor
    +* @param {Phaser.Game} game reference to the current game instance.
    +*/
    +Phaser.Physics.Arcade = function (game) {
    +    
    +    /**
    +    * @property {Phaser.Game} game - Local reference to game.
    +    */
    +    this.game = game;
    +
    +    /**
    +    * @property {Phaser.Point} gravity - The World gravity setting. Defaults to x: 0, y: 0, or no gravity.
    +    */
    +    this.gravity = new Phaser.Point;
    +
    +    /**
    +    * @property {Phaser.Rectangle} bounds - The bounds inside of which the physics world exists. Defaults to match the world bounds.
    +    */
    +    this.bounds = new Phaser.Rectangle(0, 0, game.world.width, game.world.height);
    +
    +    /**
    +    * @property {number} maxObjects - Used by the QuadTree to set the maximum number of objects per quad.
    +    */
    +    this.maxObjects = 10;
    +
    +    /**
    +    * @property {number} maxLevels - Used by the QuadTree to set the maximum number of iteration levels.
    +    */
    +    this.maxLevels = 4;
    +
    +    /**
    +    * @property {number} OVERLAP_BIAS - A value added to the delta values during collision checks.
    +    */
    +    this.OVERLAP_BIAS = 4;
    +
    +    /**
    +    * @property {Phaser.QuadTree} quadTree - The world QuadTree.
    +    */
    +    this.quadTree = new Phaser.QuadTree(this, this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels);
    +
    +    /**
    +    * @property {number} quadTreeID - The QuadTree ID.
    +    */
    +    this.quadTreeID = 0;
    +
    +    //  Avoid gc spikes by caching these values for re-use
    +
    +    /**
    +    * @property {Phaser.Rectangle} _bounds1 - Internal cache var.
    +    * @private
    +    */
    +    this._bounds1 = new Phaser.Rectangle;
    +
    +    /**
    +    * @property {Phaser.Rectangle} _bounds2 - Internal cache var.
    +    * @private
    +    */
    +    this._bounds2 = new Phaser.Rectangle;
    +
    +    /**
    +    * @property {number} _overlap - Internal cache var.
    +    * @private
    +    */
    +    this._overlap = 0;
    +
    +    /**
    +    * @property {number} _maxOverlap - Internal cache var.
    +    * @private
    +    */
    +    this._maxOverlap = 0;
    +
    +    /**
    +    * @property {number} _velocity1 - Internal cache var.
    +    * @private
    +    */
    +    this._velocity1 = 0;
    +
    +    /**
    +    * @property {number} _velocity2 - Internal cache var.
    +    * @private
    +    */
    +    this._velocity2 = 0;
    +
    +    /**
    +    * @property {number} _newVelocity1 - Internal cache var.
    +    * @private
    +    */
    +    this._newVelocity1 = 0;
    +
    +    /**
    +    * @property {number} _newVelocity2 - Internal cache var.
    +    * @private
    +    */
    +    this._newVelocity2 = 0;
    +
    +    /**
    +    * @property {number} _average - Internal cache var.
    +    * @private
    +    */
    +    this._average = 0;
    +
    +    /**
    +    * @property {Array} _mapData - Internal cache var.
    +    * @private
    +    */
    +    this._mapData = [];
    +
    +    /**
    +    * @property {number} _mapTiles - Internal cache var.
    +    * @private
    +    */
    +    this._mapTiles = 0;
    +
    +    /**
    +    * @property {boolean} _result - Internal cache var.
    +    * @private
    +    */
    +    this._result = false;
    +
    +    /**
    +    * @property {number} _total - Internal cache var.
    +    * @private
    +    */
    +    this._total = 0;
    +
    +    /**
    +    * @property {number} _angle - Internal cache var.
    +    * @private
    +    */
    +    this._angle = 0;
    +
    +    /**
    +    * @property {number} _dx - Internal cache var.
    +    * @private
    +    */
    +    this._dx = 0;
    +
    +    /**
    +    * @property {number} _dy - Internal cache var.
    +    * @private
    +    */
    +    this._dy = 0;
    +
    +};
    +
    +Phaser.Physics.Arcade.prototype = {
    +
    +    /**
    +    * Called automatically by a Physics body, it updates all motion related values on the Body.
    +    *
    +    * @method Phaser.Physics.Arcade#updateMotion
    +    * @param {Phaser.Physics.Arcade.Body} The Body object to be updated.
    +    */
    +    updateMotion: function (body) {
    +
    +        //  If you're wondering why the velocity is halved and applied twice, read this: http://www.niksula.hut.fi/~hkankaan/Homepages/gravity.html
    +
    +        //  Rotation
    +        this._velocityDelta = (this.computeVelocity(0, body, body.angularVelocity, body.angularAcceleration, body.angularDrag, body.maxAngular) - body.angularVelocity) / 2;
    +        body.angularVelocity += this._velocityDelta;
    +        body.rotation += (body.angularVelocity * this.game.time.physicsElapsed);
    +        body.angularVelocity += this._velocityDelta;
    +
    +        //  Horizontal
    +        this._velocityDelta = (this.computeVelocity(1, body, body.velocity.x, body.acceleration.x, body.drag.x, body.maxVelocity.x) - body.velocity.x) / 2;
    +        body.velocity.x += this._velocityDelta;
    +        body.x += (body.velocity.x * this.game.time.physicsElapsed);
    +        body.velocity.x += this._velocityDelta;
    +
    +        //  Vertical
    +        this._velocityDelta = (this.computeVelocity(2, body, body.velocity.y, body.acceleration.y, body.drag.y, body.maxVelocity.y) - body.velocity.y) / 2;
    +        body.velocity.y += this._velocityDelta;
    +        body.y += (body.velocity.y * this.game.time.physicsElapsed);
    +        body.velocity.y += this._velocityDelta;
    +
    +    },
    +
    +    /**
    +    * A tween-like function that takes a starting velocity and some other factors and returns an altered velocity.
    +    *
    +    * @method Phaser.Physics.Arcade#computeVelocity
    +    * @param {number} axis - 1 for horizontal, 2 for vertical.
    +    * @param {Phaser.Physics.Arcade.Body} body - The Body object to be updated.
    +    * @param {number} velocity - Any component of velocity (e.g. 20).
    +    * @param {number} acceleration - Rate at which the velocity is changing.
    +    * @param {number} drag - Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set.
    +    * @param {number} mMax - An absolute value cap for the velocity.
    +    * @return {number} The altered Velocity value.
    +    */
    +    computeVelocity: function (axis, body, velocity, acceleration, drag, max) {
    +
    +        max = max || 10000;
    +
    +        if (axis == 1 && body.allowGravity)
    +        {
    +            velocity += this.gravity.x + body.gravity.x;
    +        }
    +        else if (axis == 2 && body.allowGravity)
    +        {
    +            velocity += this.gravity.y + body.gravity.y;
    +        }
    +
    +        if (acceleration !== 0)
    +        {
    +            velocity += acceleration * this.game.time.physicsElapsed;
    +        }
    +        else if (drag !== 0)
    +        {
    +            this._drag = drag * this.game.time.physicsElapsed;
    +
    +            if (velocity - this._drag > 0)
    +            {
    +                velocity -= this._drag;
    +            }
    +            else if (velocity + this._drag < 0)
    +            {
    +                velocity += this._drag;
    +            }
    +            else
    +            {
    +                velocity = 0;
    +            }
    +        }
    +
    +        if (velocity > max)
    +        {
    +            velocity = max;
    +        }
    +        else if (velocity < -max)
    +        {
    +            velocity = -max;
    +        }
    +
    +        return velocity;
    +
    +    },
    +
    +    /**
    +    * Called automatically by the core game loop.
    +    *
    +    * @method Phaser.Physics.Arcade#preUpdate
    +    * @protected
    +    */
    +    preUpdate: function () {
    +
    +        //  Clear the tree
    +        this.quadTree.clear();
    +
    +        //  Create our tree which all of the Physics bodies will add themselves to
    +        this.quadTreeID = 0;
    +        this.quadTree = new Phaser.QuadTree(this, this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels);
    +
    +    },
    +
    +    /**
    +    * Called automatically by the core game loop.
    +    *
    +    * @method Phaser.Physics.Arcade#postUpdate
    +    * @protected
    +    */
    +    postUpdate: function () {
    +
    +        //  Clear the tree ready for the next update
    +        this.quadTree.clear();
    +
    +    },
    +
    +    /**
    +    * Checks if two Sprite objects overlap.
    +    *
    +    * @method Phaser.Physics.Arcade#overlap
    +    * @param {Phaser.Sprite} object1 - The first object to check. Can be an instance of Phaser.Sprite or anything that extends it.
    +    * @param {Phaser.Sprite} object2 - The second object to check. Can be an instance of Phaser.Sprite or anything that extends it.
    +    * @returns {boolean} true if the two objects overlap.
    +    */
    +    overlap: function (object1, object2) {
    +
    +        //  Only test valid objects
    +        if (object1 && object2 && object1.exists && object2.exists)
    +        {
    +            return (Phaser.Rectangle.intersects(object1.body, object2.body));
    +        }
    +
    +        return false;
    +
    +    },
    +
    +    /**
    +    * Checks for collision between two game objects. The objects can be Sprites, Groups, Emitters or Tilemaps.
    +    * You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap or Group vs. Tilemap collisions.
    +    * The objects are also automatically separated.
    +    *
    +    * @method Phaser.Physics.Arcade#collide
    +    * @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object1 - The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.Tilemap
    +    * @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object2 - The second object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.Tilemap
    +    * @param {function} [collideCallback=null] - 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 passed them to Collision.overlap.
    +    * @param {function} [processCallback=null] - A 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 processCallback returns true.
    +    * @param {object} [callbackContext] - The context in which to run the callbacks.
    +    * @returns {number} The number of collisions that were processed.
    +    */
    +    collide: function (object1, object2, collideCallback, processCallback, callbackContext) {
    +
    +        collideCallback = collideCallback || null;
    +        processCallback = processCallback || null;
    +        callbackContext = callbackContext || collideCallback;
    +
    +        this._result = false;
    +        this._total = 0;
    +
    +        //  Only collide valid objects
    +        if (object1 && object2 && object1.exists && object2.exists)
    +        {
    +            //  Can expand to support Buttons, Text, etc at a later date. For now these are the essentials.
    +
    +            //  SPRITES
    +            if (object1.type == Phaser.SPRITE)
    +            {
    +                if (object2.type == Phaser.SPRITE)
    +                {
    +                    this.collideSpriteVsSprite(object1, object2, collideCallback, processCallback, callbackContext);
    +                }
    +                else if (object2.type == Phaser.GROUP || object2.type == Phaser.EMITTER)
    +                {
    +                    this.collideSpriteVsGroup(object1, object2, collideCallback, processCallback, callbackContext);
    +                }
    +                else if (object2.type == Phaser.TILEMAPLAYER)
    +                {
    +                    this.collideSpriteVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext);
    +                }
    +            }
    +            //  GROUPS
    +            else if (object1.type == Phaser.GROUP)
    +            {
    +                if (object2.type == Phaser.SPRITE)
    +                {
    +                    this.collideSpriteVsGroup(object2, object1, collideCallback, processCallback, callbackContext);
    +                }
    +                else if (object2.type == Phaser.GROUP || object2.type == Phaser.EMITTER)
    +                {
    +                    this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext);
    +                }
    +                else if (object2.type == Phaser.TILEMAPLAYER)
    +                {
    +                    this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext);
    +                }
    +            }
    +            //  TILEMAP LAYERS
    +            else if (object1.type == Phaser.TILEMAPLAYER)
    +            {
    +                if (object2.type == Phaser.SPRITE)
    +                {
    +                    this.collideSpriteVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext);
    +                }
    +                else if (object2.type == Phaser.GROUP || object2.type == Phaser.EMITTER)
    +                {
    +                    this.collideGroupVsTilemapLayer(object2, object1, collideCallback, processCallback, callbackContext);
    +                }
    +            }
    +            //  EMITTER
    +            else if (object1.type == Phaser.EMITTER)
    +            {
    +                if (object2.type == Phaser.SPRITE)
    +                {
    +                    this.collideSpriteVsGroup(object2, object1, collideCallback, processCallback, callbackContext);
    +                }
    +                else if (object2.type == Phaser.GROUP || object2.type == Phaser.EMITTER)
    +                {
    +                    this.collideGroupVsGroup(object1, object2, collideCallback, processCallback, callbackContext);
    +                }
    +                else if (object2.type == Phaser.TILEMAPLAYER)
    +                {
    +                    this.collideGroupVsTilemapLayer(object1, object2, collideCallback, processCallback, callbackContext);
    +                }
    +            }
    +        }
    +
    +        return (this._total > 0);
    +
    +    },
    +
    +    /**
    +    * An internal function. Use Phaser.Physics.Arcade.collide instead.
    +    *
    +    * @method Phaser.Physics.Arcade#collideSpriteVsTilemapLayer
    +    * @private
    +    */
    +    collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext) {
    +
    +        this._mapData = tilemapLayer.getTiles(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height, true);
    +
    +        if (this._mapData.length > 1)
    +        {
    +            for (var i = 1; i < this._mapData.length; i++)
    +            {
    +                this.separateTile(sprite.body, this._mapData[i]);
    +
    +                if (this._result)
    +                {
    +                    //  They collided, is there a custom process callback?
    +                    if (processCallback)
    +                    {
    +                        if (processCallback.call(callbackContext, sprite, this._mapData[i]))
    +                        {
    +                            this._total++;
    +
    +                            if (collideCallback)
    +                            {
    +                                collideCallback.call(callbackContext, sprite, this._mapData[i]);
    +                            }
    +                        }
    +                    }
    +                    else
    +                    {
    +                        this._total++;
    +
    +                        if (collideCallback)
    +                        {
    +                            collideCallback.call(callbackContext, sprite, this._mapData[i]);
    +                        }
    +                    }
    +                }
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * An internal function. Use Phaser.Physics.Arcade.collide instead.
    +    *
    +    * @method Phaser.Physics.Arcade#collideGroupVsTilemapLayer
    +    * @private
    +    */
    +    collideGroupVsTilemapLayer: function (group, tilemapLayer, collideCallback, processCallback, callbackContext) {
    +
    +        if (group.length == 0)
    +        {
    +            return;
    +        }
    +
    +        if (group._container.first._iNext)
    +        {
    +            var currentNode = group._container.first._iNext;
    +                
    +            do  
    +            {
    +                if (currentNode.exists)
    +                {
    +                    this.collideSpriteVsTilemapLayer(currentNode, tilemapLayer, collideCallback, processCallback, callbackContext);
    +                }
    +                currentNode = currentNode._iNext;
    +            }
    +            while (currentNode != group._container.last._iNext);
    +        }
    +
    +    },
    +
    +    /**
    +    * An internal function. Use Phaser.Physics.Arcade.collide instead.
    +    *
    +    * @method Phaser.Physics.Arcade#collideSpriteVsSprite
    +    * @private
    +    */
    +    collideSpriteVsSprite: function (sprite1, sprite2, collideCallback, processCallback, callbackContext) {
    +
    +        this.separate(sprite1.body, sprite2.body);
    +
    +        if (this._result)
    +        {
    +            //  They collided, is there a custom process callback?
    +            if (processCallback)
    +            {
    +                if (processCallback.call(callbackContext, sprite1, sprite2))
    +                {
    +                    this._total++;
    +
    +                    if (collideCallback)
    +                    {
    +                        collideCallback.call(callbackContext, sprite1, sprite2);
    +                    }
    +                }
    +            }
    +            else
    +            {
    +                this._total++;
    +
    +                if (collideCallback)
    +                {
    +                    collideCallback.call(callbackContext, sprite1, sprite2);
    +                }
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * An internal function. Use Phaser.Physics.Arcade.collide instead.
    +    *
    +    * @method Phaser.Physics.Arcade#collideSpriteVsGroup
    +    * @private
    +    */
    +    collideSpriteVsGroup: function (sprite, group, collideCallback, processCallback, callbackContext) {
    +
    +        if (group.length == 0)
    +        {
    +            return;
    +        }
    +
    +        //  What is the sprite colliding with in the quadtree?
    +        this._potentials = this.quadTree.retrieve(sprite);
    +
    +        for (var i = 0, len = this._potentials.length; i < len; i++)
    +        {
    +            //  We have our potential suspects, are they in this group?
    +            if (this._potentials[i].sprite.group == group)
    +            {
    +                this.separate(sprite.body, this._potentials[i]);
    +
    +                if (this._result && processCallback)
    +                {
    +                    this._result = processCallback.call(callbackContext, sprite, this._potentials[i].sprite);
    +                }
    +
    +                if (this._result)
    +                {
    +                    this._total++;
    +
    +                    if (collideCallback)
    +                    {
    +                        collideCallback.call(callbackContext, sprite, this._potentials[i].sprite);
    +                    }
    +                }
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * An internal function. Use Phaser.Physics.Arcade.collide instead.
    +    *
    +    * @method Phaser.Physics.Arcade#collideGroupVsGroup
    +    * @private
    +    */
    +    collideGroupVsGroup: function (group1, group2, collideCallback, processCallback, callbackContext) {
    +
    +        if (group1.length == 0 || group2.length == 0)
    +        {
    +            return;
    +        }
    +
    +        if (group1._container.first._iNext)
    +        {
    +            var currentNode = group1._container.first._iNext;
    +                
    +            do  
    +            {
    +                if (currentNode.exists)
    +                {
    +                    this.collideSpriteVsGroup(currentNode, group2, collideCallback, processCallback, callbackContext);
    +                }
    +                currentNode = currentNode._iNext;
    +            }
    +            while (currentNode != group1._container.last._iNext);
    +        }
    +
    +    },
    +
    +    /**
    +    * The core separation function to separate two physics bodies.
    +    * @method Phaser.Physics.Arcade#separate
    +    * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate.
    +    * @param {Phaser.Physics.Arcade.Body} body2 - The Body object to separate.
    +    * @returns {boolean} Returns true if the bodies were separated, otherwise false.
    +    */
    +    separate: function (body1, body2) {
    +
    +        this._result = (this.separateX(body1, body2) || this.separateY(body1, body2));
    +
    +    },
    +
    +    /**
    +    * The core separation function to separate two physics bodies on the x axis.
    +    * @method Phaser.Physics.Arcade#separateX
    +    * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate.
    +    * @param {Phaser.Physics.Arcade.Body} body2 - The Body object to separate.
    +    * @returns {boolean} Returns true if the bodies were separated, otherwise false.
    +    */
    +    separateX: function (body1, body2) {
    +
    +        //  Can't separate two immovable bodies
    +        if (body1.immovable && body2.immovable)
    +        {
    +            return false;
    +        }
    +
    +        this._overlap = 0;
    +
    +        //  Check if the hulls actually overlap
    +        if (Phaser.Rectangle.intersects(body1, body2))
    +        {
    +            this._maxOverlap = body1.deltaAbsX() + body2.deltaAbsX() + this.OVERLAP_BIAS;
    +
    +            if (body1.deltaX() == 0 && body2.deltaX() == 0)
    +            {
    +                //  They overlap but neither of them are moving
    +                body1.embedded = true;
    +                body2.embedded = true;
    +            }
    +            else if (body1.deltaX() > body2.deltaX())
    +            {
    +                //  Body1 is moving right and/or Body2 is moving left
    +                this._overlap = body1.x + body1.width - body2.x;
    +
    +                if ((this._overlap > this._maxOverlap) || body1.allowCollision.right == false || body2.allowCollision.left == false)
    +                {
    +                    this._overlap = 0;
    +                }
    +                else
    +                {
    +                    body1.touching.right = true;
    +                    body2.touching.left = true;
    +                }
    +            }
    +            else if (body1.deltaX() < body2.deltaX())
    +            {
    +                //  Body1 is moving left and/or Body2 is moving right
    +                this._overlap = body1.x - body2.width - body2.x;
    +
    +                if ((-this._overlap > this._maxOverlap) || body1.allowCollision.left == false || body2.allowCollision.right == false)
    +                {
    +                    this._overlap = 0;
    +                }
    +                else
    +                {
    +                    body1.touching.left = true;
    +                    body2.touching.right = true;
    +                }
    +            }
    +
    +            //  Then adjust their positions and velocities accordingly (if there was any overlap)
    +            if (this._overlap != 0)
    +            {
    +                body1.overlapX = this._overlap;
    +                body2.overlapX = this._overlap;
    +
    +                if (body1.customSeparateX || body2.customSeparateX)
    +                {
    +                    return true;
    +                }
    +
    +                this._velocity1 = body1.velocity.x;
    +                this._velocity2 = body2.velocity.x;
    +
    +                if (!body1.immovable && !body2.immovable)
    +                {
    +                    this._overlap *= 0.5;
    +
    +                    body1.x = body1.x - this._overlap;
    +                    body2.x += this._overlap;
    +
    +                    this._newVelocity1 = Math.sqrt((this._velocity2 * this._velocity2 * body2.mass) / body1.mass) * ((this._velocity2 > 0) ? 1 : -1);
    +                    this._newVelocity2 = Math.sqrt((this._velocity1 * this._velocity1 * body1.mass) / body2.mass) * ((this._velocity1 > 0) ? 1 : -1);
    +                    this._average = (this._newVelocity1 + this._newVelocity2) * 0.5;
    +                    this._newVelocity1 -= this._average;
    +                    this._newVelocity2 -= this._average;
    +
    +                    body1.velocity.x = this._average + this._newVelocity1 * body1.bounce.x;
    +                    body2.velocity.x = this._average + this._newVelocity2 * body2.bounce.x;
    +                }
    +                else if (!body1.immovable)
    +                {
    +                    body1.x = body1.x - this._overlap;
    +                    body1.velocity.x = this._velocity2 - this._velocity1 * body1.bounce.x;
    +                }
    +                else if (!body2.immovable)
    +                {
    +                    body2.x += this._overlap;
    +                    body2.velocity.x = this._velocity1 - this._velocity2 * body2.bounce.x;
    +                }
    +
    +                return true;
    +            }
    +        }
    +
    +        return false;
    +
    +    },
    +
    +    /**
    +    * The core separation function to separate two physics bodies on the y axis.
    +    * @method Phaser.Physics.Arcade#separateY
    +    * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate.
    +    * @param {Phaser.Physics.Arcade.Body} body2 - The Body object to separate.
    +    * @returns {boolean} Returns true if the bodies were separated, otherwise false.
    +    */
    +    separateY: function (body1, body2) {
    +
    +        //  Can't separate two immovable or non-existing bodys
    +        if (body1.immovable && body2.immovable)
    +        {
    +            return false;
    +        }
    +
    +        this._overlap = 0;
    +
    +        //  Check if the hulls actually overlap
    +        if (Phaser.Rectangle.intersects(body1, body2))
    +        {
    +            this._maxOverlap = body1.deltaAbsY() + body2.deltaAbsY() + this.OVERLAP_BIAS;
    +
    +            if (body1.deltaY() == 0 && body2.deltaY() == 0)
    +            {
    +                //  They overlap but neither of them are moving
    +                body1.embedded = true;
    +                body2.embedded = true;
    +            }
    +            else if (body1.deltaY() > body2.deltaY())
    +            {
    +                //  Body1 is moving down and/or Body2 is moving up
    +                this._overlap = body1.y + body1.height - body2.y;
    +
    +                if ((this._overlap > this._maxOverlap) || body1.allowCollision.down == false || body2.allowCollision.up == false)
    +                {
    +                    this._overlap = 0;
    +                }
    +                else
    +                {
    +                    body1.touching.down = true;
    +                    body2.touching.up = true;
    +                }
    +            }
    +            else if (body1.deltaY() < body2.deltaY())
    +            {
    +                //  Body1 is moving up and/or Body2 is moving down
    +                this._overlap = body1.y - body2.height - body2.y;
    +
    +                if ((-this._overlap > this._maxOverlap) || body1.allowCollision.up == false || body2.allowCollision.down == false)
    +                {
    +                    this._overlap = 0;
    +                }
    +                else
    +                {
    +                    body1.touching.up = true;
    +                    body2.touching.down = true;
    +                }
    +            }
    +
    +            //  Then adjust their positions and velocities accordingly (if there was any overlap)
    +            if (this._overlap != 0)
    +            {
    +                body1.overlapY = this._overlap;
    +                body2.overlapY = this._overlap;
    +
    +                if (body1.customSeparateY || body2.customSeparateY)
    +                {
    +                    return true;
    +                }
    +
    +                this._velocity1 = body1.velocity.y;
    +                this._velocity2 = body2.velocity.y;
    +
    +                if (!body1.immovable && !body2.immovable)
    +                {
    +                    this._overlap *= 0.5;
    +
    +                    body1.y = body1.y - this._overlap;
    +                    body2.y += this._overlap;
    +
    +                    this._newVelocity1 = Math.sqrt((this._velocity2 * this._velocity2 * body2.mass) / body1.mass) * ((this._velocity2 > 0) ? 1 : -1);
    +                    this._newVelocity2 = Math.sqrt((this._velocity1 * this._velocity1 * body1.mass) / body2.mass) * ((this._velocity1 > 0) ? 1 : -1);
    +                    this._average = (this._newVelocity1 + this._newVelocity2) * 0.5;
    +                    this._newVelocity1 -= this._average;
    +                    this._newVelocity2 -= this._average;
    +
    +                    body1.velocity.y = this._average + this._newVelocity1 * body1.bounce.y;
    +                    body2.velocity.y = this._average + this._newVelocity2 * body2.bounce.y;
    +                }
    +                else if (!body1.immovable)
    +                {
    +                    body1.y = body1.y - this._overlap;
    +                    body1.velocity.y = this._velocity2 - this._velocity1 * body1.bounce.y;
    +
    +                    //  This is special case code that handles things like horizontal moving platforms you can ride
    +                    if (body2.active && body2.moves && (body1.deltaY() > body2.deltaY()))
    +                    {
    +                        body1.x += body2.x - body2.lastX;
    +                    }
    +                }
    +                else if (!body2.immovable)
    +                {
    +                    body2.y += this._overlap;
    +                    body2.velocity.y = this._velocity1 - this._velocity2 * body2.bounce.y;
    +
    +                    //  This is special case code that handles things like horizontal moving platforms you can ride
    +                    if (body1.sprite.active && body1.moves && (body1.deltaY() < body2.deltaY()))
    +                    {
    +                        body2.x += body1.x - body1.lastX;
    +                    }
    +                }
    +
    +                return true;
    +            }
    +
    +        }
    +
    +        return false;
    +
    +    },
    +
    +    /**
    +    * The core separation function to separate a physics body and a tile.
    +    * @method Phaser.Physics.Arcade#separateTile
    +    * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate.
    +    * @param {Phaser.Tile} tile - The tile to collide against.
    +    * @returns {boolean} Returns true if the bodies were separated, otherwise false.
    +    */
    +    separateTile: function (body, tile) {
    +
    +        this._result = (this.separateTileX(body, tile, true) || this.separateTileY(body, tile, true));
    +
    +    },
    +
    +    /**
    +    * The core separation function to separate a physics body and a tile on the x axis.
    +    * @method Phaser.Physics.Arcade#separateTileX
    +    * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate.
    +    * @param {Phaser.Tile} tile - The tile to collide against.
    +    * @returns {boolean} Returns true if the bodies were separated, otherwise false.
    +    */
    +    separateTileX: function (body, tile, separate) {
    +
    +        //  Can't separate two immovable objects (tiles are always immovable)
    +        if (body.immovable || body.deltaX() == 0 || Phaser.Rectangle.intersects(body.hullX, tile) == false)
    +        {
    +            return false;
    +        }
    +
    +        this._overlap = 0;
    +
    +        //  The hulls overlap, let's process it
    +        this._maxOverlap = body.deltaAbsX() + this.OVERLAP_BIAS;
    +
    +        if (body.deltaX() < 0)
    +        {
    +            //  Moving left
    +            this._overlap = tile.right - body.hullX.x;
    +
    +            if ((this._overlap > this._maxOverlap) || body.allowCollision.left == false || tile.tile.collideRight == false)
    +            {
    +                this._overlap = 0;
    +            }
    +            else
    +            {
    +                body.touching.left = true;
    +            }
    +        }
    +        else
    +        {
    +            //  Moving right
    +            this._overlap = body.hullX.right - tile.x;
    +
    +            if ((this._overlap > this._maxOverlap) || body.allowCollision.right == false || tile.tile.collideLeft == false)
    +            {
    +                this._overlap = 0;
    +            }
    +            else
    +            {
    +                body.touching.right = true;
    +            }
    +        }
    +
    +        //  Then adjust their positions and velocities accordingly (if there was any overlap)
    +        if (this._overlap != 0)
    +        {
    +            if (separate)
    +            {
    +                if (body.deltaX() < 0)
    +                {
    +                    body.x = body.x + this._overlap;
    +                }
    +                else
    +                {
    +                    body.x = body.x - this._overlap;
    +                }
    +
    +                if (body.bounce.x == 0)
    +                {
    +                    body.velocity.x = 0;
    +                }
    +                else
    +                {
    +                    body.velocity.x = -body.velocity.x * body.bounce.x;
    +                }
    +
    +                body.updateHulls();
    +            }
    +
    +            return true;
    +        }
    +        else
    +        {
    +            return false;
    +        }
    +
    +    },
    +
    +    /**
    +    * The core separation function to separate a physics body and a tile on the x axis.
    +    * @method Phaser.Physics.Arcade#separateTileY
    +    * @param {Phaser.Physics.Arcade.Body} body1 - The Body object to separate.
    +    * @param {Phaser.Tile} tile - The tile to collide against.
    +    * @returns {boolean} Returns true if the bodies were separated, otherwise false.
    +    */
    +    separateTileY: function (body, tile, separate) {
    +
    +        //  Can't separate two immovable objects (tiles are always immovable)
    +        if (body.immovable || body.deltaY() == 0 || Phaser.Rectangle.intersects(body.hullY, tile) == false)
    +        {
    +            return false;
    +        }
    +
    +        this._overlap = 0;
    +
    +        //  The hulls overlap, let's process it
    +        this._maxOverlap = body.deltaAbsY() + this.OVERLAP_BIAS;
    +
    +        if (body.deltaY() < 0)
    +        {
    +            //  Moving up
    +            this._overlap = tile.bottom - body.hullY.y;
    +
    +            if ((this._overlap > this._maxOverlap) || body.allowCollision.up == false || tile.tile.collideDown == false)
    +            {
    +                this._overlap = 0;
    +            }
    +            else
    +            {
    +                body.touching.up = true;
    +            }
    +        }
    +        else
    +        {
    +            //  Moving down
    +            this._overlap = body.hullY.bottom - tile.y;
    +
    +            if ((this._overlap > this._maxOverlap) || body.allowCollision.down == false || tile.tile.collideUp == false)
    +            {
    +                this._overlap = 0;
    +            }
    +            else
    +            {
    +                body.touching.down = true;
    +            }
    +        }
    +
    +        //  Then adjust their positions and velocities accordingly (if there was any overlap)
    +        if (this._overlap != 0)
    +        {
    +            if (separate)
    +            {
    +                if (body.deltaY() < 0)
    +                {
    +                    body.y = body.y + this._overlap;
    +                }
    +                else
    +                {
    +                    body.y = body.y - this._overlap;
    +                }
    +
    +                if (body.bounce.y == 0)
    +                {
    +                    body.velocity.y = 0;
    +                }
    +                else
    +                {
    +                    body.velocity.y = -body.velocity.y * body.bounce.y;
    +                }
    +
    +                body.updateHulls();
    +            }
    +            
    +            return true;
    +        }
    +        else
    +        {
    +            return false;
    +        }
    +
    +    },
    +
    +    /**
    +    * Move the given display object towards the destination object at a steady velocity.
    +    * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
    +    * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms.
    +    * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course.
    +    * Note: The display object doesn't stop moving once it reaches the destination coordinates.
    +    * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all)
    +    * 
    +    * @method Phaser.Physics.Arcade#moveToObject
    +    * @param {any} displayObject - The display object to move.
    +    * @param {any} destination - The display object to move towards. Can be any object but must have visible x/y properties.
    +    * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec)
    +    * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms.
    +    * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity.
    +    */
    +    moveToObject: function (displayObject, destination, speed, maxTime) {
    +
    +        speed = speed || 60;
    +        maxTime = maxTime || 0;
    +
    +        this._angle = Math.atan2(destination.y - displayObject.y, destination.x - displayObject.x);
    +        
    +        if (maxTime > 0)
    +        {
    +            //  We know how many pixels we need to move, but how fast?
    +            speed = this.distanceBetween(displayObject, destination) / (maxTime / 1000);
    +        }
    +        
    +        displayObject.body.velocity.x = Math.cos(this._angle) * speed;
    +        displayObject.body.velocity.y = Math.sin(this._angle) * speed;
    +
    +        return this._angle;
    +
    +    },
    +
    +    /**
    +    * Move the given display object towards the pointer at a steady velocity. If no pointer is given it will use Phaser.Input.activePointer.
    +    * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
    +    * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms.
    +    * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course.
    +    * Note: The display object doesn't stop moving once it reaches the destination coordinates.
    +    * 
    +    * @method Phaser.Physics.Arcade#moveToPointer
    +    * @param {any} displayObject - The display object to move.
    +    * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec)
    +    * @param {Phaser.Pointer} [pointer] - The pointer to move towards. Defaults to Phaser.Input.activePointer.
    +    * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms.
    +    * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity.
    +    */
    +    moveToPointer: function (displayObject, speed, pointer, maxTime) {
    +
    +        speed = speed || 60;
    +        pointer = pointer || this.game.input.activePointer;
    +        maxTime = maxTime || 0;
    +
    +        this._angle = this.angleToPointer(displayObject, pointer);
    +        
    +        if (maxTime > 0)
    +        {
    +            //  We know how many pixels we need to move, but how fast?
    +            speed = this.distanceToPointer(displayObject, pointer) / (maxTime / 1000);
    +        }
    +        
    +        displayObject.body.velocity.x = Math.cos(this._angle) * speed;
    +        displayObject.body.velocity.y = Math.sin(this._angle) * speed;
    +
    +        return this._angle;
    +
    +    },
    +
    +    /**
    +    * Move the given display object towards the x/y coordinates at a steady velocity.
    +    * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
    +    * Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms.
    +    * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course.
    +    * Note: The display object doesn't stop moving once it reaches the destination coordinates.
    +    * Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all)
    +    * 
    +    * @method Phaser.Physics.Arcade#moveToXY
    +    * @param {any} displayObject - The display object to move.
    +    * @param {number} x - The x coordinate to move towards.
    +    * @param {number} y - The y coordinate to move towards.
    +    * @param {number} [speed=60] - The speed it will move, in pixels per second (default is 60 pixels/sec)
    +    * @param {number} [maxTime=0] - Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms.
    +    * @return {number} The angle (in radians) that the object should be visually set to in order to match its new velocity.
    +    */
    +    moveToXY: function (displayObject, x, y, speed, maxTime) {
    +
    +        speed = speed || 60;
    +        maxTime = maxTime || 0;
    +
    +        this._angle = Math.atan2(y - displayObject.y, x - displayObject.x);
    +        
    +        if (maxTime > 0)
    +        {
    +            //  We know how many pixels we need to move, but how fast?
    +            speed = this.distanceToXY(displayObject, x, y) / (maxTime / 1000);
    +        }
    +        
    +        displayObject.body.velocity.x = Math.cos(this._angle) * speed;
    +        displayObject.body.velocity.y = Math.sin(this._angle) * speed;
    +
    +        return this._angle;
    +
    +    },
    +
    +    /**
    +    * Given the angle (in degrees) and speed calculate the velocity and return it as a Point object, or set it to the given point object.
    +    * One way to use this is: velocityFromAngle(angle, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object.
    +    * 
    +    * @method Phaser.Physics.Arcade#velocityFromAngle
    +    * @param {number} angle - The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
    +    * @param {number} [speed=60] - The speed it will move, in pixels per second sq.
    +    * @param {Phaser.Point|object} [point] - The Point object in which the x and y properties will be set to the calculated velocity.
    +    * @return {Phaser.Point} - A Point where point.x contains the velocity x value and point.y contains the velocity y value.
    +    */
    +    velocityFromAngle: function (angle, speed, point) {
    +
    +        speed = speed || 60;
    +        point = point || new Phaser.Point;
    +
    +        return point.setTo((Math.cos(this.game.math.degToRad(angle)) * speed), (Math.sin(this.game.math.degToRad(angle)) * speed));
    +
    +    },
    +
    +    /**
    +    * Given the rotation (in radians) and speed calculate the velocity and return it as a Point object, or set it to the given point object.
    +    * One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object.
    +    * 
    +    * @method Phaser.Physics.Arcade#velocityFromRotation
    +    * @param {number} rotation - The angle in radians.
    +    * @param {number} [speed=60] - The speed it will move, in pixels per second sq.
    +    * @param {Phaser.Point|object} [point] - The Point object in which the x and y properties will be set to the calculated velocity.
    +    * @return {Phaser.Point} - A Point where point.x contains the velocity x value and point.y contains the velocity y value.
    +    */
    +    velocityFromRotation: function (rotation, speed, point) {
    +
    +        speed = speed || 60;
    +        point = point || new Phaser.Point;
    +
    +        return point.setTo((Math.cos(rotation) * speed), (Math.sin(rotation) * speed));
    +
    +    },
    +
    +    /**
    +    * Given the rotation (in radians) and speed calculate the acceleration and return it as a Point object, or set it to the given point object.
    +    * One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object.
    +    * 
    +    * @method Phaser.Physics.Arcade#accelerationFromRotation
    +    * @param {number} rotation - The angle in radians.
    +    * @param {number} [speed=60] - The speed it will move, in pixels per second sq.
    +    * @param {Phaser.Point|object} [point] - The Point object in which the x and y properties will be set to the calculated acceleration.
    +    * @return {Phaser.Point} - A Point where point.x contains the acceleration x value and point.y contains the acceleration y value.
    +    */
    +    accelerationFromRotation: function (rotation, speed, point) {
    +
    +        speed = speed || 60;
    +        point = point || new Phaser.Point;
    +
    +        return point.setTo((Math.cos(rotation) * speed), (Math.sin(rotation) * speed));
    +
    +    },
    +
    +    /**
    +    * Sets the acceleration.x/y property on the display object so it will move towards the target at the given speed (in pixels per second sq.)
    +    * You must give a maximum speed value, beyond which the display object won't go any faster.
    +    * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course.
    +    * Note: The display object doesn't stop moving once it reaches the destination coordinates.
    +    * 
    +    * @method Phaser.Physics.Arcade#accelerateToObject
    +    * @param {any} displayObject - The display object to move.
    +    * @param {any} destination - The display object to move towards. Can be any object but must have visible x/y properties.
    +    * @param {number} [speed=60] - The speed it will accelerate in pixels per second.
    +    * @param {number} [xSpeedMax=500] - The maximum x velocity the display object can reach.
    +    * @param {number} [ySpeedMax=500] - The maximum y velocity the display object can reach.
    +    * @return {number} The angle (in radians) that the object should be visually set to in order to match its new trajectory.
    +    */
    +    accelerateToObject: function (displayObject, destination, speed, xSpeedMax, ySpeedMax) {
    +
    +        if (typeof speed === 'undefined') { speed = 60; }
    +        if (typeof xSpeedMax === 'undefined') { xSpeedMax = 1000; }
    +        if (typeof ySpeedMax === 'undefined') { ySpeedMax = 1000; }
    +
    +        this._angle = this.angleBetween(displayObject, destination);
    +
    +        displayObject.body.acceleration.setTo(Math.cos(this._angle) * speed, Math.sin(this._angle) * speed);
    +        displayObject.body.maxVelocity.setTo(xSpeedMax, ySpeedMax);
    +
    +        return this._angle;
    +
    +    },
    +
    +    /**
    +    * Sets the acceleration.x/y property on the display object so it will move towards the target at the given speed (in pixels per second sq.)
    +    * You must give a maximum speed value, beyond which the display object won't go any faster.
    +    * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course.
    +    * Note: The display object doesn't stop moving once it reaches the destination coordinates.
    +    * 
    +    * @method Phaser.Physics.Arcade#accelerateToPointer
    +    * @param {any} displayObject - The display object to move.
    +    * @param {Phaser.Pointer} [pointer] - The pointer to move towards. Defaults to Phaser.Input.activePointer.
    +    * @param {number} [speed=60] - The speed it will accelerate in pixels per second.
    +    * @param {number} [xSpeedMax=500] - The maximum x velocity the display object can reach.
    +    * @param {number} [ySpeedMax=500] - The maximum y velocity the display object can reach.
    +    * @return {number} The angle (in radians) that the object should be visually set to in order to match its new trajectory.
    +    */
    +    accelerateToPointer: function (displayObject, pointer, speed, xSpeedMax, ySpeedMax) {
    +
    +        if (typeof speed === 'undefined') { speed = 60; }
    +        if (typeof pointer === 'undefined') { pointer = this.game.input.activePointer; }
    +        if (typeof xSpeedMax === 'undefined') { xSpeedMax = 1000; }
    +        if (typeof ySpeedMax === 'undefined') { ySpeedMax = 1000; }
    +
    +        this._angle = this.angleToPointer(displayObject, pointer);
    +        
    +        displayObject.body.acceleration.setTo(Math.cos(this._angle) * speed, Math.sin(this._angle) * speed);
    +        displayObject.body.maxVelocity.setTo(xSpeedMax, ySpeedMax);
    +
    +        return this._angle;
    +
    +    },
    +
    +    /**
    +    * Sets the acceleration.x/y property on the display object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.)
    +    * You must give a maximum speed value, beyond which the display object won't go any faster.
    +    * Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course.
    +    * Note: The display object doesn't stop moving once it reaches the destination coordinates.
    +    * 
    +    * @method Phaser.Physics.Arcade#accelerateToXY
    +    * @param {any} displayObject - The display object to move.
    +    * @param {number} x - The x coordinate to accelerate towards.
    +    * @param {number} y - The y coordinate to accelerate towards.
    +    * @param {number} [speed=60] - The speed it will accelerate in pixels per second.
    +    * @param {number} [xSpeedMax=500] - The maximum x velocity the display object can reach.
    +    * @param {number} [ySpeedMax=500] - The maximum y velocity the display object can reach.
    +    * @return {number} The angle (in radians) that the object should be visually set to in order to match its new trajectory.
    +    */
    +    accelerateToXY: function (displayObject, x, y, speed, xSpeedMax, ySpeedMax) {
    +
    +        if (typeof speed === 'undefined') { speed = 60; }
    +        if (typeof xSpeedMax === 'undefined') { xSpeedMax = 1000; }
    +        if (typeof ySpeedMax === 'undefined') { ySpeedMax = 1000; }
    +
    +        this._angle = this.angleToXY(displayObject, x, y);
    +
    +        displayObject.body.acceleration.setTo(Math.cos(this._angle) * speed, Math.sin(this._angle) * speed);
    +        displayObject.body.maxVelocity.setTo(xSpeedMax, ySpeedMax);
    +
    +        return this._angle;
    +
    +    },
    +
    +    /**
    +    * Find the distance between two display objects (like Sprites).
    +    * 
    +    * @method Phaser.Physics.Arcade#distanceBetween
    +    * @param {any} source - The Display Object to test from.
    +    * @param {any} target - The Display Object to test to.
    +    * @return {number} The distance between the source and target objects.
    +    */
    +    distanceBetween: function (source, target) {
    +
    +        this._dx = source.x - target.x;
    +        this._dy = source.y - target.y;
    +        
    +        return Math.sqrt(this._dx * this._dx + this._dy * this._dy);
    +
    +    },
    +
    +    /**
    +    * Find the distance between a display object (like a Sprite) and the given x/y coordinates.
    +    * The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed.
    +    * If you need to calculate from the center of a display object instead use the method distanceBetweenCenters()
    +    * 
    +    * @method Phaser.Physics.Arcade#distanceToXY
    +    * @param {any} displayObject - The Display Object to test from.
    +    * @param {number} x - The x coordinate to move towards.
    +    * @param {number} y - The y coordinate to move towards.
    +    * @return {number} The distance between the object and the x/y coordinates.
    +    */
    +    distanceToXY: function (displayObject, x, y) {
    +
    +        this._dx = displayObject.x - x;
    +        this._dy = displayObject.y - y;
    +        
    +        return Math.sqrt(this._dx * this._dx + this._dy * this._dy);
    +
    +    },
    +
    +    /**
    +    * Find the distance between a display object (like a Sprite) and a Pointer. If no Pointer is given the Input.activePointer is used.
    +    * The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed.
    +    * If you need to calculate from the center of a display object instead use the method distanceBetweenCenters()
    +    * 
    +    * @method Phaser.Physics.Arcade#distanceToPointer
    +    * @param {any} displayObject - The Display Object to test from.
    +    * @param {Phaser.Pointer} [pointer] - The Phaser.Pointer to test to. If none is given then Input.activePointer is used.
    +    * @return {number} The distance between the object and the Pointer.
    +    */
    +    distanceToPointer: function (displayObject, pointer) {
    +
    +        pointer = pointer || this.game.input.activePointer;
    +
    +        this._dx = displayObject.worldX - pointer.x;
    +        this._dy = displayObject.worldY - pointer.y;
    +        
    +        return Math.sqrt(this._dx * this._dx + this._dy * this._dy);
    +
    +    },
    +
    +    /**
    +    * Find the angle in radians between two display objects (like Sprites).
    +    * 
    +    * @method Phaser.Physics.Arcade#angleBetween
    +    * @param {any} source - The Display Object to test from.
    +    * @param {any} target - The Display Object to test to.
    +    * @return {number} The angle in radians between the source and target display objects.
    +    */
    +    angleBetween: function (source, target) {
    +
    +        this._dx = target.x - source.x;
    +        this._dy = target.y - source.y;
    +
    +        return Math.atan2(this._dy, this._dx);
    +
    +    },
    +
    +    /**
    +    * Find the angle in radians between a display object (like a Sprite) and the given x/y coordinate.
    +    * 
    +    * @method Phaser.Physics.Arcade#angleToXY
    +    * @param {any} displayObject - The Display Object to test from.
    +    * @param {number} x - The x coordinate to get the angle to.
    +    * @param {number} y - The y coordinate to get the angle to.
    +    * @return {number} The angle in radians between displayObject.x/y to Pointer.x/y
    +    */
    +    angleToXY: function (displayObject, x, y) {
    +
    +        this._dx = x - displayObject.x;
    +        this._dy = y - displayObject.y;
    +        
    +        return Math.atan2(this._dy, this._dx);
    +
    +    },
    +    
    +    /**
    +    * Find the angle in radians between a display object (like a Sprite) and a Pointer, taking their x/y and center into account.
    +    * 
    +    * @method Phaser.Physics.Arcade#angleToPointer
    +    * @param {any} displayObject - The Display Object to test from.
    +    * @param {Phaser.Pointer} [pointer] - The Phaser.Pointer to test to. If none is given then Input.activePointer is used.
    +    * @return {number} The angle in radians between displayObject.x/y to Pointer.x/y
    +    */
    +    angleToPointer: function (displayObject, pointer) {
    +
    +        pointer = pointer || this.game.input.activePointer;
    +
    +        this._dx = pointer.worldX - displayObject.x;
    +        this._dy = pointer.worldY - displayObject.y;
    +        
    +        return Math.atan2(this._dy, this._dx);
    +
    +    }
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/BitmapText.js.html b/docs/BitmapText.js.html new file mode 100644 index 00000000..66f82bd1 --- /dev/null +++ b/docs/BitmapText.js.html @@ -0,0 +1,671 @@ + + + + + + Phaser Source: gameobjects/BitmapText.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: gameobjects/BitmapText.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Creates a new <code>BitmapText</code>.
    +* @class Phaser.BitmapText
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +* @param {number} x - X position of the new bitmapText object.
    +* @param {number} y - Y position of the new bitmapText object.
    +* @param {string} text - The actual text that will be written.
    +* @param {object} style - The style object containing style attributes like font, font size , etc.
    +*/
    +Phaser.BitmapText = function (game, x, y, text, style) {
    +
    +    x = x || 0;
    +    y = y || 0;
    +
    +    text = text || '';
    +    style = style || '';
    +
    +	/** 
    +	* @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
    +	* @default
    +	*/
    +    this.exists = true;
    +
    +	/**
    +    * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.
    +	* @default
    +	*/
    +    this.alive = true;
    +
    +	/**
    +    * @property {Description} group - Description.
    + 	* @default
    + 	*/
    +    this.group = null;
    +
    +	/**
    +    * @property {string} name - Description.
    +  	* @default
    +  	*/
    +    this.name = '';
    +
    +    /**
    +    * @property {Phaser.Game} game - A reference to the currently running Game.
    +    */
    +    this.game = game;
    +
    +    PIXI.BitmapText.call(this, text, style);
    +
    +    /**
    +    * @property {Description} type - Description.
    +    */
    +    this.type = Phaser.BITMAPTEXT;
    +
    +	/**
    +	* @property {number} position.x - Description.
    +	*/
    +    this.position.x = x;
    +    
    +	/**
    +	* @property {number} position.y - Description.
    +	*/
    +    this.position.y = y;
    +
    +    //  Replaces the PIXI.Point with a slightly more flexible one
    +	/**
    +	* @property {Phaser.Point} anchor - Description.
    +	*/
    +    this.anchor = new Phaser.Point();
    +    
    +	/**
    +	* @property {Phaser.Point} scale - Description.
    +	*/
    +    this.scale = new Phaser.Point(1, 1);
    +
    +    //  A mini cache for storing all of the calculated values
    +	/**
    +	* @property {function} _cache - Description.
    +	* @private
    +	*/
    +    this._cache = { 
    +
    +        dirty: false,
    +
    +        //  Transform cache
    +        a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, 
    +
    +        //  The previous calculated position
    +        x: -1, y: -1,
    +
    +        //  The actual scale values based on the worldTransform
    +        scaleX: 1, scaleY: 1
    +
    +    };
    +
    +    this._cache.x = this.x;
    +    this._cache.y = this.y;
    +
    +	/**
    +	* @property {boolean} renderable - Description.
    +	* @private
    +	*/
    +    this.renderable = true;
    +
    +};
    +
    +Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype);
    +// Phaser.BitmapText.prototype = Phaser.Utils.extend(true, PIXI.BitmapText.prototype);
    +Phaser.BitmapText.prototype.constructor = Phaser.BitmapText;
    +
    +/**
    +* Automatically called by World.update
    +* @method Phaser.BitmapText.prototype.update
    +*/
    +Phaser.BitmapText.prototype.update = function() {
    +
    +    if (!this.exists)
    +    {
    +        return;
    +    }
    +
    +    this._cache.dirty = false;
    +
    +    this._cache.x = this.x;
    +    this._cache.y = this.y;
    +
    +    if (this.position.x != this._cache.x || this.position.y != this._cache.y)
    +    {
    +        this.position.x = this._cache.x;
    +        this.position.y = this._cache.y;
    +        this._cache.dirty = true;
    +    }
    +
    +    this.pivot.x = this.anchor.x*this.width;
    +    this.pivot.y = this.anchor.y*this.height;
    +
    +}
    +
    +/**
    +* @method Phaser.Text.prototype.destroy
    +*/
    +Phaser.BitmapText.prototype.destroy = function() {
    +
    +    if (this.group)
    +    {
    +        this.group.remove(this);
    +    }
    +
    +    if (this.canvas.parentNode)
    +    {
    +        this.canvas.parentNode.removeChild(this.canvas);
    +    }
    +    else
    +    {
    +        this.canvas = null;
    +        this.context = null;
    +    }
    +
    +    this.exists = false;
    +
    +    this.group = null;
    +
    +}
    +
    +/**
    +* Get
    +* @returns {Description}
    +*//**
    +* Set
    +* @param {Description} value - Description
    +*/
    +Object.defineProperty(Phaser.BitmapText.prototype, 'angle', {
    +
    +    get: function() {
    +        return Phaser.Math.radToDeg(this.rotation);
    +    },
    +
    +    set: function(value) {
    +        this.rotation = Phaser.Math.degToRad(value);
    +    }
    +
    +});
    +
    +/**
    +* Get
    +* @returns {Description}
    +*//**
    +* Set
    +* @param {Description} value - Description
    +*/
    +Object.defineProperty(Phaser.BitmapText.prototype, 'x', {
    +
    +    get: function() {
    +        return this.position.x;
    +    },
    +
    +    set: function(value) {
    +        this.position.x = value;
    +    }
    +
    +});
    +
    +/**
    +* Get
    +* @returns {Description}
    +*//**
    +* Set
    +* @param {Description} value - Description
    +*/
    +Object.defineProperty(Phaser.BitmapText.prototype, 'y', {
    +
    +    get: function() {
    +        return this.position.y;
    +    },
    +
    +    set: function(value) {
    +        this.position.y = value;
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Body.js.html b/docs/Body.js.html new file mode 100644 index 00000000..39daa201 --- /dev/null +++ b/docs/Body.js.html @@ -0,0 +1,1085 @@ + + + + + + Phaser Source: physics/arcade/Body.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: physics/arcade/Body.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than
    +* the Sprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body.
    +*
    +* @class Phaser.Physics.Arcade.Body
    +* @classdesc Arcade Physics Body Constructor
    +* @constructor
    +* @param {Phaser.Sprite} sprite - The Sprite object this physics body belongs to.
    +*/
    +Phaser.Physics.Arcade.Body = function (sprite) {
    +
    +    /**
    +    * @property {Phaser.Sprite} sprite - Reference to the parent Sprite.
    +    */
    +	this.sprite = sprite;
    +
    +    /**
    +    * @property {Phaser.Game} game - Local reference to game.
    +    */
    +	this.game = sprite.game;
    +
    +    /**
    +    * @property {Phaser.Point} offset - The offset of the Physics Body from the Sprite x/y position.
    +    */
    +	this.offset = new Phaser.Point;
    +
    +    /**
    +    * @property {number} x - The x position of the physics body.
    +    * @readonly
    +    */
    +	this.x = sprite.x;
    +
    +    /**
    +    * @property {number} y - The y position of the physics body.
    +    * @readonly
    +    */
    +	this.y = sprite.y;
    +
    +    /**
    +    * @property {number} preX - The previous x position of the physics body.
    +    * @readonly
    +    */
    +	this.preX = sprite.x;
    +
    +    /**
    +    * @property {number} preY - The previous y position of the physics body.
    +    * @readonly
    +    */
    +	this.preY = sprite.y;
    +
    +    /**
    +    * @property {number} preRotation - The previous rotation of the physics body.
    +    * @readonly
    +    */
    +	this.preRotation = sprite.angle;
    +
    +    /**
    +    * @property {number} screenX - The x position of the physics body translated to screen space.
    +    * @readonly
    +    */
    +	this.screenX = sprite.x;
    +
    +    /**
    +    * @property {number} screenY - The y position of the physics body translated to screen space.
    +    * @readonly
    +    */
    +	this.screenY = sprite.y;
    +
    +    /**
    +    * @property {number} sourceWidth - The un-scaled original size.
    +    * @readonly
    +    */
    +	this.sourceWidth = sprite.currentFrame.sourceSizeW;
    +
    +    /**
    +    * @property {number} sourceHeight - The un-scaled original size.
    +    * @readonly
    +    */
    +	this.sourceHeight = sprite.currentFrame.sourceSizeH;
    +
    +    /**
    +    * @property {number} width - The calculated width of the physics body.
    +    */
    +	this.width = sprite.currentFrame.sourceSizeW;
    +
    +    /**
    +    * @property .numInternal ID cache
    +    */
    +	this.height = sprite.currentFrame.sourceSizeH;
    +
    +    /**
    +    * @property {number} halfWidth - The calculated width / 2 of the physics body.
    +    */
    +	this.halfWidth = Math.floor(sprite.currentFrame.sourceSizeW / 2);
    +
    +    /**
    +    * @property {number} halfHeight - The calculated height / 2 of the physics body.
    +    */
    +	this.halfHeight = Math.floor(sprite.currentFrame.sourceSizeH / 2);
    +
    +    /**
    +    * @property {number} _sx - Internal cache var.
    +    * @private
    +    */
    +	this._sx = sprite.scale.x;
    +
    +    /**
    +    * @property {number} _sy - Internal cache var.
    +    * @private
    +    */
    +	this._sy = sprite.scale.y;
    +
    +    /**
    +    * @property {Phaser.Point} velocity - The velocity in pixels per second sq. of the Body.
    +    */
    +    this.velocity = new Phaser.Point;
    +
    +    /**
    +    * @property {Phaser.Point} acceleration - The velocity in pixels per second sq. of the Body.
    +    */
    +    this.acceleration = new Phaser.Point;
    +
    +    /**
    +    * @property {Phaser.Point} drag - The drag applied to the motion of the Body.
    +    */
    +    this.drag = new Phaser.Point;
    +
    +    /**
    +    * @property {Phaser.Point} gravity - A private Gravity setting for the Body.
    +    */
    +    this.gravity = new Phaser.Point;
    +
    +    /**
    +    * @property {Phaser.Point} bounce - The elasticitiy of the Body when colliding. bounce.x/y = 1 means full rebound, bounce.x/y = 0.5 means 50% rebound velocity.
    +    */
    +    this.bounce = new Phaser.Point;
    +
    +    /**
    +    * @property {Phaser.Point} maxVelocity - The maximum velocity in pixels per second sq. that the Body can reach.
    +    * @default
    +    */
    +    this.maxVelocity = new Phaser.Point(10000, 10000);
    +
    +    /**
    +    * @property {number} angularVelocity - The angular velocity in pixels per second sq. of the Body.
    +    * @default
    +    */
    +    this.angularVelocity = 0;
    +
    +    /**
    +    * @property {number} angularAcceleration - The angular acceleration in pixels per second sq. of the Body.
    +    * @default
    +    */
    +    this.angularAcceleration = 0;
    +
    +    /**
    +    * @property {number} angularDrag - The angular drag applied to the rotation of the Body.
    +    * @default
    +    */
    +    this.angularDrag = 0;
    +
    +    /**
    +    * @property {number} maxAngular - The maximum angular velocity in pixels per second sq. that the Body can reach.
    +    * @default
    +    */
    +    this.maxAngular = 1000;
    +
    +    /**
    +    * @property {number} mass - The mass of the Body.
    +    * @default
    +    */
    +    this.mass = 1;
    +
    +    /**
    +    * @property {boolean} skipQuadTree - If the Body is an irregular shape you can set this to true to avoid it being added to the World quad tree.
    +    * @default
    +    */
    +    this.skipQuadTree = false;
    +
    +    /**
    +    * @property {Array} quadTreeIDs - Internal ID cache.
    +    * @protected
    +    */
    +    this.quadTreeIDs = [];
    +
    +    /**
    +    * @property {number} quadTreeIndex - Internal ID cache.
    +    * @protected
    +    */
    +    this.quadTreeIndex = -1;
    +
    +    //	Allow collision
    +
    +    /**
    +    * Set the allowCollision properties to control which directions collision is processed for this Body.
    +    * For example allowCollision.up = false means it won't collide when the collision happened while moving up.
    +    * @property {object} allowCollision - An object containing allowed collision.
    +    */
    +    this.allowCollision = { none: false, any: true, up: true, down: true, left: true, right: true };
    +
    +    /**
    +    * This object is populated with boolean values when the Body collides with another.
    +    * touching.up = true means the collision happened to the top of this Body for example.
    +    * @property {object} touching - An object containing touching results.
    +    */
    +    this.touching = { none: true, up: false, down: false, left: false, right: false };
    +
    +    /**
    +    * This object is populated with previous touching values from the bodies previous collision.
    +    * @property {object} wasTouching - An object containing previous touching results.
    +    */
    +    this.wasTouching = { none: true, up: false, down: false, left: false, right: false };
    +
    +    /**
    +    * @property {number} facing - A const reference to the direction the Body is traveling or facing.
    +    * @default
    +    */
    +    this.facing = Phaser.NONE;
    +
    +    /**
    +    * @property {boolean} immovable - An immovable Body will not receive any impacts from other bodies.
    +    * @default
    +    */
    +    this.immovable = false;
    +
    +    /**
    +    * @property {boolean} moves - Set to true to allow the Physics system to move this Body, other false to move it manually.
    +    * @default
    +    */
    +    this.moves = true;
    +
    +    /**
    +    * @property {number} rotation - The amount the Body is rotated.
    +    * @default
    +    */
    +    this.rotation = 0;
    +
    +    /**
    +    * @property {boolean} allowRotation - Allow this Body to be rotated? (via angularVelocity, etc)
    +    * @default
    +    */
    +    this.allowRotation = true;
    +
    +    /**
    +    * @property {boolean} allowGravity - Allow this Body to be influenced by the global Gravity?
    +    * @default
    +    */
    +    this.allowGravity = true;
    +
    +    /**
    +    * This flag allows you to disable the custom x separation that takes place by Physics.Arcade.separate.
    +    * Used in combination with your own collision processHandler you can create whatever type of collision response you need.
    +    * @property {boolean} customSeparateX - Use a custom separation system or the built-in one?
    +    * @default
    +    */
    +    this.customSeparateX = false;
    +
    +    /**
    +    * This flag allows you to disable the custom y separation that takes place by Physics.Arcade.separate.
    +    * Used in combination with your own collision processHandler you can create whatever type of collision response you need.
    +    * @property {boolean} customSeparateY - Use a custom separation system or the built-in one?
    +    * @default
    +    */
    +    this.customSeparateY = false;
    +
    +    /**
    +    * When this body collides with another, the amount of overlap is stored here.
    +    * @property {number} overlapX - The amount of horizontal overlap during the collision.
    +    */
    +    this.overlapX = 0;
    +
    +    /**
    +    * When this body collides with another, the amount of overlap is stored here.
    +    * @property {number} overlapY - The amount of vertical overlap during the collision.
    +    */
    +    this.overlapY = 0;
    +
    +    /**
    +    * @property {Phaser.Rectangle} hullX - The dynamically calculated hull used during collision.
    +    */
    +    this.hullX = new Phaser.Rectangle();
    +
    +    /**
    +    * @property {Phaser.Rectangle} hullY - The dynamically calculated hull used during collision.
    +    */
    +    this.hullY = new Phaser.Rectangle();
    +
    +    /**
    +    * If a body is overlapping with another body, but neither of them are moving (maybe they spawned on-top of each other?) this is set to true.
    +    * @property {boolean} embedded - Body embed value.
    +    */
    +    this.embedded = false;
    +
    +    /**
    +    * A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World.
    +    * @property {boolean} collideWorldBounds - Should the Body collide with the World bounds?
    +    */
    +    this.collideWorldBounds = false;
    +
    +};
    +
    +Phaser.Physics.Arcade.Body.prototype = {
    +
    +    /**
    +    * Internal method.
    +    *
    +    * @method Phaser.Physics.Arcade#updateBounds
    +    * @protected
    +    */
    +	updateBounds: function (centerX, centerY, scaleX, scaleY) {
    +
    +		if (scaleX != this._sx || scaleY != this._sy)
    +		{
    +			this.width = this.sourceWidth * scaleX;
    +			this.height = this.sourceHeight * scaleY;
    +			this.halfWidth = Math.floor(this.width / 2);
    +			this.halfHeight = Math.floor(this.height / 2);
    +			this._sx = scaleX;
    +			this._sy = scaleY;
    +		}
    +
    +	},
    +
    +    /**
    +    * Internal method.
    +    *
    +    * @method Phaser.Physics.Arcade#preUpdate
    +    * @protected
    +    */
    +	preUpdate: function () {
    +
    +		//	Store and reset collision flags
    +	    this.wasTouching.none = this.touching.none;
    +	    this.wasTouching.up = this.touching.up;
    +	    this.wasTouching.down = this.touching.down;
    +	    this.wasTouching.left = this.touching.left;
    +	    this.wasTouching.right = this.touching.right;
    +
    +	    this.touching.none = true;
    +	    this.touching.up = false;
    +	    this.touching.down = false;
    +	    this.touching.left = false;
    +	    this.touching.right = false;
    +
    +	    this.embedded = false;
    +
    +		this.screenX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
    +		this.screenY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
    +
    +		this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
    +		this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
    +
    +		this.preRotation = this.sprite.angle;
    +
    +		this.x = this.preX;
    +		this.y = this.preY;
    +		this.rotation = this.preRotation;
    +
    +		if (this.moves)
    +		{
    +			this.game.physics.updateMotion(this);
    +
    +			if (this.collideWorldBounds)
    +			{
    +				this.checkWorldBounds();
    +			}
    +
    +			this.updateHulls();Array		}
    +
    +		if (this.skipQuadTree == false && this.allowCollision.none == false && this.sprite.visible && this.sprite.alive)
    +		{
    +		    this.quadTreeIDs = [];
    +		    this.quadTreeIndex = -1;
    +			this.game.physics.quadTree.insert(this);
    +		}
    +
    +	},
    +
    +    /**
    +    * Internal method.
    +    *
    +    * @method Phaser.Physics.Arcade#postUpdate
    +    * @protected
    +    */
    +	postUpdate: function () {
    +
    +		//	Calculate forward-facing edge
    +		if (this.deltaX() == 0 && this.deltaY() == 0)
    +		{
    +			//	Can't work it out from the Body, how about from x position?
    +			if (this.sprite.deltaX() == 0 && this.sprite.deltaY() == 0)
    +			{
    +				//	still as a statue
    +			}
    +		}
    +
    +		if (this.deltaX() < 0)
    +		{
    +			this.facing = Phaser.LEFT;
    +		}
    +		else if (this.deltaX() > 0)
    +		{
    +			this.facing = Phaser.RIGHT;
    +		}
    +
    +		if (this.deltaY() < 0)
    +		{
    +			this.facing = Phaser.UP;
    +		}
    +		else if (this.deltaY() > 0)
    +		{
    +			this.facing = Phaser.DOWN;
    +		}
    +
    +		this.sprite.x += this.deltaX();
    +		this.sprite.y += this.deltaY();
    +
    +		if (this.allowRotation)
    +		{
    +			this.sprite.angle += this.deltaZ();
    +		}
    +
    +	},
    +
    +    /**
    +    * Internal method.
    +    *
    +    * @method Phaser.Physics.Arcade#updateHulls
    +    * @protected
    +    */
    +	updateHulls: function () {
    +
    +		this.hullX.setTo(this.x, this.preY, this.width, this.height);
    +		this.hullY.setTo(this.preX, this.y, this.width, this.height);
    +
    +	},
    +
    +    /**
    +    * Internal method.
    +    *
    +    * @method Phaser.Physics.Arcade#checkWorldBounds
    +    * @protected
    +    */
    +	checkWorldBounds: function () {
    +
    +		if (this.x < this.game.world.bounds.x)
    +		{
    +			this.x = this.game.world.bounds.x;
    +			this.velocity.x *= -this.bounce.x;
    +		}
    +		else if (this.right > this.game.world.bounds.right)
    +		{
    +			this.x = this.game.world.bounds.right - this.width;
    +			this.velocity.x *= -this.bounce.x;
    +		}
    +
    +		if (this.y < this.game.world.bounds.y)
    +		{
    +			this.y = this.game.world.bounds.y;
    +			this.velocity.y *= -this.bounce.y;
    +		}
    +		else if (this.bottom > this.game.world.bounds.bottom)
    +		{
    +			this.y = this.game.world.bounds.bottom - this.height;
    +			this.velocity.y *= -this.bounce.y;
    +		}
    +
    +	},
    +
    +    /**
    +    * You can modify the size of the physics Body to be any dimension you need.
    +    * So it could be smaller or larger than the parent Sprite. You can also control the x and y offset, which
    +    * is the position of the Body relative to the top-left of the Sprite.
    +    *
    +    * @method Phaser.Physics.Arcade#setSize
    +    * @param {number} width - The width of the Body.
    +    * @param {number} height - The height of the Body.
    +    * @param {number} offsetX - The X offset of the Body from the Sprite position.
    +    * @param {number} offsetY - The Y offset of the Body from the Sprite position.
    +    */
    +	setSize: function (width, height, offsetX, offsetY) {
    +
    +		offsetX = offsetX || this.offset.x;
    +		offsetY = offsetY || this.offset.y;
    +
    +		this.sourceWidth = width;
    +		this.sourceHeight = height;
    +		this.width = this.sourceWidth * this._sx;
    +		this.height = this.sourceHeight * this._sy;
    +		this.halfWidth = Math.floor(this.width / 2);
    +		this.halfHeight = Math.floor(this.height / 2);
    +		this.offset.setTo(offsetX, offsetY);
    +
    +	},
    +
    +    /**
    +    * Resets all Body values (velocity, acceleration, rotation, etc)
    +    *
    +    * @method Phaser.Physics.Arcade#reset
    +    */
    +	reset: function () {
    +
    +		this.velocity.setTo(0, 0);
    +		this.acceleration.setTo(0, 0);
    +
    +	    this.angularVelocity = 0;
    +	    this.angularAcceleration = 0;
    +		this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
    +		this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
    +		this.preRotation = this.sprite.angle;
    +
    +		this.x = this.preX;
    +		this.y = this.preY;
    +		this.rotation = this.preRotation;
    +
    +	},
    +
    +    /**
    +    * Returns the absolute delta x value.
    +    *
    +    * @method Phaser.Physics.Arcade.Body#deltaAbsX
    +    * @return {number} The absolute delta value.
    +    */
    +    deltaAbsX: function () {
    +        return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX());
    +    },
    +
    +    /**
    +    * Returns the absolute delta y value.
    +    *
    +    * @method Phaser.Physics.Arcade.Body#deltaAbsY
    +    * @return {number} The absolute delta value.
    +    */
    +    deltaAbsY: function () {
    +        return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY());
    +    },
    +
    +    /**
    +    * Returns the delta x value.
    +    *
    +    * @method Phaser.Physics.Arcade.Body#deltaX
    +    * @return {number} The delta value.
    +    */
    +    deltaX: function () {
    +        return this.x - this.preX;
    +    },
    +
    +    /**
    +    * Returns the delta y value.
    +    *
    +    * @method Phaser.Physics.Arcade.Body#deltaY
    +    * @return {number} The delta value.
    +    */
    +    deltaY: function () {
    +        return this.y - this.preY;
    +    },
    +
    +    deltaZ: function () {
    +        return this.rotation - this.preRotation;
    +    }
    +
    +};
    +
    +/**
    +* @name Phaser.Physics.Arcade.Body#bottom
    +* @property {number} bottom - The bottom value of this Body (same as Body.y + Body.height)
    +*/
    +Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", {
    +    
    +    /**
    +    * 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.
    +    * @method bottom
    +    * @return {number}
    +    **/
    +    get: function () {
    +        return this.y + this.height;
    +    },
    +
    +    /**
    +    * 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.
    +    * @method bottom
    +    * @param {number} value
    +    **/    
    +    set: function (value) {
    +
    +        if (value <= this.y)
    +        {
    +            this.height = 0;
    +        }
    +        else
    +        {
    +            this.height = (this.y - value);
    +        }
    +        
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Physics.Arcade.Body#right
    +* @property {number} right - The right value of this Body (same as Body.x + Body.width)
    +*/
    +Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", {
    +    
    +    /**
    +    * 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.
    +    * @method right
    +    * @return {number}
    +    **/    
    +    get: function () {
    +        return this.x + this.width;
    +    },
    +
    +    /**
    +    * 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.
    +    * @method right
    +    * @param {number} value
    +    **/
    +    set: function (value) {
    +
    +        if (value <= this.x)
    +        {
    +            this.width = 0;
    +        }
    +        else
    +        {
    +            this.width = this.x + value;
    +        }
    +
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Bullet.js.html b/docs/Bullet.js.html new file mode 100644 index 00000000..fcae3569 --- /dev/null +++ b/docs/Bullet.js.html @@ -0,0 +1,1068 @@ + + + + + + Phaser Source: gameobjects/Bullet.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: gameobjects/Bullet.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Warning: Bullet is an experimental object that we don't advise using for now.
    +*
    +* A Bullet is like a stripped-down Sprite, useful for when you just need to get something moving around the screen quickly with little of the extra
    +* features that a Sprite supports.
    +* Bullet is MISSING the following:
    +*
    +* animation, all input events, crop support, health/damage, loadTexture
    +*
    +* @class Phaser.Bullet
    +* @constructor
    +* @param {Phaser.Game} game - Current game instance.
    +* @param {number} x - X position of the new bullet.
    +* @param {number} y - Y position of the new bullet.
    +* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
    +* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
    +*/
    +Phaser.Bullet = function (game, x, y, key, frame) {
    +
    +    x = x || 0;
    +    y = y || 0;
    +    key = key || null;
    +    frame = frame || null;
    +    
    +    /**
    +	* @property {Phaser.Game} game - A reference to the currently running Game.
    +	*/
    +	this.game = game;
    + 
    +	/**
    +	* @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
    +	* @default
    +	*/
    +    this.exists = true;
    +
    +	/**
    +    * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.
    +   	* @default
    +   	*/
    +    this.alive = true;
    +
    +	/**
    +    * @property {Description} group - Description.
    +   	* @default
    +   	*/
    +    this.group = null;
    +
    +    /**
    +     * @property {string} name - The user defined name given to this Sprite.
    +     * @default
    +     */
    +    this.name = '';
    +
    +    /**
    +	* @property {Description} type - Description.
    +	*/
    +    this.type = Phaser.BULLET;
    +
    +    /**
    +	* @property {number} renderOrderID - Description.
    +	* @default
    +	*/
    +    this.renderOrderID = -1;
    +
    +    /**
    +    * If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc.
    +	* The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called.
    +	* @property {number} lifespan
    +	* @default
    +	*/    
    +    this.lifespan = 0;
    +
    +    /**
    +    * @property {Events} events - The Signals you can subscribe to that are dispatched when certain things happen on this Sprite or its components
    +    */
    +    this.events = new Phaser.Events(this);
    +
    +    /**
    +    *  @property {Description} key - Description.
    +    */
    +    this.key = key;
    +
    +    if (key instanceof Phaser.RenderTexture)
    +    {
    +        PIXI.Sprite.call(this, key);
    +
    +        this.currentFrame = this.game.cache.getTextureFrame(key.name);
    +    }
    +    else if (key instanceof PIXI.Texture)
    +    {
    +        PIXI.Sprite.call(this, key);
    +
    +        this.currentFrame = frame;
    +    }
    +    else
    +    {
    +        if (key == null || this.game.cache.checkImageKey(key) == false)
    +        {
    +            key = '__default';
    +        }
    +
    +        PIXI.Sprite.call(this, PIXI.TextureCache[key]);
    +
    +        if (this.game.cache.isSpriteSheet(key))
    +        {
    +        	/*
    +            this.animations.loadFrameData(this.game.cache.getFrameData(key));
    +
    +            if (frame !== null)
    +            {
    +                if (typeof frame === 'string')
    +                {
    +                    this.frameName = frame;
    +                }
    +                else
    +                {
    +                    this.frame = frame;
    +                }
    +            }
    +            */
    +        }
    +        else
    +        {
    +            this.currentFrame = this.game.cache.getFrame(key);
    +        }
    +    }
    +
    +    /**
    +    * The anchor sets the origin point of the texture.
    +    * The default is 0,0 this means the textures origin is the top left 
    +    * Setting than anchor to 0.5,0.5 means the textures origin is centered
    +    * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right
    +    *
    +    * @property {Phaser.Point} anchor
    +    */
    +    this.anchor = new Phaser.Point();
    +
    +    /**
    +    * @property {number} x - Description.
    +    */
    +    this.x = x;
    +    
    +    /**
    +    * @property {number} y - Description.
    +    */
    +    this.y = y;
    +
    +    /**
    +    * @property {Description} position - Description.
    +    */
    +	this.position.x = x;
    +	this.position.y = y;
    +
    +    /**
    +    * Should this Sprite be automatically culled if out of range of the camera?
    +    * A culled sprite has its visible property set to 'false'.
    +    * Note that this check doesn't look at this Sprites children, which may still be in camera range.
    +    * So you should set autoCull to false if the Sprite will have children likely to still be in camera range.
    +    *
    +    * @property {boolean} autoCull
    +    * @default
    +    */
    +    this.autoCull = false;
    +
    +    /**
    +    * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one.
    +    */ 
    +    this.scale = new Phaser.Point(1, 1);
    +
    +    /**
    +    * @property {Phaser.Point} _cache - A mini cache for storing all of the calculated values.
    +    * @private
    +    */
    +    this._cache = { 
    +
    +        dirty: false,
    +
    +        //  Transform cache
    +        a00: -1, a01: -1, a02: -1, a10: -1, a11: -1, a12: -1, id: -1, 
    +
    +        //  Input specific transform cache
    +        i01: -1, i10: -1, idi: -1,
    +
    +        //  Bounds check
    +        left: null, right: null, top: null, bottom: null, 
    +
    +        //  The previous calculated position
    +        x: -1, y: -1,
    +
    +        //  The actual scale values based on the worldTransform
    +        scaleX: 1, scaleY: 1,
    +
    +        //  The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size
    +        width: this.currentFrame.sourceSizeW, height: this.currentFrame.sourceSizeH,
    +
    +        //  The actual width/height of the image if from a trimmed atlas, multiplied by the final calculated scale size
    +        halfWidth: Math.floor(this.currentFrame.sourceSizeW / 2), halfHeight: Math.floor(this.currentFrame.sourceSizeH / 2),
    +
    +        boundsX: 0, boundsY: 0,
    +
    +        //  If this sprite visible to the camera (regardless of being set to visible or not)
    +        cameraVisible: true
    +
    +    };
    +  
    +    /**
    +    * @property {Phaser.Point} offset - Corner point defaults.
    +    */    
    +    this.offset = new Phaser.Point;
    +    
    +    /**
    +    * @property {Phaser.Point} center - Description.
    +    */
    +    this.center = new Phaser.Point(x + Math.floor(this._cache.width / 2), y + Math.floor(this._cache.height / 2));
    +   
    +    /**
    +    * @property {Phaser.Point} topLeft - Description.
    +    */
    +    this.topLeft = new Phaser.Point(x, y);
    +    
    +    /**
    +    * @property {Phaser.Point} topRight - Description.
    +    */
    +    this.topRight = new Phaser.Point(x + this._cache.width, y);
    +    
    +    /**
    +    * @property {Phaser.Point} bottomRight - Description.
    +    */
    +    this.bottomRight = new Phaser.Point(x + this._cache.width, y + this._cache.height);
    +    
    +    /**
    +    * @property {Phaser.Point} bottomLeft - Description.
    +    */
    +    this.bottomLeft = new Phaser.Point(x, y + this._cache.height);
    +    
    +    /**
    +    * @property {Phaser.Rectangle} bounds - Description.
    +    */
    +    this.bounds = new Phaser.Rectangle(x, y, this._cache.width, this._cache.height);
    +
    +    /**
    +    * @property {Phaser.Physics.Arcade.Body} body - Set-up the physics body.
    +    */
    +    this.body = new Phaser.Physics.Arcade.Body(this);
    +
    +    /**
    +    * @property {Description} inWorld - World bounds check.
    +    */
    +    this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds);
    +    
    +    /**
    +    * @property {number} inWorldThreshold - World bounds check.
    +    * @default
    +    */
    +    this.inWorldThreshold = 0;
    +
    +    /**
    +    * @property {boolean} outOfBoundsKill - Kills this sprite as soon as it goes outside of the World bounds.
    +    * @default
    +    */
    +    this.outOfBoundsKill = false;
    +    
    +    /**
    +    * @property {boolean} _outOfBoundsFired - Description.
    +    * @private
    +    * @default
    +    */
    +    this._outOfBoundsFired = false;
    +
    +    /**
    +    * A Sprite that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera.
    +    * @property {boolean} fixedToCamera - Fixes this Sprite to the Camera.
    +    * @default
    +    */
    +    this.fixedToCamera = false;
    +
    +};
    +
    +Phaser.Bullet.prototype = Object.create(PIXI.Sprite.prototype);
    +Phaser.Bullet.prototype.constructor = Phaser.Bullet;
    +
    +/**
    +* Automatically called by World.preUpdate. You can create your own update in Objects that extend Phaser.Sprite.
    +* @method Phaser.Sprite.prototype.preUpdate
    +*/
    +Phaser.Bullet.prototype.preUpdate = function() {
    +
    +    if (!this.exists)
    +    {
    +        this.renderOrderID = -1;
    +        return;
    +    }
    +
    +    if (this.lifespan > 0)
    +    {
    +        this.lifespan -= this.game.time.elapsed;
    +
    +        if (this.lifespan <= 0)
    +        {
    +            this.kill();
    +            return;
    +        }
    +    }
    +
    +    this._cache.dirty = false;
    +
    +    if (this.visible)
    +    {
    +        this.renderOrderID = this.game.world.currentRenderOrderID++;
    +    }
    +
    +    this.prevX = this.x;
    +    this.prevY = this.y;
    +
    +    //  |a c tx|
    +    //  |b d ty|
    +    //  |0 0  1|
    +
    +    if (this.worldTransform[1] != this._cache.i01 || this.worldTransform[3] != this._cache.i10)
    +    {
    +        this._cache.a00 = this.worldTransform[0];  //  scaleX         a
    +        this._cache.a01 = this.worldTransform[1];  //  skewY          c
    +        this._cache.a10 = this.worldTransform[3];  //  skewX          b
    +        this._cache.a11 = this.worldTransform[4];  //  scaleY         d
    +
    +        this._cache.i01 = this.worldTransform[1];  //  skewY          c (remains non-modified for input checks)
    +        this._cache.i10 = this.worldTransform[3];  //  skewX          b (remains non-modified for input checks)
    +
    +        this._cache.scaleX = Math.sqrt((this._cache.a00 * this._cache.a00) + (this._cache.a01 * this._cache.a01)); // round this off a bit?
    +        this._cache.scaleY = Math.sqrt((this._cache.a10 * this._cache.a10) + (this._cache.a11 * this._cache.a11)); // round this off a bit?
    +
    +        this._cache.a01 *= -1;
    +        this._cache.a10 *= -1;
    +
    +        this._cache.dirty = true;
    +    }
    +
    +    if (this.worldTransform[2] != this._cache.a02 || this.worldTransform[5] != this._cache.a12)
    +    {
    +        this._cache.a02 = this.worldTransform[2];  //  translateX     tx
    +        this._cache.a12 = this.worldTransform[5];  //  translateY     ty
    +        this._cache.dirty = true;
    +    }
    +
    +    //  Re-run the camera visibility check
    +    if (this._cache.dirty)
    +    {
    +        this._cache.cameraVisible = Phaser.Rectangle.intersects(this.game.world.camera.screenView, this.bounds, 0);
    +
    +        if (this.autoCull == true)
    +        {
    +            //  Won't get rendered but will still get its transform updated
    +            this.renderable = this._cache.cameraVisible;
    +        }
    +
    +        //  Update our physics bounds
    +        if (this.body)
    +        {
    +            this.body.updateBounds(this.center.x, this.center.y, this._cache.scaleX, this._cache.scaleY);
    +        }
    +    }
    +
    +    if (this.body)
    +    {
    +        this.body.preUpdate();
    +    }
    +
    +}
    +
    +Phaser.Bullet.prototype.postUpdate = function() {
    +
    +    if (this.exists)
    +    {
    +        //  The sprite is positioned in this call, after taking into consideration motion updates and collision
    +        if (this.body)
    +        {
    +            this.body.postUpdate();
    +        }
    +
    +        if (this.fixedToCamera)
    +        {
    +            this._cache.x = this.game.camera.view.x + this.x;
    +            this._cache.y = this.game.camera.view.y + this.y;
    +        }
    +        else
    +        {
    +            this._cache.x = this.x;
    +            this._cache.y = this.y;
    +        }
    +
    +        if (this.position.x != this._cache.x || this.position.y != this._cache.y)
    +        {
    +            this.position.x = this._cache.x;
    +            this.position.y = this._cache.y;
    +        }
    +    }
    +
    +}
    +
    +Phaser.Bullet.prototype.deltaAbsX = function () {
    +    return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX());
    +}
    +
    +Phaser.Bullet.prototype.deltaAbsY = function () {
    +    return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY());
    +}
    +
    +Phaser.Bullet.prototype.deltaX = function () {
    +    return this.x - this.prevX;
    +}
    +
    +Phaser.Bullet.prototype.deltaY = function () {
    +    return this.y - this.prevY;
    +}
    +
    +/**
    +* Description.
    +* 
    +* @method Phaser.Bullet.prototype.revive
    +*/
    +Phaser.Bullet.prototype.revive = function(health) {
    +
    +    if (typeof health === 'undefined') { health = 1; }
    +
    +    this.alive = true;
    +    this.exists = true;
    +    this.visible = true;
    +    this.health = health;
    +
    +    this.events.onRevived.dispatch(this);
    +
    +}
    +
    +/**
    +* Description.
    +* 
    +* @method Phaser.Bullet.prototype.kill
    +*/
    +Phaser.Bullet.prototype.kill = function() {
    +
    +    this.alive = false;
    +    this.exists = false;
    +    this.visible = false;
    +    this.events.onKilled.dispatch(this);
    +
    +}
    +
    +/**
    +* Description.
    +* 
    +* @method Phaser.Bullet.prototype.destroy
    +*/
    +Phaser.Bullet.prototype.destroy = function() {
    +
    +    if (this.group)
    +    {
    +        this.group.remove(this);
    +    }
    +
    +    this.events.destroy();
    +
    +    this.alive = false;
    +    this.exists = false;
    +    this.visible = false;
    +
    +    this.game = null;
    +
    +}
    +
    +/**
    +* Description.
    +* 
    +* @method Phaser.Sprite.prototype.reset
    +*/
    +Phaser.Bullet.prototype.reset = function(x, y) {
    +
    +    this.x = x;
    +    this.y = y;
    +    this.position.x = this.x;
    +    this.position.y = this.y;
    +    this.alive = true;
    +    this.exists = true;
    +    this.visible = true;
    +    this.renderable = true;
    +    this._outOfBoundsFired = false;
    +
    +    if (this.body)
    +    {
    +        this.body.reset();
    +    }
    +    
    +}
    +
    +/**
    +* Description.
    +*   
    +* @method Phaser.Sprite.prototype.updateBounds
    +*/
    +Phaser.Bullet.prototype.updateBounds = function() {
    +
    +    //  Update the edge points
    +
    +    this.offset.setTo(this._cache.a02 - (this.anchor.x * this._cache.width), this._cache.a12 - (this.anchor.y * this._cache.height));
    +
    +    this.getLocalPosition(this.center, this.offset.x + this._cache.halfWidth, this.offset.y + this._cache.halfHeight);
    +    this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y);
    +    this.getLocalPosition(this.topRight, this.offset.x + this._cache.width, this.offset.y);
    +    this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this._cache.height);
    +    this.getLocalPosition(this.bottomRight, this.offset.x + this._cache.width, this.offset.y + this._cache.height);
    +
    +    this._cache.left = Phaser.Math.min(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x);
    +    this._cache.right = Phaser.Math.max(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x);
    +    this._cache.top = Phaser.Math.min(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y);
    +    this._cache.bottom = Phaser.Math.max(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y);
    +
    +    this.bounds.setTo(this._cache.left, this._cache.top, this._cache.right - this._cache.left, this._cache.bottom - this._cache.top);
    +
    +    //  This is the coordinate the Bullet was at when the last bounds was created
    +    this._cache.boundsX = this._cache.x;
    +    this._cache.boundsY = this._cache.y;
    +
    +    if (this.inWorld == false)
    +    {
    +        //  Bullet WAS out of the screen, is it still?
    +        this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
    +
    +        if (this.inWorld)
    +        {
    +            //  It's back again, reset the OOB check
    +            this._outOfBoundsFired = false;
    +        }
    +    }
    +    else
    +    {
    +        //   Bullet WAS in the screen, has it now left?
    +        this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
    +
    +        if (this.inWorld == false)
    +        {
    +            this.events.onOutOfBounds.dispatch(this);
    +            this._outOfBoundsFired = true;
    +
    +            if (this.outOfBoundsKill)
    +            {
    +                this.kill();
    +            }
    +        }
    +    }
    +
    +}
    +
    +/**
    +* Description.
    +* 
    +* @method Phaser.Bullet.prototype.getLocalPosition
    +* @param {Description} p - Description.
    +* @param {number} x - Description.
    +* @param {number} y - Description.
    +* @return {Description} Description.
    +*/
    +Phaser.Bullet.prototype.getLocalPosition = function(p, x, y) {
    +
    +    p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * this._cache.scaleX) + this._cache.a02;
    +    p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * this._cache.scaleY) + this._cache.a12;
    +
    +    return p;
    +
    +}
    +
    +/**
    +* Description.
    +* 
    +* @method Phaser.Bullet.prototype.bringToTop
    +*/
    +Phaser.Bullet.prototype.bringToTop = function() {
    +
    +    if (this.group)
    +    {
    +        this.group.bringToTop(this);
    +    }
    +    else
    +    {
    +        this.game.world.bringToTop(this);
    +    }
    +
    +}
    +
    +/**
    +* Indicates the rotation of the Bullet, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
    +* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90.
    +* If you wish to work in radians instead of degrees use the property Bullet.rotation instead.
    +* @name Phaser.Bullet#angle
    +* @property {number} angle - Gets or sets the Bullets angle of rotation in degrees.
    +*/
    +Object.defineProperty(Phaser.Bullet.prototype, 'angle', {
    +
    +    get: function() {
    +        return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation));
    +    },
    +
    +    set: function(value) {
    +        this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value));
    +    }
    +
    +});
    +
    +/**
    +* Is this sprite visible to the camera or not?
    +* @returns {boolean}
    +*/
    +Object.defineProperty(Phaser.Bullet.prototype, "inCamera", {
    +    
    +    get: function () {
    +        return this._cache.cameraVisible;
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Button.js.html b/docs/Button.js.html new file mode 100644 index 00000000..bb6b3066 --- /dev/null +++ b/docs/Button.js.html @@ -0,0 +1,765 @@ + + + + + + Phaser Source: gameobjects/Button.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: gameobjects/Button.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +
    +/**
    +* Create a new <code>Button</code> object.
    +* @class Phaser.Button
    +* @constructor
    +*
    +* @param {Phaser.Game} game Current game instance.
    +* @param {number} [x] X position of the button.
    +* @param {number} [y] Y position of the button.
    +* @param {string} [key] The image key as defined in the Game.Cache to use as the texture for this button.
    +* @param {function} [callback] The function to call when this button is pressed
    +* @param {object} [callbackContext] The context in which the callback will be called (usually 'this')
    +* @param {string|number} [overFrame] This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
    +* @param {string|number} [outFrame] This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
    +* @param {string|number} [downFrame] This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
    +*/
    +Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) {
    +
    +    x = x || 0;
    +    y = y || 0;
    +    key = key || null;
    +    callback = callback || null;
    +    callbackContext = callbackContext || this;
    +
    +	Phaser.Sprite.call(this, game, x, y, key, outFrame);
    +
    +	/** 
    +	* @property {Description} type - Description.
    +	*/
    +    this.type = Phaser.BUTTON;
    +
    +	/** 
    +	* @property {Description} _onOverFrameName - Description.
    +	* @private
    +	* @default
    +	*/
    +    this._onOverFrameName = null;
    +    
    +	/** 
    +	* @property {Description} _onOutFrameName - Description.
    +	* @private
    +	* @default
    +	*/
    +    this._onOutFrameName = null;
    +    
    +	/** 
    +	* @property {Description} _onDownFrameName - Description.
    +	* @private
    +	* @default
    +	*/
    +    this._onDownFrameName = null;
    +    
    +	/** 
    +	* @property {Description} _onUpFrameName - Description.
    +	* @private
    +	* @default
    +	*/
    +    this._onUpFrameName = null;
    +    
    +	/** 
    +	* @property {Description} _onOverFrameID - Description.
    +	* @private
    +	* @default
    +	*/
    +    this._onOverFrameID = null;
    +    
    +	/** 
    +	* @property {Description} _onOutFrameID - Description.
    +	* @private
    +	* @default
    +	*/
    +    this._onOutFrameID = null;
    +    
    +	/** 
    +	* @property {Description} _onDownFrameID - Description.
    +	* @private
    +	* @default
    +	*/
    +    this._onDownFrameID = null;
    +    
    +	/** 
    +	* @property {Description} _onUpFrameID - Description.
    +	* @private
    +	* @default
    +	*/
    +    this._onUpFrameID = null;
    +
    +    //  These are the signals the game will subscribe to
    +	/** 
    +	* @property {Phaser.Signal} onInputOver - Description.
    +	*/
    +    this.onInputOver = new Phaser.Signal;
    +    
    +	/** 
    +	* @property {Phaser.Signal} onInputOut - Description.
    +	*/
    +    this.onInputOut = new Phaser.Signal;
    +    
    +	/** 
    +	* @property {Phaser.Signal} onInputDown - Description.
    +	*/
    +    this.onInputDown = new Phaser.Signal;
    +    
    +	/** 
    +	* @property {Phaser.Signal} onInputUp - Description.
    +	*/
    +    this.onInputUp = new Phaser.Signal;
    +
    +    this.setFrames(overFrame, outFrame, downFrame);
    +
    +    if (callback !== null)
    +    {
    +        this.onInputUp.add(callback, callbackContext);
    +    }
    +
    +    this.freezeFrames = false;
    +
    +    this.input.start(0, true);
    +
    +    //  Redirect the input events to here so we can handle animation updates, etc
    +    this.events.onInputOver.add(this.onInputOverHandler, this);
    +    this.events.onInputOut.add(this.onInputOutHandler, this);
    +    this.events.onInputDown.add(this.onInputDownHandler, this);
    +    this.events.onInputUp.add(this.onInputUpHandler, this);
    +
    +};
    +
    +Phaser.Button.prototype = Phaser.Utils.extend(true, Phaser.Sprite.prototype, PIXI.Sprite.prototype);
    +Phaser.Button.prototype.constructor = Phaser.Button;
    +
    +/**
    +* Used to manually set the frames that will be used for the different states of the button
    +* exactly like setting them in the constructor.
    +*
    +* @method Phaser.Button.prototype.setFrames
    +* @param {string|number} [overFrame] - This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
    +* @param {string|number} [outFrame] - This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
    +* @param {string|number} [downFrame] - This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
    +*/
    +Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) {
    +
    +    if (overFrame !== null)
    +    {
    +        if (typeof overFrame === 'string')
    +        {
    +            this._onOverFrameName = overFrame;
    +            
    +            if (this.input.pointerOver())
    +            {
    +                this.frameName = overFrame;
    +            }
    +        }
    +        else
    +        {
    +            this._onOverFrameID = overFrame;
    +
    +            if (this.input.pointerOver())
    +            {
    +                this.frame = overFrame;
    +            }
    +        }
    +    }
    +
    +    if (outFrame !== null)
    +    {
    +        if (typeof outFrame === 'string')
    +        {
    +            this._onOutFrameName = outFrame;
    +            this._onUpFrameName = outFrame;
    +
    +            if (this.input.pointerOver() == false)
    +            {
    +                this.frameName = outFrame;
    +            }
    +        }
    +        else
    +        {
    +            this._onOutFrameID = outFrame;
    +            this._onUpFrameID = outFrame;
    +
    +            if (this.input.pointerOver() == false)
    +            {
    +                this.frame = outFrame;
    +            }
    +        }
    +    }
    +
    +    if (downFrame !== null)
    +    {
    +        if (typeof downFrame === 'string')
    +        {
    +            this._onDownFrameName = downFrame;
    +
    +            if (this.input.pointerOver())
    +            {
    +                this.frameName = downFrame;
    +            }
    +        }
    +        else
    +        {
    +            this._onDownFrameID = downFrame;
    +
    +            if (this.input.pointerOver())
    +            {
    +                this.frame = downFrame;
    +            }
    +        }
    +    }
    +
    +};
    +
    +/**
    +* Description.
    +*
    +* @method Phaser.Button.prototype.onInputOverHandler
    +* @param {Description} pointer - Description.
    +*/
    +Phaser.Button.prototype.onInputOverHandler = function (pointer) {
    +
    +    if (this.freezeFrames == false)
    +    {
    +        if (this._onOverFrameName != null)
    +        {
    +            this.frameName = this._onOverFrameName;
    +        }
    +        else if (this._onOverFrameID != null)
    +        {
    +            this.frame = this._onOverFrameID;
    +        }
    +    }
    +
    +    if (this.onInputOver)
    +    {
    +        this.onInputOver.dispatch(this, pointer);
    +    }
    +};
    +
    +/**
    +* Description.
    +*
    +* @method Phaser.Button.prototype.onInputOutHandler
    +* @param {Description} pointer - Description.
    +*/
    +Phaser.Button.prototype.onInputOutHandler = function (pointer) {
    +
    +    if (this.freezeFrames == false)
    +    {
    +        if (this._onOutFrameName != null)
    +        {
    +            this.frameName = this._onOutFrameName;
    +        }
    +        else if (this._onOutFrameID != null)
    +        {
    +            this.frame = this._onOutFrameID;
    +        }
    +    }
    +
    +    if (this.onInputOut)
    +    {
    +        this.onInputOut.dispatch(this, pointer);
    +    }
    +};
    +
    +/**
    +* Description.
    +*
    +* @method Phaser.Button.prototype.onInputDownHandler
    +* @param {Description} pointer - Description.
    +*/
    +Phaser.Button.prototype.onInputDownHandler = function (pointer) {
    +
    +    if (this.freezeFrames == false)
    +    {
    +        if (this._onDownFrameName != null)
    +        {
    +            this.frameName = this._onDownFrameName;
    +        }
    +        else if (this._onDownFrameID != null)
    +        {
    +            this.frame = this._onDownFrameID;
    +        }
    +    }
    +
    +    if (this.onInputDown)
    +    {
    +        this.onInputDown.dispatch(this, pointer);
    +    }
    +};
    +
    +/**
    +* Description.
    +*
    +* @method Phaser.Button.prototype.onInputUpHandler
    +* @param {Description} pointer - Description.
    +*/
    +Phaser.Button.prototype.onInputUpHandler = function (pointer) {
    +
    +    if (this.freezeFrames == false)
    +    {
    +        if (this._onUpFrameName != null)
    +        {
    +            this.frameName = this._onUpFrameName;
    +        }
    +        else if (this._onUpFrameID != null)
    +        {
    +            this.frame = this._onUpFrameID;
    +        }
    +    }
    +
    +    if (this.onInputUp)
    +    {
    +        this.onInputUp.dispatch(this, pointer);
    +    }
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Cache.js.html b/docs/Cache.js.html new file mode 100644 index 00000000..8c915f0a --- /dev/null +++ b/docs/Cache.js.html @@ -0,0 +1,1242 @@ + + + + + + Phaser Source: loader/Cache.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: loader/Cache.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser.Cache constructor.
    +*
    +* @class    Phaser.Cache
    +* @classdesc A game only has one instance of a Cache and it is used to store all externally loaded assets such
    +* as images, sounds and data files as a result of Loader calls. Cache items use string based keys for look-up.
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +*/
    +Phaser.Cache = function (game) {
    +
    +    /**
    +	* @property {Phaser.Game} game - Local reference to game.
    +	*/
    +	this.game = game;
    +
    +	/**
    +	* @property {object} game - Canvas key-value container.
    +	* @private
    +	*/
    +    this._canvases = {};
    +
    +    /**
    +	* @property {object} _images - Image key-value container.
    +	* @private
    +	*/
    +    this._images = {};
    +
    +    /**
    +	* @property {object} _textures - RenderTexture key-value container.
    +	* @private
    +	*/
    +    this._textures = {};
    +
    +    /**
    +	* @property {object} _sounds - Sound key-value container.
    +	* @private
    +	*/
    +    this._sounds = {};
    +
    +    /**
    +	* @property {object} _text - Text key-value container.
    +	* @private
    +	*/
    +    this._text = {};
    +
    +    /**
    +	* @property {object} _tilemaps - Tilemap key-value container.
    +	* @private
    +	*/
    +    this._tilemaps = {};
    +
    +    /**
    +    * @property {object} _tilesets - Tileset key-value container.
    +    * @private
    +    */
    +    this._tilesets = {};
    +
    +    this.addDefaultImage();
    +
    +    /**
    +	* @property {Phaser.Signal} onSoundUnlock - Description.
    +	*/
    +    this.onSoundUnlock = new Phaser.Signal;
    +
    +};
    +
    +Phaser.Cache.prototype = {
    +
    +    /**
    +    * Add a new canvas object in to the cache.
    +    * @method Phaser.Cache#addCanvas
    +    * @param {string} key - Asset key for this canvas.
    +    * @param {HTMLCanvasElement} canvas - Canvas DOM element.
    +    * @param {CanvasRenderingContext2D} context - Render context of this canvas.
    +    */
    +    addCanvas: function (key, canvas, context) {
    +
    +        this._canvases[key] = { canvas: canvas, context: context };
    +
    +    },
    +
    +    /**
    +    * Add a new Phaser.RenderTexture in to the cache.
    +    *
    +    * @method Phaser.Cache#addRenderTexture
    +    * @param {string} key - The unique key by which you will reference this object.
    +    * @param {Phaser.Texture} textue - The texture to use as the base of the RenderTexture.
    +    */
    +    addRenderTexture: function (key, texture) {
    +
    +        var frame = new Phaser.Frame(0, 0, 0, texture.width, texture.height, '', '');
    +
    +        this._textures[key] = { texture: texture, frame: frame };
    +
    +    },
    +
    +    /**
    +    * Add a new sprite sheet in to the cache.
    +    *
    +    * @method Phaser.Cache#addSpriteSheet
    +    * @param {string} key - The unique key by which you will reference this object.
    +    * @param {string} url - URL of this sprite sheet file.
    +    * @param {object} data - Extra sprite sheet data.
    +    * @param {number} frameWidth - Width of the sprite sheet.
    +    * @param {number} frameHeight - Height of the sprite sheet.
    +    * @param {number} frameMax - How many frames stored in the sprite sheet.
    +    */
    +    addSpriteSheet: function (key, url, data, frameWidth, frameHeight, frameMax) {
    +
    +        this._images[key] = { url: url, data: data, spriteSheet: true, frameWidth: frameWidth, frameHeight: frameHeight };
    +
    +        PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
    +        PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
    +
    +        this._images[key].frameData = Phaser.AnimationParser.spriteSheet(this.game, key, frameWidth, frameHeight, frameMax);
    +
    +    },
    +
    +    /**
    +    * Add a new tile set in to the cache.
    +    *
    +    * @method Phaser.Cache#addTileset
    +    * @param {string} key - The unique key by which you will reference this object.
    +    * @param {string} url - URL of this tile set file.
    +    * @param {object} data - Extra tile set data.
    +    * @param {number} tileWidth - Width of the sprite sheet.
    +    * @param {number} tileHeight - Height of the sprite sheet.
    +    * @param {number} tileMax - How many tiles stored in the sprite sheet.
    +    * @param {number} [tileMargin=0] - If the tiles have been drawn with a margin, specify the amount here.
    +    * @param {number} [tileSpacing=0] - If the tiles have been drawn with spacing between them, specify the amount here.
    +    */
    +    addTileset: function (key, url, data, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing) {
    +
    +        this._tilesets[key] = { url: url, data: data, tileWidth: tileWidth, tileHeight: tileHeight, tileMargin: tileMargin, tileSpacing: tileSpacing };
    +
    +        PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
    +        PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
    +
    +        this._tilesets[key].tileData = Phaser.TilemapParser.tileset(this.game, key, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing);
    +
    +    },
    +
    +    /**
    +    * Add a new tilemap.
    +    *
    +    * @method Phaser.Cache#addTilemap
    +    * @param {string} key - The unique key by which you will reference this object.
    +    * @param {string} url - URL of the tilemap image.
    +    * @param {object} mapData - The tilemap data object.
    +    * @param {number} format - The format of the tilemap data.
    +    */
    +    addTilemap: function (key, url, mapData, format) {
    +
    +        this._tilemaps[key] = { url: url, data: mapData, format: format };
    +
    +        this._tilemaps[key].layers = Phaser.TilemapParser.parse(this.game, mapData, format);
    +
    +    },
    +
    +    /**
    +    * Add a new texture atlas.
    +    *
    +    * @method Phaser.Cache#addTextureAtlas
    +    * @param {string} key - The unique key by which you will reference this object.
    +    * @param {string} url - URL of this texture atlas file.
    +    * @param {object} data - Extra texture atlas data.
    +    * @param {object} atlasData  - Texture atlas frames data.
    +    * @param {number} format - The format of the texture atlas.
    +    */
    +    addTextureAtlas: function (key, url, data, atlasData, format) {
    +
    +        this._images[key] = { url: url, data: data, spriteSheet: true };
    +
    +        PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
    +        PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
    +
    +        if (format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY)
    +        {
    +            this._images[key].frameData = Phaser.AnimationParser.JSONData(this.game, atlasData, key);
    +        }
    +        else if (format == Phaser.Loader.TEXTURE_ATLAS_JSON_HASH)
    +        {
    +            this._images[key].frameData = Phaser.AnimationParser.JSONDataHash(this.game, atlasData, key);
    +        }
    +        else if (format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING)
    +        {
    +            this._images[key].frameData = Phaser.AnimationParser.XMLData(this.game, atlasData, key);
    +        }
    +
    +    },
    +
    +    /**
    +    * Add a new Bitmap Font.
    +    *
    +    * @method Phaser.Cache#addBitmapFont
    +    * @param {string} key - The unique key by which you will reference this object.
    +    * @param {string} url - URL of this font xml file.
    +    * @param {object} data - Extra font data.
    +    * @param xmlData {object} Texture atlas frames data.
    +    */
    +    addBitmapFont: function (key, url, data, xmlData) {
    +
    +        this._images[key] = { url: url, data: data, spriteSheet: true };
    +
    +        PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
    +        PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
    +
    +        Phaser.LoaderParser.bitmapFont(this.game, xmlData, key);
    +        // this._images[key].frameData = Phaser.AnimationParser.XMLData(this.game, xmlData, key);
    +
    +    },
    +
    +    /**
    +    * Adds a default image to be used when a key is wrong / missing. Is mapped to the key __default.
    +    *
    +    * @method Phaser.Cache#addDefaultImage
    +    */
    +    addDefaultImage: function () {
    +
    +        var img = new Image();
    +        img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==";
    +
    +        this._images['__default'] = { url: null, data: img, spriteSheet: false };
    +        this._images['__default'].frame = new Phaser.Frame(0, 0, 0, 32, 32, '', '');
    +
    +        PIXI.BaseTextureCache['__default'] = new PIXI.BaseTexture(img);
    +        PIXI.TextureCache['__default'] = new PIXI.Texture(PIXI.BaseTextureCache['__default']);
    +
    +    },
    +
    +    /**
    +    * Add a new text data.
    +    *
    +    * @method Phaser.Cache#addText
    +    * @param {string} key - Asset key for the text data. 
    +    * @param {string} url - URL of this text data file.
    +    * @param {object} data - Extra text data.
    +    */    
    +    addText: function (key, url, data) {
    +
    +        this._text[key] = {
    +            url: url,
    +            data: data
    +        };
    +
    +    },
    +
    +    /**
    +    * Add a new image.
    +    *
    +    * @method Phaser.Cache#addImage
    +    * @param {string} key - The unique key by which you will reference this object.
    +    * @param {string} url - URL of this image file.
    +    * @param {object} data - Extra image data.
    +    */
    +    addImage: function (key, url, data) {
    +
    +        this._images[key] = { url: url, data: data, spriteSheet: false };
    +
    +        this._images[key].frame = new Phaser.Frame(0, 0, 0, data.width, data.height, key, this.game.rnd.uuid());
    +
    +        PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
    +        PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
    +
    +    },
    +
    +    /**
    +    * Add a new sound.
    +    *
    +    * @method Phaser.Cache#addSound
    +    * @param {string} key - Asset key for the sound.
    +    * @param {string} url - URL of this sound file.
    +    * @param {object} data - Extra sound data.
    +    * @param {boolean} webAudio - True if the file is using web audio.
    +    * @param {boolean} audioTag - True if the file is using legacy HTML audio.
    +    */
    +    addSound: function (key, url, data, webAudio, audioTag) {
    +
    +        webAudio = webAudio || true;
    +        audioTag = audioTag || false;
    +
    +        var locked = this.game.sound.touchLocked;
    +        var decoded = false;
    +
    +        if (audioTag)
    +        {
    +            decoded = true;
    +        }
    +
    +        this._sounds[key] = { url: url, data: data, isDecoding: false, decoded: decoded, webAudio: webAudio, audioTag: audioTag };
    +
    +    },
    +
    +    /**
    +    * Reload a sound.
    +    * @method Phaser.Cache#reloadSound
    +    * @param {string} key - Asset key for the sound.
    +    */
    +    reloadSound: function (key) {
    +
    +        var _this = this;
    +
    +        if (this._sounds[key])
    +        {
    +            this._sounds[key].data.src = this._sounds[key].url;
    +
    +            this._sounds[key].data.addEventListener('canplaythrough', function () {
    +                return _this.reloadSoundComplete(key);
    +            }, false);
    +
    +            this._sounds[key].data.load();
    +        }
    +    },
    +
    +    /**
    +    * Description.
    +    * @method Phaser.Cache#reloadSoundComplete
    +    * @param {string} key - Asset key for the sound.
    +    */
    +    reloadSoundComplete: function (key) {
    +
    +        if (this._sounds[key])
    +        {
    +            this._sounds[key].locked = false;
    +            this.onSoundUnlock.dispatch(key);
    +        }
    +
    +    },
    +
    +    /**
    +    * Description.
    +    * @method Phaser.Cache#updateSound
    +    * @param {string} key - Asset key for the sound.
    +    */
    +    updateSound: function (key, property, value) {
    +        
    +        if (this._sounds[key])
    +        {
    +            this._sounds[key][property] = value;
    +        }
    +
    +    },
    +
    +	/**
    +	* Add a new decoded sound.
    +    *
    +    * @method Phaser.Cache#decodedSound
    +	* @param {string} key - Asset key for the sound.
    +	* @param {object} data - Extra sound data.
    +	*/
    +    decodedSound: function (key, data) {
    +
    +        this._sounds[key].data = data;
    +        this._sounds[key].decoded = true;
    +        this._sounds[key].isDecoding = false;
    +
    +    },
    +
    +	/**
    +	* Get acanvas object from the cache by its key.
    +    *
    +    * @method Phaser.Cache#getCanvas
    +	* @param {string} key - Asset key of the canvas you want.
    +	* @return {object} The canvas you want.
    +	*/
    +    getCanvas: function (key) {
    +
    +        if (this._canvases[key])
    +        {
    +            return this._canvases[key].canvas;
    +        }
    +
    +        return null;
    +    },
    +
    +    /**
    +    * Checks if an image key exists.
    +    *
    +    * @method Phaser.Cache#checkImageKey
    +    * @param {string} key - Asset key of the image you want.
    +    * @return {boolean} True if the key exists, otherwise false.
    +    */    
    +    checkImageKey: function (key) {
    +
    +        if (this._images[key])
    +        {
    +            return true;
    +        }
    +
    +        return false;
    +
    +    },
    +
    +	/**
    +	* Get image data by key.
    +    *
    +    * @method Phaser.Cache#getImage
    +	* @param {string} key - Asset key of the image you want.
    +	* @return {object} The image data you want.
    +	*/    
    +    getImage: function (key) {
    +
    +        if (this._images[key])
    +        {
    +            return this._images[key].data;
    +        }
    +
    +        return null;
    +    },
    +
    +    /**
    +    * Get tile set image data by key.
    +    *
    +    * @method Phaser.Cache#getTileSetImage
    +    * @param {string} key - Asset key of the image you want.
    +    * @return {object} The image data you want.
    +    */    
    +    getTilesetImage: function (key) {
    +
    +        if (this._tilesets[key])
    +        {
    +            return this._tilesets[key].data;
    +        }
    +
    +        return null;
    +
    +    },
    +
    +    /**
    +    * Get tile set image data by key.
    +    *
    +    * @method Phaser.Cache#getTileset
    +    * @param {string} key - Asset key of the image you want.
    +    * @return {Phaser.Tileset} The tileset data. The tileset image is in the data property, the tile data in tileData.
    +    */    
    +    getTileset: function (key) {
    +
    +        if (this._tilesets[key])
    +        {
    +            return this._tilesets[key].tileData;
    +        }
    +
    +        return null;
    +
    +    },
    +
    +    /**
    +    * Get tilemap data by key.
    +    *
    +    * @method Phaser.Cache#getTilemap
    +    * @param {string} key - Asset key of the tilemap you want.
    +    * @return {Object} The tilemap data. The tileset image is in the data property, the map data in mapData.
    +    */
    +    getTilemapData: function (key) {
    +
    +        if (this._tilemaps[key])
    +        {
    +            return this._tilemaps[key];
    +        }
    +
    +        return null;
    +    },
    +
    +	/**
    +	* Get frame data by key.
    +    *
    +    * @method Phaser.Cache#getFrameData
    +	* @param {string} key - Asset key of the frame data you want.
    +	* @return {Phaser.FrameData} The frame data you want.
    +	*/
    +    getFrameData: function (key) {
    +
    +        if (this._images[key] && this._images[key].frameData)
    +        {
    +            return this._images[key].frameData;
    +        }
    +
    +        return null;
    +    },
    +
    +    /**
    +    * Get a single frame out of a frameData set by key.
    +    *
    +    * @method Phaser.Cache#getFrameByIndex
    +    * @param {string} key - Asset key of the frame data you want.
    +    * @return {Phaser.Frame} The frame data you want.
    +    */
    +    getFrameByIndex: function (key, frame) {
    +
    +        if (this._images[key] && this._images[key].frameData)
    +        {
    +            return this._images[key].frameData.getFrame(frame);
    +        }
    +
    +        return null;
    +    },
    +
    +    /**
    +    * Get a single frame out of a frameData set by key.
    +    *
    +    * @method Phaser.Cache#getFrameByName
    +    * @param {string} key - Asset key of the frame data you want.
    +    * @return {Phaser.Frame} The frame data you want.
    +    */
    +    getFrameByName: function (key, frame) {
    +
    +        if (this._images[key] && this._images[key].frameData)
    +        {
    +            return this._images[key].frameData.getFrameByName(frame);
    +        }
    +
    +        return null;
    +    },
    +
    +    /**
    +    * Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image.
    +    *
    +    * @method Phaser.Cache#getFrame
    +    * @param {string} key - Asset key of the frame data you want.
    +    * @return {Phaser.Frame} The frame data you want.
    +    */
    +    getFrame: function (key) {
    +
    +        if (this._images[key] && this._images[key].spriteSheet == false)
    +        {
    +            return this._images[key].frame;
    +        }
    +
    +        return null;
    +    },
    +
    +    /**
    +    * Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image.
    +    *
    +    * @method Phaser.Cache#getTextureFrame
    +    * @param {string} key - Asset key of the frame data you want.
    +    * @return {Phaser.Frame} The frame data you want.
    +    */
    +    getTextureFrame: function (key) {
    +
    +        if (this._textures[key])
    +        {
    +            return this._textures[key].frame;
    +        }
    +
    +        return null;
    +    },
    +
    +    /**
    +    * Get a RenderTexture by key.
    +    *
    +    * @method Phaser.Cache#getTexture
    +    * @param {string} key - Asset key of the RenderTexture you want.
    +    * @return {Phaser.RenderTexture} The RenderTexture you want.
    +    */
    +    getTexture: function (key) {
    +
    +        if (this._textures[key])
    +        {
    +            return this._textures[key];
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +	* Get sound by key.
    +    *
    +    * @method Phaser.Cache#getSound
    +	* @param {string} key - Asset key of the sound you want.
    +	* @return {Phaser.Sound} The sound you want.
    +	*/
    +    getSound: function (key) {
    +
    +        if (this._sounds[key])
    +        {
    +            return this._sounds[key];
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +	* Get sound data by key.
    +    *
    +    * @method Phaser.Cache#getSoundData
    +	* @param {string} key - Asset key of the sound you want.
    +	* @return {object} The sound data you want.
    +	*/
    +    getSoundData: function (key) {
    +
    +        if (this._sounds[key])
    +        {
    +            return this._sounds[key].data;
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +	* Check if the given sound has finished decoding.
    +    *
    +    * @method Phaser.Cache#isSoundDecoded
    +	* @param {string} key - Asset key of the sound you want.
    +	* @return {boolean} The decoded state of the Sound object.
    +	*/
    +    isSoundDecoded: function (key) {
    +
    +        if (this._sounds[key])
    +        {
    +            return this._sounds[key].decoded;
    +        }
    +
    +    },
    +
    +	/**
    +	* Check if the given sound is ready for playback. A sound is considered ready when it has finished decoding and the device is no longer touch locked.
    +    *
    +    * @method Phaser.Cache#isSoundReady
    +	* @param {string} key - Asset key of the sound you want.
    +	* @return {boolean} True if the sound is decoded and the device is not touch locked.
    +	*/
    +    isSoundReady: function (key) {
    +
    +        return (this._sounds[key] && this._sounds[key].decoded && this.game.sound.touchLocked == false);
    +
    +    },
    +
    +	/**
    +	* Check whether an image asset is sprite sheet or not.
    +    *
    +    * @method Phaser.Cache#isSpriteSheet
    +	* @param {string} key - Asset key of the sprite sheet you want.
    +	* @return {boolean} True if the image is a sprite sheet.
    +	*/
    +    isSpriteSheet: function (key) {
    +
    +        if (this._images[key])
    +        {
    +            return this._images[key].spriteSheet;
    +        }
    +
    +        return false;
    +
    +    },
    +
    +	/**
    +	* Get text data by key.
    +    *
    +    * @method Phaser.Cache#getText
    +	* @param {string} key - Asset key of the text data you want.
    +	* @return {object} The text data you want.
    +	*/
    +    getText: function (key) {
    +
    +        if (this._text[key])
    +        {
    +            return this._text[key].data;
    +        }
    +
    +        return null;
    +        
    +    },
    +
    +    /**
    +    * Get the cache keys from a given array of objects.
    +    * Normally you don't call this directly but instead use getImageKeys, getSoundKeys, etc.
    +    *
    +    * @method Phaser.Cache#getKeys
    +    * @param {Array} array - An array of items to return the keys for.
    +    * @return {Array} The array of item keys.
    +    */
    +    getKeys: function (array) {
    +
    +        var output = [];
    +
    +        for (var item in array)
    +        {
    +            if (item !== '__default')
    +            {
    +                output.push(item);
    +            }
    +        }
    +
    +        return output;
    +
    +    },
    +
    +	/**
    +	* Returns an array containing all of the keys of Images in the Cache.
    +    *
    +    * @method Phaser.Cache#getImageKeys
    +	* @return {Array} The string based keys in the Cache.
    +	*/
    +    getImageKeys: function () {
    +    	return this.getKeys(this._images);
    +    },
    +
    +	/**
    +	* Returns an array containing all of the keys of Sounds in the Cache.
    +    *
    +    * @method Phaser.Cache#getSoundKeys
    +	* @return {Array} The string based keys in the Cache.
    +	*/
    +    getSoundKeys: function () {
    +    	return this.getKeys(this._sounds);
    +    },
    +
    +	/**
    +	* Returns an array containing all of the keys of Text Files in the Cache.
    +    *
    +    * @method Phaser.Cache#getTextKeys
    +	* @return {Array} The string based keys in the Cache.
    +	*/
    +    getTextKeys: function () {
    +    	return this.getKeys(this._text);
    +    },
    +
    +	/**
    +	* Removes a canvas from the cache.
    +    *
    +	* @method Phaser.Cache#removeCanvas
    +    * @param {string} key - Key of the asset you want to remove.
    +	*/
    +    removeCanvas: function (key) {
    +        delete this._canvases[key];
    +    },
    +
    +    /**
    +    * Removes an image from the cache.
    +    *
    +    * @method Phaser.Cache#removeImage
    +    * @param {string} key - Key of the asset you want to remove.
    +    */
    +    removeImage: function (key) {
    +        delete this._images[key];
    +    },
    +
    +    /**
    +    * Removes a sound from the cache.
    +    *
    +    * @method Phaser.Cache#removeSound
    +    * @param {string} key - Key of the asset you want to remove.
    +    */
    +    removeSound: function (key) {
    +        delete this._sounds[key];
    +    },
    +
    +    /**
    +    * Removes a text from the cache.
    +    *
    +    * @method Phaser.Cache#removeText
    +    * @param {string} key - Key of the asset you want to remove.
    +    */
    +    removeText: function (key) {
    +        delete this._text[key];
    +    },
    +
    +	/**
    +	* Clears the cache. Removes every local cache object reference.
    +    *
    +	* @method Phaser.Cache#destroy
    +	*/
    +    destroy: function () {
    +
    +        for (var item in this._canvases)
    +        {
    +            delete this._canvases[item['key']];
    +        }
    +
    +        for (var item in this._images)
    +        {
    +            delete this._images[item['key']];
    +        }
    +
    +        for (var item in this._sounds)
    +        {
    +            delete this._sounds[item['key']];
    +        }
    +
    +        for (var item in this._text)
    +        {
    +            delete this._text[item['key']];
    +        }
    +    }
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Camera.js.html b/docs/Camera.js.html new file mode 100644 index 00000000..91a6d8e5 --- /dev/null +++ b/docs/Camera.js.html @@ -0,0 +1,852 @@ + + + + + + Phaser Source: core/Camera.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/Camera.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view.
    +* The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y
    +*
    +* @class Phaser.Camera
    +* @constructor
    +* @param {Phaser.Game} game - Game reference to the currently running game.
    +* @param {number} id - Not being used at the moment, will be when Phaser supports multiple camera
    +* @param {number} x - Position of the camera on the X axis
    +* @param {number} y - Position of the camera on the Y axis
    +* @param {number} width - The width of the view rectangle
    +* @param {number} height - The height of the view rectangle
    +*/
    +Phaser.Camera = function (game, id, x, y, width, height) {
    +    
    +	/**
    +	* @property {Phaser.Game} game - A reference to the currently running Game.
    +	*/
    +	this.game = game;
    +
    +	/**
    +	* @property {Phaser.World} world - A reference to the game world.
    +	*/
    +	this.world = game.world;
    +
    +	/**
    +	* @property {number} id - Reserved for future multiple camera set-ups.
    +	* @default
    +	*/
    +	this.id = 0; 
    +
    +	/**
    +	* Camera view. 
    +	* The view into the world we wish to render (by default the game dimensions).
    +    * The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render.
    +    * Objects outside of this view are not rendered (unless set to ignore the Camera, i.e. UI?).
    +	* @property {Phaser.Rectangle} view
    +	*/
    +    this.view = new Phaser.Rectangle(x, y, width, height);
    +
    +    /**
    +	* @property {Phaser.Rectangle} screenView - Used by Sprites to work out Camera culling.
    +	*/
    +	this.screenView = new Phaser.Rectangle(x, y, width, height);
    +
    +    /**
    +    * The Camera is bound to this Rectangle and cannot move outside of it. By default it is enabled and set to the size of the World.
    +    * The Rectangle can be located anywhere in the world and updated as often as you like. If you don't wish the Camera to be bound
    +    * at all then set this to null. The values can be anything and are in World coordinates, with 0,0 being the center of the world.
    +    * @property {Phaser.Rectangle} bounds - The Rectangle in which the Camera is bounded. Set to null to allow for movement anywhere.
    +    */
    +    this.bounds = new Phaser.Rectangle(x, y, width, height);
    +
    +    /**
    +	* @property {Phaser.Rectangle} deadzone - Moving inside this Rectangle will not cause camera moving.
    +	*/
    +    this.deadzone = null;
    +
    +	/**
    +	* @property {boolean} visible - Whether this camera is visible or not.
    +	* @default
    +	*/
    +    this.visible = true;
    +
    +	/**
    +	* @property {boolean} atLimit - Whether this camera is flush with the World Bounds or not.
    +    */
    +    this.atLimit = { x: false, y: false };
    +
    +	/**
    +	* @property {Phaser.Sprite} target - If the camera is tracking a Sprite, this is a reference to it, otherwise null.
    +    * @default
    +    */
    +    this.target = null;
    +
    +	/**
    +	* @property {number} edge - Edge property.
    +    * @private
    +    * @default
    +    */
    +    this._edge = 0;
    +
    +    this.displayObject = null;
    +	
    +};
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Camera.FOLLOW_LOCKON = 0;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Camera.FOLLOW_PLATFORMER = 1;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Camera.FOLLOW_TOPDOWN = 2;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Camera.FOLLOW_TOPDOWN_TIGHT = 3;
    +
    +Phaser.Camera.prototype = {
    +
    +	/**
    +    * Tells this camera which sprite to follow.
    +    * @method Phaser.Camera#follow
    +    * @param {Phaser.Sprite} target - The object you want the camera to track. Set to null to not follow anything.
    +    * @param {number} [style] Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().
    +    */
    +    follow: function (target, style) {
    +
    +        if (typeof style === "undefined") { style = Phaser.Camera.FOLLOW_LOCKON; }
    +
    +        this.target = target;
    +
    +        var helper;
    +
    +        switch (style) {
    +
    +            case Phaser.Camera.FOLLOW_PLATFORMER:
    +                var w = this.width / 8;
    +                var h = this.height / 3;
    +                this.deadzone = new Phaser.Rectangle((this.width - w) / 2, (this.height - h) / 2 - h * 0.25, w, h);
    +                break;
    +
    +            case Phaser.Camera.FOLLOW_TOPDOWN:
    +                helper = Math.max(this.width, this.height) / 4;
    +                this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
    +                break;
    +
    +            case Phaser.Camera.FOLLOW_TOPDOWN_TIGHT:
    +                helper = Math.max(this.width, this.height) / 8;
    +                this.deadzone = new Phaser.Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
    +                break;
    +
    +            case Phaser.Camera.FOLLOW_LOCKON:
    +            default:
    +                this.deadzone = null;
    +                break;
    +        }
    +
    +    },
    +
    +    /**
    +    * Move the camera focus on a display object instantly.
    +    * @method Phaser.Camera#focusOn
    +    * @param {any} displayObject - The display object to focus the camera on. Must have visible x/y properties.
    +    */
    +    focusOn: function (displayObject) {
    +
    +        this.setPosition(Math.round(displayObject.x - this.view.halfWidth), Math.round(displayObject.y - this.view.halfHeight));
    +
    +    },
    +
    +	/**
    +    * Move the camera focus on a location instantly.
    +    * @method Phaser.Camera#focusOnXY
    +    * @param {number} x - X position.
    +    * @param {number} y - Y position.
    +    */
    +    focusOnXY: function (x, y) {
    +
    +        this.setPosition(Math.round(x - this.view.halfWidth), Math.round(y - this.view.halfHeight));
    +
    +    },
    +
    +	/**
    +    * Update focusing and scrolling.
    +    * @method Phaser.Camera#update
    +    */
    +    update: function () {
    +
    +        if (this.target)
    +        {
    +            this.updateTarget();
    +        }
    +
    +        if (this.bounds)
    +        {
    +            this.checkBounds();
    +        }
    +
    +        if (this.view.x !== -this.displayObject.position.x)
    +        {
    +            this.displayObject.position.x = -this.view.x;
    +        }
    +
    +        if (this.view.y !== -this.displayObject.position.y)
    +        {
    +            this.displayObject.position.y = -this.view.y;
    +        }
    +
    +    },
    +
    +    updateTarget: function () {
    +
    +        if (this.deadzone)
    +        {
    +            this._edge = this.target.x - this.deadzone.x;
    +
    +            if (this.view.x > this._edge)
    +            {
    +                this.view.x = this._edge;
    +            }
    +
    +            this._edge = this.target.x + this.target.width - this.deadzone.x - this.deadzone.width;
    +
    +            if (this.view.x < this._edge)
    +            {
    +                this.view.x = this._edge;
    +            }
    +
    +            this._edge = this.target.y - this.deadzone.y;
    +
    +            if (this.view.y > this._edge)
    +            {
    +                this.view.y = this._edge;
    +            }
    +
    +            this._edge = this.target.y + this.target.height - this.deadzone.y - this.deadzone.height;
    +
    +            if (this.view.y < this._edge)
    +            {
    +                this.view.y = this._edge;
    +            }
    +        }
    +        else
    +        {
    +            this.focusOnXY(this.target.x, this.target.y);
    +        }
    +
    +    },
    +
    +    setBoundsToWorld: function () {
    +
    +        this.bounds.setTo(this.game.world.x, this.game.world.y, this.game.world.width, this.game.world.height);
    +
    +    },
    +
    +    /**
    +    * Method called to ensure the camera doesn't venture outside of the game world.
    +    * @method Phaser.Camera#checkWorldBounds
    +    */
    +    checkBounds: function () {
    +
    +        this.atLimit.x = false;
    +        this.atLimit.y = false;
    +
    +        //  Make sure we didn't go outside the cameras bounds
    +        if (this.view.x < this.bounds.x)
    +        {
    +            this.atLimit.x = true;
    +            this.view.x = this.bounds.x;
    +        }
    +
    +        if (this.view.x > this.bounds.right - this.width)
    +        {
    +            this.atLimit.x = true;
    +            this.view.x = (this.bounds.right - this.width) + 1;
    +        }
    +
    +        if (this.view.y < this.bounds.top)
    +        {
    +            this.atLimit.y = true;
    +            this.view.y = this.bounds.top;
    +        }
    +
    +        if (this.view.y > this.bounds.bottom - this.height)
    +        {
    +            this.atLimit.y = true;
    +            this.view.y = (this.bounds.bottom - this.height) + 1;
    +        }
    +
    +        this.view.floor();
    +
    +    },
    +
    +    /**
    +    * A helper function to set both the X and Y properties of the camera at once
    +    * without having to use game.camera.x and game.camera.y.
    +    * 
    +    * @method Phaser.Camera#setPosition
    +    * @param {number} x - X position.
    +    * @param {number} y - Y position.
    +    */
    +    setPosition: function (x, y) {
    +
    +        this.view.x = x;
    +        this.view.y = y;
    +
    +        if (this.bounds)
    +        {
    +            this.checkBounds();
    +        }
    +
    +    },
    +
    +    /**
    +    * Sets the size of the view rectangle given the width and height in parameters.
    +    * 
    +    * @method Phaser.Camera#setSize
    +    * @param {number} width - The desired width.
    +    * @param {number} height - The desired height.
    +    */
    +    setSize: function (width, height) {
    +
    +        this.view.width = width;
    +        this.view.height = height;
    +
    +    }
    +
    +};
    +
    +/**
    +* The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds.
    +* @name Phaser.Camera#x
    +* @property {number} x - Gets or sets the cameras x position.
    +*/
    +Object.defineProperty(Phaser.Camera.prototype, "x", {
    +
    +    get: function () {
    +        return this.view.x;
    +    },
    + 
    +    set: function (value) {
    +
    +        this.view.x = value;
    +
    +        if (this.bounds)
    +        {
    +            this.checkBounds();
    +        }
    +    }
    +
    +});
    +
    +/**
    +* The Cameras y coordinate. This value is automatically clamped if it falls outside of the World bounds.
    +* @name Phaser.Camera#y
    +* @property {number} y - Gets or sets the cameras y position.
    +*/
    +Object.defineProperty(Phaser.Camera.prototype, "y", {
    +	
    +    get: function () {
    +        return this.view.y;
    +    },
    +
    +    set: function (value) {
    +
    +        this.view.y = value;
    +
    +        if (this.bounds)
    +        {
    +            this.checkBounds();
    +        }
    +    }
    +
    +});
    +
    +/**
    +* The Cameras width. By default this is the same as the Game size and should not be adjusted for now.
    +* @name Phaser.Camera#width
    +* @property {number} width - Gets or sets the cameras width.
    +*/
    +Object.defineProperty(Phaser.Camera.prototype, "width", {
    +
    +    get: function () {
    +        return this.view.width;
    +    },
    +
    +    set: function (value) {
    +        this.view.width = value;
    +    }
    +
    +});
    +
    +/**
    +* The Cameras height. By default this is the same as the Game size and should not be adjusted for now.
    +* @name Phaser.Camera#height
    +* @property {number} height - Gets or sets the cameras height.
    +*/
    +Object.defineProperty(Phaser.Camera.prototype, "height", {
    +
    +    get: function () {
    +        return this.view.height;
    +    },
    +
    +    set: function (value) {
    +        this.view.height = value;
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Canvas.js.html b/docs/Canvas.js.html new file mode 100644 index 00000000..7960c51c --- /dev/null +++ b/docs/Canvas.js.html @@ -0,0 +1,701 @@ + + + + + + Phaser Source: system/Canvas.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: system/Canvas.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* The Canvas class handles everything related to the <canvas> tag as a DOM Element, like styles, offset, aspect ratio
    +*
    +* @class Phaser.Canvas
    +* @static
    +*/
    +Phaser.Canvas = {
    +
    +    /**
    +    * Creates the <canvas> tag
    +    *
    +    * @method Phaser.Canvas.create
    +    * @param {number} width - The desired width.
    +    * @param {number} height - The desired height.
    +    * @return {HTMLCanvasElement} The newly created <canvas> tag.
    +    */
    +    create: function (width, height) {
    +
    +        width = width || 256;
    +        height = height || 256;
    +
    +        var canvas = document.createElement('canvas');
    +        canvas.width = width;
    +        canvas.height = height;
    +        canvas.style.display = 'block';
    +
    +        return canvas;
    +
    +    },
    +
    +    /**
    +    * Get the DOM offset values of any given element
    +    * @method Phaser.Canvas.getOffset
    +    * @param {HTMLElement} element - The targeted element that we want to retrieve the offset.
    +    * @param {Phaser.Point} [point] - The point we want to take the x/y values of the offset.
    +    * @return {Phaser.Point} - A point objet with the offsetX and Y as its properties.
    +    */    
    +    getOffset: function (element, point) {
    +
    +        point = point || new Phaser.Point;
    +
    +        var box = element.getBoundingClientRect();
    +        var clientTop = element.clientTop || document.body.clientTop || 0;
    +        var clientLeft = element.clientLeft || document.body.clientLeft || 0;
    +        var scrollTop = window.pageYOffset || element.scrollTop || document.body.scrollTop;
    +        var scrollLeft = window.pageXOffset || element.scrollLeft || document.body.scrollLeft;
    +
    +        point.x = box.left + scrollLeft - clientLeft;
    +        point.y = box.top + scrollTop - clientTop;
    +
    +        return point;
    +
    +    },
    +
    +    /**
    +    * Returns the aspect ratio of the given canvas.
    +    *
    +    * @method Phaser.Canvas.getAspectRatio
    +    * @param {HTMLCanvasElement} canvas - The canvas to get the aspect ratio from.
    +    * @return {number} The ratio between canvas' width and height.
    +    */        
    +    getAspectRatio: function (canvas) {
    +        return canvas.width / canvas.height;
    +    },
    +
    +    /**
    +    * Sets the background color behind the canvas. This changes the canvas style property.
    +    *
    +    * @method Phaser.Canvas.setBackgroundColor
    +    * @param {HTMLCanvasElement} canvas - The canvas to set the background color on.
    +    * @param {string} [color] - The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color.
    +    * @return {HTMLCanvasElement} Returns the source canvas.
    +    */
    +    setBackgroundColor: function (canvas, color) {
    +
    +        color = color || 'rgb(0,0,0)';
    +
    +        canvas.style.backgroundColor = color;
    +        
    +        return canvas;
    +
    +    },
    +
    +    /**
    +    * Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions.
    +    *
    +    * @method Phaser.Canvas.setTouchAction
    +    * @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
    +    * @param {String} [value] - The touch action to set. Defaults to 'none'.
    +    * @return {HTMLCanvasElement} The source canvas.
    +    */
    +    setTouchAction: function (canvas, value) {
    +
    +        value = value || 'none';
    +
    +        canvas.style.msTouchAction = value;
    +        canvas.style['ms-touch-action'] = value;
    +        canvas.style['touch-action'] = value;
    +
    +        return canvas;
    +
    +    },
    +
    +    /**
    +    * Sets the user-select property on the canvas style. Can be used to disable default browser selection actions.
    +    *
    +    * @method Phaser.Canvas.setUserSelect
    +    * @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
    +    * @param {String} [value] - The touch action to set. Defaults to 'none'.
    +    * @return {HTMLCanvasElement} The source canvas.
    +    */
    +    setUserSelect: function (canvas, value) {
    +
    +        value = value || 'none';
    +
    +        canvas.style['-webkit-touch-callout'] = value;
    +        canvas.style['-webkit-user-select'] = value;
    +        canvas.style['-khtml-user-select'] = value;
    +        canvas.style['-moz-user-select'] = value;
    +        canvas.style['-ms-user-select'] = value;
    +        canvas.style['user-select'] = value;
    +        canvas.style['-webkit-tap-highlight-color'] = 'rgba(0, 0, 0, 0)';
    +
    +        return canvas;
    +
    +    },
    +
    +    /**
    +    * Adds the given canvas element to the DOM. The canvas will be added as a child of the given parent.
    +    * If no parent is given it will be added as a child of the document.body.
    +    *
    +    * @method Phaser.Canvas.addToDOM
    +    * @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
    +    * @param {string} parent - The DOM element to add the canvas to. Defaults to ''.
    +    * @param {boolean} overflowHidden - If set to true it will add the overflow='hidden' style to the parent DOM element.
    +    * @return {HTMLCanvasElement} Returns the source canvas.
    +    */
    +    addToDOM: function (canvas, parent, overflowHidden) {
    +
    +        parent = parent || '';
    +
    +        if (typeof overflowHidden === 'undefined') { overflowHidden = true; }
    +
    +        if (parent !== '')
    +        {
    +            if (document.getElementById(parent))
    +            {
    +                document.getElementById(parent).appendChild(canvas);
    +
    +                if (overflowHidden)
    +                {
    +                    document.getElementById(parent).style.overflow = 'hidden';
    +                }
    +            }
    +            else
    +            {
    +                document.body.appendChild(canvas);
    +            }
    +        }
    +        else
    +        {
    +            document.body.appendChild(canvas);
    +        }
    +
    +        return canvas;
    +
    +    },
    +
    +    /**
    +    * Sets the transform of the given canvas to the matrix values provided.
    +    *
    +    * @method Phaser.Canvas.setTransform
    +    * @param {CanvasRenderingContext2D} context - The context to set the transform on.
    +    * @param {number} translateX - The value to translate horizontally by.
    +    * @param {number} translateY - The value to translate vertically by.
    +    * @param {number} scaleX - The value to scale horizontally by.
    +    * @param {number} scaleY - The value to scale vertically by.
    +    * @param {number} skewX - The value to skew horizontaly by.
    +    * @param {number} skewY - The value to skew vertically by.
    +    * @return {CanvasRenderingContext2D} Returns the source context.
    +    */
    +    setTransform: function (context, translateX, translateY, scaleX, scaleY, skewX, skewY) {
    +
    +        context.setTransform(scaleX, skewX, skewY, scaleY, translateX, translateY);
    +
    +        return context;
    +
    +    },
    +
    +    /**
    +    * Sets the Image Smoothing property on the given context. Set to false to disable image smoothing.
    +    * By default browsers have image smoothing enabled, which isn't always what you visually want, especially
    +    * 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.
    +    *
    +    * @method Phaser.Canvas.setSmoothingEnabled
    +    * @param {CanvasRenderingContext2D} context - The context to enable or disable the image smoothing on.
    +    * @param {boolean} value - If set to true it will enable image smoothing, false will disable it.
    +    * @return {CanvasRenderingContext2D} Returns the source context.
    +    */
    +    setSmoothingEnabled: function (context, value) {
    +
    +        context['imageSmoothingEnabled'] = value;
    +        context['mozImageSmoothingEnabled'] = value;
    +        context['oImageSmoothingEnabled'] = value;
    +        context['webkitImageSmoothingEnabled'] = value;
    +        context['msImageSmoothingEnabled'] = value;
    +
    +        return context;
    +
    +    },
    +
    +    /**
    +    * Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast on webkit').
    +    * Note that if this doesn't given the desired result then see the setSmoothingEnabled.
    +    *
    +    * @method Phaser.Canvas.setImageRenderingCrisp
    +    * @param {HTMLCanvasElement} canvas - The canvas to set image-rendering crisp on.
    +    * @return {HTMLCanvasElement} Returns the source canvas.
    +    */
    +    setImageRenderingCrisp: function (canvas) {
    +
    +        canvas.style['image-rendering'] = 'crisp-edges';
    +        canvas.style['image-rendering'] = '-moz-crisp-edges';
    +        canvas.style['image-rendering'] = '-webkit-optimize-contrast';
    +        canvas.style.msInterpolationMode = 'nearest-neighbor';
    +
    +        return canvas;
    +
    +    },
    +
    +    /**
    +    * Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto').
    +    * Note that if this doesn't given the desired result then see the CanvasUtils.setSmoothingEnabled method.
    +    *
    +    * @method Phaser.Canvas.setImageRenderingBicubic
    +    * @param {HTMLCanvasElement} canvas The canvas to set image-rendering bicubic on.
    +    * @return {HTMLCanvasElement} Returns the source canvas.
    +    */
    +    setImageRenderingBicubic: function (canvas) {
    +
    +        canvas.style['image-rendering'] = 'auto';
    +        canvas.style.msInterpolationMode = 'bicubic';
    +
    +        return canvas;
    +
    +    }
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Circle.js.html b/docs/Circle.js.html new file mode 100644 index 00000000..fbc48b91 --- /dev/null +++ b/docs/Circle.js.html @@ -0,0 +1,915 @@ + + + + + + Phaser Source: geom/Circle.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: geom/Circle.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created.
    +* @class Circle
    +* @classdesc Phaser - Circle
    +* @constructor
    +* @param {number} [x] The x coordinate of the center of the circle.
    +* @param {number} [y] The y coordinate of the center of the circle.
    +* @param {number} [diameter] The diameter of the circle.
    +* @return {Phaser.Circle} This circle object
    +**/
    +Phaser.Circle = function (x, y, diameter) {
    +
    +    x = x || 0;
    +    y = y || 0;
    +    diameter = diameter || 0;
    +
    +    /**
    +    * @property {number} x - The x coordinate of the center of the circle.
    +    **/
    +    this.x = x;
    +
    +    /**
    +    * @property {number} y - The y coordinate of the center of the circle.
    +    **/
    +    this.y = y;
    +
    +    /**
    +    * @property {number} _diameter - The diameter of the circle.
    +    * @private
    +    **/
    +    this._diameter = diameter;
    +
    +    if (diameter > 0)
    +    {
    +    	/**
    +    	* @property {number} _radius - The radius of the circle.
    +    	* @private
    +        **/
    +        this._radius = diameter * 0.5;
    +    }
    +    else
    +    {
    +        this._radius = 0;
    +    }
    +
    +};
    +
    +Phaser.Circle.prototype = {
    +
    +    /**
    +    * The circumference of the circle.
    +    * @method Phaser.Circle#circumference
    +    * @return {number}
    +    **/
    +    circumference: function () {
    +        return 2 * (Math.PI * this._radius);
    +    },
    +
    +    /**
    +    * Sets the members of Circle to the specified values.
    +    * @method Phaser.Circle#setTo
    +    * @param {number} x - The x coordinate of the center of the circle.
    +    * @param {number} y - The y coordinate of the center of the circle.
    +    * @param {number} diameter - The diameter of the circle in pixels.
    +    * @return {Circle} This circle object.
    +    **/
    +    setTo: function (x, y, diameter) {
    +        this.x = x;
    +        this.y = y;
    +        this._diameter = diameter;
    +        this._radius = diameter * 0.5;
    +        return this;
    +    },
    +
    +    /**
    +    * Copies the x, y and diameter properties from any given object to this Circle.
    +    * @method Phaser.Circle#copyFrom
    +    * @param {any} source - The object to copy from.
    +    * @return {Circle} This Circle object.
    +    **/
    +    copyFrom: function (source) {
    +        return this.setTo(source.x, source.y, source.diameter);
    +    },
    +
    +    /**
    +    * Copies the x, y and diameter properties from this Circle to any given object.
    +    * @method Phaser.Circle#copyTo
    +    * @param {any} dest - The object to copy to.
    +    * @return {Object} This dest object.
    +    **/
    +    copyTo: function(dest) {
    +        dest[x] = this.x;
    +        dest[y] = this.y;
    +        dest[diameter] = this._diameter;
    +        return dest;
    +    },
    +
    +    /**
    +    * Returns the distance from the center of the Circle object to the given object
    +    * (can be Circle, Point or anything with x/y properties)
    +    * @method Phaser.Circle#distance
    +    * @param {object} dest - The target object. Must have visible x and y properties that represent the center of the object.
    +    * @param {boolean} [round] - Round the distance to the nearest integer (default false).
    +    * @return {number} The distance between this Point object and the destination Point object.
    +    */
    +    distance: function (dest, round) {
    +
    +        if (typeof round === "undefined") { round = false }
    +
    +        if (round)
    +        {
    +            return Phaser.Math.distanceRound(this.x, this.y, dest.x, dest.y);
    +        }
    +        else
    +        {
    +            return Phaser.Math.distance(this.x, this.y, dest.x, dest.y);
    +        }
    +
    +    },
    +
    +    /**
    +    * Returns a new Circle object with the same values for the x, y, width, and height properties as this Circle object.
    +    * @method Phaser.Circle#clone
    +    * @param {Phaser.Circle} out - Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned.
    +    * @return {Phaser.Circle} The cloned Circle object.
    +    */
    +    clone: function(out) {
    +
    +        if (typeof out === "undefined") { out = new Phaser.Circle(); }
    +
    +        return out.setTo(a.x, a.y, a.diameter);
    +
    +    },
    +
    +    /**
    +    * Return true if the given x/y coordinates are within this Circle object.
    +    * @method Phaser.Circle#contains
    +    * @param {number} x - The X value of the coordinate to test.
    +    * @param {number} y - The Y value of the coordinate to test.
    +    * @return {boolean} True if the coordinates are within this circle, otherwise false.
    +    */
    +    contains: function (x, y) {
    +        return Phaser.Circle.contains(this, x, y);
    +    },
    +
    +    /**
    +    * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
    +    * @method Phaser.Circle#circumferencePoint
    +    * @param {number} angle - The angle in radians (unless asDegrees is true) to return the point from.
    +    * @param {boolean} asDegrees - Is the given angle in radians (false) or degrees (true)?
    +    * @param {Phaser.Point} [out] - An optional Point object to put the result in to. If none specified a new Point object will be created.
    +    * @return {Phaser.Point} The Point object holding the result.
    +    */
    +    circumferencePoint: function (angle, asDegrees, out) {
    +        return Phaser.Circle.circumferencePoint(this, angle, asDegrees, out);
    +    },
    +
    +    /**
    +    * Adjusts the location of the Circle object, as determined by its center coordinate, by the specified amounts.
    +    * @method Phaser.Circle#offset
    +    * @param {number} dx - Moves the x value of the Circle object by this amount.
    +    * @param {number} dy - Moves the y value of the Circle object by this amount.
    +    * @return {Circle} This Circle object.
    +    **/
    +    offset: function (dx, dy) {
    +        this.x += dx;
    +        this.y += dy;
    +        return this;
    +    },
    +
    +    /**
    +    * Adjusts the location of the Circle object using a Point object as a parameter. This method is similar to the Circle.offset() method, except that it takes a Point object as a parameter.
    +    * @method Phaser.Circle#offsetPoint
    +    * @param {Point} point A Point object to use to offset this Circle object (or any valid object with exposed x and y properties).
    +    * @return {Circle} This Circle object.
    +    **/
    +    offsetPoint: function (point) {
    +        return this.offset(point.x, point.y);
    +    },
    +
    +    /**
    +    * Returns a string representation of this object.
    +    * @method Phaser.Circle#toString
    +    * @return {string} a string representation of the instance.
    +    **/
    +    toString: function () {
    +        return "[{Phaser.Circle (x=" + this.x + " y=" + this.y + " diameter=" + this.diameter + " radius=" + this.radius + ")}]";
    +    }
    +
    +};
    +
    +/**
    +* The largest distance between any two points on the circle. The same as the radius * 2.
    +* @name Phaser.Circle#diameter
    +* @property {number} diameter - Gets or sets the diameter of the circle.
    +*/
    +Object.defineProperty(Phaser.Circle.prototype, "diameter", {
    +
    +    get: function () {
    +        return this._diameter;
    +    },
    +
    +    set: function (value) {
    +        if (value > 0) {
    +            this._diameter = value;
    +            this._radius = value * 0.5;
    +        }
    +    }
    +
    +});
    +
    +/**
    +* The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter.
    +* @name Phaser.Circle#radius
    +* @property {number} radius - Gets or sets the radius of the circle.
    +*/
    +Object.defineProperty(Phaser.Circle.prototype, "radius", {
    +    
    +    get: function () {
    +        return this._radius;
    +    },
    +
    +    set: function (value) {
    +        if (value > 0) {
    +            this._radius = value;
    +            this._diameter = value * 2;
    +        }
    +    }
    +
    +});
    +
    +/**
    +* The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
    +* @name Phaser.Circle#left
    +* @propety {number} left - Gets or sets the value of the leftmost point of the circle.
    +*/
    +Object.defineProperty(Phaser.Circle.prototype, "left", {
    +    
    +    get: function () {
    +        return this.x - this._radius;
    +    },
    +
    +    set: function (value) {
    +        if (value > this.x) {
    +            this._radius = 0;
    +            this._diameter = 0;
    +        } else {
    +            this.radius = this.x - value;
    +        }
    +    }
    +
    +});
    +
    +/**
    +* The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.
    +* @name Phaser.Circle#right
    +* @property {number} right - Gets or sets the value of the rightmost point of the circle.
    +*/
    +Object.defineProperty(Phaser.Circle.prototype, "right", {
    +
    +    get: function () {
    +        return this.x + this._radius;
    +    },
    +
    +    set: function (value) {
    +        if (value < this.x) {
    +            this._radius = 0;
    +            this._diameter = 0;
    +        } else {
    +            this.radius = value - this.x;
    +        }
    +    }
    +
    +});
    +
    +/**
    +* The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter.
    +* @name Phaser.Circle#top
    +* @property {number} top - Gets or sets the top of the circle.
    +*/
    +Object.defineProperty(Phaser.Circle.prototype, "top", {
    +
    +    get: function () {
    +        return this.y - this._radius;
    +    },
    +    
    +    set: function (value) {
    +        if (value > this.y) {
    +            this._radius = 0;
    +            this._diameter = 0;
    +        } else {
    +            this.radius = this.y - value;
    +        }
    +    }
    +
    +});
    +
    +/**
    +* The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter.
    +* @name Phaser.Circle#bottom
    +* @property {number} bottom - Gets or sets the bottom of the circle.
    +*/
    +Object.defineProperty(Phaser.Circle.prototype, "bottom", {
    +
    +    get: function () {
    +        return this.y + this._radius;
    +    },
    +
    +    set: function (value) {
    +
    +        if (value < this.y) {
    +            this._radius = 0;
    +            this._diameter = 0;
    +        } else {
    +            this.radius = value - this.y;
    +        }
    +    }
    +
    +});
    +
    +/**
    +* The area of this Circle.
    +* @name Phaser.Circle#area
    +* @property {number} area - The area of this circle.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Circle.prototype, "area", {
    +
    +    get: function () {
    +        if (this._radius > 0) {
    +            return Math.PI * this._radius * this._radius;
    +        } else {
    +            return 0;
    +        }
    +    }
    +
    +});
    +
    +/**
    +* Determines whether or not this Circle object is empty. Will return a value of true if the Circle objects diameter is less than or equal to 0; otherwise false.
    +* If set to true it will reset all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0.
    +* @name Phaser.Circle#empty
    +* @property {boolean} empty - Gets or sets the empty state of the circle.
    +*/
    +Object.defineProperty(Phaser.Circle.prototype, "empty", {
    +
    +    get: function () {
    +        return (this._diameter == 0);
    +    },
    +
    +    set: function (value) {
    +        this.setTo(0, 0, 0);
    +    }
    +
    +});
    +
    +/**
    +* Return true if the given x/y coordinates are within the Circle object.
    +* @method Phaser.Circle.contains
    +* @param {Phaser.Circle} a - The Circle to be checked.
    +* @param {number} x - The X value of the coordinate to test.
    +* @param {number} y - The Y value of the coordinate to test.
    +* @return {boolean} True if the coordinates are within this circle, otherwise false.
    +*/
    +Phaser.Circle.contains = function (a, x, y) {
    +
    +    //  Check if x/y are within the bounds first
    +    if (x >= a.left && x <= a.right && y >= a.top && y <= a.bottom) {
    +
    +        var dx = (a.x - x) * (a.x - x);
    +        var dy = (a.y - y) * (a.y - y);
    +
    +        return (dx + dy) <= (a.radius * a.radius);
    +
    +    }
    +
    +    return false;
    +
    +};
    +
    +/**
    +* Determines whether the two Circle objects match. This method compares the x, y and diameter properties.
    +* @method Phaser.Circle.equals
    +* @param {Phaser.Circle} a - The first Circle object.
    +* @param {Phaser.Circle} b - The second Circle object.
    +* @return {boolean} A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false.
    +*/
    +Phaser.Circle.equals = function (a, b) {
    +    return (a.x == b.x && a.y == b.y && a.diameter == b.diameter);
    +};
    +
    +/**
    +* Determines whether the two Circle objects intersect.
    +* This method checks the radius distances between the two Circle objects to see if they intersect.
    +* @method Phaser.Circle.intersects
    +* @param {Phaser.Circle} a - The first Circle object.
    +* @param {Phaser.Circle} b - The second Circle object.
    +* @return {boolean} A value of true if the specified object intersects with this Circle object; otherwise false.
    +*/
    +Phaser.Circle.intersects = function (a, b) {
    +    return (Phaser.Math.distance(a.x, a.y, b.x, b.y) <= (a.radius + b.radius));
    +};
    +
    +/**
    +* Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.
    +* @method Phaser.Circle.circumferencePoint
    +* @param {Phaser.Circle} a - The first Circle object.
    +* @param {number} angle - The angle in radians (unless asDegrees is true) to return the point from.
    +* @param {boolean} asDegrees - Is the given angle in radians (false) or degrees (true)?
    +* @param {Phaser.Point} [out] - An optional Point object to put the result in to. If none specified a new Point object will be created.
    +* @return {Phaser.Point} The Point object holding the result.
    +*/
    +Phaser.Circle.circumferencePoint = function (a, angle, asDegrees, out) {
    +
    +    if (typeof asDegrees === "undefined") { asDegrees = false; }
    +    if (typeof out === "undefined") { out = new Phaser.Point(); }
    +
    +    if (asDegrees === true) {
    +        angle = Phaser.Math.radToDeg(angle);
    +    }
    +
    +    out.x = a.x + a.radius * Math.cos(angle);
    +    out.y = a.y + a.radius * Math.sin(angle);
    +
    +    return out;
    +
    +};
    +
    +/**
    +* Checks if the given Circle and Rectangle objects intersect.
    +* @method Phaser.Circle.intersectsRectangle
    +* @param {Phaser.Circle} c - The Circle object to test.
    +* @param {Phaser.Rectangle} r - The Rectangle object to test.
    +* @return {boolean} True if the two objects intersect, otherwise false.
    +*/
    +Phaser.Circle.intersectsRectangle = function (c, r) {
    +
    +    var cx = Math.abs(c.x - r.x - r.halfWidth);
    +    var xDist = r.halfWidth + c.radius;
    +
    +    if (cx > xDist) {
    +        return false;
    +    }
    +
    +    var cy = Math.abs(c.y - r.y - r.halfHeight);
    +    var yDist = r.halfHeight + c.radius;
    +
    +    if (cy > yDist) {
    +        return false;
    +    }
    +
    +    if (cx <= r.halfWidth || cy <= r.halfHeight) {
    +        return true;
    +    }
    +
    +    var xCornerDist = cx - r.halfWidth;
    +    var yCornerDist = cy - r.halfHeight;
    +    var xCornerDistSq = xCornerDist * xCornerDist;
    +    var yCornerDistSq = yCornerDist * yCornerDist;
    +    var maxCornerDistSq = c.radius * c.radius;
    +
    +    return xCornerDistSq + yCornerDistSq <= maxCornerDistSq;
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Color.js.html b/docs/Color.js.html new file mode 100644 index 00000000..21dad46a --- /dev/null +++ b/docs/Color.js.html @@ -0,0 +1,772 @@ + + + + + + Phaser Source: utils/Color.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: utils/Color.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* A collection of methods useful for manipulating and comparing colors.
    +*
    +* @class Phaser.Color
    +*/
    +Phaser.Color = {
    +
    +    /**
    +    * Given an alpha and 3 color values this will return an integer representation of it.
    +    *
    +    * @method Phaser.Color.getColor32
    +    * @param {number} alpha - The Alpha value (between 0 and 255).
    +    * @param {number} red - The Red channel value (between 0 and 255).
    +    * @param {number} green - The Green channel value (between 0 and 255).
    +    * @param {number} blue - The Blue channel value (between 0 and 255).
    +    * @returns {number} A native color value integer (format: 0xAARRGGBB).
    +    */
    +    getColor32: function (alpha, red, green, blue) {
    +        return alpha << 24 | red << 16 | green << 8 | blue;
    +    },
    +
    +    /**
    +    * Given 3 color values this will return an integer representation of it.
    +    *
    +    * @method Phaser.Color.getColor
    +    * @param {number} red - The Red channel value (between 0 and 255).
    +    * @param {number} green - The Green channel value (between 0 and 255).
    +    * @param {number} blue - The Blue channel value (between 0 and 255).
    +    * @returns {number} A native color value integer (format: 0xRRGGBB).
    +    */
    +    getColor: function (red, green, blue) {
    +        return red << 16 | green << 8 | blue;
    +    },
    +
    +    /**
    +    * Converts the given hex string into an object containing the RGB values.
    +    *
    +    * @method Phaser.Color.hexToRGB
    +    * @param {string} h - The string hex color to convert.
    +    * @returns {object} An object with 3 properties: r,g and b.
    +    */
    +    hexToRGB: function (h) {
    +
    +        var hex16 = (h.charAt(0) == "#") ? h.substring(1, 7) : h;
    +        var red = parseInt(hex16.substring(0, 2), 16);
    +        var green = parseInt(hex16.substring(2, 4), 16);
    +        var blue = parseInt(hex16.substring(4, 6), 16);
    +
    +        return red << 16 | green << 8 | blue;
    +        
    +    },
    +
    +    /**
    +    * Returns a string containing handy information about the given color including string hex value,
    +    * RGB format information and HSL information. Each section starts on a newline, 3 lines in total.
    +    *
    +    * @method Phaser.Color.getColorInfo
    +    * @param {number} color - A color value in the format 0xAARRGGBB.
    +    * @returns {string} String containing the 3 lines of information.
    +    */
    +    getColorInfo: function (color) {
    +
    +        var argb = Phaser.Color.getRGB(color);
    +        var hsl = Phaser.Color.RGBtoHSV(color);
    +        
    +        //	Hex format
    +        var result = Phaser.Color.RGBtoHexstring(color) + "\n";
    +        
    +        //	RGB format
    +        result = result.concat("Alpha: " + argb.alpha + " Red: " + argb.red + " Green: " + argb.green + " Blue: " + argb.blue) + "\n";
    +        
    +        //	HSL info
    +        result = result.concat("Hue: " + hsl.hue + " Saturation: " + hsl.saturation + " Lightnes: " + hsl.lightness);
    +
    +        return result;
    +
    +    },
    +
    +    /**
    +    * Return a string representation of the color in the format 0xAARRGGBB.
    +    *
    +    * @method Phaser.Color.RGBtoHexstring
    +    * @param {number} color - The color to get the string representation for
    +    * @returns {string} A string of length 10 characters in the format 0xAARRGGBB
    +    */
    +    RGBtoHexstring: function (color) {
    +
    +        var argb = Phaser.Color.getRGB(color);
    +
    +        return "0x" + Phaser.Color.colorToHexstring(argb.alpha) + Phaser.Color.colorToHexstring(argb.red) + Phaser.Color.colorToHexstring(argb.green) + Phaser.Color.colorToHexstring(argb.blue);
    +
    +    },
    +
    +    /**
    +    * Return a string representation of the color in the format #RRGGBB.
    +    *
    +    * @method Phaser.Color.RGBtoWebstring
    +    * @param {number} color - The color to get the string representation for.
    +    * @returns {string} A string of length 10 characters in the format 0xAARRGGBB.
    +    */
    +    RGBtoWebstring: function (color) {
    +
    +        var argb = Phaser.Color.getRGB(color);
    +
    +        return "#" + Phaser.Color.colorToHexstring(argb.red) + Phaser.Color.colorToHexstring(argb.green) + Phaser.Color.colorToHexstring(argb.blue);
    +
    +    },
    +
    +    /**
    +    * Return a string containing a hex representation of the given color.
    +    *
    +    * @method Phaser.Color.colorToHexstring
    +    * @param {number} color - The color channel to get the hex value for, must be a value between 0 and 255).
    +    * @returns {string} A string of length 2 characters, i.e. 255 = FF, 0 = 00.
    +    */
    +    colorToHexstring: function (color) {
    +
    +        var digits = "0123456789ABCDEF";
    +        var lsd = color % 16;
    +        var msd = (color - lsd) / 16;
    +        var hexified = digits.charAt(msd) + digits.charAt(lsd);
    +        return hexified;
    +
    +    },
    +
    +    /**
    +    * Interpolates the two given colours based on the supplied step and currentStep properties.
    +    * @method Phaser.Color.interpolateColor
    +    * @param {number} color1 - Description.
    +    * @param {number} color2 - Description.
    +    * @param {number} steps - Description.
    +    * @param {number} currentStep - Description.
    +    * @param {number} alpha - Description.
    +    * @returns {number} The interpolated color value.
    +    */
    +    interpolateColor: function (color1, color2, steps, currentStep, alpha) {
    +
    +        if (typeof alpha === "undefined") { alpha = 255; }
    +
    +        var src1 = Phaser.Color.getRGB(color1);
    +        var src2 = Phaser.Color.getRGB(color2);
    +        var r = (((src2.red - src1.red) * currentStep) / steps) + src1.red;
    +        var g = (((src2.green - src1.green) * currentStep) / steps) + src1.green;
    +        var b = (((src2.blue - src1.blue) * currentStep) / steps) + src1.blue;
    +
    +        return Phaser.Color.getColor32(alpha, r, g, b);
    +
    +    },
    +
    +    /**
    +    * Interpolates the two given colours based on the supplied step and currentStep properties.
    +    * @method Phaser.Color.interpolateColorWithRGB
    +    * @param {number} color - Description.
    +    * @param {number} r - Description.
    +    * @param {number} g - Description.
    +    * @param {number} b - Description.
    +    * @param {number} steps - Description.
    +    * @param {number} currentStep - Description.
    +    * @returns {number} The interpolated color value.
    +    */
    +    interpolateColorWithRGB: function (color, r, g, b, steps, currentStep) {
    +
    +        var src = Phaser.Color.getRGB(color);
    +        var or = (((r - src.red) * currentStep) / steps) + src.red;
    +        var og = (((g - src.green) * currentStep) / steps) + src.green;
    +        var ob = (((b - src.blue) * currentStep) / steps) + src.blue;
    +
    +        return Phaser.Color.getColor(or, og, ob);
    +
    +    },
    +
    +    /**
    +    * Interpolates the two given colours based on the supplied step and currentStep properties.
    +    * @method Phaser.Color.interpolateRGB
    +    * @param {number} r1 - Description.
    +    * @param {number} g1 - Description.
    +    * @param {number} b1 - Description.
    +    * @param {number} r2 - Description.
    +    * @param {number} g2 - Description.
    +    * @param {number} b2 - Description.
    +    * @param {number} steps - Description.
    +    * @param {number} currentStep - Description.
    +    * @returns {number} The interpolated color value.
    +    */
    +    interpolateRGB: function (r1, g1, b1, r2, g2, b2, steps, currentStep) {
    +
    +        var r = (((r2 - r1) * currentStep) / steps) + r1;
    +        var g = (((g2 - g1) * currentStep) / steps) + g1;
    +        var b = (((b2 - b1) * currentStep) / steps) + b1;
    +
    +        return Phaser.Color.getColor(r, g, b);
    +
    +    },
    +
    +    /**
    +    * Returns a random color value between black and white
    +    * <p>Set the min value to start each channel from the given offset.</p>
    +    * <p>Set the max value to restrict the maximum color used per channel</p>
    +    *
    +    * @method Phaser.Color.getRandomColor
    +    * @param {number} min - The lowest value to use for the color.
    +    * @param {number} max - The highest value to use for the color.
    +    * @param {number} alpha - The alpha value of the returning color (default 255 = fully opaque).
    +    * @returns {number} 32-bit color value with alpha.
    +    */
    +    getRandomColor: function (min, max, alpha) {
    +
    +        if (typeof min === "undefined") { min = 0; }
    +        if (typeof max === "undefined") { max = 255; }
    +        if (typeof alpha === "undefined") { alpha = 255; }
    +
    +        //	Sanity checks
    +        if (max > 255) {
    +            return Phaser.Color.getColor(255, 255, 255);
    +        }
    +
    +        if (min > max) {
    +            return Phaser.Color.getColor(255, 255, 255);
    +        }
    +
    +        var red = min + Math.round(Math.random() * (max - min));
    +        var green = min + Math.round(Math.random() * (max - min));
    +        var blue = min + Math.round(Math.random() * (max - min));
    +
    +        return Phaser.Color.getColor32(alpha, red, green, blue);
    +
    +    },
    +
    +    /**
    +    * Return the component parts of a color as an Object with the properties alpha, red, green, blue
    +    *
    +    * <p>Alpha will only be set if it exist in the given color (0xAARRGGBB)</p>
    +    *
    +    * @method Phaser.Color.getRGB
    +    * @param {number} color - Color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB).
    +    * @returns {object} An Object with properties: alpha, red, green, blue.
    +    */
    +    getRGB: function (color) {
    +
    +        return {
    +            alpha: color >>> 24,
    +            red: color >> 16 & 0xFF,
    +            green: color >> 8 & 0xFF,
    +            blue: color & 0xFF
    +        };
    +
    +    },
    +
    +    /**
    +    * Returns a CSS friendly string value from the given color.
    +    * @method Phaser.Color.getWebRGB
    +    * @param {number} color
    +    * @returns {string}A string in the format: 'rgba(r,g,b,a)'
    +    */
    +    getWebRGB: function (color) {
    +
    +        var alpha = (color >>> 24) / 255;
    +        var red = color >> 16 & 0xFF;
    +        var green = color >> 8 & 0xFF;
    +        var blue = color & 0xFF;
    +
    +        return 'rgba(' + red.toString() + ',' + green.toString() + ',' + blue.toString() + ',' + alpha.toString() + ')';
    +        
    +    },
    +
    +    /**
    +    * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255.
    +    *
    +    * @method Phaser.Color.getAlpha
    +    * @param {number} color - In the format 0xAARRGGBB.
    +    * @returns {number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)).
    +    */
    +    getAlpha: function (color) {
    +        return color >>> 24;
    +    },
    +
    +    /**
    +    * Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1.
    +    *
    +    * @method Phaser.Color.getAlphaFloat
    +    * @param {number} color - In the format 0xAARRGGBB.
    +    * @returns {number} The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)).
    +    */
    +    getAlphaFloat: function (color) {
    +        return (color >>> 24) / 255;
    +    },
    +
    +    /**
    +    * Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255.
    +    *
    +    * @method Phaser.Color.getRed
    +    * @param {number} color In the format 0xAARRGGBB.
    +    * @returns {number} The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red).
    +    */
    +    getRed: function (color) {
    +        return color >> 16 & 0xFF;
    +    },
    +
    +    /**
    +    * Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255.
    +    *
    +    * @method Phaser.Color.getGreen
    +    * @param {number} color - In the format 0xAARRGGBB.
    +    * @returns {number} The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green).
    +    */
    +    getGreen: function (color) {
    +        return color >> 8 & 0xFF;
    +    },
    +
    +    /**
    +    * Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255.
    +    *
    +    * @method Phaser.Color.getBlue
    +    * @param {number} color - In the format 0xAARRGGBB.
    +    * @returns {number} The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue).
    +    */
    +    getBlue: function (color) {
    +        return color & 0xFF;
    +    }
    +	
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Debug.js.html b/docs/Debug.js.html new file mode 100644 index 00000000..e6047948 --- /dev/null +++ b/docs/Debug.js.html @@ -0,0 +1,1317 @@ + + + + + + Phaser Source: utils/Debug.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: utils/Debug.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* A collection of methods for displaying debug information about game objects. Phaser.Debug requires a CANVAS game type in order to render, so if you've got
    +* your game set to use Phaser.AUTO then swap it for Phaser.CANVAS to ensure WebGL doesn't kick in, then the Debug functions will all display.
    +*
    +* @class Phaser.Utils.Debug
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +*/
    +Phaser.Utils.Debug = function (game) {
    +
    +    /**
    +	* @property {Phaser.Game} game - A reference to the currently running Game.
    +	*/
    +    this.game = game;
    +  
    +	/**
    +	* @property {Context} context - The canvas context on which to render the debug information.
    +	*/
    +    this.context = game.context;
    +
    +	/**
    +	* @property {string} font - The font that the debug information is rendered in.
    +	* @default '14px Courier'
    +	*/
    +    this.font = '14px Courier';
    +   
    +	/**
    +	* @property {number} lineHeight - The line height between the debug text.
    +	*/
    +    this.lineHeight = 16;
    +    
    +	/**
    +	* @property {boolean} renderShadow - Should the text be rendered with a slight shadow? Makes it easier to read on different types of background.
    +	*/
    +    this.renderShadow = true;
    +    
    +	/**
    +	* @property {Context} currentX - The current X position the debug information will be rendered at.
    +	* @default
    +	*/
    +    this.currentX = 0;
    +    
    +	/**
    +	* @property {number} currentY - The current Y position the debug information will be rendered at.
    +	* @default
    +	*/
    +    this.currentY = 0;
    +    
    +	/**
    +	* @property {number} currentAlpha - The current alpha the debug information will be rendered at.
    +	* @default
    +	*/
    +    this.currentAlpha = 1;
    +
    +};
    +
    +Phaser.Utils.Debug.prototype = {
    +
    +    /**
    +    * Internal method that resets and starts the debug output values.
    +    * @method Phaser.Utils.Debug#start
    +    * @param {number} x - The X value the debug info will start from.
    +    * @param {number} y - The Y value the debug info will start from.
    +    * @param {string} color - The color the debug info will drawn in.
    +    */
    +    start: function (x, y, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        if (typeof x !== 'number') { x = 0; }
    +        if (typeof y !== 'number') { y = 0; }
    +
    +        color = color || 'rgb(255,255,255)';
    +
    +        this.currentX = x;
    +        this.currentY = y;
    +        this.currentColor = color;
    +        this.currentAlpha = this.context.globalAlpha;
    +
    +        this.context.save();
    +        this.context.setTransform(1, 0, 0, 1, 0, 0);
    +        this.context.fillStyle = color;
    +        this.context.font = this.font;
    +        this.context.globalAlpha = 1;
    +
    +    },
    +
    +    /**
    +    * Internal method that stops the debug output.
    +    * @method Phaser.Utils.Debug#stop
    +    */
    +    stop: function () {
    +
    +
    +        this.context.restore();
    +        this.context.globalAlpha = this.currentAlpha;
    +
    +    },
    +
    +    /**
    +    * Internal method that outputs a single line of text.
    +    * @method Phaser.Utils.Debug#line
    +    * @param {string} text - The line of text to draw.
    +    * @param {number} x - The X value the debug info will start from.
    +    * @param {number} y - The Y value the debug info will start from.
    +    */
    +    line: function (text, x, y) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        x = x || null;
    +        y = y || null;
    +
    +        if (x !== null) {
    +            this.currentX = x;
    +        }
    +
    +        if (y !== null) {
    +            this.currentY = y;
    +        }
    +
    +        if (this.renderShadow)
    +        {
    +            this.context.fillStyle = 'rgb(0,0,0)';
    +            this.context.fillText(text, this.currentX + 1, this.currentY + 1);
    +            this.context.fillStyle = this.currentColor;
    +        }
    +
    +        this.context.fillText(text, this.currentX, this.currentY);
    +        this.currentY += this.lineHeight;
    +
    +    },
    +
    +    /**
    +    * Visually renders a QuadTree to the display.
    +    * @method Phaser.Utils.Debug#renderQuadTree
    +    * @param {Phaser.QuadTree} quadtree - The quadtree to render.
    +    * @param {string} color - The color of the lines in the quadtree.
    +    */
    +    renderQuadTree: function (quadtree, color) {
    +
    +        color = color || 'rgba(255,0,0,0.3)';
    +
    +        this.start();
    +
    +        var bounds = quadtree.bounds;
    +
    +        if (quadtree.nodes.length === 0)
    +        {
    +            this.context.strokeStyle = color;
    +            this.context.strokeRect(bounds.x, bounds.y, bounds.width, bounds.height);
    +            this.renderText(quadtree.ID + ' / ' + quadtree.objects.length, bounds.x + 4, bounds.y + 16, 'rgb(0,200,0)', '12px Courier');
    +
    +            this.context.strokeStyle = 'rgb(0,255,0)';
    +
    +            // children
    +            for (var i = 0; i < quadtree.objects.length; i++)
    +            {
    +                this.context.strokeRect(quadtree.objects[i].x, quadtree.objects[i].y, quadtree.objects[i].width, quadtree.objects[i].height);
    +            }
    +        }
    +        else
    +        {
    +            for (var i = 0; i < quadtree.nodes.length; i++)
    +            {
    +                this.renderQuadTree(quadtree.nodes[i]);
    +            }
    +        }
    +
    +        this.stop();
    +
    +    },
    +
    +    /**
    +     * Renders the corners and point information of the given Sprite.
    +     * @method Phaser.Utils.Debug#renderSpriteCorners
    +     * @param {Phaser.Sprite} sprite - The sprite to be rendered.
    +     * @param {boolean} [showText=false] - If true the x/y coordinates of each point will be rendered.
    +     * @param {boolean} [showBounds=false] - If true the bounds will be rendered over the top of the sprite.
    +     * @param {string} [color='rgb(255,0,255)'] - The color the text is rendered in.
    +     */
    +    renderSpriteCorners: function (sprite, showText, showBounds, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        showText = showText || false;
    +        showBounds = showBounds || false;
    +        color = color || 'rgb(255,255,255)';
    +
    +        this.start(0, 0, color);
    +
    +        if (showBounds)
    +        {
    +            this.context.beginPath();
    +            this.context.strokeStyle = 'rgba(0, 255, 0, 0.7)';
    +            this.context.strokeRect(sprite.bounds.x, sprite.bounds.y, sprite.bounds.width, sprite.bounds.height);
    +            this.context.closePath();
    +            this.context.stroke();
    +        }
    +
    +        this.context.beginPath();
    +        this.context.moveTo(sprite.topLeft.x, sprite.topLeft.y);
    +        this.context.lineTo(sprite.topRight.x, sprite.topRight.y);
    +        this.context.lineTo(sprite.bottomRight.x, sprite.bottomRight.y);
    +        this.context.lineTo(sprite.bottomLeft.x, sprite.bottomLeft.y);
    +        this.context.closePath();
    +        this.context.strokeStyle = 'rgba(255, 0, 255, 0.7)';
    +        this.context.stroke();
    +
    +        this.renderPoint(sprite.center);
    +        this.renderPoint(sprite.topLeft);
    +        this.renderPoint(sprite.topRight);
    +        this.renderPoint(sprite.bottomLeft);
    +        this.renderPoint(sprite.bottomRight);
    +
    +        if (showText)
    +        {
    +            this.currentColor = color;
    +            this.line('x: ' + Math.floor(sprite.topLeft.x) + ' y: ' + Math.floor(sprite.topLeft.y), sprite.topLeft.x, sprite.topLeft.y);
    +            this.line('x: ' + Math.floor(sprite.topRight.x) + ' y: ' + Math.floor(sprite.topRight.y), sprite.topRight.x, sprite.topRight.y);
    +            this.line('x: ' + Math.floor(sprite.bottomLeft.x) + ' y: ' + Math.floor(sprite.bottomLeft.y), sprite.bottomLeft.x, sprite.bottomLeft.y);
    +            this.line('x: ' + Math.floor(sprite.bottomRight.x) + ' y: ' + Math.floor(sprite.bottomRight.y), sprite.bottomRight.x, sprite.bottomRight.y);
    +        }
    +
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Render Sound information, including decoded state, duration, volume and more.
    +    * @method Phaser.Utils.Debug#renderSoundInfo
    +    * @param {Phaser.Sound} sound - The sound object to debug.
    +    * @param {number} x - X position of the debug info to be rendered.
    +    * @param {number} y - Y position of the debug info to be rendered.
    +    * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
    +    */
    +    renderSoundInfo: function (sound, x, y, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgb(255,255,255)';
    +
    +        this.start(x, y, color);
    +        this.line('Sound: ' + sound.key + ' Locked: ' + sound.game.sound.touchLocked);
    +        this.line('Is Ready?: ' + this.game.cache.isSoundReady(sound.key) + ' Pending Playback: ' + sound.pendingPlayback);
    +        this.line('Decoded: ' + sound.isDecoded + ' Decoding: ' + sound.isDecoding);
    +        this.line('Total Duration: ' + sound.totalDuration + ' Playing: ' + sound.isPlaying);
    +        this.line('Time: ' + sound.currentTime);
    +        this.line('Volume: ' + sound.volume + ' Muted: ' + sound.mute);
    +        this.line('WebAudio: ' + sound.usingWebAudio + ' Audio: ' + sound.usingAudioTag);
    +
    +        if (sound.currentMarker !== '')
    +        {
    +            this.line('Marker: ' + sound.currentMarker + ' Duration: ' + sound.duration);
    +            this.line('Start: ' + sound.markers[sound.currentMarker].start + ' Stop: ' + sound.markers[sound.currentMarker].stop);
    +            this.line('Position: ' + sound.position);
    +        }
    +
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Render camera information including dimensions and location.
    +    * @method Phaser.Utils.Debug#renderCameraInfo
    +    * @param {Phaser.Camera} camera - Description.
    +    * @param {number} x - X position of the debug info to be rendered.
    +    * @param {number} y - Y position of the debug info to be rendered.
    +    * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
    +    */
    +    renderCameraInfo: function (camera, x, y, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgb(255,255,255)';
    +
    +        this.start(x, y, color);
    +        this.line('Camera (' + camera.width + ' x ' + camera.height + ')');
    +        this.line('X: ' + camera.x + ' Y: ' + camera.y);
    +        this.line('Bounds x: ' + camera.bounds.x + ' Y: ' + camera.bounds.y + ' w: ' + camera.bounds.width + ' h: ' + camera.bounds.height);
    +        this.line('View x: ' + camera.view.x + ' Y: ' + camera.view.y + ' w: ' + camera.view.width + ' h: ' + camera.view.height);
    +        this.stop();
    +        
    +    },
    +
    +    /**
    +    * Renders the Pointer.circle object onto the stage in green if down or red if up along with debug text.
    +    * @method Phaser.Utils.Debug#renderDebug
    +    * @param {Phaser.Pointer} pointer - Description.
    +    * @param {boolean} [hideIfUp=false] - Doesn't render the circle if the pointer is up.
    +    * @param {string} [downColor='rgba(0,255,0,0.5)'] - The color the circle is rendered in if down.
    +    * @param {string} [upColor='rgba(255,0,0,0.5)'] - The color the circle is rendered in if up (and hideIfUp is false).
    +    * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
    +    */
    +    renderPointer: function (pointer, hideIfUp, downColor, upColor, color) {
    +
    +        if (this.context == null || pointer == null)
    +        {
    +            return;
    +        }
    +
    +        if (typeof hideIfUp === 'undefined') { hideIfUp = false; }
    +        downColor = downColor || 'rgba(0,255,0,0.5)';
    +        upColor = upColor || 'rgba(255,0,0,0.5)';
    +        color = color || 'rgb(255,255,255)';
    +
    +        if (hideIfUp == true && pointer.isUp == true)
    +        {
    +            return;
    +        }
    +
    +        this.start(pointer.x, pointer.y - 100, color);
    +        this.context.beginPath();
    +        this.context.arc(pointer.x, pointer.y, pointer.circle.radius, 0, Math.PI * 2);
    +
    +        if (pointer.active)
    +        {
    +            this.context.fillStyle = downColor;
    +        }
    +        else
    +        {
    +            this.context.fillStyle = upColor;
    +        }
    +
    +        this.context.fill();
    +        this.context.closePath();
    +
    +        //  Render the points
    +        this.context.beginPath();
    +        this.context.moveTo(pointer.positionDown.x, pointer.positionDown.y);
    +        this.context.lineTo(pointer.position.x, pointer.position.y);
    +        this.context.lineWidth = 2;
    +        this.context.stroke();
    +        this.context.closePath();
    +
    +        //  Render the text
    +        // this.start(pointer.x, pointer.y - 100, color);
    +        this.line('ID: ' + pointer.id + " Active: " + pointer.active);
    +        this.line('World X: ' + pointer.worldX + " World Y: " + pointer.worldY);
    +        this.line('Screen X: ' + pointer.x + " Screen Y: " + pointer.y);
    +        this.line('Duration: ' + pointer.duration + " ms");
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Render Sprite Input Debug information.
    +    * @method Phaser.Utils.Debug#renderSpriteInputInfo
    +    * @param {Phaser.Sprite} sprite - The sprite to be rendered.
    +    * @param {number} x - X position of the debug info to be rendered.
    +    * @param {number} y - Y position of the debug info to be rendered.
    +    * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
    +    */    
    +    renderSpriteInputInfo: function (sprite, x, y, color) {
    +
    +        color = color || 'rgb(255,255,255)';
    +
    +        this.start(x, y, color);
    +        this.line('Sprite Input: (' + sprite.width + ' x ' + sprite.height + ')');
    +        this.line('x: ' + sprite.input.pointerX().toFixed(1) + ' y: ' + sprite.input.pointerY().toFixed(1));
    +        this.line('over: ' + sprite.input.pointerOver() + ' duration: ' + sprite.input.overDuration().toFixed(0));
    +        this.line('down: ' + sprite.input.pointerDown() + ' duration: ' + sprite.input.downDuration().toFixed(0));
    +        this.line('just over: ' + sprite.input.justOver() + ' just out: ' + sprite.input.justOut());
    +        this.stop();
    +
    +    },
    +
    +    /**
    +     * Render Sprite collision.
    +     * @method Phaser.Utils.Debug#renderSpriteCollision
    +     * @param {Phaser.Sprite} sprite - The sprite to be rendered.
    +     * @param {number} x - X position of the debug info to be rendered.
    +     * @param {number} y - Y position of the debug info to be rendered.
    +    * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
    +     */ 
    +    renderSpriteCollision: function (sprite, x, y, color) {
    +
    +        color = color || 'rgb(255,255,255)';
    +
    +        this.start(x, y, color);
    +        this.line('Sprite Collision: (' + sprite.width + ' x ' + sprite.height + ')');
    +        this.line('left: ' + sprite.body.touching.left);
    +        this.line('right: ' + sprite.body.touching.right);
    +        this.line('up: ' + sprite.body.touching.up);
    +        this.line('down: ' + sprite.body.touching.down);
    +        this.line('velocity.x: ' + sprite.body.velocity.x);
    +        this.line('velocity.y: ' + sprite.body.velocity.y);
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Render debug information about the Input object.
    +    * @method Phaser.Utils.Debug#renderInputInfo
    +    * @param {number} x - X position of the debug info to be rendered.
    +    * @param {number} y - Y position of the debug info to be rendered.
    +    * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
    +    */
    +    renderInputInfo: function (x, y, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgb(255,255,0)';
    +
    +        this.start(x, y, color);
    +        this.line('Input');
    +        this.line('X: ' + this.game.input.x + ' Y: ' + this.game.input.y);
    +        this.line('World X: ' + this.game.input.worldX + ' World Y: ' + this.game.input.worldY);
    +        this.line('Scale X: ' + this.game.input.scale.x.toFixed(1) + ' Scale Y: ' + this.game.input.scale.x.toFixed(1));
    +        this.line('Screen X: ' + this.game.input.activePointer.screenX + ' Screen Y: ' + this.game.input.activePointer.screenY);
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Render debug infos (including name, bounds info, position and some other properties) about the Sprite.
    +    * @method Phaser.Utils.Debug#renderSpriteInfo
    +    * @param {Phaser.Sprite} sprite - Description.
    +    * @param {number} x - X position of the debug info to be rendered.
    +    * @param {number} y - Y position of the debug info to be rendered.
    +    * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
    +    */
    +    renderSpriteInfo: function (sprite, x, y, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgb(255, 255, 255)';
    +
    +        this.start(x, y, color);
    +
    +        this.line('Sprite: ' + ' (' + sprite.width + ' x ' + sprite.height + ') anchor: ' + sprite.anchor.x + ' x ' + sprite.anchor.y);
    +        this.line('x: ' + sprite.x.toFixed(1) + ' y: ' + sprite.y.toFixed(1));
    +        this.line('angle: ' + sprite.angle.toFixed(1) + ' rotation: ' + sprite.rotation.toFixed(1));
    +        this.line('visible: ' + sprite.visible + ' in camera: ' + sprite.inCamera);
    +        this.line('body x: ' + sprite.body.x.toFixed(1) + ' y: ' + sprite.body.y.toFixed(1));
    +
    +        //  0 = scaleX
    +        //  1 = skewY
    +        //  2 = translateX
    +        //  3 = skewX
    +        //  4 = scaleY
    +        //  5 = translateY
    +
    +        // this.line('id: ' + sprite._id);
    +        // this.line('scale x: ' + sprite.worldTransform[0]);
    +        // this.line('scale y: ' + sprite.worldTransform[4]);
    +        // this.line('tx: ' + sprite.worldTransform[2]);
    +        // this.line('ty: ' + sprite.worldTransform[5]);
    +        // this.line('skew x: ' + sprite.worldTransform[3]);
    +        // this.line('skew y: ' + sprite.worldTransform[1]);
    +        this.line('deltaX: ' + sprite.body.deltaX());
    +        this.line('deltaY: ' + sprite.body.deltaY());
    +        // this.line('sdx: ' + sprite.deltaX());
    +        // this.line('sdy: ' + sprite.deltaY());
    +
    +        // this.line('inCamera: ' + this.game.renderer.spriteRenderer.inCamera(this.game.camera, sprite));
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Render the World Transform information of the given Sprite.
    +    * @method Phaser.Utils.Debug#renderWorldTransformInfo
    +    * @param {Phaser.Sprite} sprite - Description.
    +    * @param {number} x - X position of the debug info to be rendered.
    +    * @param {number} y - Y position of the debug info to be rendered.
    +    * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
    +    */
    +    renderWorldTransformInfo: function (sprite, x, y, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgb(255, 255, 255)';
    +
    +        this.start(x, y, color);
    +
    +        this.line('World Transform');
    +        this.line('skewX:  ' + sprite.worldTransform[3]);
    +        this.line('skewY:  ' + sprite.worldTransform[1]);
    +        this.line('scaleX: ' + sprite.worldTransform[0]);
    +        this.line('scaleY: ' + sprite.worldTransform[4]);
    +        this.line('transX: ' + sprite.worldTransform[2]);
    +        this.line('transY: ' + sprite.worldTransform[5]);
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Render the Local Transform information of the given Sprite.
    +    * @method Phaser.Utils.Debug#renderLocalTransformInfo
    +    * @param {Phaser.Sprite} sprite - Description.
    +    * @param {number} x - X position of the debug info to be rendered.
    +    * @param {number} y - Y position of the debug info to be rendered.
    +    * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
    +    */
    +    renderLocalTransformInfo: function (sprite, x, y, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgb(255, 255, 255)';
    +
    +        this.start(x, y, color);
    +
    +        this.line('Local Transform');
    +        this.line('skewX:  ' + sprite.localTransform[3]);
    +        this.line('skewY:  ' + sprite.localTransform[1]);
    +        this.line('scaleX: ' + sprite.localTransform[0]);
    +        this.line('scaleY: ' + sprite.localTransform[4]);
    +        this.line('transX: ' + sprite.localTransform[2]);
    +        this.line('transY: ' + sprite.localTransform[5]);
    +        this.stop();
    +
    +    },
    +
    +    renderSpriteCoords: function (sprite, x, y, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgb(255, 255, 255)';
    +
    +        this.start(x, y, color);
    +
    +        this.line(sprite.name);
    +        this.line('x: ' + sprite.x);
    +        this.line('y: ' + sprite.y);
    +        this.line('local x: ' + sprite.localTransform[2]);
    +        this.line('local y: ' + sprite.localTransform[5]);
    +        this.line('world x: ' + sprite.worldTransform[2]);
    +        this.line('world y: ' + sprite.worldTransform[5]);
    +
    +        this.stop();
    +
    +    },
    +
    +    renderGroupInfo: function (group, x, y, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgb(255, 255, 255)';
    +
    +        this.start(x, y, color);
    +
    +        this.line('Group (size: ' + group.length + ')');
    +        this.line('x: ' + group.x);
    +        this.line('y: ' + group.y);
    +
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Renders Point coordinates in the given color.
    +    * @method Phaser.Utils.Debug#renderPointInfo
    +    * @param {Phaser.Point} sprite - Description.
    +    * @param {number} x - X position of the debug info to be rendered.
    +    * @param {number} y - Y position of the debug info to be rendered.
    +    * @param {string} [color='rgb(255,255,255)'] - color of the debug info to be rendered. (format is css color string).
    +    */
    +    renderPointInfo: function (point, x, y, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgb(255, 255, 255)';
    +
    +        this.start(x, y, color);
    +        this.line('px: ' + point.x.toFixed(1) + ' py: ' + point.y.toFixed(1));
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Renders just the Sprite.body bounds.
    +    * @method Phaser.Utils.Debug#renderSpriteBody
    +    * @param {Phaser.Sprite} sprite - Description.
    +    * @param {string} [color] - Color of the debug info to be rendered (format is css color string).
    +    */
    +    renderSpriteBody: function (sprite, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgba(255,0,255, 0.3)';
    +
    +        this.start(0, 0, color);
    +
    +        this.context.fillStyle = color;
    +        this.context.fillRect(sprite.body.screenX, sprite.body.screenY, sprite.body.width, sprite.body.height);
    +
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Renders just the full Sprite bounds.
    +    * @method Phaser.Utils.Debug#renderSpriteBounds
    +    * @param {Phaser.Sprite} sprite - Description.
    +    * @param {string} [color] - Color of the debug info to be rendered (format is css color string).
    +    * @param {boolean} [fill=false] - If false the bounds outline is rendered, if true the whole rectangle is rendered.
    +    */
    +    renderSpriteBounds: function (sprite, color, fill) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgb(255,0,255)';
    +
    +        if (typeof fill === 'undefined') { fill = false; }
    +
    +        this.start(0, 0, color);
    +
    +        if (fill)
    +        {
    +            this.context.fillStyle = color;
    +            this.context.fillRect(sprite.bounds.x, sprite.bounds.y, sprite.bounds.width, sprite.bounds.height);
    +        }
    +        else
    +        {
    +            this.context.strokeStyle = color;
    +            this.context.strokeRect(sprite.bounds.x, sprite.bounds.y, sprite.bounds.width, sprite.bounds.height);
    +            this.context.stroke();
    +        }
    +
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Renders a single pixel.
    +    * @method Phaser.Utils.Debug#renderPixel
    +    * @param {number} x - X position of the debug info to be rendered.
    +    * @param {number} y - Y position of the debug info to be rendered.
    +    * @param {string} [color] - Color of the debug info to be rendered (format is css color string).
    +    */
    +    renderPixel: function (x, y, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgba(0,255,0,1)';
    +
    +        this.start();
    +        this.context.fillStyle = color;
    +        this.context.fillRect(x, y, 2, 2);
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Renders a Point object.
    +    * @method Phaser.Utils.Debug#renderPoint
    +    * @param {Phaser.Point} point - The Point to render.
    +    * @param {string} [color] - Color of the debug info to be rendered (format is css color string).
    +    */
    +    renderPoint: function (point, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgba(0,255,0,1)';
    +
    +        this.start();
    +        this.context.fillStyle = color;
    +        this.context.fillRect(point.x, point.y, 4, 4);
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Renders a Rectangle.
    +    * @method Phaser.Utils.Debug#renderRectangle
    +    * @param {Phaser.Rectangle} rect - The Rectangle to render.
    +    * @param {string} [color] - Color of the debug info to be rendered (format is css color string).
    +    */
    +    renderRectangle: function (rect, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgba(0,255,0,0.3)';
    +
    +        this.start();
    +        this.context.fillStyle = color;
    +        this.context.fillRect(rect.x, rect.y, rect.width, rect.height);
    +        this.stop();
    +        
    +    },
    +
    +    /**
    +    * Renders a Circle.
    +    * @method Phaser.Utils.Debug#renderCircle
    +    * @param {Phaser.Circle} circle - The Circle to render.
    +    * @param {string} [color] - Color of the debug info to be rendered (format is css color string).
    +    */
    +    renderCircle: function (circle, color) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgba(0,255,0,0.3)';
    +
    +        this.start();
    +        this.context.beginPath();
    +        this.context.fillStyle = color;
    +        this.context.arc(circle.x, circle.y, circle.radius, 0, Math.PI * 2, false);
    +        this.context.fill();
    +        this.context.closePath();
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Render text.
    +    * @method Phaser.Utils.Debug#renderText
    +    * @param {string} text - The line of text to draw.
    +    * @param {number} x - X position of the debug info to be rendered.
    +    * @param {number} y - Y position of the debug info to be rendered.
    +    * @param {string} [color] - Color of the debug info to be rendered (format is css color string).
    +    * @param {string} font - The font of text to draw.
    +    */    
    +    renderText: function (text, x, y, color, font) {
    +
    +        if (this.context == null)
    +        {
    +            return;
    +        }
    +
    +        color = color || 'rgb(255,255,255)';
    +        font = font || '16px Courier';
    +
    +        this.start();
    +        this.context.font = font;
    +        this.context.fillStyle = color;
    +        this.context.fillText(text, x, y);
    +        this.stop();
    +
    +    },
    +
    +    /**
    +    * Dumps the Linked List to the console.
    +    * 
    +    * @method Phaser.Utils.Debug#Phaser.LinkedList#dump 
    +    * @param {Phaser.LinkedList} list - The LinkedList to dump.
    +    */
    +    dumpLinkedList: function (list) {
    +
    +        var spacing = 20;
    +
    +        var output = "\n" + Phaser.Utils.pad('Node', spacing) + "|" + Phaser.Utils.pad('Next', spacing) + "|" + Phaser.Utils.pad('Previous', spacing) + "|" + Phaser.Utils.pad('First', spacing) + "|" + Phaser.Utils.pad('Last', spacing);
    +        console.log(output);
    +
    +        var output = Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing);
    +        console.log(output);
    +
    +        var entity = list;
    +
    +        var testObject = entity.last.next;
    +        entity = entity.first;
    +        
    +        do  
    +        {
    +            var name = entity.sprite.name || '*';
    +            var nameNext = '-';
    +            var namePrev = '-';
    +            var nameFirst = '-';
    +            var nameLast = '-';
    +
    +            if (entity.next)
    +            {
    +                nameNext = entity.next.sprite.name;
    +            }
    +
    +            if (entity.prev)
    +            {
    +                namePrev = entity.prev.sprite.name;
    +            }
    +
    +            if (entity.first)
    +            {
    +                nameFirst = entity.first.sprite.name;
    +            }
    +
    +            if (entity.last)
    +            {
    +                nameLast = entity.last.sprite.name;
    +            }
    +
    +            if (typeof nameNext === 'undefined')
    +            {
    +                nameNext = '-';
    +            }
    +
    +            if (typeof namePrev === 'undefined')
    +            {
    +                namePrev = '-';
    +            }
    +
    +            if (typeof nameFirst === 'undefined')
    +            {
    +                nameFirst = '-';
    +            }
    +
    +            if (typeof nameLast === 'undefined')
    +            {
    +                nameLast = '-';
    +            }
    +
    +            var output = Phaser.Utils.pad(name, spacing) + "|" + Phaser.Utils.pad(nameNext, spacing) + "|" + Phaser.Utils.pad(namePrev, spacing) + "|" + Phaser.Utils.pad(nameFirst, spacing) + "|" + Phaser.Utils.pad(nameLast, spacing);
    +            console.log(output);
    +
    +            entity = entity.next;
    +
    +        }
    +        while(entity != testObject)
    +
    +    }
    +
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Device.js.html b/docs/Device.js.html new file mode 100644 index 00000000..a7986ed3 --- /dev/null +++ b/docs/Device.js.html @@ -0,0 +1,988 @@ + + + + + + Phaser Source: system/Device.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: system/Device.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Detects device support capabilities. Using some elements from System.js by MrDoob and Modernizr
    +*
    +* @class Phaser.Device
    +* @constructor
    +*/
    +
    +Phaser.Device = function () {
    +
    +    /**
    +    * An optional 'fix' for the horrendous Android stock browser bug https://code.google.com/p/android/issues/detail?id=39247
    +    * @property {boolean} patchAndroidClearRectBug - Description.
    +    * @default
    +    */
    +    this.patchAndroidClearRectBug = false;
    +
    +    //  Operating System
    +
    +    /**
    +    * @property {boolean} desktop - Is running desktop?
    +    * @default
    +    */
    +    this.desktop = false;
    +
    +    /**
    +    * @property {boolean} iOS - Is running on iOS?
    +    * @default
    +    */
    +    this.iOS = false;
    +
    +    /**
    +    * @property {boolean} android - Is running on android?
    +    * @default
    +    */
    +    this.android = false;
    +
    +    /**
    +    * @property {boolean} chromeOS - Is running on chromeOS?
    +    * @default
    +    */
    +    this.chromeOS = false;
    +
    +    /**
    +    * @property {boolean} linux - Is running on linux?
    +    * @default
    +    */
    +    this.linux = false;
    +
    +    /**
    +    * @property {boolean} macOS - Is running on macOS?
    +    * @default
    +    */
    +    this.macOS = false;
    +
    +    /**
    +    * @property {boolean} windows - Is running on windows?
    +    * @default
    +    */
    +    this.windows = false;
    +
    +    //  Features
    +
    +    /**
    +    * @property {boolean} canvas - Is canvas available?
    +    * @default
    +    */
    +    this.canvas = false;
    +
    +    /**
    +    * @property {boolean} file - Is file available?
    +    * @default
    +    */
    +    this.file = false;
    +
    +    /**
    +    * @property {boolean} fileSystem - Is fileSystem available?
    +    * @default
    +    */
    +    this.fileSystem = false;
    +
    +    /**
    +    * @property {boolean} localStorage - Is localStorage available?
    +    * @default
    +    */
    +    this.localStorage = false;
    +
    +    /**
    +    * @property {boolean} webGL - Is webGL available?
    +    * @default
    +    */
    +    this.webGL = false;
    +
    +    /**
    +    * @property {boolean} worker - Is worker available?
    +    * @default
    +    */
    +    this.worker = false;
    +
    +    /**
    +    * @property {boolean} touch - Is touch available?
    +    * @default
    +    */
    +    this.touch = false;
    +
    +    /**
    +    * @property {boolean} mspointer - Is mspointer available?
    +    * @default
    +    */
    +    this.mspointer = false;
    +
    +    /**
    +    * @property {boolean} css3D - Is css3D available?
    +    * @default
    +    */
    +    this.css3D = false;
    +
    +    /** 
    +    * @property {boolean} pointerLock - Is Pointer Lock available?
    +    * @default
    +    */
    +    this.pointerLock = false;
    +
    +    //  Browser
    +
    +    /**
    +    * @property {boolean} arora - Is running in arora?
    +    * @default
    +    */
    +    this.arora = false;
    +
    +    /**
    +    * @property {boolean} chrome - Is running in chrome?
    +    * @default
    +    */
    +    this.chrome = false;
    +
    +    /**
    +    * @property {boolean} epiphany - Is running in epiphany?
    +    * @default
    +    */
    +    this.epiphany = false;
    +
    +    /**
    +    * @property {boolean} firefox - Is running in firefox?
    +    * @default
    +    */
    +    this.firefox = false;
    +
    +    /**
    +    * @property {boolean} ie - Is running in ie?
    +    * @default
    +    */
    +    this.ie = false;
    +
    +    /**
    +    * @property {number} ieVersion - Version of ie?
    +    * @default
    +    */
    +    this.ieVersion = 0;
    +
    +    /**
    +    * @property {boolean} mobileSafari - Is running in mobileSafari?
    +    * @default
    +    */
    +    this.mobileSafari = false;
    +
    +    /**
    +    * @property {boolean} midori - Is running in midori?
    +    * @default
    +    */
    +    this.midori = false;
    +
    +    /**
    +    * @property {boolean} opera - Is running in opera?
    +    * @default
    +    */
    +    this.opera = false;
    +
    +    /**
    +    * @property {boolean} safari - Is running in safari?
    +    * @default
    +    */
    +    this.safari = false;
    +    this.webApp = false;
    +
    +    //  Audio
    +
    +    /**
    +    * @property {boolean} audioData - Are Audio tags available?
    +    * @default
    +    */
    +    this.audioData = false;
    +
    +    /**
    +    * @property {boolean} webAudio - Is the WebAudio API available?
    +    * @default
    +    */
    +    this.webAudio = false;
    +
    +    /**
    +    * @property {boolean} ogg - Can this device play ogg files?
    +    * @default
    +    */
    +    this.ogg = false;
    +
    +    /**
    +    * @property {boolean} opus - Can this device play opus files?
    +    * @default
    +    */
    +    this.opus = false;
    +
    +    /**
    +    * @property {boolean} mp3 - Can this device play mp3 files?
    +    * @default
    +    */
    +    this.mp3 = false;
    +
    +    /**
    +    * @property {boolean} wav - Can this device play wav files?
    +    * @default
    +    */
    +    this.wav = false;
    +    /**
    +    * Can this device play m4a files?
    +    * @property {boolean} m4a - True if this device can play m4a files.
    +    * @default
    +    */
    +    this.m4a = false;
    +
    +    /**
    +    * @property {boolean} webm - Can this device play webm files?
    +    * @default
    +    */
    +    this.webm = false;
    +
    +    //  Device
    +
    +    /**
    +    * @property {boolean} iPhone - Is running on iPhone?
    +    * @default
    +    */
    +    this.iPhone = false;
    +
    +    /**
    +    * @property {boolean} iPhone4 - Is running on iPhone4?
    +    * @default
    +    */
    +    this.iPhone4 = false;
    +
    +    /** 
    +    * @property {boolean} iPad - Is running on iPad?
    +    * @default
    +    */
    +    this.iPad = false;
    +
    +    /**
    +    * @property {number} pixelRatio - PixelRatio of the host device?
    +    * @default
    +    */
    +    this.pixelRatio = 0;
    +
    +    //  Run the checks
    +    this._checkAudio();
    +    this._checkBrowser();
    +    this._checkCSS3D();
    +    this._checkDevice();
    +    this._checkFeatures();
    +    this._checkOS();
    +    
    +};
    +
    +Phaser.Device.prototype = {
    +
    +    /**
    +    * Check which OS is game running on.
    +    * @method Phaser.Device#_checkOS
    +    * @private
    +    */
    +    _checkOS: function () {
    +
    +        var ua = navigator.userAgent;
    +
    +        if (/Android/.test(ua)) {
    +            this.android = true;
    +        } else if (/CrOS/.test(ua)) {
    +            this.chromeOS = true;
    +        } else if (/iP[ao]d|iPhone/i.test(ua)) {
    +            this.iOS = true;
    +        } else if (/Linux/.test(ua)) {
    +            this.linux = true;
    +        } else if (/Mac OS/.test(ua)) {
    +            this.macOS = true;
    +        } else if (/Windows/.test(ua)) {
    +            this.windows = true;
    +        }
    +
    +        if (this.windows || this.macOS || this.linux) {
    +            this.desktop = true;
    +        }
    +
    +    },
    +
    +    /**
    +    * Check HTML5 features of the host environment.
    +    * @method Phaser.Device#_checkFeatures
    +    * @private
    +    */
    +    _checkFeatures: function () {
    +
    +        this.canvas = !!window['CanvasRenderingContext2D'];
    +
    +        try {
    +            this.localStorage = !!localStorage.getItem;
    +        } catch (error) {
    +            this.localStorage = false;
    +        }
    +
    +        this.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob'];
    +        this.fileSystem = !!window['requestFileSystem'];
    +        this.webGL = ( function () { try { var canvas = document.createElement( 'canvas' ); return !! window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ); } catch( e ) { return false; } } )();
    +
    +        if (this.webGL === null)
    +        {
    +            this.webGL = false;
    +        }
    +        else
    +        {
    +            this.webGL = true;
    +        }
    +
    +        this.worker = !!window['Worker'];
    +        
    +        if ('ontouchstart' in document.documentElement || window.navigator.msPointerEnabled) {
    +            this.touch = true;
    +        }
    +
    +        if (window.navigator.msPointerEnabled) {
    +            this.mspointer = true;
    +        }
    +        
    +        this.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document;
    +
    +    },
    +
    +    /**
    +    * Check what browser is game running in.
    +    * @method Phaser.Device#_checkBrowser
    +    * @private
    +    */
    +    _checkBrowser: function () {
    +
    +        var ua = navigator.userAgent;
    +
    +        if (/Arora/.test(ua)) {
    +            this.arora = true;
    +        } else if (/Chrome/.test(ua)) {
    +            this.chrome = true;
    +        } else if (/Epiphany/.test(ua)) {
    +            this.epiphany = true;
    +        } else if (/Firefox/.test(ua)) {
    +            this.firefox = true;
    +        } else if (/Mobile Safari/.test(ua)) {
    +            this.mobileSafari = true;
    +        } else if (/MSIE (\d+\.\d+);/.test(ua)) {
    +            this.ie = true;
    +            this.ieVersion = parseInt(RegExp.$1);
    +        } else if (/Midori/.test(ua)) {
    +            this.midori = true;
    +        } else if (/Opera/.test(ua)) {
    +            this.opera = true;
    +        } else if (/Safari/.test(ua)) {
    +            this.safari = true;
    +        }
    +
    +        // WebApp mode in iOS
    +        if (navigator['standalone']) {
    +            this.webApp = true;
    +        }
    +
    +    },
    +
    +    /**
    +    * Check audio support.
    +    * @method Phaser.Device#_checkAudio
    +    * @private
    +    */
    +    _checkAudio: function () {
    +
    +        this.audioData = !!(window['Audio']);
    +        this.webAudio = !!(window['webkitAudioContext'] || window['AudioContext']);
    +        var audioElement = document.createElement('audio');
    +        var result = false;
    +
    +        try {
    +            if (result = !!audioElement.canPlayType) {
    +                
    +                if (audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
    +                    this.ogg = true;
    +                }
    +
    +                if (audioElement.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, '')) {
    +                    this.opus = true;
    +                }
    +
    +                if (audioElement.canPlayType('audio/mpeg;').replace(/^no$/, '')) {
    +                    this.mp3 = true;
    +                }
    +
    +                // Mimetypes accepted:
    +                //   developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements
    +                //   bit.ly/iphoneoscodecs
    +                if (audioElement.canPlayType('audio/wav; codecs="1"').replace(/^no$/, '')) {
    +                    this.wav = true;
    +                }
    +
    +                if (audioElement.canPlayType('audio/x-m4a;') || audioElement.canPlayType('audio/aac;').replace(/^no$/, '')) {
    +                    this.m4a = true;
    +                }
    +
    +                if (audioElement.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')) {
    +                    this.webm = true;
    +                }
    +            }
    +        } catch (e) {
    +        }
    +
    +    },
    +
    +    /**
    +    * Check PixelRatio of devices.
    +    * @method Phaser.Device#_checkDevice
    +    * @private
    +    */
    +    _checkDevice: function () {
    +
    +        this.pixelRatio = window['devicePixelRatio'] || 1;
    +        this.iPhone = navigator.userAgent.toLowerCase().indexOf('iphone') != -1;
    +        this.iPhone4 = (this.pixelRatio == 2 && this.iPhone);
    +        this.iPad = navigator.userAgent.toLowerCase().indexOf('ipad') != -1;
    +
    +    },
    +
    +    /**
    +    * Check whether the host environment support 3D CSS.
    +    * @method Phaser.Device#_checkCSS3D
    +    * @private
    +    */
    +    _checkCSS3D: function () {
    +
    +        var el = document.createElement('p');
    +        var has3d;
    +        var transforms = {
    +            'webkitTransform': '-webkit-transform',
    +            'OTransform': '-o-transform',
    +            'msTransform': '-ms-transform',
    +            'MozTransform': '-moz-transform',
    +            'transform': 'transform'
    +        };
    +
    +        // Add it to the body to get the computed style.
    +        document.body.insertBefore(el, null);
    +
    +        for (var t in transforms) {
    +            if (el.style[t] !== undefined) {
    +                el.style[t] = "translate3d(1px,1px,1px)";
    +                has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
    +            }
    +        }
    +        
    +        document.body.removeChild(el);
    +        this.css3D = (has3d !== undefined && has3d.length > 0 && has3d !== "none");
    +
    +    },
    +
    +    /**
    +    * Check whether the host environment can play audio.
    +    * @method Phaser.Device#canPlayAudio
    +    * @param {string} type - One of 'mp3, 'ogg', 'm4a', 'wav', 'webm'.
    +    * @return {boolean} True if the given file type is supported by the browser, otherwise false.
    +    */
    +    canPlayAudio: function (type) {
    +
    +        if (type == 'mp3' && this.mp3)
    +        {
    +            return true;
    +        }
    +        else if (type == 'ogg' && (this.ogg || this.opus))
    +        {
    +            return true;
    +        }
    +        else if (type == 'm4a' && this.m4a)
    +        {
    +            return true;
    +        }
    +        else if (type == 'wav' && this.wav)
    +        {
    +            return true;
    +        }
    +        else if (type == 'webm' && this.webm)
    +        {
    +            return true;
    +        }
    +
    +        return false;
    +
    +    },
    +
    +    /**
    +    * Check whether the console is open.
    +    * @method Phaser.Device#isConsoleOpen
    +    * @return {boolean} True if the browser dev console is open.
    +    */
    +    isConsoleOpen: function () {
    +
    +        if (window.console && window.console['firebug'])
    +        {
    +            return true;
    +        }
    +
    +        if (window.console)
    +        {
    +            console.profile();
    +            console.profileEnd();
    +
    +            if (console.clear)
    +            {
    +                console.clear();
    +            }
    +
    +            return console['profiles'].length > 0;
    +        }
    +
    +        return false;
    +
    +    }
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Easing.js.html b/docs/Easing.js.html new file mode 100644 index 00000000..8f1aae89 --- /dev/null +++ b/docs/Easing.js.html @@ -0,0 +1,1006 @@ + + + + + + Phaser Source: tween/Easing.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: tween/Easing.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* A collection of easing methods defining ease-in ease-out curves.
    +*
    +* @class Phaser.Easing
    +*/
    +Phaser.Easing = {
    +
    +    /**
    +    * Linear easing.
    +    *
    +    * @class Phaser.Easing.Linear
    +    */
    +	Linear: {
    +
    +		/**
    +		* Ease-in.
    +		*
    +		* @method Phaser.Easing.Linear#In 
    +		* @param {number} k - The value to be tweened.
    +		* @returns {number} k^2.
    +		*/
    +		None: function ( k ) {
    +
    +			return k;
    +
    +		}
    +
    +	},
    +
    +    /**
    +    * Quadratic easing.
    +    *
    +    * @class Phaser.Easing.Quadratic
    +    */
    +	Quadratic: {
    +
    +		/**
    +		* Ease-in.
    +		*
    +		* @method Phaser.Easing.Quadratic#In 
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} k^2.
    +		*/
    +		In: function ( k ) {
    +
    +			return k * k;
    +
    +		},
    +
    +		/**
    +		* Ease-out.
    +		*
    +		* @method Phaser.Easing.Quadratic#Out 
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} k* (2-k).
    +		*/
    +		Out: function ( k ) {
    +
    +			return k * ( 2 - k );
    +
    +		},
    +
    +		/**
    +		* Ease-in/out.
    +		*
    +		* @method Phaser.Easing.Quadratic#InOut
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		InOut: function ( k ) {
    +
    +			if ( ( k *= 2 ) < 1 ) return 0.5 * k * k;
    +			return - 0.5 * ( --k * ( k - 2 ) - 1 );
    +
    +		}
    +
    +	},
    +
    +    /**
    +    * Cubic easing.
    +    *
    +    * @class Phaser.Easing.Cubic
    +    */
    +	Cubic: {
    +
    +		/**
    +		* Cubic ease-in.
    +		*
    +		* @method Phaser.Easing.Cubic#In 
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		In: function ( k ) {
    +
    +			return k * k * k;
    +
    +		},
    +
    +		/**
    +		* Cubic ease-out.
    +		*
    +		* @method Phaser.Easing.Cubic#Out
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		Out: function ( k ) {
    +
    +			return --k * k * k + 1;
    +
    +		},
    +
    +		/**
    +		* Cubic ease-in/out.
    +		*
    +		* @method Phaser.Easing.Cubic#InOut
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		InOut: function ( k ) {
    +
    +			if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k;
    +			return 0.5 * ( ( k -= 2 ) * k * k + 2 );
    +
    +		}
    +
    +	},
    +
    +    /**
    +    * Quartic easing.
    +    *
    +    * @class Phaser.Easing.Quartic
    +    */
    +	Quartic: {
    +
    +		/**
    +		* Quartic ease-in.
    +		*
    +		* @method Phaser.Easing.Quartic#In 
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		In: function ( k ) {
    +
    +			return k * k * k * k;
    +
    +		},
    +
    +		/**
    +		* Quartic ease-out.
    +		*
    +		* @method Phaser.Easing.Quartic#Out
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		Out: function ( k ) {
    +
    +			return 1 - ( --k * k * k * k );
    +
    +		},
    +
    +		/**
    +		* Quartic ease-in/out.
    +		*
    +		* @method Phaser.Easing.Quartic#InOut
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		InOut: function ( k ) {
    +
    +			if ( ( k *= 2 ) < 1) return 0.5 * k * k * k * k;
    +			return - 0.5 * ( ( k -= 2 ) * k * k * k - 2 );
    +
    +		}
    +
    +	},
    +
    +    /**
    +    * Quintic easing.
    +    *
    +    * @class Phaser.Easing.Quintic
    +    */
    +	Quintic: {
    +
    +		/**
    +		* Quintic ease-in.
    +		*
    +		* @method Phaser.Easing.Quintic#In 
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		In: function ( k ) {
    +
    +			return k * k * k * k * k;
    +
    +		},
    +
    +		/**
    +		* Quintic ease-out.
    +		*
    +		* @method Phaser.Easing.Quintic#Out
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		Out: function ( k ) {
    +
    +			return --k * k * k * k * k + 1;
    +
    +		},
    +
    +		/**
    +		* Quintic ease-in/out.
    +		*
    +		* @method Phaser.Easing.Quintic#InOut
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		InOut: function ( k ) {
    +
    +			if ( ( k *= 2 ) < 1 ) return 0.5 * k * k * k * k * k;
    +			return 0.5 * ( ( k -= 2 ) * k * k * k * k + 2 );
    +
    +		}
    +
    +	},
    +
    +    /**
    +    * Sinusoidal easing.
    +    *
    +    * @class Phaser.Easing.Sinusoidal
    +    */
    +	Sinusoidal: {
    +
    +		/**
    +		* Sinusoidal ease-in.
    +		*
    +		* @method Phaser.Easing.Sinusoidal#In 
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		In: function ( k ) {
    +
    +			return 1 - Math.cos( k * Math.PI / 2 );
    +
    +		},
    +
    +		/**
    +		* Sinusoidal ease-out.
    +		*
    +		* @method Phaser.Easing.Sinusoidal#Out
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		Out: function ( k ) {
    +
    +			return Math.sin( k * Math.PI / 2 );
    +
    +		},
    +
    +		/**
    +		* Sinusoidal ease-in/out.
    +		*
    +		* @method Phaser.Easing.Sinusoidal#InOut
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		InOut: function ( k ) {
    +
    +			return 0.5 * ( 1 - Math.cos( Math.PI * k ) );
    +
    +		}
    +
    +	},
    +
    +    /**
    +    * Exponential easing.
    +    *
    +    * @class Phaser.Easing.Exponential
    +    */
    +	Exponential: {
    +
    +		/**
    +		* Exponential ease-in.
    +		*
    +		* @method Phaser.Easing.Exponential#In 
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		In: function ( k ) {
    +
    +			return k === 0 ? 0 : Math.pow( 1024, k - 1 );
    +
    +		},
    +
    +		/**
    +		* Exponential ease-out.
    +		*
    +		* @method Phaser.Easing.Exponential#Out
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		Out: function ( k ) {
    +
    +			return k === 1 ? 1 : 1 - Math.pow( 2, - 10 * k );
    +
    +		},
    +
    +		/**
    +		* Exponential ease-in/out.
    +		*
    +		* @method Phaser.Easing.Exponential#InOut
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		InOut: function ( k ) {
    +
    +			if ( k === 0 ) return 0;
    +			if ( k === 1 ) return 1;
    +			if ( ( k *= 2 ) < 1 ) return 0.5 * Math.pow( 1024, k - 1 );
    +			return 0.5 * ( - Math.pow( 2, - 10 * ( k - 1 ) ) + 2 );
    +
    +		}
    +
    +	},
    +
    +    /**
    +    * Circular easing.
    +    *
    +    * @class Phaser.Easing.Circular
    +    */
    +	Circular: {
    +
    +		/**
    +		* Circular ease-in.
    +		*
    +		* @method Phaser.Easing.Circular#In 
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		In: function ( k ) {
    +
    +			return 1 - Math.sqrt( 1 - k * k );
    +
    +		},
    +
    +		/**
    +		* Circular ease-out.
    +		*
    +		* @method Phaser.Easing.Circular#Out
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +		*/
    +		Out: function ( k ) {
    +
    +			return Math.sqrt( 1 - ( --k * k ) );
    +
    +		},
    +
    +		/**
    +		* Circular ease-in/out.
    +        *
    +		* @method Phaser.Easing.Circular#InOut
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +        */
    +		InOut: function ( k ) {
    +
    +			if ( ( k *= 2 ) < 1) return - 0.5 * ( Math.sqrt( 1 - k * k) - 1);
    +			return 0.5 * ( Math.sqrt( 1 - ( k -= 2) * k) + 1);
    +
    +		}
    +
    +	},
    +
    +    /**
    +    * Elastic easing.
    +    *
    +    * @class Phaser.Easing.Elastic
    +    */
    +	Elastic: {
    +
    +		/**
    +		* Elastic ease-in.
    +        *
    +		* @method Phaser.Easing.Elastic#In 
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +        */
    +		In: function ( k ) {
    +
    +			var s, a = 0.1, p = 0.4;
    +			if ( k === 0 ) return 0;
    +			if ( k === 1 ) return 1;
    +			if ( !a || a < 1 ) { a = 1; s = p / 4; }
    +			else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI );
    +			return - ( a * Math.pow( 2, 10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) );
    +
    +		},
    +
    +		/**
    +		* Elastic ease-out.
    +        *
    +		* @method Phaser.Easing.Elastic#Out
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +        */
    +		Out: function ( k ) {
    +
    +			var s, a = 0.1, p = 0.4;
    +			if ( k === 0 ) return 0;
    +			if ( k === 1 ) return 1;
    +			if ( !a || a < 1 ) { a = 1; s = p / 4; }
    +			else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI );
    +			return ( a * Math.pow( 2, - 10 * k) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) + 1 );
    +
    +		},
    +
    +		/**
    +		* Elastic ease-in/out.
    +        *
    +		* @method Phaser.Easing.Elastic#InOut
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +        */
    +		InOut: function ( k ) {
    +
    +			var s, a = 0.1, p = 0.4;
    +			if ( k === 0 ) return 0;
    +			if ( k === 1 ) return 1;
    +			if ( !a || a < 1 ) { a = 1; s = p / 4; }
    +			else s = p * Math.asin( 1 / a ) / ( 2 * Math.PI );
    +			if ( ( k *= 2 ) < 1 ) return - 0.5 * ( a * Math.pow( 2, 10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) );
    +			return a * Math.pow( 2, -10 * ( k -= 1 ) ) * Math.sin( ( k - s ) * ( 2 * Math.PI ) / p ) * 0.5 + 1;
    +
    +		}
    +
    +	},
    +
    +    /**
    +    * Back easing.
    +    *
    +    * @class Phaser.Easing.Back
    +    */
    +	Back: {
    +
    +		/**
    +		* Back ease-in.
    +        *
    +		* @method Phaser.Easing.Back#In 
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +        */
    +		In: function ( k ) {
    +
    +			var s = 1.70158;
    +			return k * k * ( ( s + 1 ) * k - s );
    +
    +		},
    +
    +		/**
    +		* Back ease-out.
    +        *
    +		* @method Phaser.Easing.Back#Out
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +        */
    +		Out: function ( k ) {
    +
    +			var s = 1.70158;
    +			return --k * k * ( ( s + 1 ) * k + s ) + 1;
    +
    +		},
    +
    +		/**
    +		* Back ease-in/out.
    +        *
    +		* @method Phaser.Easing.Back#InOut
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +        */
    +		InOut: function ( k ) {
    +
    +			var s = 1.70158 * 1.525;
    +			if ( ( k *= 2 ) < 1 ) return 0.5 * ( k * k * ( ( s + 1 ) * k - s ) );
    +			return 0.5 * ( ( k -= 2 ) * k * ( ( s + 1 ) * k + s ) + 2 );
    +
    +		}
    +
    +	},
    +
    +    /**
    +    * Bounce easing.
    +    *
    +    * @class Phaser.Easing.Bounce
    +    */
    +	Bounce: {
    +
    +		/**
    +		* Bounce ease-in.
    +        *
    +		* @method Phaser.Easing.Bounce#In 
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +        */
    +		In: function ( k ) {
    +
    +			return 1 - Phaser.Easing.Bounce.Out( 1 - k );
    +
    +		},
    +
    +		/**
    +		* Bounce ease-out.
    +        *
    +		* @method Phaser.Easing.Bounce#Out
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +        */
    +		Out: function ( k ) {
    +
    +			if ( k < ( 1 / 2.75 ) ) {
    +
    +				return 7.5625 * k * k;
    +
    +			} else if ( k < ( 2 / 2.75 ) ) {
    +
    +				return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
    +
    +			} else if ( k < ( 2.5 / 2.75 ) ) {
    +
    +				return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
    +
    +			} else {
    +
    +				return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
    +
    +			}
    +
    +		},
    +
    +		/**
    +		* Bounce ease-in/out.
    +        *
    +		* @method Phaser.Easing.Bounce#InOut
    +		* @param {number} k - The value to be tweened. 
    +		* @returns {number} The tweened value.
    +        */
    +		InOut: function ( k ) {
    +
    +			if ( k < 0.5 ) return Phaser.Easing.Bounce.In( k * 2 ) * 0.5;
    +			return Phaser.Easing.Bounce.Out( k * 2 - 1 ) * 0.5 + 0.5;
    +
    +		}
    +
    +	}
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Emitter.js.html b/docs/Emitter.js.html new file mode 100644 index 00000000..cc9911c7 --- /dev/null +++ b/docs/Emitter.js.html @@ -0,0 +1,1120 @@ + + + + + + Phaser Source: particles/arcade/Emitter.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: particles/arcade/Emitter.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser - ArcadeEmitter
    +*
    +* @class Phaser.Particles.Arcade.Emitter
    +* @classdesc Emitter is a lightweight particle emitter. It can be used for one-time explosions or for
    +* continuous effects like rain and fire. All it really does is launch Particle objects out
    +* at set intervals, and fixes their positions and velocities accorindgly.
    +* @constructor
    +* @extends Phaser.Group
    +* @param {Phaser.Game} game - Current game instance.
    +* @param {number} [x=0] - The x coordinate within the Emitter that the particles are emitted from.
    +* @param {number} [y=0] - The y coordinate within the Emitter that the particles are emitted from.
    +* @param {number} [maxParticles=50] - The total number of particles in this emitter..
    +*/
    +
    +Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
    +
    +    /**
    +    * The total number of particles in this emitter.
    +    * @property {number} maxParticles - The total number of particles in this emitter..
    +    * @default
    +    */
    +	this.maxParticles = maxParticles || 50;
    +
    +	Phaser.Group.call(this, game);
    +
    +    /**
    +	* @property {string} name - Description.
    +	*/
    +    this.name = 'emitter' + this.game.particles.ID++;
    +
    +    /**
    +	* @property {Description} type - Description.
    +	*/
    +    this.type = Phaser.EMITTER;
    +
    +    /**
    +     * @property {number} x - The X position of the top left corner of the emitter in world space.
    +     * @default
    +     */
    +    this.x = 0;
    +
    +    /**
    +     * @property {number} y - The Y position of the top left corner of emitter in world space.
    +     * @default
    +     */
    +    this.y = 0;
    +
    +    /**
    +     * @property {number} width - The width of the emitter.  Particles can be randomly generated from anywhere within this box.
    +     * @default
    +     */
    +    this.width = 1;
    +
    +    /**
    +    * @property {number} height - The height of the emitter.  Particles can be randomly generated from anywhere within this box.
    +    * @default
    +    */
    +    this.height = 1;
    +
    +    /**
    +    * The minimum possible velocity of a particle.
    +    * The default value is (-100,-100).
    +    * @property {Phaser.Point} minParticleSpeed
    +    */
    +    this.minParticleSpeed = new Phaser.Point(-100, -100);
    +
    +    /**
    +    * The maximum possible velocity of a particle.
    +    * The default value is (100,100).
    +    * @property {Phaser.Point} maxParticleSpeed
    +    */
    +    this.maxParticleSpeed = new Phaser.Point(100, 100);
    +
    +    /**
    +    * The minimum possible scale of a particle.
    +    * The default value is 1.
    +    * @property {number} minParticleScale
    +    * @default
    +    */
    +    this.minParticleScale = 1;
    +
    +    /**
    +     * The maximum possible scale of a particle.
    +     * The default value is 1.
    +     * @property {number} maxParticleScale
    +     * @default
    +     */
    +    this.maxParticleScale = 1;
    +
    +    /**
    +     * The minimum possible angular velocity of a particle.  The default value is -360.
    +     * @property {number} minRotation
    +     * @default
    +     */
    +    this.minRotation = -360;
    +
    +    /**
    +     * The maximum possible angular velocity of a particle.  The default value is 360.
    +     * @property {number} maxRotation
    +     * @default
    +     */
    +    this.maxRotation = 360;
    +
    +    /**
    +     * Sets the <code>gravity.y</code> of each particle to this value on launch.
    +     * @property {number} gravity
    +     * @default
    +     */
    +    this.gravity = 2;
    +
    +    /**
    +     * Set your own particle class type here.
    +     * @property {Description} particleClass
    +     * @default
    +     */
    +    this.particleClass = null;
    +
    +    /**
    +     * The X and Y drag component of particles launched from the emitter.
    +     * @property {Phaser.Point} particleDrag
    +     */
    +    this.particleDrag = new Phaser.Point();
    +
    +    /**
    +     * The angular drag component of particles launched from the emitter if they are rotating.
    +     * @property {number} angularDrag
    +     * @default
    +     */
    +    this.angularDrag = 0;
    +
    +    /**
    +     * How often a particle is emitted in ms (if emitter is started with Explode == false).
    +     * @property {boolean} frequency
    +     * @default
    +     */
    +    this.frequency = 100;
    +
    +    /**
    +     * How long each particle lives once it is emitted in ms. Default is 2 seconds.
    +     * Set lifespan to 'zero' for particles to live forever.
    +     * @property {number} lifespan
    +     * @default
    +     */
    +    this.lifespan = 2000;
    +
    +    /**
    +     * How much each particle should bounce on each axis.  1 = full bounce, 0 = no bounce.
    +     * @property {Phaser.Point} bounce
    +     */
    +    this.bounce = new Phaser.Point();
    +
    +    /**
    +     * Internal helper for deciding how many particles to launch.
    +     * @property {number} _quantity
    +     * @private
    +     * @default
    +     */
    +    this._quantity = 0;
    +
    +   /**
    +     * Internal helper for deciding when to launch particles or kill them.
    +     * @property {number} _timer
    +     * @private
    +     * @default
    +     */
    +    this._timer = 0;
    +
    +    /**
    +     * Internal counter for figuring out how many particles to launch.
    +     * @property {number} _counter
    +     * @private
    +     * @default
    +     */
    +    this._counter = 0;
    +
    +    /**
    +     * Internal helper for the style of particle emission (all at once, or one at a time).
    +     * @property {boolean} _explode
    +     * @private
    +     * @default
    +     */
    +    this._explode = true;
    +
    +    /**
    +     * Determines whether the emitter is currently emitting particles.
    +     * It is totally safe to directly toggle this.
    +     * @property {boolean} on
    +     * @default
    +     */
    +    this.on = false;
    +
    +    /**
    +     * Determines whether the emitter is being updated by the core game loop.
    +     * @property {boolean} exists
    +     * @default
    +     */
    +    this.exists = true;
    +
    +    /**
    +     * The point the particles are emitted from.
    +     * Emitter.x and Emitter.y control the containers location, which updates all current particles
    +     * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position.
    +     * @property {boolean} emitX
    +     */
    +    this.emitX = x;
    +    
    +    /**
    +     * The point the particles are emitted from.
    +     * Emitter.x and Emitter.y control the containers location, which updates all current particles
    +     * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position.
    +     * @property {boolean} emitY
    +     */
    +    this.emitY = y;
    +	
    +};
    +
    +Phaser.Particles.Arcade.Emitter.prototype = Object.create(Phaser.Group.prototype);
    +Phaser.Particles.Arcade.Emitter.prototype.constructor = Phaser.Particles.Arcade.Emitter;
    +
    +/**
    +* Called automatically by the game loop, decides when to launch particles and when to "die".
    +* @method Phaser.Particles.Arcade.Emitter#update
    +*/
    +Phaser.Particles.Arcade.Emitter.prototype.update = function () {
    +
    +    if (this.on)
    +    {
    +        if (this._explode)
    +        {
    +			this._counter = 0;
    +
    +            do
    +            {
    +            	this.emitParticle();
    +            	this._counter++;
    +            }
    +            while (this._counter < this._quantity);
    +
    +            this.on = false;
    +        }
    +        else
    +        {
    +        	if (this.game.time.now >= this._timer)
    +        	{
    +                this.emitParticle();
    +				
    +				this._counter++;
    +
    +                if (this._quantity > 0)
    +                {
    +	                if (this._counter >= this._quantity)
    +	                {
    +	                	this.on = false;
    +	                }
    +                }
    +
    +                this._timer = this.game.time.now + this.frequency;
    +        	}
    +        }
    +    }
    +
    +}
    +
    +/**
    +* This function generates a new array of particle sprites to attach to the emitter.
    +*
    +* @method Phaser.Particles.Arcade.Emitter#makeParticles
    +* @param {Description} keys - Description.
    +* @param {number} frames - Description.
    +* @param {number} quantity - The number of particles to generate when using the "create from image" option.
    +* @param {number} collide - Description.
    +* @param {boolean} collideWorldBounds - Description.
    +* @return This Emitter instance (nice for chaining stuff together, if you're into that).
    +*/
    +Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide, collideWorldBounds) {
    +
    +    if (typeof frames == 'undefined')
    +    {
    +        frames = 0;
    +    }
    +
    +	quantity = quantity || this.maxParticles;
    +    collide = collide || 0;
    +
    +    if (typeof collideWorldBounds == 'undefined')
    +    {
    +        collideWorldBounds = false;
    +    }
    +
    +    var particle;
    +    var i = 0;
    +    var rndKey = keys;
    +    var rndFrame = 0;
    +
    +    while (i < quantity)
    +    {
    +        if (this.particleClass == null)
    +        {
    +            if (typeof keys == 'object')
    +            {
    +                rndKey = this.game.rnd.pick(keys);
    +            }
    +
    +            if (typeof frames == 'object')
    +            {
    +                rndFrame = this.game.rnd.pick(frames);
    +            }
    +
    +            particle = new Phaser.Sprite(this.game, 0, 0, rndKey, rndFrame);
    +        }
    +        else
    +        {
    +            // particle = new this.particleClass(this.game);
    +        }
    +
    +        if (collide > 0)
    +        {
    +            particle.body.allowCollision.any = true;
    +            particle.body.allowCollision.none = false;
    +        }
    +        else
    +        {
    +            particle.body.allowCollision.none = true;
    +        }
    +
    +        particle.body.collideWorldBounds = collideWorldBounds;
    +
    +        particle.exists = false;
    +        particle.visible = false;
    +
    +        //  Center the origin for rotation assistance
    +        particle.anchor.setTo(0.5, 0.5);
    +
    +        this.add(particle);
    +
    +        i++;
    +    }
    +
    +    return this;
    +}
    +
    +/**
    + * Call this function to turn off all the particles and the emitter.
    + * @method Phaser.Particles.Arcade.Emitter#kill
    + */
    +Phaser.Particles.Arcade.Emitter.prototype.kill = function () {
    +
    +    this.on = false;
    +    this.alive = false;
    +    this.exists = false;
    +
    +}
    +
    +/**
    + * Handy for bringing game objects "back to life". Just sets alive and exists back to true.
    + * In practice, this is most often called by <code>Object.reset()</code>.
    + * @method Phaser.Particles.Arcade.Emitter#revive
    + */
    +Phaser.Particles.Arcade.Emitter.prototype.revive = function () {
    +
    +    this.alive = true;
    +    this.exists = true;
    +
    +}
    +
    +/**
    + * Call this function to start emitting particles.
    + * @method Phaser.Particles.Arcade.Emitter#start
    + * @param {boolean} explode - Whether the particles should all burst out at once.
    + * @param {number} lifespan - How long each particle lives once emitted. 0 = forever.
    + * @param {number} frequency - Ignored if Explode is set to true. Frequency is how often to emit a particle in ms.
    + * @param {number} quantity - How many particles to launch. 0 = "all of the particles".
    + */
    +Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, frequency, quantity) {
    +
    +	if (typeof explode !== 'boolean')
    +	{
    +		explode = true;
    +	}
    +
    +	lifespan = lifespan || 0;
    +
    +	//	How many ms between emissions?
    +	frequency = frequency || 250;
    +
    +	//	Total number of particles to emit
    +	quantity = quantity || 0;
    +
    +    this.revive();
    +
    +    this.visible = true;
    +    this.on = true;
    +
    +    this._explode = explode;
    +    this.lifespan = lifespan;
    +    this.frequency = frequency;
    +
    +    if (explode)
    +    {
    +        this._quantity = quantity;
    +    }
    +    else
    +    {
    +        this._quantity += quantity;
    +    }
    +
    +    this._counter = 0;
    +    this._timer = this.game.time.now + frequency;
    +
    +}
    +
    +/**
    + * This function can be used both internally and externally to emit the next particle.
    + * @method Phaser.Particles.Arcade.Emitter#emitParticle
    + */
    +Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
    +
    +    var particle = this.getFirstExists(false);
    +
    +    if (particle == null)
    +    {
    +    	return;
    +    }
    +
    +    if (this.width > 1 || this.height > 1)
    +    {
    +    	particle.reset(this.game.rnd.integerInRange(this.left, this.right), this.game.rnd.integerInRange(this.top, this.bottom));
    +    }
    +    else
    +    {
    +    	particle.reset(this.emitX, this.emitY);
    +    }
    +
    +    particle.lifespan = this.lifespan;
    +
    +    particle.body.bounce.setTo(this.bounce.x, this.bounce.y);
    +
    +    if (this.minParticleSpeed.x != this.maxParticleSpeed.x)
    +    {
    +        particle.body.velocity.x = this.game.rnd.integerInRange(this.minParticleSpeed.x, this.maxParticleSpeed.x);
    +    }
    +    else
    +    {
    +        particle.body.velocity.x = this.minParticleSpeed.x;
    +    }
    +
    +    if (this.minParticleSpeed.y != this.maxParticleSpeed.y)
    +    {
    +        particle.body.velocity.y = this.game.rnd.integerInRange(this.minParticleSpeed.y, this.maxParticleSpeed.y);
    +    }
    +    else
    +    {
    +        particle.body.velocity.y = this.minParticleSpeed.y;
    +    }
    +
    +    particle.body.gravity.y = this.gravity;
    +
    +    if (this.minRotation != this.maxRotation)
    +    {
    +        particle.body.angularVelocity = this.game.rnd.integerInRange(this.minRotation, this.maxRotation);
    +    }
    +    else
    +    {
    +        particle.body.angularVelocity = this.minRotation;
    +    }
    +
    +    if (this.minParticleScale !== 1 || this.maxParticleScale !== 1)
    +    {
    +        var scale = this.game.rnd.realInRange(this.minParticleScale, this.maxParticleScale);
    +        particle.scale.setTo(scale, scale);
    +    }
    +
    +    particle.body.drag.x = this.particleDrag.x;
    +    particle.body.drag.y = this.particleDrag.y;
    +    particle.body.angularDrag = this.angularDrag;
    +
    +}
    +
    +/**
    +* A more compact way of setting the width and height of the emitter.
    +* @method Phaser.Particles.Arcade.Emitter#setSize
    +* @param  {number} width - The desired width of the emitter (particles are spawned randomly within these dimensions).
    +* @param  {number} height - The desired height of the emitter.
    +*/
    +Phaser.Particles.Arcade.Emitter.prototype.setSize = function (width, height) {
    +
    +    this.width = width;
    +    this.height = height;
    +
    +}
    +
    +/**
    +* A more compact way of setting the X velocity range of the emitter.
    +* @method Phaser.Particles.Arcade.Emitter#setXSpeed
    +* @param  {number} min - The minimum value for this range.
    +* @param  {number} max - The maximum value for this range.
    +*/
    +Phaser.Particles.Arcade.Emitter.prototype.setXSpeed = function (min, max) {
    +
    +	min = min || 0;
    +	max = max || 0;
    +
    +    this.minParticleSpeed.x = min;
    +    this.maxParticleSpeed.x = max;
    +
    +}
    +
    +/**
    +* A more compact way of setting the Y velocity range of the emitter.
    +* @method Phaser.Particles.Arcade.Emitter#setYSpeed
    +* @param  {number} min - The minimum value for this range.
    +* @param  {number} max - The maximum value for this range.
    +*/
    +Phaser.Particles.Arcade.Emitter.prototype.setYSpeed = function (min, max) {
    +
    +	min = min || 0;
    +	max = max || 0;
    +
    +    this.minParticleSpeed.y = min;
    +    this.maxParticleSpeed.y = max;
    +
    +}
    +
    +/**
    +* A more compact way of setting the angular velocity constraints of the emitter.
    +* @method Phaser.Particles.Arcade.Emitter#setRotation
    +* @param {number} min -  The minimum value for this range.
    +* @param {number} max -  The maximum value for this range.
    +*/
    +Phaser.Particles.Arcade.Emitter.prototype.setRotation = function (min, max) {
    +
    +	min = min || 0;
    +	max = max || 0;
    +
    +    this.minRotation = min;
    +    this.maxRotation = max;
    +
    +}
    +
    +/**
    +* Change the emitter's midpoint to match the midpoint of a <code>Object</code>.
    +* @method Phaser.Particles.Arcade.Emitter#at
    +* @param  {object} object - The <code>Object</code> that you want to sync up with.
    +*/
    +Phaser.Particles.Arcade.Emitter.prototype.at = function (object) {
    +
    +    this.emitX = object.center.x;
    +    this.emitY = object.center.y;
    +
    +}
    +
    +/**
    +* The emitters alpha value.
    +* @name Phaser.Particles.Arcade.Emitter#alpha
    +* @property {number} alpha - Gets or sets the alpha value of the Emitter.
    +*/
    +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "alpha", {
    +    
    +    get: function () {
    +        return this._container.alpha;
    +    },
    +
    +    set: function (value) {
    +        this._container.alpha = value;
    +    }
    +
    +});
    +
    +/**
    +* The emitter visible state.
    +* @name Phaser.Particles.Arcade.Emitter#visible
    +* @property {boolean} visible - Gets or sets the Emitter visible state.
    +*/
    +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "visible", {
    +    
    +    get: function () {
    +        return this._container.visible;
    +    },
    +
    +    set: function (value) {
    +        this._container.visible = value;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Particles.Arcade.Emitter#x
    +* @property {number} x - Gets or sets the x position of the Emitter.
    +*/
    +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "x", {
    +
    +    get: function () {
    +        return this.emitX;
    +    },
    +
    +    set: function (value) {
    +        this.emitX = value;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Particles.Arcade.Emitter#y
    +* @property {number} y - Gets or sets the y position of the Emitter.
    +*/
    +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "y", {
    +
    +    get: function () {
    +        return this.emitY;
    +    },
    +
    +    set: function (value) {
    +        this.emitY = value;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Particles.Arcade.Emitter#left
    +* @property {number} left - Gets the left position of the Emitter.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "left", {
    +    
    +    get: function () {
    +        return Math.floor(this.x - (this.width / 2));
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Particles.Arcade.Emitter#right
    +* @property {number} right - Gets the right position of the Emitter.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "right", {
    +    
    +    get: function () {
    +        return Math.floor(this.x + (this.width / 2));
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Particles.Arcade.Emitter#top
    +* @property {number} top - Gets the top position of the Emitter.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "top", {
    +    
    +    get: function () {
    +        return Math.floor(this.y - (this.height / 2));
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Particles.Arcade.Emitter#bottom
    +* @property {number} bottom - Gets the bottom position of the Emitter.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", {
    +    
    +    get: function () {
    +        return Math.floor(this.y + (this.height / 2));
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Events.js.html b/docs/Events.js.html new file mode 100644 index 00000000..68bb6f91 --- /dev/null +++ b/docs/Events.js.html @@ -0,0 +1,512 @@ + + + + + + Phaser Source: gameobjects/Events.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: gameobjects/Events.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +
    +/**
    +* The Events component is a collection of events fired by the parent game object and its components.
    +* 
    +* @class Phaser.Events
    +* @constructor
    +*
    +* @param {Phaser.Sprite} sprite - A reference to Description.
    +*/
    +Phaser.Events = function (sprite) {
    +	
    +	this.parent = sprite;
    +	this.onAddedToGroup = new Phaser.Signal;
    +	this.onRemovedFromGroup = new Phaser.Signal;
    +	this.onKilled = new Phaser.Signal;
    +	this.onRevived = new Phaser.Signal;
    +	this.onOutOfBounds = new Phaser.Signal;
    +
    +    this.onInputOver = null;
    +    this.onInputOut = null;
    +    this.onInputDown = null;
    +    this.onInputUp = null;
    +    this.onDragStart = null;
    +    this.onDragStop = null;
    +
    +	this.onAnimationStart = null;
    +	this.onAnimationComplete = null;
    +	this.onAnimationLoop = null;
    +
    +};
    +
    +Phaser.Events.prototype = {
    +
    +	destroy: function () {
    +
    +		this.parent = null;
    +		this.onAddedToGroup.dispose();
    +		this.onRemovedFromGroup.dispose();
    +		this.onKilled.dispose();
    +		this.onRevived.dispose();
    +		this.onOutOfBounds.dispose();
    +
    +		if (this.onInputOver)
    +		{
    +		    this.onInputOver.dispose();
    +		    this.onInputOut.dispose();
    +		    this.onInputDown.dispose();
    +		    this.onInputUp.dispose();
    +		    this.onDragStart.dispose();
    +		    this.onDragStop.dispose();
    +		}
    +
    +		if (this.onAnimationStart)
    +		{
    +			this.onAnimationStart.dispose();
    +			this.onAnimationComplete.dispose();
    +			this.onAnimationLoop.dispose();
    +		}
    +
    +	}
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Frame.js.html b/docs/Frame.js.html new file mode 100644 index 00000000..7187b4ae --- /dev/null +++ b/docs/Frame.js.html @@ -0,0 +1,605 @@ + + + + + + Phaser Source: animation/Frame.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: animation/Frame.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* A Frame is a single frame of an animation and is part of a FrameData collection.
    +*
    +* @class Phaser.Frame
    +* @constructor
    +* @param {number} index - The index of this Frame within the FrameData set it is being added to.
    +* @param {number} x - X position of the frame within the texture image.
    +* @param {number} y - Y position of the frame within the texture image.
    +* @param {number} width - Width of the frame within the texture image.
    +* @param {number} height - Height of the frame within the texture image.
    +* @param {string} name - The name of the frame. In Texture Atlas data this is usually set to the filename.
    +* @param {string} uuid - Internal UUID key.
    +*/
    +Phaser.Frame = function (index, x, y, width, height, name, uuid) {
    +
    +	/**
    +	* @property {number} index - The index of this Frame within the FrameData set it is being added to.
    +	*/
    +	this.index = index;
    +	
    +	/**
    +	* @property {number} x - X position within the image to cut from.
    +	*/
    +	this.x = x;
    +
    +	/**
    +	* @property {number} y - Y position within the image to cut from.
    +	*/
    +	this.y = y;
    +
    +	/**
    +	* @property {number} width - Width of the frame.
    +	*/
    +	this.width = width;
    +
    +	/**
    +	* @property {number} height - Height of the frame.
    +	*/
    +	this.height = height;
    +
    +	/**
    +	* @property {string} name - Useful for Texture Atlas files (is set to the filename value).
    +	*/
    +	this.name = name;
    +
    +	/**
    +	* @property {string} uuid - A link to the PIXI.TextureCache entry.
    +	*/
    +	this.uuid = uuid;
    +
    +	/**
    +	* @property {number} centerX - Center X position within the image to cut from.
    +	*/
    +    this.centerX = Math.floor(width / 2);
    +
    +	/**
    +	* @property {number} centerY - Center Y position within the image to cut from.
    +	*/
    +    this.centerY = Math.floor(height / 2);
    +
    +	/**
    +	* @property {number} distance - The distance from the top left to the bottom-right of this Frame.
    +	*/
    +	this.distance = Phaser.Math.distance(0, 0, width, height);
    +
    +	/**
    +	* @property {boolean} rotated - Rotated? (not yet implemented)
    +	* @default
    +	*/
    +	this.rotated = false;
    +
    +	/**
    +	* @property {string} rotationDirection - Either 'cw' or 'ccw', rotation is always 90 degrees.
    +	* @default 'cw'
    +	*/
    +	this.rotationDirection = 'cw';
    +
    +	/**
    +	* @property {boolean} trimmed - Was it trimmed when packed?
    +	* @default
    +	*/
    +	this.trimmed = false;
    +
    +	/**
    +	* @property {number} sourceSizeW - Width of the original sprite.
    +	*/
    +    this.sourceSizeW = width;
    +
    +	/**
    +	* @property {number} sourceSizeH - Height of the original sprite.
    +	*/
    +    this.sourceSizeH = height;
    +
    +	/**
    +	* @property {number} spriteSourceSizeX - X position of the trimmed sprite inside original sprite.
    +	* @default
    +	*/
    +	this.spriteSourceSizeX = 0;
    +
    +	/**
    +	* @property {number} spriteSourceSizeY - Y position of the trimmed sprite inside original sprite.
    +	* @default
    +	*/
    +	this.spriteSourceSizeY = 0;
    +
    +	/**
    +	* @property {number} spriteSourceSizeW - Width of the trimmed sprite.
    +	* @default
    +	*/
    +	this.spriteSourceSizeW = 0;
    +
    +	/**
    +	* @property {number} spriteSourceSizeH - Height of the trimmed sprite.
    +	* @default
    +	*/
    +	this.spriteSourceSizeH = 0;
    +
    +};
    +
    +Phaser.Frame.prototype = {
    +
    +	/**
    +	* If the frame was trimmed when added to the Texture Atlas this records the trim and source data.
    +	*
    +	* @method Phaser.Frame#setTrim
    +	* @param {boolean} trimmed - If this frame was trimmed or not.
    +	* @param {number} actualWidth - The width of the frame before being trimmed.
    +	* @param {number} actualHeight - The height of the frame before being trimmed.
    +	* @param {number} destX - The destination X position of the trimmed frame for display.
    +	* @param {number} destY - The destination Y position of the trimmed frame for display.
    +	* @param {number} destWidth - The destination width of the trimmed frame for display.
    +	* @param {number} destHeight - The destination height of the trimmed frame for display.
    +	*/
    +    setTrim: function (trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) {
    +
    +        this.trimmed = trimmed;
    +
    +        if (trimmed)
    +        {
    +            this.width = actualWidth;
    +            this.height = actualHeight;
    +            this.sourceSizeW = actualWidth;
    +            this.sourceSizeH = actualHeight;
    +		    this.centerX = Math.floor(actualWidth / 2);
    +		    this.centerY = Math.floor(actualHeight / 2);
    +            this.spriteSourceSizeX = destX;
    +            this.spriteSourceSizeY = destY;
    +            this.spriteSourceSizeW = destWidth;
    +            this.spriteSourceSizeH = destHeight;
    +        }
    +
    +    }
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/FrameData.js.html b/docs/FrameData.js.html new file mode 100644 index 00000000..7bbe8801 --- /dev/null +++ b/docs/FrameData.js.html @@ -0,0 +1,682 @@ + + + + + + Phaser Source: animation/FrameData.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: animation/FrameData.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* FrameData is a container for Frame objects, which are the internal representation of animation data in Phaser.
    +*
    +* @class Phaser.FrameData
    +* @constructor
    +*/
    +Phaser.FrameData = function () {
    +
    +	/**
    +	* @property {Array} _frames - Local array of frames.
    +	* @private
    +	*/
    +    this._frames = [];
    +
    +
    +	/**
    +	* @property {Array} _frameNames - Local array of frame names for name to index conversions.
    +	* @private
    +	*/
    +    this._frameNames = [];
    +
    +};
    +
    +Phaser.FrameData.prototype = {
    +
    +    /**
    +    * Adds a new Frame to this FrameData collection. Typically called by the Animation.Parser and not directly.
    +    *
    +    * @method Phaser.FrameData#addFrame
    +    * @param {Phaser.Frame} frame - The frame to add to this FrameData set.
    +    * @return {Phaser.Frame} The frame that was just added.
    +    */
    +    addFrame: function (frame) {
    +
    +        frame.index = this._frames.length;
    +
    +        this._frames.push(frame);
    +
    +        if (frame.name !== '')
    +        {
    +            this._frameNames[frame.name] = frame.index;
    +        }
    +
    +        return frame;
    +
    +    },
    +
    +	/**
    +	* Get a Frame by its numerical index.
    +    *
    +    * @method Phaser.FrameData#getFrame
    +	* @param {number} index - The index of the frame you want to get.
    +	* @return {Phaser.Frame} The frame, if found.
    +	*/
    +    getFrame: function (index) {
    +
    +        if (this._frames.length > index)
    +        {
    +            return this._frames[index];
    +        }
    +
    +        return null;
    +
    +    },
    +
    +    /**
    +    * Get a Frame by its frame name.
    +    *
    +    * @method Phaser.FrameData#getFrameByName
    +    * @param {string} name - The name of the frame you want to get.
    +    * @return {Phaser.Frame} The frame, if found.
    +    */
    +    getFrameByName: function (name) {
    +
    +        if (typeof this._frameNames[name] === 'number')
    +        {
    +            return this._frames[this._frameNames[name]];
    +        }
    +
    +        return null;
    +
    +    },
    +
    +    /**
    +    * Check if there is a Frame with the given name.
    +    *
    +    * @method Phaser.FrameData#checkFrameName
    +    * @param {string} name - The name of the frame you want to check.
    +    * @return {boolean} True if the frame is found, otherwise false.
    +    */
    +    checkFrameName: function (name) {
    +
    +        if (this._frameNames[name] == null)
    +        {
    +            return false;
    +        }
    +
    +        return true;
    +        
    +    },
    +
    +	/**
    +	* Returns a range of frames based on the given start and end frame indexes and returns them in an Array.
    +    *
    +    * @method Phaser.FrameData#getFrameRange
    +    * @param {number} start - The starting frame index.
    +	* @param {number} end - The ending frame index.
    +	* @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
    +	* @return {Array} An array of Frames between the start and end index values, or an empty array if none were found.
    +	*/
    +    getFrameRange: function (start, end, output) {
    +        
    +        if (typeof output === "undefined") { output = []; }
    +
    +        for (var i = start; i <= end; i++)
    +        {
    +            output.push(this._frames[i]);
    +        }
    +
    +        return output;
    +
    +    },
    +
    +	/**
    +	* Returns all of the Frames in this FrameData set where the frame index is found in the input array.
    +    * The frames are returned in the output array, or if none is provided in a new Array object.
    +    *
    +    * @method Phaser.FrameData#getFrames
    +    * @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
    +    * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false)
    +    * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
    +    * @return {Array} An array of all Frames in this FrameData set matching the given names or IDs.
    +	*/
    +    getFrames: function (frames, useNumericIndex, output) {
    +
    +        if (typeof useNumericIndex === "undefined") { useNumericIndex = true; }
    +        if (typeof output === "undefined") { output = []; }
    +
    +        if (typeof frames === "undefined" || frames.length == 0)
    +        {
    +            //  No input array, so we loop through all frames
    +            for (var i = 0; i < this._frames.length; i++)
    +            {
    +                //  We only need the indexes
    +                output.push(this._frames[i]);
    +            }
    +        }
    +        else
    +        {
    +            //  Input array given, loop through that instead
    +            for (var i = 0, len = frames.length; i < len; i++)
    +            {
    +                //  Does the input array contain names or indexes?
    +                if (useNumericIndex)
    +                {
    +                    //  The actual frame
    +                    output.push(this.getFrame(frames[i]));
    +                }
    +                else
    +                {
    +                    //  The actual frame
    +                    output.push(this.getFrameByName(frames[i]));
    +                }
    +            }
    +        }
    +
    +        return output;
    +
    +    },
    +
    +    /**
    +    * Returns all of the Frame indexes in this FrameData set.
    +    * The frames indexes are returned in the output array, or if none is provided in a new Array object.
    +    *
    +    * @method Phaser.FrameData#getFrameIndexes
    +    * @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
    +    * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false)
    +    * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
    +    * @return {Array} An array of all Frame indexes matching the given names or IDs.
    +    */
    +    getFrameIndexes: function (frames, useNumericIndex, output) {
    +
    +        if (typeof useNumericIndex === "undefined") { useNumericIndex = true; }
    +        if (typeof output === "undefined") { output = []; }
    +
    +        if (typeof frames === "undefined" || frames.length == 0)
    +        {
    +            //  No frames array, so we loop through all frames
    +            for (var i = 0, len = this._frames.length; i < len; i++)
    +            {
    +                output.push(this._frames[i].index);
    +            }
    +        }
    +        else
    +        {
    +            //  Input array given, loop through that instead
    +            for (var i = 0, len = frames.length; i < len; i++)
    +            {
    +                //  Does the frames array contain names or indexes?
    +                if (useNumericIndex)
    +                {
    +                    output.push(frames[i]);
    +                }
    +                else
    +                {
    +                    if (this.getFrameByName(frames[i]))
    +                    {
    +                        output.push(this.getFrameByName(frames[i]).index);
    +                    }
    +                }
    +            }
    +        }
    +
    +        return output;
    +
    +    }
    +
    +};
    +
    +/**
    +* @name Phaser.FrameData#total
    +* @property {number} total - The total number of frames in this FrameData set.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.FrameData.prototype, "total", {
    +
    +    get: function () {
    +        return this._frames.length;
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Game.js.html b/docs/Game.js.html new file mode 100644 index 00000000..49709934 --- /dev/null +++ b/docs/Game.js.html @@ -0,0 +1,932 @@ + + + + + + Phaser Source: core/Game.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/Game.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Game constructor
    +*
    +* Instantiate a new <code>Phaser.Game</code> object.
    +* @class Phaser.Game
    +* @classdesc This is where the magic happens. The Game object is the heart of your game,
    +* providing quick access to common functions and handling the boot process.
    +* <p>"Hell, there are no rules here - we're trying to accomplish something."</p><br>
    +*                                                       Thomas A. Edison
    +* @constructor
    +* @param {number} width - The width of your game in game pixels.
    +* @param {number} height - The height of your game in game pixels.
    +* @param {number} renderer -Which renderer to use (canvas or webgl)
    +* @param {HTMLElement} parent -The Games DOM parent.
    +* @param {Description} state - Description.
    +* @param {boolean} transparent - Use a transparent canvas background or not.
    +* @param  {boolean} antialias - Anti-alias graphics.
    +*/
    +Phaser.Game = function (width, height, renderer, parent, state, transparent, antialias) {
    +
    +	width = width || 800;
    +	height = height || 600;
    +	renderer = renderer || Phaser.AUTO;
    +	parent = parent || '';
    +	state = state || null;
    +
    +	if (typeof transparent == 'undefined') { transparent = false; }
    +	if (typeof antialias == 'undefined') { antialias = true; }
    +
    +	/**
    +	* @property {number} id - Phaser Game ID (for when Pixi supports multiple instances).
    +	*/
    +	this.id = Phaser.GAMES.push(this) - 1;
    +
    +	/**
    +	* @property {HTMLElement} parent - The Games DOM parent.
    +	*/
    +	this.parent = parent;
    +
    +	//	Do some more intelligent size parsing here, so they can set "100%" for example, maybe pass the scale mode in here too?
    +
    +	/**
    +	* @property {number} width - The Game width (in pixels).
    +	*/
    +	this.width = width;
    +
    +	/**
    +	* @property {number} height - The Game height (in pixels).
    +	*/
    +	this.height = height;
    +
    +	/**
    +	* @property {boolean} transparent - Use a transparent canvas background or not.
    +	*/
    +	this.transparent = transparent;
    +
    +	/**
    +	* @property {boolean} antialias - Anti-alias graphics (in WebGL this helps with edges, in Canvas2D it retains pixel-art quality).
    +	*/
    +	this.antialias = antialias;
    +
    +	/**
    +	* @property {number} renderer - The Pixi Renderer
    +	* @default
    +	*/
    +	this.renderer = null;
    +
    +	/**
    +	* @property {number} state - The StateManager.
    +	*/
    +	this.state = new Phaser.StateManager(this, state);
    +
    +	/**
    +	* @property {boolean} _paused - Is game paused?
    +	* @private
    +	* @default
    +	*/
    +	this._paused = false;
    +
    +	/**
    +	* @property {number} renderType - The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL.
    +	*/
    +	this.renderType = renderer;
    +
    +	/**
    +	* @property {boolean} _loadComplete - Whether load complete loading or not.
    +	* @private
    +	* @default
    +	*/
    +	this._loadComplete = false;
    +
    +	/**
    +	* @property {boolean} isBooted - Whether the game engine is booted, aka available.
    +	* @default
    +	*/
    +	this.isBooted = false;
    +
    +	/**
    +	* @property {boolean} id -Is game running or paused?
    +	* @default
    +	*/
    +	this.isRunning = false;
    +
    +	/**
    +	* @property {Phaser.RequestAnimationFrame} raf - Automatically handles the core game loop via requestAnimationFrame or setTimeout
    +	* @default
    +	*/
    +	this.raf = null;
    +
    +	/**
    +	* @property {Phaser.GameObjectFactory} add - Reference to the GameObject Factory.
    +	* @default
    +	*/
    +    this.add = null;
    +
    +    /**
    +	* @property {Phaser.Cache} cache - Reference to the assets cache.
    +	* @default
    +	*/
    +    this.cache = null;
    +
    +    /**
    +	* @property {Phaser.Input} input - Reference to the input manager
    +	* @default
    +	*/
    +    this.input = null;
    +
    +    /**
    +	* @property {Phaser.Loader} load - Reference to the assets loader.
    +	* @default
    +	*/
    +    this.load = null;
    +
    +    /**
    +	* @property {Phaser.GameMath} math - Reference to the math helper.
    +	* @default
    +	*/
    +    this.math = null;
    +
    +    /**
    +	* @property {Phaser.Net} net - Reference to the network class.
    +	* @default
    +	*/
    +    this.net = null;
    +
    +    /**
    +	* @property {Phaser.SoundManager} sound - Reference to the sound manager.
    +	* @default
    +	*/
    +    this.sound = null;
    +
    +    /**
    +	* @property {Phaser.Stage} stage - Reference to the stage.
    +	* @default
    +	*/
    +    this.stage = null;
    +
    +    /**
    +	* @property {Phaser.TimeManager} time - Reference to game clock.
    +	* @default
    +	*/
    +    this.time = null;
    +
    +    /**
    +	* @property {Phaser.TweenManager} tweens - Reference to the tween manager.
    +	* @default
    +	*/
    +    this.tweens = null;
    +
    +    /**
    +	* @property {Phaser.World} world - Reference to the world.
    +	* @default
    +	*/
    +    this.world = null;
    +
    +    /**
    +	* @property {Phaser.Physics.PhysicsManager} physics - Reference to the physics manager.
    +	* @default
    +	*/
    +    this.physics = null;
    +
    +    /**
    +	* @property {Phaser.RandomDataGenerator} rnd - Instance of repeatable random data generator helper.
    +	* @default
    +	*/
    +    this.rnd = null;
    +
    +    /**
    +	* @property {Phaser.Device} device - Contains device information and capabilities.
    +	* @default
    +	*/
    +    this.device = null;
    +
    +    /**
    +	* @property {Phaser.Physics.PhysicsManager} camera - A handy reference to world.camera.
    +	* @default
    +	*/
    +	this.camera = null;
    +
    +	   /**
    +	* @property {HTMLCanvasElement} canvas - A handy reference to renderer.view.
    +	* @default
    +	*/
    +	this.canvas = null;
    +
    +	/**
    +	* @property {Context} context - A handy reference to renderer.context (only set for CANVAS games)
    +	* @default
    +	*/
    +	this.context = null;
    +
    +    /**
    +	* @property {Phaser.Utils.Debug} debug - A set of useful debug utilitie.
    +	* @default
    +	*/
    +	this.debug = null;
    +
    +	/**
    +	* @property {Phaser.Particles} particles - The Particle Manager.
    +	* @default
    +	*/
    +	this.particles = null;
    +
    +	var _this = this;
    +
    +    this._onBoot = function () {
    +        return _this.boot();
    +    }
    +
    +	if (document.readyState === 'complete' || document.readyState === 'interactive')
    +	{
    +		window.setTimeout(this._onBoot, 0);
    +	}
    +	else
    +	{
    +		document.addEventListener('DOMContentLoaded', this._onBoot, false);
    +		window.addEventListener('load', this._onBoot, false);
    +	}
    +
    +	return this;
    +
    +};
    +
    +Phaser.Game.prototype = {
    +
    +	/**
    +	* Initialize engine sub modules and start the game.
    +	*
    +	* @method Phaser.Game#boot
    +	* @protected
    +	*/
    +	boot: function () {
    +
    +		if (this.isBooted)
    +		{
    +			return;
    +		}
    +
    +		if (!document.body)
    +		{
    +			window.setTimeout(this._onBoot, 20);
    +		}
    +		else
    +		{
    +			document.removeEventListener('DOMContentLoaded', this._onBoot);
    +			window.removeEventListener('load', this._onBoot);
    +
    +			this.onPause = new Phaser.Signal;
    +			this.onResume = new Phaser.Signal;
    +
    +			this.isBooted = true;
    +
    +			this.device = new Phaser.Device();
    +			this.math = Phaser.Math;
    +			this.rnd = new Phaser.RandomDataGenerator([(Date.now() * Math.random()).toString()]);
    +
    +			this.stage = new Phaser.Stage(this, this.width, this.height);
    +
    +			this.setUpRenderer();
    +
    +			this.world = new Phaser.World(this);
    +			this.add = new Phaser.GameObjectFactory(this);
    +			this.cache = new Phaser.Cache(this);
    +			this.load = new Phaser.Loader(this);
    +			this.time = new Phaser.Time(this);
    +			this.tweens = new Phaser.TweenManager(this);
    +			this.input = new Phaser.Input(this);
    +			this.sound = new Phaser.SoundManager(this);
    +			this.physics = new Phaser.Physics.Arcade(this);
    +			this.particles = new Phaser.Particles(this);
    +			this.plugins = new Phaser.PluginManager(this, this);
    +			this.net = new Phaser.Net(this);
    +			this.debug = new Phaser.Utils.Debug(this);
    +
    +			this.stage.boot();
    +			this.world.boot();
    +			this.input.boot();
    +			this.sound.boot();
    +			this.state.boot();
    +
    +			this.load.onLoadComplete.add(this.loadComplete, this);
    +
    +			if (this.renderType == Phaser.CANVAS)
    +			{
    +				console.log('%cPhaser ' + Phaser.VERSION + ' initialized. Rendering to Canvas', 'color: #ffff33; background: #000000');
    +			}
    +			else
    +			{
    +				console.log('%cPhaser ' + Phaser.VERSION + ' initialized. Rendering to WebGL', 'color: #ffff33; background: #000000');
    +			}
    +
    +			var pos = Phaser.VERSION.indexOf('-');
    +            var versionQualifier = (pos >= 0) ? Phaser.VERSION.substr(pos + 1) : null;
    +            if (versionQualifier)
    +            {
    +                var article = ['a', 'e', 'i', 'o', 'u', 'y'].indexOf(versionQualifier.charAt(0)) >= 0 ? 'an' : 'a';
    +                console.warn('You are using %s %s version of Phaser. Some things may not work.', article, versionQualifier);
    +            }
    +
    +	        this.isRunning = true;
    +            this._loadComplete = false;
    +
    +			this.raf = new Phaser.RequestAnimationFrame(this);
    +			this.raf.start();
    +
    +		}
    +
    +	},
    +
    +	/**
    +	* Checks if the device is capable of using the requested renderer and sets it up or an alternative if not.
    +	*
    +	* @method Phaser.Game#setUpRenderer
    +	* @protected
    +	*/
    +	setUpRenderer: function () {
    +
    +		if (this.renderType === Phaser.CANVAS || (this.renderType === Phaser.AUTO && this.device.webGL == false))
    +		{
    +			if (this.device.canvas)
    +			{
    +				this.renderType = Phaser.CANVAS;
    +				this.renderer = new PIXI.CanvasRenderer(this.width, this.height, this.stage.canvas, this.transparent);
    +				Phaser.Canvas.setSmoothingEnabled(this.renderer.context, this.antialias);
    +				this.canvas = this.renderer.view;
    +				this.context = this.renderer.context;
    +			}
    +			else
    +			{
    +				throw new Error('Phaser.Game - cannot create Canvas or WebGL context, aborting.');
    +			}
    +		}
    +		else
    +		{
    +			//	They requested WebGL, and their browser supports it
    +			this.renderType = Phaser.WEBGL;
    +			this.renderer = new PIXI.WebGLRenderer(this.width, this.height, this.stage.canvas, this.transparent, this.antialias);
    +			this.canvas = this.renderer.view;
    +			this.context = null;
    +		}
    +
    +        Phaser.Canvas.addToDOM(this.renderer.view, this.parent, true);
    +        Phaser.Canvas.setTouchAction(this.renderer.view);
    +
    +	},
    +
    +	/**
    +    * Called when the load has finished, after preload was run.
    +    *
    +    * @method Phaser.Game#loadComplete
    +    * @protected
    +    */
    +    loadComplete: function () {
    +
    +        this._loadComplete = true;
    +
    +        this.state.loadComplete();
    +
    +    },
    +
    +	/**
    +    * The core game loop.
    +    *
    +    * @method Phaser.Game#update
    +    * @protected
    +	* @param {number} time - The current time as provided by RequestAnimationFrame.
    +    */
    +	update: function (time) {
    +
    +		this.time.update(time);
    +
    +		if (!this._paused)
    +		{
    +	        this.plugins.preUpdate();
    +	        this.physics.preUpdate();
    +
    +	        this.stage.update();
    +	        this.input.update();
    +	        this.tweens.update();
    +	        this.sound.update();
    +			this.world.update();
    +			this.particles.update();
    +			this.state.update();
    +	        this.plugins.update();
    +
    +			this.world.postUpdate();
    +
    +			this.renderer.render(this.stage._stage);
    +			this.plugins.render();
    +			this.state.render();
    +
    +			this.plugins.postRender();
    +		}
    +
    +	},
    +
    +	/**
    +    * Nuke the entire game from orbit
    +    *
    +    * @method Phaser.Game#destroy
    +    */
    +    destroy: function () {
    +
    +		this.raf.stop();
    +
    +    	this.input.destroy();
    +
    +    	this.state.destroy();
    +
    +        this.state = null;
    +        this.cache = null;
    +        this.input = null;
    +        this.load = null;
    +        this.sound = null;
    +        this.stage = null;
    +        this.time = null;
    +        this.world = null;
    +        this.isBooted = false;
    +
    +    }
    +
    +};
    +
    +/**
    +* The paused state of the Game. A paused game doesn't update any of its subsystems.
    +* When a game is paused the onPause event is dispatched. When it is resumed the onResume event is dispatched.
    +* @name Phaser.Game#paused
    +* @property {boolean} paused - Gets and sets the paused state of the Game.
    +*/
    +Object.defineProperty(Phaser.Game.prototype, "paused", {
    +
    +    get: function () {
    +        return this._paused;
    +    },
    +
    +    set: function (value) {
    +
    +    	if (value === true)
    +    	{
    +    		if (this._paused == false)
    +    		{
    +	    		this._paused = true;
    +	    		this.onPause.dispatch(this);
    +    		}
    +    	}
    +    	else
    +    	{
    +    		if (this._paused)
    +    		{
    +	    		this._paused = false;
    +	    		this.onResume.dispatch(this);
    +    		}
    +    	}
    +
    +    }
    +
    +});
    +
    +/**
    +* "Deleted code is debugged code." - Jeff Sickel
    +*/
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/GameObjectFactory.js.html b/docs/GameObjectFactory.js.html new file mode 100644 index 00000000..f427f1f9 --- /dev/null +++ b/docs/GameObjectFactory.js.html @@ -0,0 +1,723 @@ + + + + + + Phaser Source: gameobjects/GameObjectFactory.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: gameobjects/GameObjectFactory.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* The Game Object Factory is a quick way to create all of the different sorts of core objects that Phaser uses.
    +*
    +* @class Phaser.GameObjectFactory
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +*/
    +Phaser.GameObjectFactory = function (game) {
    +
    +    /**
    +	* @property {Phaser.Game} game - A reference to the currently running Game.
    +	*/
    +	this.game = game;
    +	
    +    /**
    +	* @property {Phaser.World} world - A reference to the game world.
    +	*/
    +	this.world = this.game.world;
    +
    +};
    +
    +Phaser.GameObjectFactory.prototype = {
    +
    +    /**
    +    * Adds an existing object to the game world.
    +    * @method Phaser.GameObjectFactory#existing
    +    * @param {*} object - An instance of Phaser.Sprite, Phaser.Button or any other display object..
    +    * @return {*} The child that was added to the Group.
    +    */
    +    existing: function (object) {
    +
    +        return this.world.add(object);
    +
    +    },
    +
    +	/**
    +    * Create a new Sprite with specific position and sprite sheet key.
    +    *
    +    * @method Phaser.GameObjectFactory#sprite
    +    * @param {number} x - X position of the new sprite.
    +    * @param {number} y - Y position of the new sprite.
    +    * @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
    +    * @param {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
    +    * @returns {Phaser.Sprite} the newly created sprite object.
    +    */
    +    sprite: function (x, y, key, frame) {
    +
    +        return this.world.create(x, y, key, frame);
    +
    +    },
    +
    +    /**
    +    * Create a new Sprite with specific position and sprite sheet key that will automatically be added as a child of the given parent.
    +    *
    +    * @method Phaser.GameObjectFactory#child
    +    * @param {Phaser.Group} group - The Group to add this child to.
    +    * @param {number} x - X position of the new sprite.
    +    * @param {number} y - Y position of the new sprite.
    +    * @param {string|RenderTexture} [key] - The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture.
    +    * @param  {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.
    +    * @returns {Phaser.Sprite} the newly created sprite object.
    +    */
    +    child: function (group, x, y, key, frame) {
    +
    +        return group.create(x, y, key, frame);
    +
    +    },
    +
    +    /**
    +    * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.
    +    *
    +    * @method Phaser.GameObjectFactory#tween
    +    * @param {object} obj - Object the tween will be run on.
    +    * @return {Phaser.Tween} Description.
    +    */
    +    tween: function (obj) {
    +
    +        return this.game.tweens.create(obj);
    +
    +    },
    +
    +    /**
    +    * A Group is a container for display objects that allows for fast pooling, recycling and collision checks.
    +    *
    +    * @method Phaser.GameObjectFactory#group
    +    * @param {*} parent - The parent Group or DisplayObjectContainer that will hold this group, if any.
    +    * @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging.
    +    * @return {Phaser.Group} The newly created group.
    +    */
    +    group: function (parent, name) {
    +
    +        return new Phaser.Group(this.game, parent, name);
    +
    +    },
    +
    +    /**
    +     * Creates a new instance of the Sound class.
    +     *
    +    * @method Phaser.GameObjectFactory#audio
    +     * @param {string} key - The Game.cache key of the sound that this object will use.
    +     * @param {number} volume - The volume at which the sound will be played.
    +     * @param {boolean} loop - Whether or not the sound will loop.
    +     * @return {Phaser.Sound} The newly created text object.
    +     */
    +    audio: function (key, volume, loop) {
    +
    +        return this.game.sound.add(key, volume, loop);
    +        
    +    },
    +
    +    /**
    +     * Creates a new <code>TileSprite</code>.
    +     *
    +    * @method Phaser.GameObjectFactory#tileSprite
    +     * @param {number} x - X position of the new tileSprite.
    +     * @param {number} y - Y position of the new tileSprite.
    +     * @param {number} width - the width of the tilesprite.
    +     * @param {number} height - the height of the tilesprite.
    +     * @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
    +     * @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
    +     * @return {Phaser.TileSprite} The newly created tileSprite object.
    +     */
    +    tileSprite: function (x, y, width, height, key, frame) {
    +
    +        return this.world.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame));
    +
    +    },
    +
    +    /**
    +     * Creates a new <code>Text</code>.
    +     *
    +    * @method Phaser.GameObjectFactory#text
    +     * @param {number} x - X position of the new text object.
    +     * @param {number} y - Y position of the new text object.
    +     * @param {string} text - The actual text that will be written.
    +     * @param {object} style - The style object containing style attributes like font, font size , etc.
    +     * @return {Phaser.Text} The newly created text object.
    +     */
    +    text: function (x, y, text, style) {
    +
    +        return this.world.add(new Phaser.Text(this.game, x, y, text, style));
    +
    +    },
    +
    +    /**
    +    * Creates a new <code>Button</code> object.
    +    *
    +    * @method Phaser.GameObjectFactory#button
    +    * @param {number} [x] X position of the new button object.
    +    * @param {number} [y] Y position of the new button object.
    +    * @param {string} [key] The image key as defined in the Game.Cache to use as the texture for this button.
    +    * @param {function} [callback] The function to call when this button is pressed
    +    * @param {object} [callbackContext] The context in which the callback will be called (usually 'this')
    +    * @param {string|number} [overFrame] This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.
    +    * @param {string|number} [outFrame] This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.
    +    * @param {string|number} [downFrame] This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.
    +    * @return {Phaser.Button} The newly created button object.
    +    */
    +    button: function (x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) {
    +
    +        return this.world.add(new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame));
    +
    +    },
    +
    +    /**
    +     * Creates a new <code>Graphics</code> object.
    +     *
    +    * @method Phaser.GameObjectFactory#graphics
    +     * @param {number} x - X position of the new graphics object.
    +     * @param {number} y - Y position of the new graphics object.
    +     * @return {Phaser.Graphics} The newly created graphics object.
    +     */
    +    graphics: function (x, y) {
    +
    +        return this.world.add(new Phaser.Graphics(this.game, x, y));
    +
    +    },
    +
    +    /**
    +    * Emitter is a lightweight particle emitter. It can be used for one-time explosions or for
    +    * continuous effects like rain and fire. All it really does is launch Particle objects out
    +    * at set intervals, and fixes their positions and velocities accorindgly.
    +    *
    +    * @method Phaser.GameObjectFactory#emitter
    +    * @param {number} [x=0] - The x coordinate within the Emitter that the particles are emitted from.
    +    * @param {number} [y=0] - The y coordinate within the Emitter that the particles are emitted from.
    +    * @param {number} [maxParticles=50] - The total number of particles in this emitter.
    +    * @return {Phaser.Emitter} The newly created emitter object.
    +    */
    +    emitter: function (x, y, maxParticles) {
    +
    +        return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game, x, y, maxParticles));
    +
    +    },
    +
    +    /**
    +    * * Create a new <code>BitmapText</code>.
    +    *
    +    * @method Phaser.GameObjectFactory#bitmapText
    +    * @param {number} x - X position of the new bitmapText object.
    +    * @param {number} y - Y position of the new bitmapText object.
    +    * @param {string} text - The actual text that will be written.
    +    * @param {object} style - The style object containing style attributes like font, font size , etc.
    +    * @return {Phaser.BitmapText} The newly created bitmapText object.
    +    */
    +    bitmapText: function (x, y, text, style) {
    +
    +        return this.world.add(new Phaser.BitmapText(this.game, x, y, text, style));
    +
    +    },
    +
    +    /**
    +    * Creates a new Tilemap object.
    +    *
    +    * @method Phaser.GameObjectFactory#tilemap
    +    * @param {string} key - Asset key for the JSON file.
    +    * @return {Phaser.Tilemap} The newly created tilemap object.
    +    */
    +    tilemap: function (key) {
    +
    +        return new Phaser.Tilemap(this.game, key);
    +
    +    },
    +
    +    /**
    +    * Creates a new Tileset object.
    +    *
    +    * @method Phaser.GameObjectFactory#tileset
    +    * @param {string} key - The image key as defined in the Game.Cache to use as the tileset.
    +    * @return {Phaser.Tileset} The newly created tileset object.
    +    */
    +    tileset: function (key) {
    +
    +        return this.game.cache.getTileset(key);
    +
    +    },
    +
    +    /**
    +    * Creates a new Tilemap Layer object.
    +    *
    +    * @method Phaser.GameObjectFactory#tilemapLayer
    +    * @param {number} x - X position of the new tilemapLayer.
    +    * @param {number} y - Y position of the new tilemapLayer.
    +    * @param {number} width - the width of the tilemapLayer.
    +    * @param {number} height - the height of the tilemapLayer.
    +    * @return {Phaser.TilemapLayer} The newly created tilemaplayer object.
    +    */
    +    tilemapLayer: function (x, y, width, height, tileset, tilemap, layer) {
    +
    +        return this.world.add(new Phaser.TilemapLayer(this.game, x, y, width, height, tileset, tilemap, layer));
    +
    +    },
    +
    +    /**
    +    * A dynamic initially blank canvas to which images can be drawn.
    +    *
    +    * @method Phaser.GameObjectFactory#renderTexture
    +    * @param {string} key - Asset key for the render texture.
    +    * @param {number} width - the width of the render texture.
    +    * @param {number} height - the height of the render texture.
    +    * @return {Phaser.RenderTexture} The newly created renderTexture object.
    +    */
    +    renderTexture: function (key, width, height) {
    +
    +        var texture = new Phaser.RenderTexture(this.game, key, width, height);
    +
    +        this.game.cache.addRenderTexture(key, texture);
    +
    +        return texture;
    +
    +    }
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Graphics.js.html b/docs/Graphics.js.html new file mode 100644 index 00000000..b8fc6189 --- /dev/null +++ b/docs/Graphics.js.html @@ -0,0 +1,532 @@ + + + + + + Phaser Source: gameobjects/Graphics.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: gameobjects/Graphics.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Creates a new <code>Graphics</code> object.
    +* 
    +* @class Phaser.Graphics
    +* @constructor
    +*
    +* @param {Phaser.Game} game Current game instance.
    +* @param {number} x - X position of the new graphics object.
    +* @param {number} y - Y position of the new graphics object.
    +*/
    +Phaser.Graphics = function (game, x, y) {
    +
    +    this.game = game;
    +
    +    PIXI.Graphics.call(this);
    +
    +    /**
    +	* @property {Description} type - Description.
    +	*/
    +    this.type = Phaser.GRAPHICS;
    +
    +};
    +
    +Phaser.Graphics.prototype = Object.create(PIXI.Graphics.prototype);
    +Phaser.Graphics.prototype.constructor = Phaser.Graphics;
    +
    +//  Add our own custom methods
    +
    +/**
    +* Description.
    +* 
    +* @method Phaser.Sprite.prototype.destroy
    +*/
    +Phaser.Graphics.prototype.destroy = function() {
    +
    +    this.clear();
    +
    +    if (this.group)
    +    {
    +        this.group.remove(this);
    +    }
    +
    +    this.game = null;
    +
    +}
    +
    +Object.defineProperty(Phaser.Graphics.prototype, 'angle', {
    +
    +    get: function() {
    +        return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation));
    +    },
    +
    +    set: function(value) {
    +        this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value));
    +    }
    +
    +});
    +
    +Object.defineProperty(Phaser.Graphics.prototype, 'x', {
    +
    +    get: function() {
    +        return this.position.x;
    +    },
    +
    +    set: function(value) {
    +        this.position.x = value;
    +    }
    +
    +});
    +
    +Object.defineProperty(Phaser.Graphics.prototype, 'y', {
    +
    +    get: function() {
    +        return this.position.y;
    +    },
    +
    +    set: function(value) {
    +        this.position.y = value;
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Group.js.html b/docs/Group.js.html new file mode 100644 index 00000000..5c5bacc1 --- /dev/null +++ b/docs/Group.js.html @@ -0,0 +1,1699 @@ + + + + + + Phaser Source: core/Group.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/Group.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser Group constructor.
    +* @class Phaser.Group
    +* @classdesc A Group is a container for display objects that allows for fast pooling, recycling and collision checks.
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +* @param {*} parent - The parent Group or DisplayObjectContainer that will hold this group, if any.
    +* @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging.
    +* @param {boolean} [useStage=false] - Should the DisplayObjectContainer this Group creates be added to the World (default, false) or direct to the Stage (true).
    +*/
    +Phaser.Group = function (game, parent, name, useStage) {
    +
    +	if (typeof parent === 'undefined')
    +	{
    +		parent = game.world;
    +	}
    +
    +	if (typeof useStage === 'undefined')
    +	{
    +		useStage = false;
    +	}
    +
    +    /**
    +	* @property {Phaser.Game} game - A reference to the currently running Game.
    +	*/
    +	this.game = game;
    +	
    +    /**
    +	* @property {string} name - A name for this Group. Not used internally but useful for debugging.
    +	*/
    +	this.name = name || 'group';
    +
    +	if (useStage)
    +	{
    +		this._container = this.game.stage._stage;
    +	}
    +	else
    +	{
    +		this._container = new PIXI.DisplayObjectContainer();
    +		this._container.name = this.name;
    +
    +		if (parent)
    +		{
    +			if (parent instanceof Phaser.Group)
    +			{
    +				parent._container.addChild(this._container);
    +				parent._container.updateTransform();
    +			}
    +			else
    +			{
    +				parent.addChild(this._container);
    +				parent.updateTransform();
    +			}
    +		}
    +		else
    +		{
    +			this.game.stage._stage.addChild(this._container);
    +			this.game.stage._stage.updateTransform();
    +		}
    +	}
    +
    +	/**
    +	* @property {number} type - Internal Phaser Type value.
    +	* @protected
    +	*/
    +	this.type = Phaser.GROUP;
    +
    +	/**
    +	* @property {boolean} exists - If exists is true the the Group is updated, otherwise it is skipped.
    +	* @default
    +	*/
    +	this.exists = true;
    +
    +    /**
    +    * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one.
    +    */ 
    +    this.scale = new Phaser.Point(1, 1);
    +
    +};
    +
    +Phaser.Group.prototype = {
    +
    +    /**
    +    * Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object.
    +    * The child is automatically added to the top of the Group, so renders on-top of everything else within the Group. If you need to control
    +    * that then see the addAt method.
    +    *
    +    * @see Phaser.Group#create
    +    * @see Phaser.Group#addAt
    +    * @method Phaser.Group#add
    +	* @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object..
    +	* @return {*} The child that was added to the Group.
    +    */
    +	add: function (child) {
    +
    +		if (child.group !== this)
    +		{
    +			child.group = this;
    +
    +			if (child.events)
    +			{
    +				child.events.onAddedToGroup.dispatch(child, this);
    +			}
    +
    +			this._container.addChild(child);
    +
    +			child.updateTransform();
    +		}
    +
    +		return child;
    +
    +	},
    +
    +    /**
    +    * Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object.
    +    * The child is added to the Group at the location specified by the index value, this allows you to control child ordering.
    +	*
    +    * @method Phaser.Group#addAt
    +	* @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object..
    +	* @param {number} index - The index within the Group to insert the child to.
    +	* @return {*} The child that was added to the Group.
    +	*/
    +	addAt: function (child, index) {
    +
    +		if (child.group !== this)
    +		{
    +			child.group = this;
    +
    +			if (child.events)
    +			{
    +				child.events.onAddedToGroup.dispatch(child, this);
    +			}
    +
    +			this._container.addChildAt(child, index);
    +
    +			child.updateTransform();
    +		}
    +
    +		return child;
    +
    +	},
    +
    +    /**
    +	* Returns the child found at the given index within this Group.
    +	*
    +    * @method Phaser.Group#getAt
    +    * @memberof Phaser.Group
    +	* @param {number} index - The index to return the child from.
    +	* @return {*} The child that was found at the given index.
    +	*/
    +	getAt: function (index) {
    +
    +		return this._container.getChildAt(index);
    +
    +	},
    +
    +    /**
    +	* Automatically creates a new Phaser.Sprite object and adds it to the top of this Group.
    +	* Useful if you don't need to create the Sprite instances before-hand.
    +	*
    +    * @method Phaser.Group#create
    +	* @param {number} x - The x coordinate to display the newly created Sprite at. The value is in relation to the Group.x point.
    +	* @param {number} y - The y coordinate to display the newly created Sprite at. The value is in relation to the Group.y point.
    +	* @param {string} key - The Game.cache key of the image that this Sprite will use.
    +	* @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here.
    +	* @param {boolean} [exists=true] - The default exists state of the Sprite.
    +	* @return {Phaser.Sprite} The child that was created.
    +	*/
    +	create: function (x, y, key, frame, exists) {
    +
    +		if (typeof exists == 'undefined') { exists = true; }
    +
    +		var child = new Phaser.Sprite(this.game, x, y, key, frame);
    +
    +		child.group = this;
    +		child.exists = exists;
    +		child.visible = exists;
    +		child.alive = exists;
    +
    +		if (child.events)
    +		{
    +			child.events.onAddedToGroup.dispatch(child, this);
    +		}
    +
    +		this._container.addChild(child);
    +			
    +		child.updateTransform();
    +
    +		return child;
    +
    +	},
    +
    +    /**
    +	* Automatically creates multiple Phaser.Sprite objects and adds them to the top of this Group.
    +	* Useful if you need to quickly generate a pool of identical sprites, such as bullets. By default the sprites will be set to not exist
    +	* and will be positioned at 0, 0 (relative to the Group.x/y)
    +	*
    +    * @method Phaser.Group#createMultiple
    +	* @param {number} quantity - The number of Sprites to create.
    +	* @param {string} key - The Game.cache key of the image that this Sprite will use.
    +	* @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here.
    +	* @param {boolean} [exists=false] - The default exists state of the Sprite.
    +	*/
    +	createMultiple: function (quantity, key, frame, exists) {
    +
    +		if (typeof exists == 'undefined') { exists = false; }
    +
    +		for (var i = 0; i < quantity; i++)
    +		{
    +			var child = new Phaser.Sprite(this.game, 0, 0, key, frame);
    +
    +			child.group = this;
    +			child.exists = exists;
    +			child.visible = exists;
    +			child.alive = exists;
    +
    +			if (child.events)
    +			{
    +				child.events.onAddedToGroup.dispatch(child, this);
    +			}
    +
    +			this._container.addChild(child);
    +			child.updateTransform();
    +
    +		}
    +
    +	},
    +
    +	/**
    +	* Swaps the position of two children in this Group.
    +	*
    +    * @method Phaser.Group#swap
    +	* @param {*} child1 - The first child to swap.
    +	* @param {*} child2 - The second child to swap.
    +    * @return {boolean} True if the swap was successful, otherwise false.
    +	*/
    +	swap: function (child1, child2) {
    +
    +		if (child1 === child2 || !child1.parent || !child2.parent)
    +		{
    +			console.warn('You cannot swap a child with itself or swap un-parented children');
    +			return false;
    +		}
    +
    +		//	Cache the values
    +		var child1Prev = child1._iPrev;
    +		var child1Next = child1._iNext;
    +		var child2Prev = child2._iPrev;
    +		var child2Next = child2._iNext;
    +
    +		var endNode = this._container.last._iNext;
    +		var currentNode = this.game.stage._stage;
    +			
    +		do
    +		{
    +			if (currentNode !== child1 && currentNode !== child2)
    +			{
    +				if (currentNode.first === child1)
    +				{
    +					currentNode.first = child2;
    +				}
    +				else if (currentNode.first === child2)
    +				{
    +					currentNode.first = child1;
    +				}
    +
    +				if (currentNode.last === child1)
    +				{
    +					currentNode.last = child2;
    +				}
    +				else if (currentNode.last === child2)
    +				{
    +					currentNode.last = child1;
    +				}
    +			}
    +
    +			currentNode = currentNode._iNext;
    +		}
    +		while (currentNode != endNode)
    +
    +		if (child1._iNext == child2)
    +		{
    +			//	This is a downward (A to B) neighbour swap
    +			child1._iNext = child2Next;
    +			child1._iPrev = child2;
    +			child2._iNext = child1;
    +			child2._iPrev = child1Prev;
    +
    +			if (child1Prev) { child1Prev._iNext = child2; }
    +			if (child2Next) { child2Next._iPrev = child1; }
    +
    +			if (child1.__renderGroup)
    +			{
    +				child1.__renderGroup.updateTexture(child1);
    +			}
    +
    +			if (child2.__renderGroup)
    +			{
    +				child2.__renderGroup.updateTexture(child2);
    +			}
    +
    +			return true;
    +		}
    +		else if (child2._iNext == child1)
    +		{
    +			//	This is an upward (B to A) neighbour swap
    +			child1._iNext = child2;
    +			child1._iPrev = child2Prev;
    +			child2._iNext = child1Next;
    +			child2._iPrev = child1;
    +
    +			if (child2Prev) { child2Prev._iNext = child1; }
    +			if (child1Next) { child2Next._iPrev = child2; }
    +
    +			if (child1.__renderGroup)
    +			{
    +				child1.__renderGroup.updateTexture(child1);
    +			}
    +
    +			if (child2.__renderGroup)
    +			{
    +				child2.__renderGroup.updateTexture(child2);
    +			}
    +
    +			return true;
    +		}
    +		else
    +		{
    +			//	Children are far apart
    +			child1._iNext = child2Next;
    +			child1._iPrev = child2Prev;
    +			child2._iNext = child1Next;
    +			child2._iPrev = child1Prev;
    +
    +			if (child1Prev) { child1Prev._iNext = child2; }
    +			if (child1Next) { child1Next._iPrev = child2; }
    +			if (child2Prev) { child2Prev._iNext = child1; }
    +			if (child2Next) { child2Next._iPrev = child1; }
    +
    +			if (child1.__renderGroup)
    +			{
    +				child1.__renderGroup.updateTexture(child1);
    +			}
    +
    +			if (child2.__renderGroup)
    +			{
    +				child2.__renderGroup.updateTexture(child2);
    +			}
    +
    +			return true;
    +		}
    +
    +		return false;
    +		
    +	},
    +
    +	/**
    +	* Brings the given child to the top of this Group so it renders above all other children.
    +	*
    +    * @method Phaser.Group#bringToTop
    +	* @param {*} child - The child to bring to the top of this Group.
    +    * @return {*} The child that was moved.
    +	*/
    +	bringToTop: function (child) {
    +
    +		if (child.group === this)
    +		{
    +			this.remove(child);
    +			this.add(child);
    +		}
    +
    +		return child;
    +
    +	},
    +
    +	/**
    +	* Get the index position of the given child in this Group.
    +	*
    +    * @method Phaser.Group#getIndex
    +	* @param {*} child - The child to get the index for.
    +    * @return {number} The index of the child or -1 if it's not a member of this Group.
    +	*/
    +	getIndex: function (child) {
    +
    +		return this._container.children.indexOf(child);
    +
    +	},
    +
    +	/**
    +	* Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group.
    +	*
    +    * @method Phaser.Group#replace
    +	* @param {*} oldChild - The child in this Group that will be replaced.
    +	* @param {*} newChild - The child to be inserted into this group.
    +	*/
    +	replace: function (oldChild, newChild) {
    +
    +		if (!this._container.first._iNext)
    +		{
    +			return;
    +		}
    +
    +		var index = this.getIndex(oldChild);
    +		
    +		if (index != -1)
    +		{
    +			if (newChild.parent != undefined)
    +			{
    +				newChild.events.onRemovedFromGroup.dispatch(newChild, this);
    +				newChild.parent.removeChild(newChild);
    +			}
    +
    +			this._container.removeChild(oldChild);
    +			this._container.addChildAt(newChild, index);
    +			newChild.events.onAddedToGroup.dispatch(newChild, this);
    +			newChild.updateTransform();
    +		}
    +
    +	},
    +
    +	/**
    +     * Sets the given property to the given value on the child. The operation controls the assignment of the value.
    +     *
    +     * @method Phaser.Group#setProperty
    +     * @param {*} child - The child to set the property value on.
    +     * @param {array} key - An array of strings that make up the property that will be set.
    +     * @param {*} value - The value that will be set.
    +     * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.
    +     */
    +	setProperty: function (child, key, value, operation) {
    +
    +		operation = operation || 0;
    +
    +		//	As ugly as this approach looks, and although it's limited to a depth of only 4, it's extremely fast.
    +		//	Much faster than a for loop or object iteration. There are no checks, so if the key isn't valid then it'll fail
    +		//	but as you are likely to call this from inner loops that have to perform well, I'll take that trade off.
    +
    +		//	0 = Equals
    +		//	1 = Add
    +		//	2 = Subtract
    +		//	3 = Multiply
    +		//	4 = Divide
    +
    +		if (key.length == 1)
    +		{
    +			if (operation == 0) { child[key[0]] = value; }
    +			else if (operation == 1) { child[key[0]] += value; }
    +			else if (operation == 2) { child[key[0]] -= value; }
    +			else if (operation == 3) { child[key[0]] *= value; }
    +			else if (operation == 4) { child[key[0]] /= value; }
    +		}
    +		else if (key.length == 2)
    +		{
    +			if (operation == 0) { child[key[0]][key[1]] = value; }
    +			else if (operation == 1) { child[key[0]][key[1]] += value; }
    +			else if (operation == 2) { child[key[0]][key[1]] -= value; }
    +			else if (operation == 3) { child[key[0]][key[1]] *= value; }
    +			else if (operation == 4) { child[key[0]][key[1]] /= value; }
    +		}
    +		else if (key.length == 3)
    +		{
    +			if (operation == 0) { child[key[0]][key[1]][key[2]] = value; }
    +			else if (operation == 1) { child[key[0]][key[1]][key[2]] += value; }
    +			else if (operation == 2) { child[key[0]][key[1]][key[2]] -= value; }
    +			else if (operation == 3) { child[key[0]][key[1]][key[2]] *= value; }
    +			else if (operation == 4) { child[key[0]][key[1]][key[2]] /= value; }
    +		}
    +		else if (key.length == 4)
    +		{
    +			if (operation == 0) { child[key[0]][key[1]][key[2]][key[3]] = value; }
    +			else if (operation == 1) { child[key[0]][key[1]][key[2]][key[3]] += value; }
    +			else if (operation == 2) { child[key[0]][key[1]][key[2]][key[3]] -= value; }
    +			else if (operation == 3) { child[key[0]][key[1]][key[2]][key[3]] *= value; }
    +			else if (operation == 4) { child[key[0]][key[1]][key[2]][key[3]] /= value; }
    +		}
    +		else
    +		{
    +			//	TODO - Deep property scane
    +		}
    +
    +	},
    +
    +	/**
    +     * This function allows you to quickly set the same property across all children of this Group to a new value.
    +     * The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication.
    +     *
    +     * @method Phaser.Group#setAll
    +     * @param {string} key - The property, as a string, to be set. For example: 'body.velocity.x'
    +     * @param {*} value - The value that will be set.
    +     * @param {boolean} [checkAlive=false] - If set then only children with alive=true will be updated.
    +     * @param {boolean} [checkVisible=false] - If set then only children with visible=true will be updated.
    +     * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.
    +     */
    +	setAll: function (key, value, checkAlive, checkVisible, operation) {
    +
    +		key = key.split('.');
    +
    +		if (typeof checkAlive === 'undefined') { checkAlive = false; }
    +		if (typeof checkVisible === 'undefined') { checkVisible = false; }
    +
    +		operation = operation || 0;
    +
    +		if (this._container.children.length > 0 && this._container.first._iNext)
    +		{
    +			var currentNode = this._container.first._iNext;
    +				
    +			do	
    +			{
    +				if ((checkAlive == false || (checkAlive && currentNode.alive)) && (checkVisible == false || (checkVisible && currentNode.visible)))
    +				{
    +					this.setProperty(currentNode, key, value, operation);
    +				}
    +
    +				currentNode = currentNode._iNext;
    +			}
    +			while (currentNode != this._container.last._iNext)
    +		}
    +
    +	},
    +
    +	/**
    +     * Adds the amount to the given property on all children in this Group.
    +     * Group.addAll('x', 10) will add 10 to the child.x value.
    +     *
    +     * @method Phaser.Group#addAll
    +     * @param {string} property - The property to increment, for example 'body.velocity.x' or 'angle'.
    +     * @param {number} amount - The amount to increment the property by. If child.x = 10 then addAll('x', 40) would make child.x = 50.
    +     * @param {boolean} checkAlive - If true the property will only be changed if the child is alive.
    +     * @param {boolean} checkVisible - If true the property will only be changed if the child is visible.
    +     */
    +	addAll: function (property, amount, checkAlive, checkVisible) {
    +
    +		this.setAll(property, amount, checkAlive, checkVisible, 1);
    +
    +	},
    +
    +	/**
    +     * Subtracts the amount from the given property on all children in this Group.
    +     * Group.subAll('x', 10) will minus 10 from the child.x value.
    +     *
    +     * @method Phaser.Group#subAll
    +     * @param {string} property - The property to decrement, for example 'body.velocity.x' or 'angle'.
    +     * @param {number} amount - The amount to subtract from the property. If child.x = 50 then subAll('x', 40) would make child.x = 10.
    +     * @param {boolean} checkAlive - If true the property will only be changed if the child is alive.
    +     * @param {boolean} checkVisible - If true the property will only be changed if the child is visible.
    +     */
    +	subAll: function (property, amount, checkAlive, checkVisible) {
    +
    +		this.setAll(property, amount, checkAlive, checkVisible, 2);
    +
    +	},
    +
    +	/**
    +     * Multiplies the given property by the amount on all children in this Group.
    +     * Group.multiplyAll('x', 2) will x2 the child.x value.
    +     *
    +     * @method Phaser.Group#multiplyAll
    +     * @param {string} property - The property to multiply, for example 'body.velocity.x' or 'angle'.
    +     * @param {number} amount - The amount to multiply the property by. If child.x = 10 then multiplyAll('x', 2) would make child.x = 20.
    +     * @param {boolean} checkAlive - If true the property will only be changed if the child is alive.
    +     * @param {boolean} checkVisible - If true the property will only be changed if the child is visible.
    +     */
    +	multiplyAll: function (property, amount, checkAlive, checkVisible) {
    +
    +		this.setAll(property, amount, checkAlive, checkVisible, 3);
    +
    +	},
    +
    +	/**
    +     * Divides the given property by the amount on all children in this Group.
    +     * Group.divideAll('x', 2) will half the child.x value.
    +     *
    +     * @method Phaser.Group#divideAll
    +     * @param {string} property - The property to divide, for example 'body.velocity.x' or 'angle'.
    +     * @param {number} amount - The amount to divide the property by. If child.x = 100 then divideAll('x', 2) would make child.x = 50.
    +     * @param {boolean} checkAlive - If true the property will only be changed if the child is alive.
    +     * @param {boolean} checkVisible - If true the property will only be changed if the child is visible.
    +     */
    +	divideAll: function (property, amount, checkAlive, checkVisible) {
    +
    +		this.setAll(property, amount, checkAlive, checkVisible, 4);
    +
    +	},
    +
    +	/**
    +    * Calls a function on all of the children that have exists=true in this Group.
    +    * After the existsValue parameter you can add as many parameters as you like, which will all be passed to the child callback.
    +    * 
    +    * @method Phaser.Group#callAllExists
    +    * @param {function} callback - The function that exists on the children that will be called.
    +    * @param {boolean} existsValue - Only children with exists=existsValue will be called.
    +    * @param {...*} parameter - Additional parameters that will be passed to the callback.
    +    */
    +	callAllExists: function (callback, existsValue) {
    +
    +		var args = Array.prototype.splice.call(arguments, 2);
    +
    +		if (this._container.children.length > 0 && this._container.first._iNext)
    +		{
    +			var currentNode = this._container.first._iNext;
    +				
    +			do	
    +			{
    +				if (currentNode.exists == existsValue && currentNode[callback])
    +				{
    +					currentNode[callback].apply(currentNode, args);
    +				}
    +
    +				currentNode = currentNode._iNext;
    +			}
    +			while (currentNode != this._container.last._iNext)
    +
    +		}
    +
    +	},
    +
    +	/**
    +    * Calls a function on all of the children regardless if they are dead or alive (see callAllExists if you need control over that)
    +    * After the callback parameter you can add as many extra parameters as you like, which will all be passed to the child.
    +    * 
    +    * @method Phaser.Group#callAll
    +    * @param {function} callback - The function that exists on the children that will be called.
    +    * @param {...*} parameter - Additional parameters that will be passed to the callback.
    +    */
    +	callAll: function (callback) {
    +
    +		var args = Array.prototype.splice.call(arguments, 1);
    +
    +		if (this._container.children.length > 0 && this._container.first._iNext)
    +		{
    +			var currentNode = this._container.first._iNext;
    +				
    +			do	
    +			{
    +				if (currentNode[callback])
    +				{
    +					currentNode[callback].apply(currentNode, args);
    +				}
    +
    +				currentNode = currentNode._iNext;
    +			}
    +			while (currentNode != this._container.last._iNext)
    +
    +		}
    +
    +	},
    +
    +	/**
    +	* Allows you to call your own function on each member of this Group. You must pass the callback and context in which it will run.
    +   	* After the checkExists parameter you can add as many parameters as you like, which will all be passed to the callback along with the child.
    +   	* For example: Group.forEach(awardBonusGold, this, true, 100, 500)
    +	* 
    +	* @method Phaser.Group#forEach
    +	* @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter.
    +    * @param {Object} callbackContext - The context in which the function should be called (usually 'this').
    +    * @param {boolean} checkExists - If set only children with exists=true will be passed to the callback, otherwise all children will be passed.
    +	*/
    +	forEach: function (callback, callbackContext, checkExists) {
    +
    +		if (typeof checkExists === 'undefined')
    +		{
    +			checkExists = false;
    +		}
    +
    +		var args = Array.prototype.splice.call(arguments, 3);
    +		args.unshift(null);
    +
    +		if (this._container.children.length > 0 && this._container.first._iNext)
    +		{
    +			var currentNode = this._container.first._iNext;
    +				
    +			do	
    +			{
    +				if (checkExists == false || (checkExists && currentNode.exists))
    +				{
    +					args[0] = currentNode;
    +					callback.apply(callbackContext, args);
    +				}
    +
    +				currentNode = currentNode._iNext;
    +			}
    +			while (currentNode != this._container.last._iNext);
    +
    +		}
    +
    +	},
    +
    +	/**
    +	* Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run.
    +   	* You can add as many parameters as you like, which will all be passed to the callback along with the child.
    +   	* For example: Group.forEachAlive(causeDamage, this, 500)
    +	* 
    +	* @method Phaser.Group#forEachAlive
    +	* @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter.
    +    * @param {Object} callbackContext - The context in which the function should be called (usually 'this').
    +	*/
    +	forEachAlive: function (callback, callbackContext) {
    +
    +		var args = Array.prototype.splice.call(arguments, 2);
    +		args.unshift(null);
    +
    +		if (this._container.children.length > 0 && this._container.first._iNext)
    +		{
    +			var currentNode = this._container.first._iNext;
    +				
    +			do	
    +			{
    +				if (currentNode.alive)
    +				{
    +					args[0] = currentNode;
    +					callback.apply(callbackContext, args);
    +				}
    +
    +				currentNode = currentNode._iNext;
    +			}
    +			while (currentNode != this._container.last._iNext);
    +
    +		}
    +
    +	},
    +
    +	/**
    +	* Allows you to call your own function on each dead member of this Group (where alive=false). You must pass the callback and context in which it will run.
    +   	* You can add as many parameters as you like, which will all be passed to the callback along with the child.
    +   	* For example: Group.forEachDead(bringToLife, this)
    +	* 
    +	* @method Phaser.Group#forEachDead
    +	* @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter.
    +    * @param {Object} callbackContext - The context in which the function should be called (usually 'this').
    +	*/
    +	forEachDead: function (callback, callbackContext) {
    +
    +		var args = Array.prototype.splice.call(arguments, 2);
    +		args.unshift(null);
    +
    +		if (this._container.children.length > 0 && this._container.first._iNext)
    +		{
    +			var currentNode = this._container.first._iNext;
    +				
    +			do	
    +			{
    +				if (currentNode.alive == false)
    +				{
    +					args[0] = currentNode;
    +					callback.apply(callbackContext, args);
    +				}
    +
    +				currentNode = currentNode._iNext;
    +			}
    +			while (currentNode != this._container.last._iNext);
    +
    +		}
    +	},
    +
    +	/**
    +    * Call this function to retrieve the first object with exists == (the given state) in the Group.
    +    *
    +    * @method Phaser.Group#getFirstExists
    +    * @param {boolean} state - True or false.
    +    * @return {Any} The first child, or null if none found.
    +    */
    +	getFirstExists: function (state) {
    +
    +		if (typeof state !== 'boolean')
    +		{
    +			state = true;
    +		}
    +
    +		if (this._container.children.length > 0 && this._container.first._iNext)
    +		{
    +			var currentNode = this._container.first._iNext;
    +				
    +			do	
    +			{
    +				if (currentNode.exists === state)
    +				{
    +					return currentNode;
    +				}
    +
    +				currentNode = currentNode._iNext;
    +			}
    +			while (currentNode != this._container.last._iNext);
    +		}
    +
    +		return null;
    +
    +	},
    +
    +	/**
    +    * Call this function to retrieve the first object with alive == true in the group.
    +    * This is handy for checking if everything has been wiped out, or choosing a squad leader, etc.
    +    *
    +    * @method Phaser.Group#getFirstAlive
    +    * @return {Any} The first alive child, or null if none found.
    +    */
    +	getFirstAlive: function () {
    +
    +		if (this._container.children.length > 0 && this._container.first._iNext)
    +		{
    +			var currentNode = this._container.first._iNext;
    +				
    +			do	
    +			{
    +				if (currentNode.alive)
    +				{
    +					return currentNode;
    +				}
    +
    +				currentNode = currentNode._iNext;
    +			}
    +			while (currentNode != this._container.last._iNext);
    +		}
    +
    +		return null;
    +
    +	},
    +
    +	/**
    +    * Call this function to retrieve the first object with alive == false in the group.
    +    * This is handy for checking if everything has been wiped out, or choosing a squad leader, etc.
    +    *
    +    * @method Phaser.Group#getFirstDead
    +    * @return {Any} The first dead child, or null if none found.
    +    */
    +	getFirstDead: function () {
    +
    +		if (this._container.children.length > 0 && this._container.first._iNext)
    +		{
    +			var currentNode = this._container.first._iNext;
    +				
    +			do	
    +			{
    +				if (!currentNode.alive)
    +				{
    +					return currentNode;
    +				}
    +
    +				currentNode = currentNode._iNext;
    +			}
    +			while (currentNode != this._container.last._iNext);
    +		}
    +
    +		return null;
    +
    +	},
    +
    +	/**
    +    * Call this function to find out how many members of the group are alive.
    +    *
    +    * @method Phaser.Group#countLiving
    +    * @return {number} The number of children flagged as alive. Returns -1 if Group is empty.
    +    */
    +	countLiving: function () {
    +
    +		var total = 0;
    +
    +		if (this._container.children.length > 0 && this._container.first._iNext)
    +		{
    +			var currentNode = this._container.first._iNext;
    +				
    +			do	
    +			{
    +				if (currentNode.alive)
    +				{
    +					total++;
    +				}
    +
    +				currentNode = currentNode._iNext;
    +			}
    +			while (currentNode != this._container.last._iNext);
    +		}
    +		else
    +		{
    +			total = -1;
    +		}
    +
    +		return total;
    +
    +	},
    +
    +	/**
    +    * Call this function to find out how many members of the group are dead.
    +    *
    +    * @method Phaser.Group#countDead
    +    * @return {number} The number of children flagged as dead. Returns -1 if Group is empty.
    +    */
    +	countDead: function () {
    +
    +		var total = 0;
    +
    +		if (this._container.children.length > 0 && this._container.first._iNext)
    +		{
    +			var currentNode = this._container.first._iNext;
    +				
    +			do	
    +			{
    +				if (!currentNode.alive)
    +				{
    +					total++;
    +				}
    +
    +				currentNode = currentNode._iNext;
    +			}
    +			while (currentNode != this._container.last._iNext);
    +		}
    +		else
    +		{
    +			total = -1;
    +		}
    +
    +		return total;
    +
    +	},
    +
    +	/**
    +    * Returns a member at random from the group.
    +    *
    +    * @method Phaser.Group#getRandom
    +    * @param {number} startIndex - Optional offset off the front of the array. Default value is 0, or the beginning of the array.
    +    * @param {number} length - Optional restriction on the number of values you want to randomly select from.
    +    * @return {Any} A random child of this Group.
    +    */
    +	getRandom: function (startIndex, length) {
    +
    +		if (this._container.children.length == 0)
    +		{
    +			return null;
    +		}
    +
    +		startIndex = startIndex || 0;
    +		length = length || this._container.children.length;
    +
    +        return this.game.math.getRandom(this._container.children, startIndex, length);
    +
    +	},
    +
    +	/**
    +	* Removes the given child from this Group and sets its group property to null.
    +	*
    +	* @method Phaser.Group#remove
    +	* @param {Any} child - The child to remove.
    +	*/
    +	remove: function (child) {
    +
    +		if (child.events)
    +		{
    +			child.events.onRemovedFromGroup.dispatch(child, this);
    +		}
    +
    +		this._container.removeChild(child);
    +
    +		child.group = null;
    +
    +	},
    +
    +	/**
    +	* Removes all children from this Group, setting all group properties to null.
    +	* The Group container remains on the display list.
    +	*
    +	* @method Phaser.Group#removeAll
    +	*/
    +	removeAll: function () {
    +
    +		if (this._container.children.length == 0)
    +		{
    +			return;
    +		}
    +
    +		do
    +		{
    +			if (this._container.children[0].events)
    +			{
    +				this._container.children[0].events.onRemovedFromGroup.dispatch(this._container.children[0], this);
    +			}
    +			this._container.removeChild(this._container.children[0]);
    +		}
    +		while (this._container.children.length > 0);
    +
    +	},
    +
    +	/**
    +	* Removes all children from this Group whos index falls beteen the given startIndex and endIndex values.
    +	*
    +	* @method Phaser.Group#removeBetween
    +	* @param {number} startIndex - The index to start removing children from.
    +	* @param {number} endIndex - The index to stop removing children from. Must be higher than startIndex and less than the length of the Group.
    +	*/	
    +	removeBetween: function (startIndex, endIndex) {
    +
    +		if (this._container.children.length == 0)
    +		{
    +			return;
    +		}
    +
    +		if (startIndex > endIndex || startIndex < 0 || endIndex > this._container.children.length)
    +		{
    +			return false;
    +		}
    +
    +		for (var i = startIndex; i < endIndex; i++)
    +		{
    +			var child = this._container.children[i];
    +			child.events.onRemovedFromGroup.dispatch(child, this);
    +			this._container.removeChild(child);
    +		}
    +
    +	},
    +
    +	/**
    +	* Destroys this Group. Removes all children, then removes the container from the display list and nulls references.
    +	*
    +	* @method Phaser.Group#destroy
    +	*/
    +	destroy: function () {
    +
    +		this.removeAll();
    +
    +		this._container.parent.removeChild(this._container);
    +
    +		this._container = null;
    +
    +		this.game = null;
    +
    +		this.exists = false;
    +
    +	},
    +
    +	/**
    +	* Dumps out a list of Group children and their index positions to the browser console. Useful for group debugging.
    +	*
    +	* @method Phaser.Group#dump
    +	* @param {boolean} [full=false] - If full the dump will include the entire display list, start from the Stage. Otherwise it will only include this container.
    +	*/
    +	dump: function (full) {
    +
    +		if (typeof full == 'undefined')
    +		{
    +			full = false;
    +		}
    +
    +		var spacing = 20;
    +		var output = "\n" + Phaser.Utils.pad('Node', spacing) + "|" + Phaser.Utils.pad('Next', spacing) + "|" + Phaser.Utils.pad('Previous', spacing) + "|" + Phaser.Utils.pad('First', spacing) + "|" + Phaser.Utils.pad('Last', spacing);
    +
    +		console.log(output);
    +
    +		var output = Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing);
    +		console.log(output);
    +
    +		if (full)
    +		{
    +			var testObject = this.game.stage._stage.last._iNext;
    +			var displayObject = this.game.stage._stage;
    +		}
    +		else
    +		{
    +			var testObject = this._container.last._iNext;
    +			var displayObject = this._container;
    +		}
    +		
    +		do	
    +		{
    +			var name = displayObject.name || '*';
    +			var nameNext = '-';
    +			var namePrev = '-';
    +			var nameFirst = '-';
    +			var nameLast = '-';
    +
    +			if (displayObject._iNext)
    +			{
    +				nameNext = displayObject._iNext.name;
    +			}
    +
    +			if (displayObject._iPrev)
    +			{
    +				namePrev = displayObject._iPrev.name;
    +			}
    +
    +			if (displayObject.first)
    +			{
    +				nameFirst = displayObject.first.name;
    +			}
    +
    +			if (displayObject.last)
    +			{
    +				nameLast = displayObject.last.name;
    +			}
    +
    +			if (typeof nameNext === 'undefined')
    +			{
    +				nameNext = '-';
    +			}
    +
    +			if (typeof namePrev === 'undefined')
    +			{
    +				namePrev = '-';
    +			}
    +
    +			if (typeof nameFirst === 'undefined')
    +			{
    +				nameFirst = '-';
    +			}
    +
    +			if (typeof nameLast === 'undefined')
    +			{
    +				nameLast = '-';
    +			}
    +
    +			var output = Phaser.Utils.pad(name, spacing) + "|" + Phaser.Utils.pad(nameNext, spacing) + "|" + Phaser.Utils.pad(namePrev, spacing) + "|" + Phaser.Utils.pad(nameFirst, spacing) + "|" + Phaser.Utils.pad(nameLast, spacing);
    +			console.log(output);
    +
    +			displayObject = displayObject._iNext;
    +
    +		}
    +		while(displayObject != testObject)
    +
    +	}
    +
    +};
    +
    +/**
    +* @name Phaser.Group#total
    +* @property {number} total - The total number of children in this Group, regardless of their alive state.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Group.prototype, "total", {
    +
    +    get: function () {
    +        return this._container.children.length;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Group#length
    +* @property {number} length - The number of children in this Group.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Group.prototype, "length", {
    +
    +    get: function () {
    +        return this._container.children.length;
    +    }
    +
    +});
    +
    +/**
    +* The x coordinate of the Group container. You can adjust the Group container itself by modifying its coordinates.
    +* This will have no impact on the x/y coordinates of its children, but it will update their worldTransform and on-screen position.
    +* @name Phaser.Group#x
    +* @property {number} x - The x coordinate of the Group container.
    +*/
    +Object.defineProperty(Phaser.Group.prototype, "x", {
    +
    +    get: function () {
    +        return this._container.position.x;
    +    },
    +
    +    set: function (value) {
    +        this._container.position.x = value;
    +    }
    +
    +});
    +
    +/**
    +* The y coordinate of the Group container. You can adjust the Group container itself by modifying its coordinates.
    +* This will have no impact on the x/y coordinates of its children, but it will update their worldTransform and on-screen position.
    +* @name Phaser.Group#y
    +* @property {number} y - The y coordinate of the Group container.
    +*/
    +Object.defineProperty(Phaser.Group.prototype, "y", {
    +
    +    get: function () {
    +        return this._container.position.y;
    +    },
    +
    +    set: function (value) {
    +        this._container.position.y = value;
    +    }
    +
    +});
    +
    +/**
    +* The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation.
    +* This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position.
    +* @name Phaser.Group#angle
    +* @property {number} angle - The angle of rotation given in degrees, where 0 degrees = to the right.
    +*/
    +Object.defineProperty(Phaser.Group.prototype, "angle", {
    +
    +    get: function() {
    +        return Phaser.Math.radToDeg(this._container.rotation);
    +    },
    +
    +    set: function(value) {
    +        this._container.rotation = Phaser.Math.degToRad(value);
    +    }
    +
    +});
    +
    +/**
    +* The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation.
    +* This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position.
    +* @name Phaser.Group#rotation
    +* @property {number} rotation - The angle of rotation given in radians.
    +*/
    +Object.defineProperty(Phaser.Group.prototype, "rotation", {
    +
    +    get: function () {
    +        return this._container.rotation;
    +    },
    +
    +    set: function (value) {
    +        this._container.rotation = value;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Group#visible
    +* @property {boolean} visible - The visible state of the Group. Non-visible Groups and all of their children are not rendered.
    +*/
    +Object.defineProperty(Phaser.Group.prototype, "visible", {
    +
    +    get: function () {
    +        return this._container.visible;
    +    },
    +
    +    set: function (value) {
    +        this._container.visible = value;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Group#alpha
    +* @property {number} alpha - The alpha value of the Group container.
    +*/
    +Object.defineProperty(Phaser.Group.prototype, "alpha", {
    +
    +    get: function () {
    +        return this._container.alpha;
    +    },
    +
    +    set: function (value) {
    +        this._container.alpha = value;
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Input.js.html b/docs/Input.js.html new file mode 100644 index 00000000..767ceaf5 --- /dev/null +++ b/docs/Input.js.html @@ -0,0 +1,1257 @@ + + + + + + Phaser Source: input/Input.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: input/Input.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Constructor for Phaser Input.
    +* @class Phaser.Input
    +* @classdesc A game specific Input manager that looks after the mouse, keyboard and touch objects.
    +* This is updated by the core game loop.
    +* @constructor
    +* @param {Phaser.Game} game - Current game instance.
    +*/
    +Phaser.Input = function (game) {
    +
    +	/**
    +	* @property {Phaser.Game} game - A reference to the currently running game. 
    +	*/
    +	this.game = game;
    +
    +	/**
    +    * @property {Description} hitCanvas - Description. 
    +    * @default
    +	*/
    +    this.hitCanvas = null;
    +    
    +	/**
    +     * @property {Description} hitContext - Description. 
    +     * @default
    + 	*/
    +    this.hitContext = null;
    +	
    +};
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Input.MOUSE_OVERRIDES_TOUCH = 0;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Input.TOUCH_OVERRIDES_MOUSE = 1;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Input.MOUSE_TOUCH_COMBINE = 2;
    +
    +Phaser.Input.prototype = {
    +
    +    /** 
    +    * @property {Phaser.Game} game
    +    */	
    +    game: null,
    +
    +    /**
    +    * How often should the input pointers be checked for updates?
    +    * A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on.
    +    * @property {number} pollRate 
    +    * @default
    +    */
    +    pollRate: 0,
    +    
    +    /**
    +     * @property {number} _pollCounter - Description.
    +     * @private
    +     * @default
    +     */
    +    _pollCounter: 0,
    +
    +    /**
    +    * A vector object representing the previous position of the Pointer.
    +    * @property {Vec2} vector
    +    * @private
    +    * @default 
    +    */
    +    _oldPosition: null,
    +
    +    /**
    +    * X coordinate of the most recent Pointer event
    +    * @property {number} _x
    +    * @private
    +    * @default
    +    */
    +    _x: 0,
    +
    +    /**
    +    * Y coordinate of the most recent Pointer event
    +    * @property {number} _y
    +    * @private
    +    * @default
    +    */
    +    _y: 0,
    +
    +    /**
    +    * You can disable all Input by setting Input.disabled: true. While set all new input related events will be ignored.
    +    * If you need to disable just one type of input, for example mouse, use Input.mouse.disabled: true instead
    +    * @property {boolean} disabled
    +    * @default
    +    */
    +    disabled: false,
    +
    +    /**
    +    * Controls the expected behaviour when using a mouse and touch together on a multi-input device.
    +    * @property {Description} multiInputOverride
    +    */
    +    multiInputOverride: Phaser.Input.MOUSE_TOUCH_COMBINE,
    +
    +    /**
    +    * A vector object representing the current position of the Pointer.
    +    * @property {Phaser.Point} position
    +    * @default 
    +    */
    +    position: null,
    +
    +    /**
    +    * A vector object representing the speed of the Pointer. Only really useful in single Pointer games,
    +    * otherwise see the Pointer objects directly.
    +    * @property {Phaser.Point} speed
    +    * @default 
    +    */
    +    speed: null,
    +
    +    /**
    +    * A Circle object centered on the x/y screen coordinates of the Input.
    +    * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything.
    +    * @property {Phaser.Circle} circle
    +    * @default
    +    */
    +    circle: null,
    +
    +    /**
    +    * The scale by which all input coordinates are multiplied, calculated by the StageScaleMode.
    +    * In an un-scaled game the values will be x: 1 and y: 1.
    +    * @property {Phaser.Point} scale
    +    * @default
    +    */
    +    scale: null,
    +
    +    /**
    +    * The maximum number of Pointers allowed to be active at any one time.
    +    * For lots of games it's useful to set this to 1.
    +    * @property {number} maxPointers
    +    * @default
    +    */
    +    maxPointers: 10,
    +
    +    /**
    +    * The current number of active Pointers.
    +    * @property {number} currentPointers
    +    * @default
    +    */
    +    currentPointers: 0,
    +
    +    /**
    +    * The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or clicke
    +    * @property {number} tapRate
    +    * @default
    +    */
    +    tapRate: 200,
    +
    +    /**
    +    * The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click
    +    * @property {number} doubleTapRate
    +    * @default
    +    */
    +    doubleTapRate: 300,
    +
    +    /**
    +    * The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event
    +    * @property {number} holdRate
    +    * @default
    +    */
    +    holdRate: 2000,
    +
    +    /**
    +    * The number of milliseconds below which the Pointer is considered justPressed
    +    * @property {number} justPressedRate
    +    * @default
    +    */
    +    justPressedRate: 200,
    +
    +    /**
    +    * The number of milliseconds below which the Pointer is considered justReleased 
    +    * @property {number} justReleasedRate
    +    * @default
    +    */
    +    justReleasedRate: 200,
    +
    +    /**
    +    * Sets if the Pointer objects should record a history of x/y coordinates they have passed through.
    +    * The history is cleared each time the Pointer is pressed down.
    +    * The history is updated at the rate specified in Input.pollRate
    +    * @property {boolean} recordPointerHistory
    +    * @default
    +    */
    +    recordPointerHistory: false,
    +
    +    /**
    +    * The rate in milliseconds at which the Pointer objects should update their tracking history
    +    * @property {number} recordRate
    +    * @default
    +    */
    +    recordRate: 100,
    +
    +    /**
    +    * The total number of entries that can be recorded into the Pointer objects tracking history.
    +    * If the Pointer is tracking one event every 100ms, then a trackLimit of 100 would store the last 10 seconds worth of history.
    +    * @property {number} recordLimit
    +    * @default
    +    */
    +    recordLimit: 100,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Phaser.Pointer} pointer1
    +    */
    +    pointer1: null,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Phaser.Pointer} pointer2
    +    */
    +    pointer2: null,
    +
    +    /**
    +    * A Pointer object  
    +    * @property {Phaser.Pointer} pointer3
    +    */
    +    pointer3: null,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Phaser.Pointer} pointer4
    +    */
    +    pointer4: null,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Phaser.Pointer} pointer5
    +    */
    +    pointer5: null,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Phaser.Pointer} pointer6
    +    */
    +    pointer6: null,
    +
    +    /**
    +    * A Pointer object  
    +    * @property {Phaser.Pointer} pointer7
    +    */
    +    pointer7: null,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Phaser.Pointer} pointer8
    +    */
    +    pointer8: null,
    +
    +    /**
    +    * A Pointer object
    +    * @property {Phaser.Pointer} pointer9
    +    */ 
    +    pointer9: null,
    +
    +    /**
    +    * A Pointer object.
    +    * @property {Phaser.Pointer} pointer10
    +    */
    +    pointer10: null,
    +
    +    /**
    +    * The most recently active Pointer object.
    +    * When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse.
    +    * @property {Phaser.Pointer} activePointer
    +    * @default
    +    */
    +    activePointer: null,
    +
    +    /**
    +    * The mouse has its own unique Phaser.Pointer object which you can use if making a desktop specific game.
    +    * @property {Pointer} mousePointer
    +    * @default
    +    */
    +    mousePointer: null,
    +    
    +    /**
    +    * The Mouse Input manager.
    +    * @property {Phaser.Mouse} mouse - The Mouse Input manager.
    +    * @default
    +    */
    +    mouse: null,
    +    
    +    /**
    +    * The Keyboard Input manager.
    +    * @property {Phaser.Keyboard} keyboard - The Keyboard Input manager.
    +    * @default
    +    */
    +    keyboard: null,
    +    
    +    /**
    +    * The Touch Input manager.
    +    * @property {Phaser.Touch} touch - the Touch Input manager.
    +    * @default
    +    */
    +    touch: null,
    +    
    +    /**
    +    * The MSPointer Input manager.
    +    * @property {Phaser.MSPointer} mspointer - The MSPointer Input manager.
    +    * @default
    +    */
    +    mspointer: null,
    +
    +    /**
    +    * A Signal that is dispatched each time a pointer is pressed down.
    +    * @property {Phaser.Signal} onDown
    +    * @default
    +    */
    +    onDown: null,
    +    
    +    /**
    +    * A Signal that is dispatched each time a pointer is released.
    +    * @property {Phaser.Signal} onUp
    +    * @default
    +    */
    +    onUp: null,
    +    
    +    /**
    +    * A Signal that is dispatched each time a pointer is tapped.
    +    * @property {Phaser.Signal} onTap
    +    * @default
    +    */
    +    onTap: null,
    +    
    +    /**
    +    * A Signal that is dispatched each time a pointer is held down.
    +    * @property {Phaser.Signal} onHold
    +    * @default
    +    */
    +    onHold: null,
    +
    +    /**
    +    * A linked list of interactive objects, the InputHandler components (belonging to Sprites) register themselves with this.
    +    * @property {Phaser.LinkedList} interactiveItems
    +    */
    +    interactiveItems: new Phaser.LinkedList(),
    +
    +	/**
    +    * Starts the Input Manager running.
    +    * @method Phaser.Input#boot
    +    * @protected
    +    */
    +    boot: function () {
    +
    +	    this.mousePointer = new Phaser.Pointer(this.game, 0);
    +	    this.pointer1 = new Phaser.Pointer(this.game, 1);
    +	    this.pointer2 = new Phaser.Pointer(this.game, 2);
    +
    +	    this.mouse = new Phaser.Mouse(this.game);
    +	    this.keyboard = new Phaser.Keyboard(this.game);
    +	    this.touch = new Phaser.Touch(this.game);
    +	    this.mspointer = new Phaser.MSPointer(this.game);
    +
    +	    this.onDown = new Phaser.Signal();
    +	    this.onUp = new Phaser.Signal();
    +	    this.onTap = new Phaser.Signal();
    +	    this.onHold = new Phaser.Signal();
    +
    +	    this.scale = new Phaser.Point(1, 1);
    +	    this.speed = new Phaser.Point();
    +	    this.position = new Phaser.Point();
    +	    this._oldPosition = new Phaser.Point();
    +
    +	    this.circle = new Phaser.Circle(0, 0, 44);
    +
    +	    this.activePointer = this.mousePointer;
    +	    this.currentPointers = 0;
    +
    +	    this.hitCanvas = document.createElement('canvas');
    +	    this.hitCanvas.width = 1;
    +	    this.hitCanvas.height = 1;
    +        this.hitContext = this.hitCanvas.getContext('2d');
    +
    +        this.mouse.start();
    +        this.keyboard.start();
    +        this.touch.start();
    +        this.mspointer.start();
    +        this.mousePointer.active = true;
    +
    +    },
    +
    +    /**
    +    * Stops all of the Input Managers from running.
    +    * @method Phaser.Input#destroy
    +    */
    +    destroy: function () {
    +
    +        this.mouse.stop();
    +        this.keyboard.stop();
    +        this.touch.stop();
    +        this.mspointer.stop();
    +
    +    },
    +
    +	/**
    +    * Add a new Pointer object to the Input Manager. By default Input creates 3 pointer objects: mousePointer, pointer1 and pointer2.
    +    * If you need more then use this to create a new one, up to a maximum of 10.
    +    * @method Phaser.Input#addPointer
    +    * @return {Phaser.Pointer} A reference to the new Pointer object that was created.
    +    */
    +    addPointer: function () {
    +
    +        var next = 0;
    +
    +        for (var i = 10; i > 0; i--)
    +        {
    +            if (this['pointer' + i] === null)
    +            {
    +                next = i;
    +            }
    +        }
    +
    +        if (next == 0)
    +        {
    +            console.warn("You can only have 10 Pointer objects");
    +            return null;
    +        }
    +        else
    +        {
    +            this['pointer' + next] = new Phaser.Pointer(this.game, next);
    +            return this['pointer' + next];
    +        }
    +
    +    },
    +
    +	/**
    +    * Updates the Input Manager. Called by the core Game loop.
    +    * @method Phaser.Input#update
    +    * @protected
    +    */
    +    update: function () {
    +
    +        if (this.pollRate > 0 && this._pollCounter < this.pollRate)
    +        {
    +            this._pollCounter++;
    +            return;
    +        }
    +
    +        this.speed.x = this.position.x - this._oldPosition.x;
    +        this.speed.y = this.position.y - this._oldPosition.y;
    +
    +        this._oldPosition.copyFrom(this.position);
    +        this.mousePointer.update();
    +
    +        this.pointer1.update();
    +        this.pointer2.update();
    +
    +        if (this.pointer3) { this.pointer3.update(); }
    +        if (this.pointer4) { this.pointer4.update(); }
    +        if (this.pointer5) { this.pointer5.update(); }
    +        if (this.pointer6) { this.pointer6.update(); }
    +        if (this.pointer7) { this.pointer7.update(); }
    +        if (this.pointer8) { this.pointer8.update(); }
    +        if (this.pointer9) { this.pointer9.update(); }
    +        if (this.pointer10) { this.pointer10.update(); }
    +
    +        this._pollCounter = 0;
    +    },
    +
    +	/**
    +    * Reset all of the Pointers and Input states
    +    * @method Phaser.Input#reset
    +    * @param {boolean} hard - A soft reset (hard = false) won't reset any Signals that might be bound. A hard reset will.
    +    */
    +    reset: function (hard) {
    +
    +        if (this.game.isBooted == false)
    +        {
    +            return;
    +        }
    +
    +        if (typeof hard == 'undefined') { hard = false; }
    +
    +        this.keyboard.reset();
    +        this.mousePointer.reset();
    +
    +        for (var i = 1; i <= 10; i++)
    +        {
    +            if (this['pointer' + i])
    +            {
    +                this['pointer' + i].reset();
    +            }
    +        }
    +
    +        this.currentPointers = 0;
    +        this.game.stage.canvas.style.cursor = "default";
    +
    +        if (hard == true)
    +        {
    +            this.onDown.dispose();
    +            this.onUp.dispose();
    +            this.onTap.dispose();
    +            this.onHold.dispose();
    +            this.onDown = new Phaser.Signal();
    +            this.onUp = new Phaser.Signal();
    +            this.onTap = new Phaser.Signal();
    +            this.onHold = new Phaser.Signal();
    +
    +            this.interactiveItems.callAll('reset');
    +        }
    +
    +        this._pollCounter = 0;
    +
    +    },
    +
    +    /**
    +    * Resets the speed and old position properties.
    +    * @method Phaser.Input#resetSpeed
    +    * @param {number} x - Sets the oldPosition.x value.
    +    * @param {number} y - Sets the oldPosition.y value.
    +    */
    +    resetSpeed: function (x, y) {
    +
    +        this._oldPosition.setTo(x, y);
    +        this.speed.setTo(0, 0);
    +
    +    },
    +
    +	/**
    +    * Find the first free Pointer object and start it, passing in the event data. This is called automatically by Phaser.Touch and Phaser.MSPointer.
    +    * @method Phaser.Input#startPointer
    +    * @param {Any} event - The event data from the Touch event.
    +    * @return {Phaser.Pointer} The Pointer object that was started or null if no Pointer object is available.
    +    */
    +    startPointer: function (event) {
    +
    +        if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers)
    +        {
    +            return null;
    +        }
    +
    +        if (this.pointer1.active == false)
    +        {
    +            return this.pointer1.start(event);
    +        }
    +        else if (this.pointer2.active == false)
    +        {
    +            return this.pointer2.start(event);
    +        }
    +        else
    +        {
    +            for (var i = 3; i <= 10; i++)
    +            {
    +                if (this['pointer' + i] && this['pointer' + i].active == false)
    +                {
    +                    return this['pointer' + i].start(event);
    +                }
    +            }
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +    * Updates the matching Pointer object, passing in the event data. This is called automatically and should not normally need to be invoked.
    +    * @method Phaser.Input#updatePointer
    +    * @param {Any} event - The event data from the Touch event.
    +    * @return {Phaser.Pointer} The Pointer object that was updated or null if no Pointer object is available.
    +    */
    +    updatePointer: function (event) {
    +
    +        if (this.pointer1.active && this.pointer1.identifier == event.identifier)
    +        {
    +            return this.pointer1.move(event);
    +        }
    +        else if (this.pointer2.active && this.pointer2.identifier == event.identifier)
    +        {
    +            return this.pointer2.move(event);
    +        }
    +        else
    +        {
    +            for (var i = 3; i <= 10; i++)
    +            {
    +                if (this['pointer' + i] && this['pointer' + i].active && this['pointer' + i].identifier == event.identifier)
    +                {
    +                    return this['pointer' + i].move(event);
    +                }
    +            }
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +    * Stops the matching Pointer object, passing in the event data.
    +    * @method Phaser.Input#stopPointer
    +    * @param {Any} event - The event data from the Touch event.
    +    * @return {Phaser.Pointer} The Pointer object that was stopped or null if no Pointer object is available.
    +    */
    +    stopPointer: function (event) {
    +
    +        if (this.pointer1.active && this.pointer1.identifier == event.identifier)
    +        {
    +            return this.pointer1.stop(event);
    +        }
    +        else if (this.pointer2.active && this.pointer2.identifier == event.identifier)
    +        {
    +            return this.pointer2.stop(event);
    +        }
    +        else
    +        {
    +            for (var i = 3; i <= 10; i++)
    +            {
    +                if (this['pointer' + i] && this['pointer' + i].active && this['pointer' + i].identifier == event.identifier)
    +                {
    +                    return this['pointer' + i].stop(event);
    +                }
    +            }
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +    * Get the next Pointer object whos active property matches the given state
    +    * @method Phaser.Input#getPointer
    +    * @param {boolean} state - The state the Pointer should be in (false for inactive, true for active).
    +    * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested state.
    +    */
    +    getPointer: function (state) {
    +
    +        state = state || false;
    +
    +        if (this.pointer1.active == state)
    +        {
    +            return this.pointer1;
    +        }
    +        else if (this.pointer2.active == state)
    +        {
    +            return this.pointer2;
    +        }
    +        else
    +        {
    +            for (var i = 3; i <= 10; i++)
    +            {
    +                if (this['pointer' + i] && this['pointer' + i].active == state)
    +                {
    +                    return this['pointer' + i];
    +                }
    +            }
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +    * Get the Pointer object whos identified property matches the given identifier value.
    +    * @method Phaser.Input#getPointerFromIdentifier
    +    * @param {number} identifier - The Pointer.identifier value to search for.
    +    * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested identifier.
    +    */
    +    getPointerFromIdentifier: function (identifier) {
    +
    +        if (this.pointer1.identifier == identifier)
    +        {
    +            return this.pointer1;
    +        }
    +        else if (this.pointer2.identifier == identifier)
    +        {
    +            return this.pointer2;
    +        }
    +        else
    +        {
    +            for (var i = 3; i <= 10; i++)
    +            {
    +                if (this['pointer' + i] && this['pointer' + i].identifier == identifier)
    +                {
    +                    return this['pointer' + i];
    +                }
    +            }
    +        }
    +
    +        return null;
    +
    +    }
    +
    +};
    +
    +/**
    +* The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.
    +* @name Phaser.Input#x
    +* @property {number} x - The X coordinate of the most recently active pointer.
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "x", {
    +
    +    get: function () {
    +        return this._x;
    +    },
    +
    +    set: function (value) {
    +        this._x = Math.floor(value);
    +    }
    +
    +});
    +
    +/**
    +* The Y coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values.
    +* @name Phaser.Input#y
    +* @property {number} y - The Y coordinate of the most recently active pointer.
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "y", {
    +    
    +    get: function () {
    +        return this._y;
    +    },
    +
    +    set: function (value) {
    +        this._y = Math.floor(value);
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Input#pollLocked
    +* @property {boolean} pollLocked - True if the Input is currently poll rate locked.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "pollLocked", {
    +
    +    get: function () {
    +        return (this.pollRate > 0 && this._pollCounter < this.pollRate);
    +    }
    +
    +});
    +
    +/**
    +* The total number of inactive Pointers
    +* @name Phaser.Input#totalInactivePointers
    +* @property {number} totalInactivePointers - The total number of inactive Pointers.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", {
    +
    +    get: function () {
    +        return 10 - this.currentPointers;
    +    }
    +
    +});
    +
    +/**
    +* The total number of active Pointers
    +* @name Phaser.Input#totalActivePointers
    +* @property {number} totalActivePointers - The total number of active Pointers.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", {
    +    
    +    get: function () {
    +
    +        this.currentPointers = 0;
    +
    +        for (var i = 1; i <= 10; i++)
    +        {
    +            if (this['pointer' + i] && this['pointer' + i].active)
    +            {
    +                this.currentPointers++;
    +            }
    +        }
    +
    +        return this.currentPointers;
    +
    +    }
    +
    +});
    +
    +/**
    +* The world X coordinate of the most recently active pointer.
    +* @name Phaser.Input#worldX
    +* @property {number} worldX - The world X coordinate of the most recently active pointer.
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "worldX", {
    +
    +    get: function () {
    +		return this.game.camera.view.x + this.x;
    +    }
    +
    +});
    +
    +/**
    +* The world Y coordinate of the most recently active pointer.
    +* @name Phaser.Input#worldY
    +* @property {number} worldY - The world Y coordinate of the most recently active pointer.
    +*/
    +Object.defineProperty(Phaser.Input.prototype, "worldY", {
    +
    +    get: function () {
    +		return this.game.camera.view.y + this.y;
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/InputHandler.js.html b/docs/InputHandler.js.html new file mode 100644 index 00000000..c6af8455 --- /dev/null +++ b/docs/InputHandler.js.html @@ -0,0 +1,1494 @@ + + + + + + Phaser Source: input/InputHandler.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: input/InputHandler.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Constructor for Phaser InputHandler.
    +* @class Phaser.InputHandler
    +* @classdesc Description.
    +* @constructor
    +* @param {Phaser.Sprite} game - Description.
    +*/
    +Phaser.InputHandler = function (sprite) {
    +
    +	/**
    +	* @property {Phaser.Sprite} sprite - Description. 
    +	*/
    +	this.sprite = sprite;
    +
    +    /**
    +    * @property {Phaser.Game} game - A reference to the currently running game. 
    +    */
    +    this.game = sprite.game;
    +
    +	/**
    +	* @property {boolean} enabled - Description. 
    +	* @default
    +	*/
    +    this.enabled = false;
    +
    +    //	Linked list references
    +	/**
    +	* @property {Description} parent - Description. 
    +	* @default
    +	*/
    +    this.parent = null;
    +    
    +	/**
    +	* @property {Description} next - Description. 
    +	* @default
    +	*/
    +    this.next = null;
    +    
    +	/**
    +	* @property {Description} prev - Description. 
    +	* @default
    +	*/
    +    this.prev = null;
    +    
    +	/**
    +	* @property {Description} last - Description. 
    +	* @default
    +	*/
    +	this.last = this;
    +	
    +	/**
    +	* @property {Description} first - Description. 
    +	* @default
    +	*/
    +	this.first = this;
    +
    +	/**
    +	* @property {number} priorityID - The PriorityID controls which Sprite receives an Input event first if they should overlap.
    +	* @default
    +	*/
    +    this.priorityID = 0;
    +    
    +	/**
    +	* @property {boolean} useHandCursor - Description. 
    +	* @default
    +	*/
    +    this.useHandCursor = false;
    +	
    +	/**
    +	* @property {boolean} isDragged - Description. 
    +	* @default
    +	*/
    +    this.isDragged = false;
    +    
    +	/**
    +	* @property {boolean} allowHorizontalDrag - Description. 
    +	* @default
    +	*/
    +    this.allowHorizontalDrag = true;
    +    
    +	/**
    +	* @property {boolean} allowVerticalDrag - Description. 
    +	* @default
    +	*/
    +    this.allowVerticalDrag = true;
    +    
    +	/**
    +	* @property {boolean} bringToTop - Description. 
    +	* @default
    +	*/
    +    this.bringToTop = false;
    +
    +	/**
    +	* @property {Description} snapOffset - Description. 
    +	* @default
    +	*/
    +    this.snapOffset = null;
    +    
    +	/**
    +	* @property {boolean} snapOnDrag - Description. 
    +	* @default
    +	*/
    +    this.snapOnDrag = false;
    +    
    +	/**
    +	* @property {boolean} snapOnRelease - Description. 
    +	* @default
    +	*/
    +    this.snapOnRelease = false;
    +    
    +	/**
    +	* @property {number} snapX - Description. 
    +	* @default
    +	*/
    +    this.snapX = 0;
    +    
    +	/**
    +	* @property {number} snapY - Description. 
    +	* @default
    +	*/
    +    this.snapY = 0;
    +
    +	/**
    +	* @property {number} pixelPerfect - Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it!
    +	* @default
    +	*/
    +    this.pixelPerfect = false;
    +
    +    /**
    +    * @property {number} pixelPerfectAlpha - The alpha tolerance threshold. If the alpha value of the pixel matches or is above this value, it's considered a hit.
    +    * @default
    +    */
    +    this.pixelPerfectAlpha = 255;
    +
    +    /**
    +    * @property {boolean} draggable - Is this sprite allowed to be dragged by the mouse? true = yes, false = no
    +    * @default 
    +    */
    +    this.draggable = false;
    +
    +    /**
    +    * @property {Description} boundsRect - A region of the game world within which the sprite is restricted during drag.
    +    * @default 
    +    */
    +    this.boundsRect = null;
    +
    +    /**
    +    * @property {Description} boundsSprite - A Sprite the bounds of which this sprite is restricted during drag.
    +    * @default
    +    */
    +    this.boundsSprite = null;
    +
    +    /**
    +    * If this object is set to consume the pointer event then it will stop all propogation from this object on.
    +    * For example if you had a stack of 6 sprites with the same priority IDs and one consumed the event, none of the others would receive it.
    +    * @property {boolean} consumePointerEvent
    +    * @default
    +    */
    +    this.consumePointerEvent = false;
    +
    +    /**
    +    * @property {Phaser.Point} _tempPoint - Description.
    +    * @private
    +    */
    +    this._tempPoint = new Phaser.Point;
    +
    +    this._pointerData = [];
    +
    +    this._pointerData.push({
    +        id: 0,
    +        x: 0,
    +        y: 0,
    +        isDown: false,
    +        isUp: false,
    +        isOver: false,
    +        isOut: false,
    +        timeOver: 0,
    +        timeOut: 0,
    +        timeDown: 0,
    +        timeUp: 0,
    +        downDuration: 0,
    +        isDragged: false
    +    });
    +
    +};
    +
    +Phaser.InputHandler.prototype = {
    +
    +	/**
    +	* Description.
    +	* @method Phaser.InputHandler#start
    +	* @param {number} priority - Description.
    +	* @param {boolean} useHandCursor - Description.
    +	* @return {Phaser.Sprite} Description.
    +	*/
    +	start: function (priority, useHandCursor) {
    +
    +		priority = priority || 0;
    +		if (typeof useHandCursor == 'undefined') { useHandCursor = false; }
    +
    +        //  Turning on
    +        if (this.enabled == false)
    +        {
    +            //  Register, etc
    +			this.game.input.interactiveItems.add(this);
    +            this.useHandCursor = useHandCursor;
    +            this.priorityID = priority;
    +
    +            for (var i = 0; i < 10; i++)
    +            {
    +                this._pointerData[i] = {
    +                    id: i,
    +                    x: 0,
    +                    y: 0,
    +                    isDown: false,
    +                    isUp: false,
    +                    isOver: false,
    +                    isOut: false,
    +                    timeOver: 0,
    +                    timeOut: 0,
    +                    timeDown: 0,
    +                    timeUp: 0,
    +                    downDuration: 0,
    +                    isDragged: false
    +                };
    +            }
    +
    +            this.snapOffset = new Phaser.Point;
    +            this.enabled = true;
    +
    +            //  Create the signals the Input component will emit
    +            if (this.sprite.events && this.sprite.events.onInputOver == null)
    +            {
    +                this.sprite.events.onInputOver = new Phaser.Signal;
    +                this.sprite.events.onInputOut = new Phaser.Signal;
    +                this.sprite.events.onInputDown = new Phaser.Signal;
    +                this.sprite.events.onInputUp = new Phaser.Signal;
    +                this.sprite.events.onDragStart = new Phaser.Signal;
    +                this.sprite.events.onDragStop = new Phaser.Signal;
    +            }
    +        }
    +
    +        return this.sprite;
    +
    +	},
    +
    +	/**
    +	* Description.
    +	* @method Phaser.InputHandler#reset
    +	*/
    +    reset: function () {
    +
    +        this.enabled = false;
    +
    +        for (var i = 0; i < 10; i++)
    +        {
    +            this._pointerData[i] = {
    +                id: i,
    +                x: 0,
    +                y: 0,
    +                isDown: false,
    +                isUp: false,
    +                isOver: false,
    +                isOut: false,
    +                timeOver: 0,
    +                timeOut: 0,
    +                timeDown: 0,
    +                timeUp: 0,
    +                downDuration: 0,
    +                isDragged: false
    +            };
    +        }
    +    },
    +
    +	/**
    +	* Description.
    +	* @method Phaser.InputHandler#stop
    +	*/
    +	stop: function () {
    +
    +        //  Turning off
    +        if (this.enabled == false)
    +        {
    +            return;
    +        }
    +        else
    +        {
    +            //  De-register, etc
    +            this.enabled = false;
    +			this.game.input.interactiveItems.remove(this);
    +        }
    +
    +	},
    +
    +	/**
    +	* Clean up memory.
    +	* @method Phaser.InputHandler#destroy
    +	*/
    +    destroy: function () {
    +
    +        if (this.enabled)
    +        {
    +            this.enabled = false;
    +
    +            this.game.input.interactiveItems.remove(this);
    +
    +        	this.stop();
    +
    +        	this.sprite = null;
    +        }
    +    },
    +
    +	/**
    +    * The x coordinate of the Input pointer, relative to the top-left of the parent Sprite.
    +    * This value is only set when the pointer is over this Sprite.
    +    * @method Phaser.InputHandler#pointerX
    +    * @param {Pointer} pointer
    +    * @return {number} The x coordinate of the Input pointer.
    +    */    
    +    pointerX: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        return this._pointerData[pointer].x;
    +
    +    },
    +
    +	/**
    +    * The y coordinate of the Input pointer, relative to the top-left of the parent Sprite
    +    * This value is only set when the pointer is over this Sprite.
    +    * @method Phaser.InputHandler#pointerY
    +    * @param {Pointer} pointer
    +    * @return {number} The y coordinate of the Input pointer.
    +    */
    +    pointerY: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        return this._pointerData[pointer].y;
    +
    +    },
    +
    +	/**
    +    * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true.
    +    * @method Phaser.InputHandler#pointerDown
    +    * @param {Pointer} pointer
    +    * @return {boolean}
    +    */
    +    pointerDown: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        return this._pointerData[pointer].isDown;
    +
    +    },
    +
    +	/**
    +    * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true
    +    * @method Phaser.InputHandler#pointerUp
    +    * @param {Pointer} pointer
    +    * @return {boolean}
    +    */
    +    pointerUp: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        return this._pointerData[pointer].isUp;
    +
    +    },
    +
    +	/**
    +    * A timestamp representing when the Pointer first touched the touchscreen.
    +    * @method Phaser.InputHandler#pointerTimeDown
    +    * @param {Pointer} pointer
    +    * @return {number}
    +    */
    +    pointerTimeDown: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        return this._pointerData[pointer].timeDown;
    +
    +    },
    +
    +	/**
    +    * A timestamp representing when the Pointer left the touchscreen.
    +    * @method Phaser.InputHandler#pointerTimeUp
    +    * @param {Pointer} pointer
    +    * @return {number}
    +    */
    +    pointerTimeUp: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        return this._pointerData[pointer].timeUp;
    +
    +    },
    +
    +	/**
    +    * Is the Pointer over this Sprite?
    +    * @method Phaser.InputHandler#pointerOver
    +    * @param {Pointer} pointer
    +    * @return {bool
    +    */
    +    pointerOver: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        return this._pointerData[pointer].isOver;
    +
    +    },
    +
    +	/**
    +    * Is the Pointer outside of this Sprite?
    +    * @method Phaser.InputHandler#pointerOut
    +    * @param {Pointer} pointer
    +    * @return {boolean}
    +    */
    +    pointerOut: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        return this._pointerData[pointer].isOut;
    +
    +    },
    +
    +	/**
    +    * A timestamp representing when the Pointer first touched the touchscreen.
    +    * @method Phaser.InputHandler#pointerTimeOver
    +    * @param {Pointer} pointer
    +    * @return {number}
    +    */
    +    pointerTimeOver: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        return this._pointerData[pointer].timeOver;
    +
    +    },
    +
    +	/**
    +    * A timestamp representing when the Pointer left the touchscreen.
    +    * @method Phaser.InputHandler#pointerTimeOut
    +    * @param {Pointer} pointer
    +    * @return {number}
    +    */
    +    pointerTimeOut: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        return this._pointerData[pointer].timeOut;
    +
    +    },
    +
    +	/**
    +    * Is this sprite being dragged by the mouse or not?
    +    * @method Phaser.InputHandler#pointerTimeOut
    +    * @param {Pointer} pointer
    +    * @return {number}
    +    */
    +    pointerDragged: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        return this._pointerData[pointer].isDragged;
    +
    +    },
    +
    +	/**
    +    * Checks if the given pointer is over this Sprite.
    +    * @method Phaser.InputHandler#checkPointerOver
    +    * @param {Pointer} pointer
    +    * @return {boolean}
    +    */
    +    checkPointerOver: function (pointer) {
    +
    +        if (this.enabled && this.sprite.visible)
    +        {
    +            this.sprite.getLocalUnmodifiedPosition(this._tempPoint, pointer.x, pointer.y);
    +
    +            if (this._tempPoint.x >= 0 && this._tempPoint.x <= this.sprite.currentFrame.width && this._tempPoint.y >= 0 && this._tempPoint.y <= this.sprite.currentFrame.height)
    +            {
    +                if (this.pixelPerfect)
    +                {
    +                    return this.checkPixel(this._tempPoint.x, this._tempPoint.y);
    +                }
    +                else
    +                {
    +                    return true;
    +                }
    +            }
    +        }
    +
    +        return false;
    +
    +    },
    +
    +	/**
    +     * Description.
    +     * @method Phaser.InputHandler#checkPixel
    +     * @param {Description} x - Description.
    +     * @param {Description} y - Description.
    +     * @return {boolean}
    +     */
    +    checkPixel: function (x, y) {
    +
    +        //  Grab a pixel from our image into the hitCanvas and then test it
    +        if (this.sprite.texture.baseTexture.source)
    +        {
    +            this.game.input.hitContext.clearRect(0, 0, 1, 1);
    +
    +            //  This will fail if the image is part of a texture atlas - need to modify the x/y values here
    +
    +            x += this.sprite.texture.frame.x;
    +            y += this.sprite.texture.frame.y;
    +
    +            this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source, x, y, 1, 1, 0, 0, 1, 1);
    +            
    +            var rgb = this.game.input.hitContext.getImageData(0, 0, 1, 1);
    +
    +            if (rgb.data[3] >= this.pixelPerfectAlpha)
    +            {
    +                return true;
    +            }
    +        }
    +
    +        return false;
    +
    +    },
    +
    +	/**
    +    * Update.
    +    * @method Phaser.InputHandler#update
    +    * @param {Pointer} pointer
    +    */
    +    update: function (pointer) {
    +
    +        if (this.enabled == false || this.sprite.visible == false || (this.sprite.group && this.sprite.group.visible == false))
    +        {
    +            this._pointerOutHandler(pointer);
    +            return false;
    +        }
    +
    +        if (this.draggable && this._draggedPointerID == pointer.id)
    +        {
    +            return this.updateDrag(pointer);
    +        }
    +        else if (this._pointerData[pointer.id].isOver == true)
    +        {
    +            if (this.checkPointerOver(pointer))
    +            {
    +                this._pointerData[pointer.id].x = pointer.x - this.sprite.x;
    +                this._pointerData[pointer.id].y = pointer.y - this.sprite.y;
    +                return true;
    +            }
    +            else
    +            {
    +                this._pointerOutHandler(pointer);
    +                return false;
    +            }
    +        }
    +    },
    +
    +	/**
    +     * Description.
    +     * @method Phaser.InputHandler#_pointerOverHandler
    +     * @private
    +     * @param {Pointer} pointer
    +     */
    +    _pointerOverHandler: function (pointer) {
    +
    +        if (this._pointerData[pointer.id].isOver == false)
    +        {
    +            this._pointerData[pointer.id].isOver = true;
    +            this._pointerData[pointer.id].isOut = false;
    +            this._pointerData[pointer.id].timeOver = this.game.time.now;
    +            this._pointerData[pointer.id].x = pointer.x - this.sprite.x;
    +            this._pointerData[pointer.id].y = pointer.y - this.sprite.y;
    +
    +            if (this.useHandCursor && this._pointerData[pointer.id].isDragged == false)
    +            {
    +                this.game.stage.canvas.style.cursor = "pointer";
    +            }
    +
    +            this.sprite.events.onInputOver.dispatch(this.sprite, pointer);
    +        }
    +    },
    +
    +	/**
    +     * Description.
    +     * @method Phaser.InputHandler#_pointerOutHandler
    +     * @private
    +     * @param {Pointer} pointer
    +     */
    +    _pointerOutHandler: function (pointer) {
    +
    +        this._pointerData[pointer.id].isOver = false;
    +        this._pointerData[pointer.id].isOut = true;
    +        this._pointerData[pointer.id].timeOut = this.game.time.now;
    +
    +        if (this.useHandCursor && this._pointerData[pointer.id].isDragged == false)
    +        {
    +            this.game.stage.canvas.style.cursor = "default";
    +        }
    +
    +        if (this.sprite && this.sprite.events)
    +        {
    +            this.sprite.events.onInputOut.dispatch(this.sprite, pointer);
    +        }
    +
    +    },
    +
    +	/**
    +     * Description.
    +     * @method Phaser.InputHandler#_touchedHandler
    +     * @private
    +     * @param {Pointer} pointer
    +     */
    +    _touchedHandler: function (pointer) {
    +
    +        if (this._pointerData[pointer.id].isDown == false && this._pointerData[pointer.id].isOver == true)
    +        {
    +            this._pointerData[pointer.id].isDown = true;
    +            this._pointerData[pointer.id].isUp = false;
    +            this._pointerData[pointer.id].timeDown = this.game.time.now;
    +            this.sprite.events.onInputDown.dispatch(this.sprite, pointer);
    +
    +            //  Start drag
    +            if (this.draggable && this.isDragged == false)
    +            {
    +                this.startDrag(pointer);
    +            }
    +
    +            if (this.bringToTop)
    +            {
    +                this.sprite.bringToTop();
    +			}
    +        }
    +
    +        //  Consume the event?
    +        return this.consumePointerEvent;
    +
    +    },
    +
    +	/**
    +     * Description.
    +     * @method Phaser.InputHandler#_releasedHandler
    +     * @private
    +     * @param {Pointer} pointer
    +     */
    +    _releasedHandler: function (pointer) {
    +
    +        //  If was previously touched by this Pointer, check if still is AND still over this item
    +        if (this._pointerData[pointer.id].isDown && pointer.isUp)
    +        {
    +            this._pointerData[pointer.id].isDown = false;
    +            this._pointerData[pointer.id].isUp = true;
    +            this._pointerData[pointer.id].timeUp = this.game.time.now;
    +            this._pointerData[pointer.id].downDuration = this._pointerData[pointer.id].timeUp - this._pointerData[pointer.id].timeDown;
    +
    +            //  Only release the InputUp signal if the pointer is still over this sprite
    +            if (this.checkPointerOver(pointer))
    +            {
    +                //console.log('releasedHandler: ' + Date.now());
    +                this.sprite.events.onInputUp.dispatch(this.sprite, pointer);
    +            }
    +            else
    +            {
    +                //  Pointer outside the sprite? Reset the cursor
    +                if (this.useHandCursor)
    +                {
    +                    this.game.stage.canvas.style.cursor = "default";
    +                }
    +            }
    +
    +            //  Stop drag
    +            if (this.draggable && this.isDragged && this._draggedPointerID == pointer.id)
    +            {
    +                this.stopDrag(pointer);
    +            }
    +        }
    +
    +    },
    +
    +	/**
    +    * Updates the Pointer drag on this Sprite.
    +    * @method Phaser.InputHandler#updateDrag
    +    * @param {Pointer} pointer
    +    * @return {boolean}
    +    */
    +    updateDrag: function (pointer) {
    +
    +        if (pointer.isUp)
    +        {
    +            this.stopDrag(pointer);
    +            return false;
    +        }
    +
    +        if (this.allowHorizontalDrag)
    +        {
    +            this.sprite.x = pointer.x + this._dragPoint.x + this.dragOffset.x;
    +        }
    +
    +        if (this.allowVerticalDrag)
    +        {
    +            this.sprite.y = pointer.y + this._dragPoint.y + this.dragOffset.y;
    +        }
    +
    +        if (this.boundsRect)
    +        {
    +            this.checkBoundsRect();
    +        }
    +
    +        if (this.boundsSprite)
    +        {
    +            this.checkBoundsSprite();
    +        }
    +
    +        if (this.snapOnDrag)
    +        {
    +            this.sprite.x = Math.round(this.sprite.x / this.snapX) * this.snapX;
    +            this.sprite.y = Math.round(this.sprite.y / this.snapY) * this.snapY;
    +        }
    +
    +        return true;
    +
    +    },
    +
    +	/**
    +    * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)
    +    * @method Phaser.InputHandler#justOver
    +    * @param {Pointer} pointer
    +    * @param {number} delay - The time below which the pointer is considered as just over.
    +    * @return {boolean}
    +    */
    +    justOver: function (pointer, delay) {
    +
    +    	pointer = pointer || 0;
    +    	delay = delay || 500;
    +
    +        return (this._pointerData[pointer].isOver && this.overDuration(pointer) < delay);
    +
    +    },
    +
    +	/**
    +    * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)
    +    * @method Phaser.InputHandler#justOut
    +    * @param {Pointer} pointer
    +    * @param {number} delay - The time below which the pointer is considered as just out.
    +    * @return {boolean}
    +    */
    +    justOut: function (pointer, delay) {
    +
    +    	pointer = pointer || 0;
    +    	delay = delay || 500;
    +
    +        return (this._pointerData[pointer].isOut && (this.game.time.now - this._pointerData[pointer].timeOut < delay));
    +
    +    },
    +
    +	/**
    +    * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)
    +    * @method Phaser.InputHandler#justPressed
    +    * @param {Pointer} pointer
    +    * @param {number} delay - The time below which the pointer is considered as just over.
    +    * @return {boolean}
    +    */
    +    justPressed: function (pointer, delay) {
    +
    +    	pointer = pointer || 0;
    +    	delay = delay || 500;
    +
    +        return (this._pointerData[pointer].isDown && this.downDuration(pointer) < delay);
    +
    +    },
    +
    +	/**
    +    * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)
    +    * @method Phaser.InputHandler#justReleased
    +    * @param {Pointer} pointer
    +    * @param {number} delay - The time below which the pointer is considered as just out.
    +    * @return {boolean}
    +    */
    +    justReleased: function (pointer, delay) {
    +
    +    	pointer = pointer || 0;
    +    	delay = delay || 500;
    +
    +        return (this._pointerData[pointer].isUp && (this.game.time.now - this._pointerData[pointer].timeUp < delay));
    +
    +    },
    +
    +	/**
    +    * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.
    +    * @method Phaser.InputHandler#overDuration
    +    * @param {Pointer} pointer
    +    * @return {number} The number of milliseconds the pointer has been over the Sprite, or -1 if not over.
    +    */
    +    overDuration: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        if (this._pointerData[pointer].isOver)
    +        {
    +            return this.game.time.now - this._pointerData[pointer].timeOver;
    +        }
    +
    +        return -1;
    +
    +    },
    +
    +	/**
    +    * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.
    +    * @method Phaser.InputHandler#downDuration
    +    * @param {Pointer} pointer
    +    * @return {number} The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over.
    +    */
    +    downDuration: function (pointer) {
    +
    +    	pointer = pointer || 0;
    +
    +        if (this._pointerData[pointer].isDown)
    +        {
    +            return this.game.time.now - this._pointerData[pointer].timeDown;
    +        }
    +
    +        return -1;
    +
    +    },
    +
    +	/**
    +    * Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback
    +    * @method Phaser.InputHandler#enableDrag
    +    * @param	lockCenter			If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer.
    +    * @param	bringToTop			If true the Sprite will be bought to the top of the rendering list in its current Group.
    +    * @param	pixelPerfect		If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box.
    +    * @param	alphaThreshold		If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255)
    +    * @param	boundsRect			If you want to restrict the drag of this sprite to a specific FlxRect, pass the FlxRect here, otherwise it's free to drag anywhere
    +    * @param	boundsSprite		If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here
    +    */
    +    enableDrag: function (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite) {
    +
    +        if (typeof lockCenter == 'undefined') { lockCenter = false; }
    +        if (typeof bringToTop == 'undefined') { bringToTop = false; }
    +        if (typeof pixelPerfect == 'undefined') { pixelPerfect = false; }
    +
    +        alphaThreshold = alphaThreshold || 255;
    +        boundsRect = boundsRect || null;
    +        boundsSprite = boundsSprite || null;
    +
    +        this._dragPoint = new Phaser.Point();
    +        this.draggable = true;
    +        this.bringToTop = bringToTop;
    +        this.dragOffset = new Phaser.Point();
    +        this.dragFromCenter = lockCenter;
    +
    +        this.pixelPerfect = pixelPerfect;
    +        this.pixelPerfectAlpha = alphaThreshold;
    +
    +        if (boundsRect)
    +        {
    +            this.boundsRect = boundsRect;
    +        }
    +
    +        if (boundsSprite)
    +        {
    +            this.boundsSprite = boundsSprite;
    +        }
    +
    +    },
    +
    +	/**
    +    * Stops this sprite from being able to be dragged. If it is currently the target of an active drag it will be stopped immediately. Also disables any set callbacks.
    +    * @method Phaser.InputHandler#disableDrag
    +    */
    +    disableDrag: function () {
    +
    +        if (this._pointerData)
    +        {
    +            for (var i = 0; i < 10; i++)
    +            {
    +                this._pointerData[i].isDragged = false;
    +            }
    +        }
    +
    +        this.draggable = false;
    +        this.isDragged = false;
    +        this._draggedPointerID = -1;
    +
    +    },
    +
    +	/**
    +    * Called by Pointer when drag starts on this Sprite. Should not usually be called directly.
    +    * @method Phaser.InputHandler#startDrag
    +    */
    +    startDrag: function (pointer) {
    +
    +        this.isDragged = true;
    +        this._draggedPointerID = pointer.id;
    +        this._pointerData[pointer.id].isDragged = true;
    +
    +        if (this.dragFromCenter)
    +        {
    +            this.sprite.centerOn(pointer.x, pointer.y);
    +            this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
    +        }
    +        else
    +        {
    +            this._dragPoint.setTo(this.sprite.x - pointer.x, this.sprite.y - pointer.y);
    +        }
    +
    +        this.updateDrag(pointer);
    +        
    +        if (this.bringToTop)
    +        {
    +            this.sprite.bringToTop();
    +        }
    +
    +        this.sprite.events.onDragStart.dispatch(this.sprite, pointer);
    +
    +    },
    +
    +	/**
    +    * Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly.
    +    * @method Phaser.InputHandler#stopDrag
    +    */
    +    stopDrag: function (pointer) {
    +
    +        this.isDragged = false;
    +        this._draggedPointerID = -1;
    +        this._pointerData[pointer.id].isDragged = false;
    +        
    +        if (this.snapOnRelease)
    +        {
    +            this.sprite.x = Math.round(this.sprite.x / this.snapX) * this.snapX;
    +            this.sprite.y = Math.round(this.sprite.y / this.snapY) * this.snapY;
    +        }
    +
    +        this.sprite.events.onDragStop.dispatch(this.sprite, pointer);
    +        this.sprite.events.onInputUp.dispatch(this.sprite, pointer);
    +
    +    },
    +
    +	/**
    +    * Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move!
    +    * @method Phaser.InputHandler#setDragLock
    +    * @param	allowHorizontal		To enable the sprite to be dragged horizontally set to true, otherwise false
    +    * @param	allowVertical		To enable the sprite to be dragged vertically set to true, otherwise false
    +    */
    +    setDragLock: function (allowHorizontal, allowVertical) {
    +
    +        if (typeof allowHorizontal == 'undefined') { allowHorizontal = true; }
    +    	if (typeof allowVertical == 'undefined') { allowVertical = true; }
    +
    +        this.allowHorizontalDrag = allowHorizontal;
    +        this.allowVerticalDrag = allowVertical;
    +
    +    },
    +
    +	/**
    +    * Make this Sprite snap to the given grid either during drag or when it's released.
    +    * For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels.
    +    * @method Phaser.InputHandler#enableSnap
    +    * @param	snapX		The width of the grid cell in pixels
    +    * @param	snapY		The height of the grid cell in pixels
    +    * @param	onDrag		If true the sprite will snap to the grid while being dragged
    +    * @param	onRelease	If true the sprite will snap to the grid when released
    +    */
    +    enableSnap: function (snapX, snapY, onDrag, onRelease) {
    +
    +        if (typeof onDrag == 'undefined') { onDrag = true; }
    +        if (typeof onRelease == 'undefined') { onRelease = false; }
    +
    +        this.snapX = snapX;
    +        this.snapY = snapY;
    +        this.snapOnDrag = onDrag;
    +        this.snapOnRelease = onRelease;
    +
    +    },
    +
    +	/**
    +    * Stops the sprite from snapping to a grid during drag or release.
    +    * @method Phaser.InputHandler#disableSnap
    +    */
    +    disableSnap: function () {
    +
    +        this.snapOnDrag = false;
    +        this.snapOnRelease = false;
    +
    +    },
    +
    +	/**
    +    * Bounds Rect check for the sprite drag
    +    * @method Phaser.InputHandler#checkBoundsRect
    +    */
    +    checkBoundsRect: function () {
    +
    +        if (this.sprite.x < this.boundsRect.left)
    +        {
    +            this.sprite.x = this.boundsRect.x;
    +        }
    +        else if ((this.sprite.x + this.sprite.width) > this.boundsRect.right)
    +        {
    +            this.sprite.x = this.boundsRect.right - this.sprite.width;
    +        }
    +
    +        if (this.sprite.y < this.boundsRect.top)
    +        {
    +            this.sprite.y = this.boundsRect.top;
    +        }
    +        else if ((this.sprite.y + this.sprite.height) > this.boundsRect.bottom)
    +        {
    +            this.sprite.y = this.boundsRect.bottom - this.sprite.height;
    +        }
    +
    +    },
    +
    +	/**
    +    * Parent Sprite Bounds check for the sprite drag.
    +    * @method Phaser.InputHandler#checkBoundsSprite
    +    */
    +    checkBoundsSprite: function () {
    +
    +        if (this.sprite.x < this.boundsSprite.x)
    +        {
    +            this.sprite.x = this.boundsSprite.x;
    +        }
    +        else if ((this.sprite.x + this.sprite.width) > (this.boundsSprite.x + this.boundsSprite.width))
    +        {
    +            this.sprite.x = (this.boundsSprite.x + this.boundsSprite.width) - this.sprite.width;
    +        }
    +
    +        if (this.sprite.y < this.boundsSprite.y)
    +        {
    +            this.sprite.y = this.boundsSprite.y;
    +        }
    +        else if ((this.sprite.y + this.sprite.height) > (this.boundsSprite.y + this.boundsSprite.height))
    +        {
    +            this.sprite.y = (this.boundsSprite.y + this.boundsSprite.height) - this.sprite.height;
    +        }
    +
    +    }
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/IntroDocs.js.html b/docs/IntroDocs.js.html new file mode 100644 index 00000000..51e51dca --- /dev/null +++ b/docs/IntroDocs.js.html @@ -0,0 +1,474 @@ + + + + + + Phaser Source: IntroDocs.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: IntroDocs.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* @overview
    +*
    +* Phaser - http://www.phaser.io
    +*
    +* v1.1 - Released October 25th 2013.
    +*
    +* By Richard Davey http://www.photonstorm.com @photonstorm
    +*
    +* A feature-packed 2D HTML5 game framework born from the smouldering pits of Flixel and
    +* constructed via plenty of blood, sweat, tears and coffee by Richard Davey (@photonstorm).
    +*
    +* Phaser uses Pixi.js for rendering, created by Mat Groves http://matgroves.com/ @Doormat23.
    +*
    +* Follow Phaser development progress at http://www.photonstorm.com
    +*
    +* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from both which Phaser
    +* and my love of game development originate.
    +*
    +* "If you want your children to be intelligent,  read them fairy tales."
    +* "If you want them to be more intelligent, read them more fairy tales."
    +*                                                     -- Albert Einstein
    +*/
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Key.js.html b/docs/Key.js.html new file mode 100644 index 00000000..02465902 --- /dev/null +++ b/docs/Key.js.html @@ -0,0 +1,616 @@ + + + + + + Phaser Source: input/Key.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: input/Key.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* @class Phaser.Key
    +* @classdesc If you need more fine-grained control over the handling of specific keys you can create and use Phaser.Key objects.
    +* @constructor
    +* @param {Phaser.Game} game - Current game instance.
    +* @param {number} keycode - The key code this Key is responsible for.
    +*/
    +Phaser.Key = function (game, keycode) {
    +
    +	/**
    +	* @property {Phaser.Game} game - A reference to the currently running game. 
    +	*/
    +	this.game = game;
    +
    +	/**
    +	* @property {boolean} isDown - The "down" state of the key.
    +	* @default
    +	*/
    +	this.isDown = false;
    +
    +	/**
    +	* @property {boolean} isUp - The "up" state of the key.
    +	* @default
    +	*/
    +	this.isUp = false;
    +
    +	/**
    +	* @property {boolean} altKey - The down state of the ALT key, if pressed at the same time as this key.
    +	* @default
    +	*/
    +	this.altKey = false;
    +
    +	/**
    +	* @property {boolean} ctrlKey - The down state of the CTRL key, if pressed at the same time as this key.
    +	* @default
    +	*/
    +	this.ctrlKey = false;
    +
    +	/**
    +	* @property {boolean} shiftKey - The down state of the SHIFT key, if pressed at the same time as this key.
    +	* @default
    +	*/
    +	this.shiftKey = false;
    +
    +	/**
    +	* @property {number} timeDown - The timestamp when the key was last pressed down.
    +	* @default
    +	*/
    +	this.timeDown = 0;
    +
    +	/**
    +	* 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.
    +	* @property {number} duration - The number of milliseconds this key has been held down for.
    +	* @default
    +	*/
    +	this.duration = 0;
    +
    +	/**
    +	* @property {number} timeUp - The timestamp when the key was last released.
    +	* @default
    +	*/
    +	this.timeUp = 0;
    +
    +	/**
    +	* @property {number} repeats - If a key is held down this holds down the number of times the key has 'repeated'.
    +	* @default
    +	*/
    +	this.repeats = 0;
    +
    +	/**
    +	* @property {number} keyCode - The keycode of this key.
    +	*/
    +	this.keyCode = keycode;
    +
    +	/**
    +	* @property {Phaser.Signal} onDown - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again).
    +	*/
    +    this.onDown = new Phaser.Signal();
    +
    +	/**
    +	* @property {Phaser.Signal} onUp - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again).
    +	*/
    +    this.onUp = new Phaser.Signal();
    +	
    +};
    +
    +Phaser.Key.prototype = {
    +
    +	/**
    +    * Called automatically by Phaser.Keyboard.
    +    * @method Phaser.Key#processKeyDown
    +    * @param {KeyboardEvent} event.
    +    * @protected
    +    */
    +    processKeyDown: function (event) {
    +
    +        this.altKey = event.altKey;
    +        this.ctrlKey = event.ctrlKey;
    +        this.shiftKey = event.shiftKey;
    +
    +        if (this.isDown)
    +        {
    +            //  Key was already held down, this must be a repeat rate based event
    +            this.duration = event.timeStamp - this.timeDown;
    +            this.repeats++;
    +        }
    +        else
    +        {
    +            this.isDown = true;
    +            this.isUp = false;
    +            this.timeDown = event.timeStamp;
    +            this.duration = 0;
    +            this.repeats = 0;
    +
    +            this.onDown.dispatch(this);
    +        }
    +
    +    },
    +
    +	/**
    +    * Called automatically by Phaser.Keyboard.
    +    * @method Phaser.Key#processKeyUp
    +    * @param {KeyboardEvent} event.
    +    * @protected
    +    */
    +    processKeyUp: function (event) {
    +
    +        this.isDown = false;
    +        this.isUp = true;
    +        this.timeUp = event.timeStamp;
    +
    +        this.onUp.dispatch(this);
    +
    +    },
    +
    +	/**
    +	* Returns the "just pressed" state of the Key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms)
    +    * @method Phaser.Key#justPressed
    +    * @param {number} [duration=250] - The duration below which the key is considered as being just pressed.
    +    * @return {boolean} True if the key is just pressed otherwise false.
    +    */
    +    justPressed: function (duration) {
    +
    +        if (typeof duration === "undefined") { duration = 250; }
    +
    +        return (this.isDown && this.duration < duration);
    +
    +    },
    +
    +	/**
    +	* Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms)
    +    * @method Phaser.Key#justPressed
    +    * @param {number} [duration=250] - The duration below which the key is considered as being just released.
    +    * @return {boolean} True if the key is just released otherwise false.
    +    */
    +    justReleased: function (duration) {
    +
    +        if (typeof duration === "undefined") { duration = 250; }
    +
    +        return (this.isDown == false && (this.game.time.now - this.timeUp < duration));
    +
    +    }
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Keyboard.js.html b/docs/Keyboard.js.html new file mode 100644 index 00000000..8557ce67 --- /dev/null +++ b/docs/Keyboard.js.html @@ -0,0 +1,938 @@ + + + + + + Phaser Source: input/Keyboard.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: input/Keyboard.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser - Keyboard constructor.
    +*
    +* @class Phaser.Keyboard
    +* @classdesc A Keyboard object Description.
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +*/
    +Phaser.Keyboard = function (game) {
    +
    +	/**
    +	* @property {Phaser.Game} game - Local reference to game.
    +	*/
    +	this.game = game;
    +	
    +	/**
    +	* @property {Description} _keys - Description.
    +	* @private
    +	*/
    +    this._keys = {};
    +    
    +    /**
    +    * @property {Description} _hotkeys - Description.
    +    * @private
    +    */
    +    this._hotkeys = {};
    +
    +	/**
    +	* @property {Description} _capture - Description.
    +	* @private
    +	*/
    +    this._capture = {};
    +
    +    /**
    +    * You can disable all Keyboard Input by setting disabled to true. While true all new input related events will be ignored.
    +    * @property {boolean} disabled - The disabled state of the Keyboard.
    +    * @default
    +    */
    +    this.disabled = false;
    +
    +    /**
    +    * @property {function} _onKeyDown
    +    * @private
    +    * @default
    +    */
    +    this._onKeyDown = null;
    +    
    +    /**
    +    * @property {function} _onKeyUp
    +    * @private
    +    * @default
    +    */
    +    this._onKeyUp = null;
    +
    +    /**
    +    * @property {Object} callbackContext - The context under which the callbacks are run.
    +    */
    +    this.callbackContext = this;
    +
    +    /**
    +    * @property {function} onDownCallback - This callback is invoked every time a key is pressed down.
    +    */
    +    this.onDownCallback = null;
    +
    +    /**
    +    * @property {function} onUpCallback - This callback is invoked every time a key is released.
    +    */
    +    this.onUpCallback = null;
    +	
    +};
    +
    +Phaser.Keyboard.prototype = {
    +
    +    /**
    +    * Add callbacks to the Keyboard handler so that each time a key is pressed down or releases the callbacks are activated.
    +    * @method Phaser.Keyboard#addCallbacks
    +    * @param {Object} context - The context under which the callbacks are run.
    +    * @param {function} onDown - This callback is invoked every time a key is pressed down.
    +    * @param {function} [onUp=null] - This callback is invoked every time a key is released.
    +    */
    +    addCallbacks: function (context, onDown, onUp) {
    +
    +        this.callbackContext = context;
    +        this.onDownCallback = onDown;
    +
    +        if (typeof onUp !== 'undefined')
    +        {
    +            this.onUpCallback = onUp;
    +        }
    +
    +    },
    +
    +    /**
    +    * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method.
    +    * The Key object can then be polled, have events attached to it, etc.
    +    *
    +    * @method Phaser.Keyboard#addKey
    +    * @param {number} keycode - The keycode of the key, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR
    +    * @return {Phaser.Key} The Key object which you can store locally and reference directly.
    +    */
    +    addKey: function (keycode) {
    +
    +        this._hotkeys[keycode] = new Phaser.Key(this.game, keycode);
    +        return this._hotkeys[keycode];
    +
    +    },
    +
    +    /**
    +    * Removes a Key object from the Keyboard manager.
    +    *
    +    * @method Phaser.Keyboard#removeKey
    +    * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR
    +    */
    +    removeKey: function (keycode) {
    +
    +        delete (this._hotkeys[keycode]);
    +
    +    },
    +
    +    /**
    +    * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right.
    +    *
    +    * @method Phaser.Keyboard#createCursorKeys
    +    * @return {object} An object containing properties: up, down, left and right. Which can be polled like any other Phaser.Key object.
    +    */
    +    createCursorKeys: function () {
    +
    +        return { 
    +            up: this.addKey(Phaser.Keyboard.UP), 
    +            down: this.addKey(Phaser.Keyboard.DOWN), 
    +            left: this.addKey(Phaser.Keyboard.LEFT), 
    +            right: this.addKey(Phaser.Keyboard.RIGHT)
    +        }
    +
    +    },
    +
    +    /**
    +    * Starts the Keyboard event listeners running (keydown and keyup). They are attached to the document.body.
    +    * This is called automatically by Phaser.Input and should not normally be invoked directly.
    +    *
    +    * @method Phaser.Keyboard#start
    +    */
    +    start: function () {
    +
    +        var _this = this;
    +
    +        this._onKeyDown = function (event) {
    +            return _this.processKeyDown(event);
    +        };
    +
    +        this._onKeyUp = function (event) {
    +            return _this.processKeyUp(event);
    +        };
    +
    +        document.body.addEventListener('keydown', this._onKeyDown, false);
    +        document.body.addEventListener('keyup', this._onKeyUp, false);
    +
    +    },
    +
    +    /**
    +    * Stops the Keyboard event listeners from running (keydown and keyup). They are removed from the document.body.
    +    *
    +    * @method Phaser.Keyboard#stop
    +    */
    +    stop: function () {
    +
    +        document.body.removeEventListener('keydown', this._onKeyDown);
    +        document.body.removeEventListener('keyup', this._onKeyUp);
    +
    +    },
    +
    +	/**
    +    * 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.
    +    * You can use addKeyCapture to consume the keyboard event for specific keys so it doesn't bubble up to the the browser.
    +    * Pass in either a single keycode or an array/hash of keycodes.
    +    * @method Phaser.Keyboard#addKeyCapture
    +    * @param {Any} keycode
    +    */
    +    addKeyCapture: function (keycode) {
    +
    +        if (typeof keycode === 'object')
    +        {
    +            for (var key in keycode)
    +            {
    +                this._capture[keycode[key]] = true;
    +            }
    +        }
    +        else
    +        {
    +            this._capture[keycode] = true;
    +        }
    +    },
    +
    +	/**
    +	* Removes an existing key capture.
    +	* @method Phaser.Keyboard#removeKeyCapture
    +    * @param {number} keycode
    +    */
    +    removeKeyCapture: function (keycode) {
    +
    +        delete this._capture[keycode];
    +
    +    },
    +
    +	/**
    +	* Clear all set key captures.
    +	* @method Phaser.Keyboard#clearCaptures
    +    */
    +    clearCaptures: function () {
    +
    +        this._capture = {};
    +
    +    },
    +
    +	/**
    +	* Process the keydown event.
    +	* @method Phaser.Keyboard#processKeyDown
    +    * @param {KeyboardEvent} event
    +    * @protected
    +    */    
    +    processKeyDown: function (event) {
    +
    +        if (this.game.input.disabled || this.disabled)
    +        {
    +            return;
    +        }
    +
    +        if (this._capture[event.keyCode])
    +        {
    +            event.preventDefault();
    +        }
    +
    +        if (this.onDownCallback)
    +        {
    +            this.onDownCallback.call(this.callbackContext, event);
    +        }
    +
    +        if (this._keys[event.keyCode] && this._keys[event.keyCode].isDown)
    +        {
    +            //  Key already down and still down, so update
    +            this._keys[event.keyCode].duration = this.game.time.now - this._keys[event.keyCode].timeDown;
    +        }
    +        else
    +        {
    +            if (!this._keys[event.keyCode])
    +            {
    +                //  Not used this key before, so register it
    +                this._keys[event.keyCode] = {
    +                    isDown: true,
    +                    timeDown: this.game.time.now,
    +                    timeUp: 0,
    +                    duration: 0
    +                };
    +            }
    +            else
    +            {
    +                //  Key used before but freshly down
    +                this._keys[event.keyCode].isDown = true;
    +                this._keys[event.keyCode].timeDown = this.game.time.now;
    +                this._keys[event.keyCode].duration = 0;
    +            }
    +        }
    +
    +        if (this._hotkeys[event.keyCode])
    +        {
    +            this._hotkeys[event.keyCode].processKeyDown(event);
    +        }
    +
    +    },
    +
    +	/**
    +	* Process the keyup event.
    +	* @method Phaser.Keyboard#processKeyUp
    +    * @param {KeyboardEvent} event
    +    * @protected
    +    */
    +    processKeyUp: function (event) {
    +
    +        if (this.game.input.disabled || this.disabled)
    +        {
    +            return;
    +        }
    +
    +        if (this._capture[event.keyCode])
    +        {
    +            event.preventDefault();
    +        }
    +
    +        if (this.onUpCallback)
    +        {
    +            this.onUpCallback.call(this.callbackContext, event);
    +        }
    +
    +        if (this._hotkeys[event.keyCode])
    +        {
    +            this._hotkeys[event.keyCode].processKeyUp(event);
    +        }
    +
    +        if (this._keys[event.keyCode])
    +        {
    +            this._keys[event.keyCode].isDown = false;
    +            this._keys[event.keyCode].timeUp = this.game.time.now;
    +        }
    +        else
    +        {
    +            //  Not used this key before, so register it
    +            this._keys[event.keyCode] = {
    +                isDown: false,
    +                timeDown: this.game.time.now,
    +                timeUp: this.game.time.now,
    +                duration: 0
    +            };
    +        }
    +
    +    },
    +
    +	/**
    +	* Reset the "isDown" state of all keys.
    +	* @method Phaser.Keyboard#reset
    +    */
    +    reset: function () {
    +
    +        for (var key in this._keys)
    +        {
    +            this._keys[key].isDown = false;
    +        }
    +
    +    },
    +
    +    /**
    +    * Returns the "just pressed" state of the key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms)
    +    * @method Phaser.Keyboard#justPressed
    +    * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR
    +    * @param {number} [duration=250] - The duration below which the key is considered as being just pressed.
    +    * @return {boolean} True if the key is just pressed otherwise false.
    +    */
    +    justPressed: function (keycode, duration) {
    +
    +        if (typeof duration === "undefined") { duration = 250; }
    +
    +        if (this._keys[keycode] && this._keys[keycode].isDown && this._keys[keycode].duration < duration)
    +        {
    +            return true;
    +        }
    +
    +        return false;
    +
    +    },
    +
    +    /**
    +    * Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms)
    +    * @method Phaser.Keyboard#justPressed
    +    * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR
    +    * @param {number} [duration=250] - The duration below which the key is considered as being just released.
    +    * @return {boolean} True if the key is just released otherwise false.
    +    */
    +    justReleased: function (keycode, duration) {
    +
    +        if (typeof duration === "undefined") { duration = 250; }
    +
    +        if (this._keys[keycode] && this._keys[keycode].isDown === false && (this.game.time.now - this._keys[keycode].timeUp < duration))
    +        {
    +            return true;
    +        }
    +
    +        return false;
    +
    +    },
    +
    +    /**
    +    * Returns true of the key is currently pressed down. Note that it can only detect key presses on the web browser.
    +    * @method Phaser.Keyboard#isDown
    +    * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR
    +    * @return {boolean} True if the key is currently down.
    +    */
    +    isDown: function (keycode) {
    +
    +        if (this._keys[keycode])
    +        {
    +            return this._keys[keycode].isDown;
    +        }
    +
    +		return false;
    +
    +    }
    +
    +};
    +
    +Phaser.Keyboard.A = "A".charCodeAt(0);
    +Phaser.Keyboard.B = "B".charCodeAt(0);
    +Phaser.Keyboard.C = "C".charCodeAt(0);
    +Phaser.Keyboard.D = "D".charCodeAt(0);
    +Phaser.Keyboard.E = "E".charCodeAt(0);
    +Phaser.Keyboard.F = "F".charCodeAt(0);
    +Phaser.Keyboard.G = "G".charCodeAt(0);
    +Phaser.Keyboard.H = "H".charCodeAt(0);
    +Phaser.Keyboard.I = "I".charCodeAt(0);
    +Phaser.Keyboard.J = "J".charCodeAt(0);
    +Phaser.Keyboard.K = "K".charCodeAt(0);
    +Phaser.Keyboard.L = "L".charCodeAt(0);
    +Phaser.Keyboard.M = "M".charCodeAt(0);
    +Phaser.Keyboard.N = "N".charCodeAt(0);
    +Phaser.Keyboard.O = "O".charCodeAt(0);
    +Phaser.Keyboard.P = "P".charCodeAt(0);
    +Phaser.Keyboard.Q = "Q".charCodeAt(0);
    +Phaser.Keyboard.R = "R".charCodeAt(0);
    +Phaser.Keyboard.S = "S".charCodeAt(0);
    +Phaser.Keyboard.T = "T".charCodeAt(0);
    +Phaser.Keyboard.U = "U".charCodeAt(0);
    +Phaser.Keyboard.V = "V".charCodeAt(0);
    +Phaser.Keyboard.W = "W".charCodeAt(0);
    +Phaser.Keyboard.X = "X".charCodeAt(0);
    +Phaser.Keyboard.Y = "Y".charCodeAt(0);
    +Phaser.Keyboard.Z = "Z".charCodeAt(0);
    +Phaser.Keyboard.ZERO = "0".charCodeAt(0);
    +Phaser.Keyboard.ONE = "1".charCodeAt(0);
    +Phaser.Keyboard.TWO = "2".charCodeAt(0);
    +Phaser.Keyboard.THREE = "3".charCodeAt(0);
    +Phaser.Keyboard.FOUR = "4".charCodeAt(0);
    +Phaser.Keyboard.FIVE = "5".charCodeAt(0);
    +Phaser.Keyboard.SIX = "6".charCodeAt(0);
    +Phaser.Keyboard.SEVEN = "7".charCodeAt(0);
    +Phaser.Keyboard.EIGHT = "8".charCodeAt(0);
    +Phaser.Keyboard.NINE = "9".charCodeAt(0);
    +Phaser.Keyboard.NUMPAD_0 = 96;
    +Phaser.Keyboard.NUMPAD_1 = 97;
    +Phaser.Keyboard.NUMPAD_2 = 98;
    +Phaser.Keyboard.NUMPAD_3 = 99;
    +Phaser.Keyboard.NUMPAD_4 = 100;
    +Phaser.Keyboard.NUMPAD_5 = 101;
    +Phaser.Keyboard.NUMPAD_6 = 102;
    +Phaser.Keyboard.NUMPAD_7 = 103;
    +Phaser.Keyboard.NUMPAD_8 = 104;
    +Phaser.Keyboard.NUMPAD_9 = 105;
    +Phaser.Keyboard.NUMPAD_MULTIPLY = 106;
    +Phaser.Keyboard.NUMPAD_ADD = 107;
    +Phaser.Keyboard.NUMPAD_ENTER = 108;
    +Phaser.Keyboard.NUMPAD_SUBTRACT = 109;
    +Phaser.Keyboard.NUMPAD_DECIMAL = 110;
    +Phaser.Keyboard.NUMPAD_DIVIDE = 111;
    +Phaser.Keyboard.F1 = 112;
    +Phaser.Keyboard.F2 = 113;
    +Phaser.Keyboard.F3 = 114;
    +Phaser.Keyboard.F4 = 115;
    +Phaser.Keyboard.F5 = 116;
    +Phaser.Keyboard.F6 = 117;
    +Phaser.Keyboard.F7 = 118;
    +Phaser.Keyboard.F8 = 119;
    +Phaser.Keyboard.F9 = 120;
    +Phaser.Keyboard.F10 = 121;
    +Phaser.Keyboard.F11 = 122;
    +Phaser.Keyboard.F12 = 123;
    +Phaser.Keyboard.F13 = 124;
    +Phaser.Keyboard.F14 = 125;
    +Phaser.Keyboard.F15 = 126;
    +Phaser.Keyboard.COLON = 186;
    +Phaser.Keyboard.EQUALS = 187;
    +Phaser.Keyboard.UNDERSCORE = 189;
    +Phaser.Keyboard.QUESTION_MARK = 191;
    +Phaser.Keyboard.TILDE = 192;
    +Phaser.Keyboard.OPEN_BRACKET = 219;
    +Phaser.Keyboard.BACKWARD_SLASH = 220;
    +Phaser.Keyboard.CLOSED_BRACKET = 221;
    +Phaser.Keyboard.QUOTES = 222;
    +Phaser.Keyboard.BACKSPACE = 8;
    +Phaser.Keyboard.TAB = 9;
    +Phaser.Keyboard.CLEAR = 12;
    +Phaser.Keyboard.ENTER = 13;
    +Phaser.Keyboard.SHIFT = 16;
    +Phaser.Keyboard.CONTROL = 17;
    +Phaser.Keyboard.ALT = 18;
    +Phaser.Keyboard.CAPS_LOCK = 20;
    +Phaser.Keyboard.ESC = 27;
    +Phaser.Keyboard.SPACEBAR = 32;
    +Phaser.Keyboard.PAGE_UP = 33;
    +Phaser.Keyboard.PAGE_DOWN = 34;
    +Phaser.Keyboard.END = 35;
    +Phaser.Keyboard.HOME = 36;
    +Phaser.Keyboard.LEFT = 37;
    +Phaser.Keyboard.UP = 38;
    +Phaser.Keyboard.RIGHT = 39;
    +Phaser.Keyboard.DOWN = 40;
    +Phaser.Keyboard.INSERT = 45;
    +Phaser.Keyboard.DELETE = 46;
    +Phaser.Keyboard.HELP = 47;
    +Phaser.Keyboard.NUM_LOCK = 144;
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/LinkedList.js.html b/docs/LinkedList.js.html new file mode 100644 index 00000000..4dce9d29 --- /dev/null +++ b/docs/LinkedList.js.html @@ -0,0 +1,598 @@ + + + + + + Phaser Source: core/LinkedList.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/LinkedList.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* A basic linked list data structure.
    +*
    +* @class Phaser.LinkedList
    +* @constructor
    +*/
    +Phaser.LinkedList = function () {
    +
    +    /**
    +	* @property {object} next - Next element in the list.
    +	* @default
    +	*/
    +    this.next = null;
    +
    +    /**
    +	* @property {object} prev - Previous element in the list.
    +	* @default
    +	*/
    +    this.prev = null;
    +
    +    /**
    +	* @property {object} first - First element in the list.
    +	* @default
    +	*/
    +    this.first = null;
    +
    +    /**
    +	* @property {object} last - Last element in the list.
    +	* @default
    +	*/
    +    this.last = null;
    +    
    +    /**
    +	* @property {object} game - Number of elements in the list.
    +	* @default
    +	*/
    +    this.total = 0;
    +
    +};
    +
    +Phaser.LinkedList.prototype = {
    +
    +	/**
    +    * Adds a new element to this linked list.
    +	* 
    +	* @method Phaser.LinkedList#add
    +	* @param {object} child - The element to add to this list. Can be a Phaser.Sprite or any other object you need to quickly iterate through.
    +	* @return {object} The child that was added.
    +    */
    +    add: function (child) {
    +
    +    	//	If the list is empty
    +    	if (this.total == 0 && this.first == null && this.last == null)
    +    	{
    +    		this.first = child;
    +    		this.last = child;
    +	    	this.next = child;
    +	    	child.prev = this;
    +	    	this.total++;
    +    		return child;
    +    	}
    +
    +    	//	Get gets appended to the end of the list, regardless of anything, and it won't have any children of its own (non-nested list)
    +    	this.last.next = child;
    +
    +    	child.prev = this.last;
    +
    +    	this.last = child;
    +
    +		this.total++;
    +
    +		return child;
    +
    +    },
    +
    +	/**
    +    * Removes the given element from this linked list if it exists.
    + 	* 
    + 	* @method Phaser.LinkedList#remove
    + 	* @param {object} child - The child to be removed from the list.
    +    */
    +    remove: function (child) {
    +
    +    	if (child == this.first)
    +    	{
    +			// It was 'first', make 'first' point to first.next
    +    		this.first = this.first.next;
    +    	}      
    +		else if (child == this.last)
    +		{
    +			// It was 'last', make 'last' point to last.prev
    +			this.last = this.last.prev;
    +		} 
    +
    +		if (child.prev)
    +		{
    +			// make child.prev.next point to childs.next instead of child
    +			child.prev.next = child.next; 
    +		} 
    +
    +		if (child.next)
    +		{
    +			// make child.next.prev point to child.prev instead of child
    +			child.next.prev = child.prev;
    +		}
    +
    +		child.next = child.prev = null;
    +
    +		if (this.first == null )
    +		{
    +			this.last = null;
    +		}
    +
    +		this.total--;
    +
    +    },
    +
    +	/**
    +    * Calls a function on all members of this list, using the member as the context for the callback.
    +    * The function must exist on the member.
    +  	* 
    +  	* @method Phaser.LinkedList#callAll
    +  	* @param {function} callback - The function to call.
    +    */
    +    callAll: function (callback) {
    +
    +    	if (!this.first || !this.last)
    +    	{
    +    		return;
    +    	}
    +
    +		var entity = this.first;
    +		
    +		do	
    +		{
    +			if (entity && entity[callback])
    +			{
    +				entity[callback].call(entity);
    +			}
    +
    +			entity = entity.next;
    +
    +		}
    +		while(entity != this.last.next)			
    +
    +    }
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Loader.js.html b/docs/Loader.js.html new file mode 100644 index 00000000..25a67acf --- /dev/null +++ b/docs/Loader.js.html @@ -0,0 +1,1552 @@ + + + + + + Phaser Source: loader/Loader.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: loader/Loader.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser loader constructor.
    +* The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files.
    +* It uses a combination of Image() loading and xhr and provides progress and completion callbacks.
    +* @class Phaser.Loader
    +* @classdesc  The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files.
    +* It uses a combination of Image() loading and xhr and provides progress and completion callbacks.
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +*/
    +Phaser.Loader = function (game) {
    +
    +	/**
    +    * @property {Phaser.Game} game - Local reference to game.
    +	*/
    +	this.game = game;
    +
    +	/**
    +	* @property {array} _keys - Array stores assets keys. So you can get that asset by its unique key.
    +	* @private
    +    */
    +	this._keys = [];
    +
    +	/**
    +	* @property {Description} _fileList - Contains all the assets file infos.
    +	* @private
    +    */
    +	this._fileList = {};
    +
    +	/**
    +	* @property {number} _progressChunk - Indicates assets loading progress. (from 0 to 100)
    +	* @private
    +	* @default
    +	*/
    +	this._progressChunk = 0;
    +
    +	/**
    +	* @property {XMLHttpRequest} - An XMLHttpRequest object used for loading text and audio data.
    +	* @private
    +	*/
    +	this._xhr = new XMLHttpRequest();
    +
    +	/** 
    +	* @property {number} - Length of assets queue.
    +	* @default
    +	*/
    +	this.queueSize = 0;
    +
    +	/**
    +	* @property {boolean} isLoading - True if the Loader is in the process of loading the queue.
    +	* @default
    +	*/
    +	this.isLoading = false;
    +
    +	/**
    +	* @property {boolean} hasLoaded - True if all assets in the queue have finished loading.
    +	* @default
    +	*/
    +	this.hasLoaded = false;
    +
    +	/**
    +	* @property {number} progress - The Load progress percentage value (from 0 to 100)
    +	* @default
    +	*/
    +	this.progress = 0;
    +
    +	/**
    +	* You can optionally link a sprite to the preloader.
    +	* If you do so the Sprite's width or height will be cropped based on the percentage loaded.
    +	* @property {Description} preloadSprite
    +	* @default
    +	*/
    +	this.preloadSprite = null;
    +
    +	/**
    +	* @property {string} crossOrigin - The crossOrigin value applied to loaded images
    +	*/
    +	this.crossOrigin = '';
    +
    +	/**
    +	* If you want to append a URL before the path of any asset you can set this here.
    +	* Useful if you need to allow an asset url to be configured outside of the game code.
    +	* MUST have / on the end of it!
    +	* @property {string} baseURL
    +	* @default
    +	*/
    +	this.baseURL = '';
    +
    +	/**
    +	* @property {Phaser.Signal} onFileComplete - Event signal.
    +	*/
    +	this.onFileComplete = new Phaser.Signal;
    +	
    +	/**
    +	* @property {Phaser.Signal} onFileError - Event signal.
    +	*/
    +	this.onFileError = new Phaser.Signal;
    +	
    +	/**
    +	* @property {Phaser.Signal} onLoadStart - Event signal.
    +	*/
    +	this.onLoadStart = new Phaser.Signal;
    +	
    +	/**
    +	* @property {Phaser.Signal} onLoadComplete - Event signal.
    +	*/
    +	this.onLoadComplete = new Phaser.Signal;
    +
    +};
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY = 0;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Loader.TEXTURE_ATLAS_JSON_HASH = 1;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Loader.TEXTURE_ATLAS_XML_STARLING = 2;
    +
    +Phaser.Loader.prototype = {
    +
    +	/**
    +	* You can set a Sprite to be a "preload" sprite by passing it to this method.
    +	* A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time.
    +	* This allows you to easily make loading bars for games.
    +	*
    +	* @method Phaser.Loader#setPreloadSprite
    +    * @param {Phaser.Sprite} sprite - The sprite that will be cropped during the load.
    +    * @param {number} [direction=0] - A value of zero means the sprite width will be cropped, a value of 1 means its height will be cropped.
    +    */
    +	setPreloadSprite: function (sprite, direction) {
    +
    +		direction = direction || 0;
    +
    +		this.preloadSprite = { sprite: sprite, direction: direction, width: sprite.width, height: sprite.height, crop: null };
    +
    +		if (direction == 0)
    +		{
    +			//	Horizontal crop
    +			this.preloadSprite.crop = new Phaser.Rectangle(0, 0, 1, sprite.height);
    +		}
    +		else
    +		{
    +			//	Vertical crop
    +			this.preloadSprite.crop = new Phaser.Rectangle(0, 0, sprite.width, 1);
    +		}
    +
    +		sprite.crop = this.preloadSprite.crop;
    +		sprite.cropEnabled = true;
    +
    +	},
    +
    +	/**
    +	* Check whether asset exists with a specific key.
    +	*
    +	* @method Phaser.Loader#checkKeyExists
    +	* @param {string} key - Key of the asset you want to check.
    +	* @return {boolean} Return true if exists, otherwise return false.
    +	*/
    +	checkKeyExists: function (key) {
    +
    +		if (this._fileList[key])
    +		{
    +			return true;
    +		}
    +		else
    +		{
    +			return false;
    +		}
    +		
    +	},
    +
    +	/**
    +	* Reset loader, this will remove all loaded assets.
    +	*
    +	* @method Phaser.Loader#reset
    +	*/
    +	reset: function () {
    +
    +		this.preloadSprite = null;
    +		this.queueSize = 0;
    +		this.isLoading = false;
    +
    +	},
    +
    +	/**
    +	* Internal function that adds a new entry to the file list. Do not call directly.
    +	*
    +	* @method Phaser.Loader#addToFileList
    +	* @param {Description} type - Description.
    +	* @param {string} key - Description.
    +	* @param {string} url - URL of Description.
    +	* @param {Description} properties - Description.
    +	* @protected
    +	*/
    +	addToFileList: function (type, key, url, properties) {
    +
    +		var entry = {
    +			type: type,
    +			key: key,
    +			url: url,
    +			data: null,
    +			error: false,
    +			loaded: false
    +		};
    +
    +		if (typeof properties !== "undefined")
    +		{
    +			for (var prop in properties)
    +			{
    +				entry[prop] = properties[prop];
    +			}
    +		}
    +
    +		this._fileList[key] = entry;
    +
    +		this._keys.push(key);
    +
    +		this.queueSize++;
    +
    +	},
    +
    +	/**
    +	* Add an image to the Loader.
    +	*
    +	* @method Phaser.Loader#image
    +	* @param {string} key - Unique asset key of this image file.
    +	* @param {string} url - URL of image file.
    +	* @param {boolean} overwrite - If an entry with a matching key already exists this will over-write it
    +	*/
    +	image: function (key, url, overwrite) {
    +
    +		if (typeof overwrite === "undefined") { overwrite = false; }
    +
    +		if (overwrite || this.checkKeyExists(key) == false)
    +		{
    +			this.addToFileList('image', key, url);
    +		}
    +
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Add a text file to the Loader.
    +	*
    +	* @method Phaser.Loader#text
    +	* @param {string} key - Unique asset key of the text file.
    +	* @param {string} url - URL of the text file.
    +	* @param {boolean} overwrite - True if Description.
    +	*/
    +	text: function (key, url, overwrite) {
    +
    +		if (typeof overwrite === "undefined") { overwrite = false; }
    +
    +		if (overwrite || this.checkKeyExists(key) == false)
    +		{
    +			this.addToFileList('text', key, url);
    +		}
    +
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Add a new sprite sheet to the loader.
    +	*
    +	* @method Phaser.Loader#spritesheet
    +	* @param {string} key - Unique asset key of the sheet file.
    +	* @param {string} url - URL of the sheet file.
    +	* @param {number} frameWidth - Width of each single frame.
    +	* @param {number} frameHeight - Height of each single frame.
    +	* @param {number} [frameMax=-1] - How many frames in this sprite sheet. If not specified it will divide the whole image into frames.
    +	*/
    +	spritesheet: function (key, url, frameWidth, frameHeight, frameMax) {
    +
    +		if (typeof frameMax === "undefined") { frameMax = -1; }
    +
    +		if (this.checkKeyExists(key) === false)
    +		{
    +			this.addToFileList('spritesheet', key, url, { frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax });
    +		}
    +
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Add a new tile set to the loader. These are used in the rendering of tile maps.
    +	*
    +	* @method Phaser.Loader#tileset
    +	* @param {string} key - Unique asset key of the tileset file.
    +	* @param {string} url - URL of the tileset.
    +	* @param {number} tileWidth - Width of each single tile in pixels.
    +	* @param {number} tileHeight - Height of each single tile in pixels.
    +	* @param {number} [tileMax=-1] - How many tiles in this tileset. If not specified it will divide the whole image into tiles.
    +	* @param {number} [tileMargin=0] - If the tiles have been drawn with a margin, specify the amount here.
    +	* @param {number} [tileSpacing=0] - If the tiles have been drawn with spacing between them, specify the amount here.
    +	*/
    +	tileset: function (key, url, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing) {
    +
    +		if (typeof tileMax === "undefined") { tileMax = -1; }
    +		if (typeof tileMargin === "undefined") { tileMargin = 0; }
    +		if (typeof tileSpacing === "undefined") { tileSpacing = 0; }
    +
    +		if (this.checkKeyExists(key) === false)
    +		{
    +			this.addToFileList('tileset', key, url, { tileWidth: tileWidth, tileHeight: tileHeight, tileMax: tileMax, tileMargin: tileMargin, tileSpacing: tileSpacing });
    +		}
    +
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Add a new audio file to the loader.
    +	*
    +	* @method Phaser.Loader#audio
    +	* @param {string} key - Unique asset key of the audio file.
    +	* @param {Array} urls - An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ].
    +	* @param {boolean} autoDecode - When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process.
    +	*/
    +	audio: function (key, urls, autoDecode) {
    +
    +		if (typeof autoDecode === "undefined") { autoDecode = true; }
    +
    +		if (this.checkKeyExists(key) === false)
    +		{
    +			this.addToFileList('audio', key, urls, { buffer: null, autoDecode: autoDecode });
    +		}
    +
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Add a new tilemap loading request.
    +	*
    +	* @method Phaser.Loader#tilemap
    +	* @param {string} key - Unique asset key of the tilemap data.
    +	* @param {string} tilesetURL - The url of the tile set image file.
    +	* @param {string} [mapDataURL] - The url of the map data file (csv/json)
    +	* @param {object} [mapData] - An optional JSON data object (can be given in place of a URL).
    +	* @param {string} [format] - The format of the map data.
    +	*/
    +	tilemap: function (key, mapDataURL, mapData, format) {
    +
    +		if (typeof mapDataURL === "undefined") { mapDataURL = null; }
    +		if (typeof mapData === "undefined") { mapData = null; }
    +		if (typeof format === "undefined") { format = Phaser.Tilemap.CSV; }
    +
    +		if (mapDataURL == null && mapData == null)
    +		{
    +			console.warn('Phaser.Loader.tilemap - Both mapDataURL and mapData are null. One must be set.');
    +
    +			return this;
    +		}
    +
    +		if (this.checkKeyExists(key) === false)
    +		{
    +			//  A URL to a json/csv file has been given
    +			if (mapDataURL)
    +			{
    +				this.addToFileList('tilemap', key, mapDataURL, { format: format });
    +			}
    +			else
    +			{
    +				switch (format)
    +				{
    +					//  A csv string or object has been given
    +					case Phaser.Tilemap.CSV:
    +						break;
    +
    +					//  An xml string or object has been given
    +					case Phaser.Tilemap.TILED_JSON:
    +
    +						if (typeof mapData === 'string')
    +						{
    +							mapData = JSON.parse(mapData);
    +						}
    +						break;
    +				}
    +
    +				this.game.cache.addTilemap(key, null, mapData, format);
    +
    +			}
    +		}
    +
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Add a new bitmap font loading request.
    +	*
    +	* @method Phaser.Loader#bitmapFont
    +	* @param {string} key - Unique asset key of the bitmap font.
    +	* @param {string} textureURL - The url of the font image file.
    +	* @param {string} [xmlURL] - The url of the font data file (xml/fnt)
    +	* @param {object} [xmlData] - An optional XML data object.
    +	*/
    +	bitmapFont: function (key, textureURL, xmlURL, xmlData) {
    +
    +		if (typeof xmlURL === "undefined") { xmlURL = null; }
    +		if (typeof xmlData === "undefined") { xmlData = null; }
    +
    +		if (this.checkKeyExists(key) === false)
    +		{
    +			//  A URL to a json/xml file has been given
    +			if (xmlURL)
    +			{
    +				this.addToFileList('bitmapfont', key, textureURL, { xmlURL: xmlURL });
    +			}
    +			else
    +			{
    +				//  An xml string or object has been given
    +				if (typeof xmlData === 'string')
    +				{
    +					var xml;
    +
    +					try  {
    +						if (window['DOMParser'])
    +						{
    +							var domparser = new DOMParser();
    +							xml = domparser.parseFromString(xmlData, "text/xml");
    +						}
    +						else
    +						{
    +							xml = new ActiveXObject("Microsoft.XMLDOM");
    +							xml.async = 'false';
    +							xml.loadXML(xmlData);
    +						}
    +					}
    +					catch (e)
    +					{
    +						xml = undefined;
    +					}
    +
    +					if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length)
    +					{
    +						throw new Error("Phaser.Loader. Invalid Bitmap Font XML given");
    +					}
    +					else
    +					{
    +						this.addToFileList('bitmapfont', key, textureURL, { xmlURL: null, xmlData: xml });
    +					}
    +				}
    +			}
    +		}
    +
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Add a new texture atlas to the loader. This atlas uses the JSON Array data format.
    +	*
    +	* @method Phaser.Loader#atlasJSONArray
    +	* @param {string} key - Unique asset key of the bitmap font.
    +	* @param {Description} atlasURL - The url of the Description.
    +	* @param {Description} atlasData - Description.
    +	*/
    +	atlasJSONArray: function (key, textureURL, atlasURL, atlasData) {
    +
    +		return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY);
    +
    +	},
    +
    +	/**
    +	* Add a new texture atlas to the loader. This atlas uses the JSON Hash data format.
    +	*
    +	* @method Phaser.Loader#atlasJSONHash
    +	* @param {string} key - Unique asset key of the bitmap font.
    +	* @param {Description} atlasURL - The url of the Description.
    +	* @param {Description} atlasData - Description.
    +	*/
    +	atlasJSONHash: function (key, textureURL, atlasURL, atlasData) {
    +
    +		return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH);
    +
    +	},
    +
    +	/**
    +	* Add a new texture atlas to the loader. This atlas uses the Starling XML data format.
    +	*
    +	* @method Phaser.Loader#atlasXML
    +	* @param {string} key - Unique asset key of the bitmap font.
    +	* @param {Description} atlasURL - The url of the Description.
    +	* @param {Description} atlasData - Description.
    +	*/
    +	atlasXML: function (key, textureURL, atlasURL, atlasData) {
    +
    +		return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
    +
    +	},
    +
    +	/**
    +	* Add a new texture atlas to the loader.
    +	*
    +	* @method Phaser.Loader#atlas
    +	* @param {string} key - Unique asset key of the texture atlas file.
    +	* @param {string} textureURL - The url of the texture atlas image file.
    +	* @param {string} [atlasURL] - The url of the texture atlas data file (json/xml). You don't need this if you are passing an atlasData object instead.
    +	* @param {object} [atlasData] - A JSON or XML data object. You don't need this if the data is being loaded from a URL.
    +	* @param {number} [format] - A value describing the format of the data, the default is Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY.
    +	*/
    +	atlas: function (key, textureURL, atlasURL, atlasData, format) {
    +
    +		if (typeof atlasURL === "undefined") { atlasURL = null; }
    +		if (typeof atlasData === "undefined") { atlasData = null; }
    +		if (typeof format === "undefined") { format = Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY; }
    +
    +		if (this.checkKeyExists(key) === false)
    +		{
    +			//  A URL to a json/xml file has been given
    +			if (atlasURL)
    +			{
    +				this.addToFileList('textureatlas', key, textureURL, { atlasURL: atlasURL, format: format });
    +			}
    +			else
    +			{
    +				switch (format)
    +				{
    +					//  A json string or object has been given
    +					case Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY: 
    +
    +						if (typeof atlasData === 'string')
    +						{
    +							atlasData = JSON.parse(atlasData);
    +						}
    +						break;
    +
    +					//  An xml string or object has been given
    +					case Phaser.Loader.TEXTURE_ATLAS_XML_STARLING:
    +
    +						if (typeof atlasData === 'string')
    +						{
    +							var xml;
    +
    +							try  {
    +								if (window['DOMParser'])
    +								{
    +									var domparser = new DOMParser();
    +									xml = domparser.parseFromString(atlasData, "text/xml");
    +								}
    +								else
    +								{
    +									xml = new ActiveXObject("Microsoft.XMLDOM");
    +									xml.async = 'false';
    +									xml.loadXML(atlasData);
    +								}
    +							}
    +							catch (e)
    +							{
    +								xml = undefined;
    +							}
    +
    +							if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length)
    +							{
    +								throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");
    +							}
    +							else
    +							{
    +								atlasData = xml;
    +							}
    +						}
    +						break;
    +				}
    +
    +				this.addToFileList('textureatlas', key, textureURL, { atlasURL: null, atlasData: atlasData, format: format });
    +
    +			}
    +
    +		}
    +
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Remove loading request of a file.
    +	*
    +	* @method Phaser.Loader#removeFile
    +	* @param key {string} Key of the file you want to remove.
    +	*/
    +	removeFile: function (key) {
    +
    +		delete this._fileList[key];
    +
    +	},
    +
    +	/**
    +	* Remove all file loading requests.
    +	*
    +	* @method Phaser.Loader#removeAll
    +	*/
    +	removeAll: function () {
    +
    +		this._fileList = {};
    +
    +	},
    +
    +	/**
    +	* Start loading the assets. Normally you don't need to call this yourself as the StateManager will do so.
    +	*
    +	* @method Phaser.Loader#start
    +	*/
    +	start: function () {
    +
    +		if (this.isLoading)
    +		{
    +			return;
    +		}
    +
    +		this.progress = 0;
    +		this.hasLoaded = false;
    +		this.isLoading = true;
    +
    +		this.onLoadStart.dispatch(this.queueSize);
    +
    +		if (this._keys.length > 0)
    +		{
    +			this._progressChunk = 100 / this._keys.length;
    +			this.loadFile();
    +		}
    +		else
    +		{
    +			this.progress = 100;
    +			this.hasLoaded = true;
    +			this.onLoadComplete.dispatch();
    +		}
    +
    +	},
    +
    +	/**
    +	* Load files. Private method ONLY used by loader.
    +	*
    +	* @method Phaser.Loader#loadFile
    +	* @private
    +	*/
    +	loadFile: function () {
    +
    +		var file = this._fileList[this._keys.shift()];
    +		var _this = this;
    +
    +		//  Image or Data?
    +		switch (file.type)
    +		{
    +			case 'image':
    +			case 'spritesheet':
    +			case 'textureatlas':
    +			case 'bitmapfont':
    +			case 'tileset':
    +				file.data = new Image();
    +				file.data.name = file.key;
    +				file.data.onload = function () {
    +					return _this.fileComplete(file.key);
    +				};
    +				file.data.onerror = function () {
    +					return _this.fileError(file.key);
    +				};
    +				file.data.crossOrigin = this.crossOrigin;
    +				file.data.src = this.baseURL + file.url;
    +				break;
    +
    +			case 'audio':
    +				file.url = this.getAudioURL(file.url);
    +
    +				if (file.url !== null)
    +				{
    +					//  WebAudio or Audio Tag?
    +					if (this.game.sound.usingWebAudio)
    +					{
    +						this._xhr.open("GET", this.baseURL + file.url, true);
    +						this._xhr.responseType = "arraybuffer";
    +						this._xhr.onload = function () {
    +							return _this.fileComplete(file.key);
    +						};
    +						this._xhr.onerror = function () {
    +							return _this.fileError(file.key);
    +						};
    +						this._xhr.send();
    +					}
    +					else if (this.game.sound.usingAudioTag)
    +					{
    +						if (this.game.sound.touchLocked)
    +						{
    +							//  If audio is locked we can't do this yet, so need to queue this load request. Bum.
    +							file.data = new Audio();
    +							file.data.name = file.key;
    +							file.data.preload = 'auto';
    +							file.data.src = this.baseURL + file.url;
    +							this.fileComplete(file.key);
    +						}
    +						else
    +						{
    +							file.data = new Audio();
    +							file.data.name = file.key;
    +							file.data.onerror = function () {
    +								return _this.fileError(file.key);
    +							};
    +							file.data.preload = 'auto';
    +							file.data.src = this.baseURL + file.url;
    +							file.data.addEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete(file.key), false);
    +							file.data.load();
    +						}
    +					}
    +				}
    +				else
    +				{
    +					this.fileError(file.key);
    +				}
    +
    +				break;
    +
    +			case 'tilemap':
    +				this._xhr.open("GET", this.baseURL + file.url, true);
    +				this._xhr.responseType = "text";
    +
    +				if (file.format == Phaser.Tilemap.TILED_JSON)
    +				{
    +					this._xhr.onload = function () {
    +						return _this.jsonLoadComplete(file.key);
    +					};
    +				}
    +				else if (file.format == Phaser.Tilemap.CSV)
    +				{
    +					this._xhr.onload = function () {
    +						return _this.csvLoadComplete(file.key);
    +					};
    +				}
    +
    +				this._xhr.onerror = function () {
    +					return _this.dataLoadError(file.key);
    +				};
    +				this._xhr.send();
    +				break;
    +
    +			case 'text':
    +				this._xhr.open("GET", this.baseURL + file.url, true);
    +				this._xhr.responseType = "text";
    +				this._xhr.onload = function () {
    +					return _this.fileComplete(file.key);
    +				};
    +				this._xhr.onerror = function () {
    +					return _this.fileError(file.key);
    +				};
    +				this._xhr.send();
    +				break;
    +		}
    +
    +	},
    +
    +	/**
    +	* Private method ONLY used by loader.
    +	* @method Phaser.Loader#getAudioURL
    +	* @param {Description} urls - Description.
    +	* @private
    +	*/
    +	getAudioURL: function (urls) {
    +
    +		var extension;
    +
    +		for (var i = 0; i < urls.length; i++)
    +		{
    +			extension = urls[i].toLowerCase();
    +			extension = extension.substr((Math.max(0, extension.lastIndexOf(".")) || Infinity) + 1);
    +
    +			if (this.game.device.canPlayAudio(extension))
    +			{
    +				return urls[i];
    +			}
    +
    +		}
    +
    +		return null;
    +
    +	},
    +
    +	/**
    +	* Error occured when load a file.
    +	*
    +	* @method Phaser.Loader#fileError
    +	* @param {string} key - Key of the error loading file.
    +	*/
    +	fileError: function (key) {
    +
    +		this._fileList[key].loaded = true;
    +		this._fileList[key].error = true;
    +
    +		this.onFileError.dispatch(key);
    +
    +		console.warn("Phaser.Loader error loading file: " + key + ' from URL ' + this._fileList[key].url);
    +
    +		this.nextFile(key, false);
    +
    +	},
    +
    +	/**
    +	* Called when a file is successfully loaded.
    +	*
    +	* @method Phaser.Loader#fileComplete
    +	* @param {string} key - Key of the successfully loaded file.
    +	*/
    +	fileComplete: function (key) {
    +
    +		if (!this._fileList[key])
    +		{
    +			console.warn('Phaser.Loader fileComplete invalid key ' + key);
    +			return;
    +		}
    +		
    +		this._fileList[key].loaded = true;
    +
    +		var file = this._fileList[key];
    +		var loadNext = true;
    +		var _this = this;
    +
    +		switch (file.type)
    +		{
    +			case 'image':
    +
    +				this.game.cache.addImage(file.key, file.url, file.data);
    +				break;
    +
    +			case 'spritesheet':
    +
    +				this.game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax);
    +				break;
    +
    +			case 'tileset':
    +
    +				this.game.cache.addTileset(file.key, file.url, file.data, file.tileWidth, file.tileHeight, file.tileMax, file.tileMargin, file.tileSpacing);
    +				break;
    +
    +			case 'textureatlas':
    +
    +				if (file.atlasURL == null)
    +				{
    +					this.game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format);
    +				}
    +				else
    +				{
    +					//  Load the JSON or XML before carrying on with the next file
    +					loadNext = false;
    +					this._xhr.open("GET", this.baseURL + file.atlasURL, true);
    +					this._xhr.responseType = "text";
    +
    +					if (file.format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY || file.format == Phaser.Loader.TEXTURE_ATLAS_JSON_HASH)
    +					{
    +						this._xhr.onload = function () {
    +							return _this.jsonLoadComplete(file.key);
    +						};
    +					}
    +					else if (file.format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING)
    +					{
    +						this._xhr.onload = function () {
    +							return _this.xmlLoadComplete(file.key);
    +						};
    +					}
    +
    +					this._xhr.onerror = function () {
    +						return _this.dataLoadError(file.key);
    +					};
    +					this._xhr.send();
    +				}
    +				break;
    +
    +			case 'bitmapfont':
    +
    +				if (file.xmlURL == null)
    +				{
    +					this.game.cache.addBitmapFont(file.key, file.url, file.data, file.xmlData);
    +				}
    +				else
    +				{
    +					//  Load the XML before carrying on with the next file
    +					loadNext = false;
    +					this._xhr.open("GET", this.baseURL + file.xmlURL, true);
    +					this._xhr.responseType = "text";
    +
    +					this._xhr.onload = function () {
    +						return _this.xmlLoadComplete(file.key);
    +					};
    +
    +					this._xhr.onerror = function () {
    +						return _this.dataLoadError(file.key);
    +					};
    +					this._xhr.send();
    +				}
    +				break;
    +
    +			case 'audio':
    +
    +				if (this.game.sound.usingWebAudio)
    +				{
    +					file.data = this._xhr.response;
    +
    +					this.game.cache.addSound(file.key, file.url, file.data, true, false);
    +
    +					if (file.autoDecode)
    +					{
    +						this.game.cache.updateSound(key, 'isDecoding', true);
    +
    +						var that = this;
    +						var key = file.key;
    +
    +						this.game.sound.context.decodeAudioData(file.data, function (buffer) {
    +							if (buffer)
    +							{
    +								that.game.cache.decodedSound(key, buffer);
    +							}
    +						});
    +					}
    +				}
    +				else
    +				{
    +					file.data.removeEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete);
    +					this.game.cache.addSound(file.key, file.url, file.data, false, true);
    +				}
    +				break;
    +
    +			case 'text':
    +				file.data = this._xhr.responseText;
    +				this.game.cache.addText(file.key, file.url, file.data);
    +				break;
    +		}
    +
    +		if (loadNext)
    +		{
    +			this.nextFile(key, true);
    +		}
    +
    +	},
    +
    +	/**
    +	* Successfully loaded a JSON file.
    +	*
    +	* @method Phaser.Loader#jsonLoadComplete
    +	* @param {string} key - Key of the loaded JSON file.
    +	*/
    +	jsonLoadComplete: function (key) {
    +
    +		var data = JSON.parse(this._xhr.responseText);
    +		var file = this._fileList[key];
    +
    +		if (file.type == 'tilemap')
    +		{
    +			this.game.cache.addTilemap(file.key, file.url, data, file.format);
    +		}
    +		else
    +		{
    +			this.game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format);
    +		}
    +
    +		this.nextFile(key, true);
    +
    +	},
    +
    +	/**
    +	* Successfully loaded a CSV file.
    +	*
    +	* @method Phaser.Loader#csvLoadComplete
    +	* @param {string} key - Key of the loaded CSV file.
    +	*/
    +	csvLoadComplete: function (key) {
    +
    +		var data = this._xhr.responseText;
    +		var file = this._fileList[key];
    +
    +		this.game.cache.addTilemap(file.key, file.url, data, file.format);
    +
    +		this.nextFile(key, true);
    +
    +	},
    +
    +	/**
    +	* Error occured when load a JSON.
    +	*
    +	* @method Phaser.Loader#dataLoadError
    +	* @param {string} key - Key of the error loading JSON file.
    +	*/
    +	dataLoadError: function (key) {
    +
    +		var file = this._fileList[key];
    +
    +		file.error = true;
    +
    +		console.warn("Phaser.Loader dataLoadError: " + key);
    +
    +		this.nextFile(key, true);
    +
    +	},
    +
    +	/**
    +	* Successfully loaded an XML file.
    +	*
    +	* @method Phaser.Loader#xmlLoadComplete
    +	* @param {string} key - Key of the loaded XML file.
    +	*/
    +	xmlLoadComplete: function (key) {
    +
    +		var data = this._xhr.responseText;
    +		var xml;
    +
    +		try
    +		{
    +			if (window['DOMParser'])
    +			{
    +				var domparser = new DOMParser();
    +				xml = domparser.parseFromString(data, "text/xml");
    +			}
    +			else
    +			{
    +				xml = new ActiveXObject("Microsoft.XMLDOM");
    +				xml.async = 'false';
    +				xml.loadXML(data);
    +			}
    +		}
    +		catch (e)
    +		{
    +			xml = undefined;
    +		}
    +
    +		if (!xml || !xml.documentElement || xml.getElementsByTagName("parsererror").length)
    +		{
    +			throw new Error("Phaser.Loader. Invalid XML given");
    +		}
    +
    +		var file = this._fileList[key];
    +
    +		if (file.type == 'bitmapfont')
    +		{
    +			this.game.cache.addBitmapFont(file.key, file.url, file.data, xml);
    +		}
    +		else if (file.type == 'textureatlas')
    +		{
    +			this.game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format);
    +		}
    +
    +		this.nextFile(key, true);
    +
    +	},
    +
    +	/**
    +	* Handle loading next file.
    +	*
    +	* @param previousKey {string} Key of previous loaded asset.
    +	* @param success {boolean} Whether the previous asset loaded successfully or not.
    +	* @private
    +	*/
    +	nextFile: function (previousKey, success) {
    +
    +		this.progress = Math.round(this.progress + this._progressChunk);
    +
    +		if (this.progress > 100)
    +		{
    +			this.progress = 100;
    +		}
    +
    +		if (this.preloadSprite !== null)
    +		{
    +			if (this.preloadSprite.direction == 0)
    +			{
    +				this.preloadSprite.crop.width = Math.floor((this.preloadSprite.width / 100) * this.progress);
    +			}
    +			else
    +			{
    +				this.preloadSprite.crop.height = Math.floor((this.preloadSprite.height / 100) * this.progress);
    +			}
    +
    +			this.preloadSprite.sprite.crop = this.preloadSprite.crop;
    +		}
    +
    +		this.onFileComplete.dispatch(this.progress, previousKey, success, this.queueSize - this._keys.length, this.queueSize);
    +
    +		if (this._keys.length > 0)
    +		{
    +			this.loadFile();
    +		}
    +		else
    +		{
    +			this.hasLoaded = true;
    +			this.isLoading = false;
    +			
    +			this.removeAll();
    +
    +			this.onLoadComplete.dispatch();
    +		}
    +
    +	}
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/LoaderParser.js.html b/docs/LoaderParser.js.html new file mode 100644 index 00000000..21d32473 --- /dev/null +++ b/docs/LoaderParser.js.html @@ -0,0 +1,527 @@ + + + + + + Phaser Source: loader/LoaderParser.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: loader/LoaderParser.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser.LoaderParser parses data objects from Phaser.Loader that need more preparation before they can be inserted into the Cache.
    +*
    +* @class Phaser.LoaderParser
    +*/
    +Phaser.LoaderParser = {
    +	
    +    /**
    +    * Parse frame data from an XML file.
    +    * @method Phaser.LoaderParser.bitmapFont
    +    * @param {object} xml - XML data you want to parse.
    +    * @return {FrameData} Generated FrameData object.
    +    */
    +	bitmapFont: function (game, xml, cacheKey) {
    +
    +        //  Malformed?
    +        if (!xml.getElementsByTagName('font'))
    +        {
    +            console.warn("Phaser.LoaderParser.bitmapFont: Invalid XML given, missing <font> tag");
    +            return;
    +        }
    +
    +        var texture = PIXI.TextureCache[cacheKey];
    +
    +        var data = {};
    +        var info = xml.getElementsByTagName("info")[0];
    +        var common = xml.getElementsByTagName("common")[0];
    +        data.font = info.attributes.getNamedItem("face").nodeValue;
    +        data.size = parseInt(info.attributes.getNamedItem("size").nodeValue, 10);
    +        data.lineHeight = parseInt(common.attributes.getNamedItem("lineHeight").nodeValue, 10);
    +        data.chars = {};
    +
    +        //parse letters
    +        var letters = xml.getElementsByTagName("char");
    +
    +        for (var i = 0; i < letters.length; i++)
    +        {
    +            var charCode = parseInt(letters[i].attributes.getNamedItem("id").nodeValue, 10);
    +
    +            var textureRect = {
    +                x: parseInt(letters[i].attributes.getNamedItem("x").nodeValue, 10),
    +                y: parseInt(letters[i].attributes.getNamedItem("y").nodeValue, 10),
    +                width: parseInt(letters[i].attributes.getNamedItem("width").nodeValue, 10),
    +                height: parseInt(letters[i].attributes.getNamedItem("height").nodeValue, 10)
    +            };
    +
    +            //	Note: This means you can only have 1 BitmapFont loaded at once!
    +            //	Need to replace this with our own handler soon.
    +            PIXI.TextureCache[charCode] = new PIXI.Texture(texture, textureRect);
    +
    +            data.chars[charCode] = {
    +                xOffset: parseInt(letters[i].attributes.getNamedItem("xoffset").nodeValue, 10),
    +                yOffset: parseInt(letters[i].attributes.getNamedItem("yoffset").nodeValue, 10),
    +                xAdvance: parseInt(letters[i].attributes.getNamedItem("xadvance").nodeValue, 10),
    +                kerning: {},
    +                texture:new PIXI.Texture(texture, textureRect)
    +
    +            };
    +        }
    +
    +        //parse kernings
    +        var kernings = xml.getElementsByTagName("kerning");
    +
    +        for (i = 0; i < kernings.length; i++)
    +        {
    +           var first = parseInt(kernings[i].attributes.getNamedItem("first").nodeValue, 10);
    +           var second = parseInt(kernings[i].attributes.getNamedItem("second").nodeValue, 10);
    +           var amount = parseInt(kernings[i].attributes.getNamedItem("amount").nodeValue, 10);
    +
    +            data.chars[second].kerning[first] = amount;
    +        }
    +
    +        PIXI.BitmapText.fonts[data.font] = data;
    +
    +    }
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/MSPointer.js.html b/docs/MSPointer.js.html new file mode 100644 index 00000000..5e11db4b --- /dev/null +++ b/docs/MSPointer.js.html @@ -0,0 +1,627 @@ + + + + + + Phaser Source: input/MSPointer.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: input/MSPointer.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser - MSPointer constructor.
    +*
    +* @class Phaser.MSPointer
    +* @classdesc The MSPointer class handles touch interactions with the game and the resulting Pointer objects.
    +* It will work only in Internet Explorer 10 and Windows Store or Windows Phone 8 apps using JavaScript.
    +* http://msdn.microsoft.com/en-us/library/ie/hh673557(v=vs.85).aspx
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +*/
    +Phaser.MSPointer = function (game) {
    +
    +	/**
    +	* @property {Phaser.Game} game - Local reference to game.
    +	*/
    +	this.game = game;
    +	
    +	/**
    +	* @property {Phaser.Game} callbackContext - Description.
    +	*/
    +	this.callbackContext = this.game;
    +
    +	/**
    +	* @property {Description} mouseDownCallback - Description.
    +	* @default
    +	*/
    +	this.mouseDownCallback = null;
    +	
    +	/**
    +	* @property {Description} mouseMoveCallback - Description.
    +	* @default
    +	*/
    +	this.mouseMoveCallback = null;
    +	
    +	/**
    +	* @property {Description} mouseUpCallback - Description.
    +	* @default
    +	*/
    +	this.mouseUpCallback = null;
    +
    +    /**
    +    * You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
    +    * @property {boolean} disabled
    +    */
    +    this.disabled = false;
    +
    +    /**
    +    * Description.
    +    * @property {Description} _onMSPointerDown
    +    * @private
    +    * @default
    +    */
    +    this._onMSPointerDown = null;
    +    
    +    /**
    +    * Description.
    +    * @property {Description} _onMSPointerMove
    +    * @private
    +    * @default
    +    */
    +    this._onMSPointerMove = null;
    +    
    +    /**
    +    * Description.
    +    * @property {Description} _onMSPointerUp
    +    * @private
    +    * @default
    +    */
    +    this._onMSPointerUp = null;
    +
    +};
    +
    +Phaser.MSPointer.prototype = {
    +
    +	/**
    +    * Starts the event listeners running.
    +    * @method Phaser.MSPointer#start
    +    */
    +    start: function () {
    +
    +        var _this = this;
    +
    +        if (this.game.device.mspointer == true)
    +        {
    +            this._onMSPointerDown = function (event) {
    +                return _this.onPointerDown(event);
    +            };
    +
    +            this._onMSPointerMove = function (event) {
    +                return _this.onPointerMove(event);
    +            };
    +
    +            this._onMSPointerUp = function (event) {
    +                return _this.onPointerUp(event);
    +            };
    +
    +            this.game.renderer.view.addEventListener('MSPointerDown', this._onMSPointerDown, false);
    +            this.game.renderer.view.addEventListener('MSPointerMove', this._onMSPointerMove, false);
    +            this.game.renderer.view.addEventListener('MSPointerUp', this._onMSPointerUp, false);
    +
    +            this.game.renderer.view.style['-ms-content-zooming'] = 'none';
    +            this.game.renderer.view.style['-ms-touch-action'] = 'none';
    +
    +        }
    +
    +    },
    +
    +    /**
    +    * Description.
    +    * @method Phaser.MSPointer#onPointerDown
    +    * @param {Any} event
    +    **/
    +    onPointerDown: function (event) {
    +
    +        if (this.game.input.disabled || this.disabled)
    +        {
    +            return;
    +        }
    +
    +        event.preventDefault();
    +        event.identifier = event.pointerId;
    +
    +        this.game.input.startPointer(event);
    +
    +    },
    +
    +    /**
    +    * Description.
    +    * @method Phaser.MSPointer#onPointerMove
    +    * @param {Any} event
    +    **/
    +    onPointerMove: function (event) {
    +
    +        if (this.game.input.disabled || this.disabled)
    +        {
    +            return;
    +        }
    +
    +        event.preventDefault();
    +        event.identifier = event.pointerId;
    +
    +        this.game.input.updatePointer(event);
    +
    +    },
    +
    +    /**
    +    * Description.
    +    * @method Phaser.MSPointer#onPointerUp
    +    * @param {Any} event
    +    **/
    +    onPointerUp: function (event) {
    +
    +        if (this.game.input.disabled || this.disabled)
    +        {
    +            return;
    +        }
    +
    +        event.preventDefault();
    +        event.identifier = event.pointerId;
    +
    +        this.game.input.stopPointer(event);
    +
    +    },
    +
    +	/**
    +    * Stop the event listeners.
    +    * @method Phaser.MSPointer#stop
    +    */
    +    stop: function () {
    +
    +        this.game.stage.canvas.removeEventListener('MSPointerDown', this._onMSPointerDown);
    +        this.game.stage.canvas.removeEventListener('MSPointerMove', this._onMSPointerMove);
    +        this.game.stage.canvas.removeEventListener('MSPointerUp', this._onMSPointerUp);
    +
    +    }
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Math.js.html b/docs/Math.js.html new file mode 100644 index 00000000..f683f68b --- /dev/null +++ b/docs/Math.js.html @@ -0,0 +1,1615 @@ + + + + + + Phaser Source: math/Math.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: math/Math.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* A collection of mathematical methods.
    +*
    +* @class Phaser.Math
    +*/
    +Phaser.Math = {
    +
    +	/**
    +	* = 2 π
    +	* @method Phaser.Math#PI2
    +	*/
    +	PI2: Math.PI * 2,
    +
    +	/**
    +	* Two number are fuzzyEqual if their difference is less than ε. 
    +	* @method Phaser.Math#fuzzyEqual
    +	* @param {number} a
    +	* @param {number} b
    +	* @param {number} epsilon 
    +	* @return {boolean} True if |a-b|<ε
    +	*/
    +    fuzzyEqual: function (a, b, epsilon) {
    +        if (typeof epsilon === "undefined") { epsilon = 0.0001; }
    +        return Math.abs(a - b) < epsilon;
    +    },
    +
    +	/**
    +	* a is fuzzyLessThan b if it is less than b + ε. 
    +	* @method Phaser.Math#fuzzyEqual
    +	* @param {number} a
    +	* @param {number} b
    +	* @param {number} epsilon 
    +	* @return {boolean} True if a<b+ε
    +	*/
    +    fuzzyLessThan: function (a, b, epsilon) {
    +        if (typeof epsilon === "undefined") { epsilon = 0.0001; }
    +        return a < b + epsilon;
    +    },
    +
    +	/**
    +	* a is fuzzyGreaterThan b if it is more than b - ε.  
    +	* @method Phaser.Math#fuzzyGreaterThan
    +	* @param {number} a
    +	* @param {number} b
    +	* @param {number} epsilon 
    +	* @return {boolean} True if a>b+ε
    +	*/
    +    fuzzyGreaterThan: function (a, b, epsilon) {
    +        if (typeof epsilon === "undefined") { epsilon = 0.0001; }
    +        return a > b - epsilon;
    +    },
    +
    +	/** 
    +	* @method Phaser.Math#fuzzyCeil
    +	* @param {number} val
    +	* @param {number} epsilon 
    +	* @return {boolean} ceiling(val-ε)
    +	*/
    +    fuzzyCeil: function (val, epsilon) {
    +        if (typeof epsilon === "undefined") { epsilon = 0.0001; }
    +        return Math.ceil(val - epsilon);
    +    },
    +
    +	/** 
    +	* @method Phaser.Math#fuzzyFloor
    +	* @param {number} val
    +	* @param {number} epsilon 
    +	* @return {boolean} floor(val-ε)
    +	*/
    +    fuzzyFloor: function (val, epsilon) {
    +        if (typeof epsilon === "undefined") { epsilon = 0.0001; }
    +        return Math.floor(val + epsilon);
    +    },
    +
    +	/** 
    +    * Averages all values passed to the function and returns the result. You can pass as many parameters as you like.
    +	* @method Phaser.Math#average
    +    * @return {number} The average of all given values.
    +	*/
    +    average: function () {
    +
    +        var args = [];
    +
    +        for (var _i = 0; _i < (arguments.length - 0); _i++) {
    +            args[_i] = arguments[_i + 0];
    +        }
    +
    +        var avg = 0;
    +
    +        for (var i = 0; i < args.length; i++) {
    +            avg += args[i];
    +        }
    +
    +        return avg / args.length;
    +
    +    },
    +
    +	/** 
    +	* @method Phaser.Math#truncate
    +    * @param {number} n
    +    * @return {number}
    +	*/
    +    truncate: function (n) {
    +        return (n > 0) ? Math.floor(n) : Math.ceil(n);
    +    },
    +
    +	/** 
    +	* @method Phaser.Math#shear
    +	* @param {number} n
    +	* @return {number} n mod 1
    +	*/
    +    shear: function (n) {
    +        return n % 1;
    +    },
    +
    +	/**
    +	* Snap a value to nearest grid slice, using rounding.
    +	*
    +	* Example: if you have an interval gap of 5 and a position of 12... you will snap to 10 whereas 14 will snap to 15.
    +	*
    +	* @method Phaser.Math#snapTo
    +	* @param {number} input - The value to snap.
    +	* @param {number} gap - The interval gap of the grid.
    +	* @param {number} [start] - Optional starting offset for gap.
    +    * @return {number}
    +	*/
    +    snapTo: function (input, gap, start) {
    +
    +        if (typeof start === "undefined") { start = 0; }
    +
    +        if (gap == 0) {
    +            return input;
    +        }
    +
    +        input -= start;
    +        input = gap * Math.round(input / gap);
    +
    +        return start + input;
    +
    +    },
    +
    +	/**
    +    * Snap a value to nearest grid slice, using floor.
    +    *
    +    * Example: if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15
    +    *
    +    * @method Phaser.Math#snapToFloor
    +    * @param {number} input - The value to snap.
    +    * @param {number} gap - The interval gap of the grid.
    +    * @param {number} [start] - Optional starting offset for gap.
    +    * @return {number}
    +    */
    +    snapToFloor: function (input, gap, start) {
    +
    +        if (typeof start === "undefined") { start = 0; }
    +
    +        if (gap == 0) {
    +            return input;
    +        }
    +
    +        input -= start;
    +        input = gap * Math.floor(input / gap);
    +
    +        return start + input;
    +
    +    },
    +
    +	/**
    +	* Snap a value to nearest grid slice, using ceil.
    +	*
    +	* Example: if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20.
    +	*
    +    * @method Phaser.Math#snapToCeil
    +    * @param {number} input - The value to snap.
    +    * @param {number} gap - The interval gap of the grid.
    +    * @param {number} [start] - Optional starting offset for gap.
    +    * @return {number}
    +	*/
    +    snapToCeil: function (input, gap, start) {
    +
    +        if (typeof start === "undefined") { start = 0; }
    +
    +        if (gap == 0) {
    +            return input;
    +        }
    +
    +        input -= start;
    +        input = gap * Math.ceil(input / gap);
    +
    +        return start + input;
    +
    +    },
    +
    +
    +	/**
    +	* Snaps a value to the nearest value in an array.
    +	* @method Phaser.Math#snapToInArray
    +	* @param {number} input
    +	* @param {array} arr 
    +	* @param {boolean} sort - True if the array needs to be sorted.
    +    * @return {number}
    +	*/
    +    snapToInArray: function (input, arr, sort) {
    +
    +        if (typeof sort === "undefined") { sort = true; }
    +
    +        if (sort) {
    +            arr.sort();
    +        }
    +
    +        if (input < arr[0]) {
    +            return arr[0];
    +        }
    +
    +        var i = 1;
    +        
    +        while (arr[i] < input) {
    +            i++;
    +        }
    +
    +        var low = arr[i - 1];
    +        var high = (i < arr.length) ? arr[i] : Number.POSITIVE_INFINITY;
    +        
    +        return ((high - input) <= (input - low)) ? high : low;
    +
    +    },
    +
    +	/**
    +	* Round to some place comparative to a 'base', default is 10 for decimal place.
    +	*
    +	* 'place' is represented by the power applied to 'base' to get that place
    +	* e.g.
    +	* 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011
    +	*
    +	* roundTo(2000/7,3) == 0
    +	* roundTo(2000/7,2) == 300
    +	* roundTo(2000/7,1) == 290
    +	* roundTo(2000/7,0) == 286
    +	* roundTo(2000/7,-1) == 285.7
    +	* roundTo(2000/7,-2) == 285.71
    +	* roundTo(2000/7,-3) == 285.714
    +	* roundTo(2000/7,-4) == 285.7143
    +	* roundTo(2000/7,-5) == 285.71429
    +	*
    +	* roundTo(2000/7,3,2)  == 288       -- 100100000
    +	* roundTo(2000/7,2,2)  == 284       -- 100011100
    +	* roundTo(2000/7,1,2)  == 286       -- 100011110
    +	* roundTo(2000/7,0,2)  == 286       -- 100011110
    +	* roundTo(2000/7,-1,2) == 285.5     -- 100011101.1
    +	* roundTo(2000/7,-2,2) == 285.75    -- 100011101.11
    +	* roundTo(2000/7,-3,2) == 285.75    -- 100011101.11
    +	* roundTo(2000/7,-4,2) == 285.6875  -- 100011101.1011
    +	* roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111
    +	*
    +	* Note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed
    +	* because we are rounding 100011.1011011011011011 which rounds up.
    +	* 
    +	* @method Phaser.Math#roundTo
    +	* @param {number} value - The value to round.
    +	* @param {number} place - The place to round to.
    +	* @param {number} base - The base to round in... default is 10 for decimal.
    +    * @return {number}
    +	*/
    +    roundTo: function (value, place, base) {
    +
    +        if (typeof place === "undefined") { place = 0; }
    +        if (typeof base === "undefined") { base = 10; }
    +        
    +        var p = Math.pow(base, -place);
    +        
    +        return Math.round(value * p) / p;
    +
    +    },
    +
    +    /**
    +	* @method Phaser.Math#floorTo
    +	* @param {number} value - The value to round.
    +	* @param {number} place - The place to round to.
    +	* @param {number} base - The base to round in... default is 10 for decimal.
    +    * @return {number}
    +	*/
    +    floorTo: function (value, place, base) {
    +
    +        if (typeof place === "undefined") { place = 0; }
    +        if (typeof base === "undefined") { base = 10; }
    +
    +        var p = Math.pow(base, -place);
    +
    +        return Math.floor(value * p) / p;
    +
    +    },
    +
    +    /**
    +	* @method Phaser.Math#ceilTo
    +	* @param {number} value - The value to round.
    +	* @param {number} place - The place to round to.
    +	* @param {number} base - The base to round in... default is 10 for decimal.
    +    * @return {number}
    +	*/
    +    ceilTo: function (value, place, base) {
    +
    +        if (typeof place === "undefined") { place = 0; }
    +        if (typeof base === "undefined") { base = 10; }
    +
    +        var p = Math.pow(base, -place);
    +
    +        return Math.ceil(value * p) / p;
    +
    +    },
    +
    +	/**
    +	* A one dimensional linear interpolation of a value.
    +	* @method Phaser.Math#interpolateFloat
    +	* @param {number} a
    +	* @param {number} b
    +	* @param {number} weight 
    +    * @return {number}
    +	*/
    +    interpolateFloat: function (a, b, weight) {
    +        return (b - a) * weight + a;
    +    },
    +
    +	/**
    +	* Find the angle of a segment from (x1, y1) -> (x2, y2 ).
    +	* @method Phaser.Math#angleBetween
    +	* @param {number} x1
    +	* @param {number} y1
    +	* @param {number} x2
    +	* @param {number} y2
    +    * @return {number}
    +	*/
    +    angleBetween: function (x1, y1, x2, y2) {
    +        return Math.atan2(y2 - y1, x2 - x1);
    +    },
    +
    +	/**
    +	* Set an angle  within the bounds of -π toπ.
    +	* @method Phaser.Math#normalizeAngle
    +	* @param {number} angle
    +	* @param {boolean} radians - True if angle size is expressed in radians.
    +    * @return {number}
    +	*/
    +    normalizeAngle: function (angle, radians) {
    +
    +        if (typeof radians === "undefined") { radians = true; }
    +
    +        var rd = (radians) ? GameMath.PI : 180;
    +        return this.wrap(angle, rd, -rd);
    +        
    +    },
    +
    +	/**
    +	* Closest angle between two angles from a1 to a2
    +	* absolute value the return for exact angle
    +	* @method Phaser.Math#nearestAngleBetween
    +	* @param {number} a1
    +	* @param {number} a2
    +	* @param {boolean} radians - True if angle sizes are expressed in radians.
    +    * @return {number}
    +	*/
    +    nearestAngleBetween: function (a1, a2, radians) {
    +
    +        if (typeof radians === "undefined") { radians = true; }
    +
    +        var rd = (radians) ? Math.PI : 180;
    +        a1 = this.normalizeAngle(a1, radians);
    +        a2 = this.normalizeAngle(a2, radians);
    +        
    +        if (a1 < -rd / 2 && a2 > rd / 2)
    +        {
    +            a1 += rd * 2;
    +        }
    +
    +        if (a2 < -rd / 2 && a1 > rd / 2)
    +        {
    +            a2 += rd * 2;
    +        }
    +
    +        return a2 - a1;
    +
    +    },
    +
    +	/**
    +	* Interpolate across the shortest arc between two angles.
    +	* @method Phaser.Math#interpolateAngles
    +	* @param {number} a1 - Description.
    +	* @param {number} a2 - Description.
    +	* @param {number} weight - Description.
    +	* @param {boolean} radians - True if angle sizes are expressed in radians.
    +	* @param {Description} ease - Description.
    +    * @return {number}
    +	*/
    +    interpolateAngles: function (a1, a2, weight, radians, ease) {
    +
    +        if (typeof radians === "undefined") { radians = true; }
    +        if (typeof ease === "undefined") { ease = null; }
    +
    +        a1 = this.normalizeAngle(a1, radians);
    +        a2 = this.normalizeAngleToAnother(a2, a1, radians);
    +
    +        return (typeof ease === 'function') ? ease(weight, a1, a2 - a1, 1) : this.interpolateFloat(a1, a2, weight);
    +
    +    },
    +
    +	/**
    +	* Generate a random bool result based on the chance value.
    +	* <p>
    +	* Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance
    +	* of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed.
    +	* </p>
    +	* @method Phaser.Math#chanceRoll
    +	* @param {number} chance - The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%).
    +	* @return {boolean} True if the roll passed, or false otherwise.
    +	*/
    +    chanceRoll: function (chance) {
    +
    +        if (typeof chance === "undefined") { chance = 50; }
    +        
    +        if (chance <= 0)
    +        {
    +            return false;
    +        }
    +        else if (chance >= 100)
    +        {
    +            return true;
    +        }
    +        else
    +        {
    +            if (Math.random() * 100 >= chance)
    +            {
    +                return false;
    +            }
    +            else
    +            {
    +                return true;
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * Returns an Array containing the numbers from min to max (inclusive).
    +    *
    +    * @method Phaser.Math#numberArray
    +    * @param {number} min - The minimum value the array starts with.
    +    * @param {number} max - The maximum value the array contains.
    +    * @return {array} The array of number values.
    +    */
    +    numberArray: function (min, max) {
    +
    +        var result = [];
    +
    +        for (var i = min; i <= max; i++)
    +        {
    +            result.push(i);
    +        }
    +
    +        return result;
    +
    +    },
    +
    +	/**
    +	* Adds the given amount to the value, but never lets the value go over the specified maximum.
    +	*
    +	* @method Phaser.Math#maxAdd
    +	* @param {number} value - The value to add the amount to.
    +	* @param {number} amount - The amount to add to the value.
    +	* @param {number} max- The maximum the value is allowed to be.
    +    * @return {number}
    +	*/
    +    maxAdd: function (value, amount, max) {
    +
    +        value += amount;
    +
    +        if (value > max)
    +        {
    +            value = max;
    +        }
    +
    +        return value;
    +
    +    },
    +
    +	/**
    +	* Subtracts the given amount from the value, but never lets the value go below the specified minimum.
    +	*
    +	* @method Phaser.Math#minSub
    +	* @param {number} value - The base value.
    +	* @param {number} amount - The amount to subtract from the base value.
    +	* @param {number} min - The minimum the value is allowed to be.
    +	* @return {number} The new value.
    +	*/
    +    minSub: function (value, amount, min) {
    +
    +        value -= amount;
    +        
    +        if (value < min)
    +        {
    +            value = min;
    +        }
    +
    +        return value;
    +
    +    },
    +
    +    /**
    +    * Ensures that the value always stays between min and max, by wrapping the value around.
    +    * <p>max should be larger than min, or the function will return 0</p>
    +    *
    +    * @method Phaser.Math#wrap
    +    * @param value The value to wrap
    +    * @param min The minimum the value is allowed to be
    +    * @param max The maximum the value is allowed to be
    +    * @return {number} The wrapped value
    +    */
    +    wrap: function (value, min, max) {
    +
    +        var range = max - min;
    +
    +        if (range <= 0)
    +        {
    +            return 0;
    +        }
    +
    +        var result = (value - min) % range;
    +
    +        if (result < 0)
    +        {
    +            result += range;
    +        }
    +        
    +        return result + min;
    +
    +    },
    +
    +    /**
    +    * Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.
    +    * <p>Values must be positive integers, and are passed through Math.abs</p>
    +    *
    +	* @method Phaser.Math#wrapValue
    +	* @param {number} value - The value to add the amount to.
    +	* @param {number} amount - The amount to add to the value.
    +	* @param {number} max - The maximum the value is allowed to be.
    +	* @return {number} The wrapped value.
    +    */
    +    wrapValue: function (value, amount, max) {
    +
    +        var diff;
    +        value = Math.abs(value);
    +        amount = Math.abs(amount);
    +        max = Math.abs(max);
    +        diff = (value + amount) % max;
    +
    +        return diff;
    +
    +    },
    +
    +	/**
    +	* Randomly returns either a 1 or -1.
    +	*
    +	* @method Phaser.Math#randomSign
    +	* @return {number}	1 or -1
    +	*/
    +    randomSign: function () {
    +        return (Math.random() > 0.5) ? 1 : -1;
    +    },
    +
    +	/**
    +	* Returns true if the number given is odd.
    +	*
    +	* @method Phaser.Math#isOdd
    +	* @param {number} n - The number to check.
    +	* @return {boolean} True if the given number is odd. False if the given number is even.
    +	*/
    +    isOdd: function (n) {
    +
    +        return (n & 1);
    +
    +    },
    +
    +	/**
    +	* Returns true if the number given is even.
    +	*
    +	* @method Phaser.Math#isEven
    +	* @param {number} n - The number to check.
    +	* @return {boolean} True if the given number is even. False if the given number is odd.
    +	*/
    +    isEven: function (n) {
    +
    +        if (n & 1)
    +        {
    +            return false;
    +        }
    +        else
    +        {
    +            return true;
    +        }
    +
    +    },
    +
    +    /**
    +    * Significantly faster version of Math.max
    +    * See http://jsperf.com/math-s-min-max-vs-homemade/5
    +    *
    +    * @method Phaser.Math#max
    +    * @return {number} The highest value from those given.
    +    */
    +    max: function () {
    +
    +        for (var i = 1, max = 0, len = arguments.length; i < len; i++)
    +        {
    +            if (arguments[max] < arguments[i])
    +            {
    +                max = i;
    +            }
    +        }
    +        
    +        return arguments[max];
    +
    +    },
    +
    +    /**
    +    * Significantly faster version of Math.min
    +    * See http://jsperf.com/math-s-min-max-vs-homemade/5
    +    *
    +    * @method Phaser.Math#min
    +    * @return {number} The lowest value from those given.
    +    */
    +    min: function () {
    +
    +        for (var i =1 , min = 0, len = arguments.length; i < len; i++)
    +        {
    +            if (arguments[i] < arguments[min])
    +            {
    +                min = i;
    +            }
    +        }
    +
    +        return arguments[min];
    +
    +    },
    +
    +	/**
    +	* Keeps an angle value between -180 and +180<br>
    +	* Should be called whenever the angle is updated on the Sprite to stop it from going insane.
    +	*
    +	* @method Phaser.Math#wrapAngle
    +	* @param {number} angle - The angle value to check
    +	* @return {number} The new angle value, returns the same as the input angle if it was within bounds.
    +	*/
    +    wrapAngle: function (angle) {
    +
    +        var result = angle;
    +
    +        //  Nothing needs to change
    +        if (angle >= -180 && angle <= 180)
    +        {
    +            return angle;
    +        }
    +
    +        //  Else normalise it to -180, 180
    +        result = (angle + 180) % 360;
    +
    +        if (result < 0)
    +        {
    +            result += 360;
    +        }
    +
    +        return result - 180;
    +
    +    },
    +
    +	/**
    +	* Keeps an angle value between the given min and max values.
    +	*
    +	* @method Phaser.Math#angleLimit
    +	* @param {number} angle - The angle value to check. Must be between -180 and +180.
    +	* @param {number} min - The minimum angle that is allowed (must be -180 or greater).
    +	* @param {number} max - The maximum angle that is allowed (must be 180 or less).
    +	*
    +	* @return {number} The new angle value, returns the same as the input angle if it was within bounds
    +	*/
    +    angleLimit: function (angle, min, max) {
    +
    +        var result = angle;
    +
    +        if (angle > max)
    +        {
    +            result = max;
    +        }
    +        else if (angle < min)
    +        {
    +            result = min;
    +        }
    +
    +        return result;
    +
    +    },
    +
    +	/**
    +	* Description.
    +	* @method Phaser.Math#linearInterpolation
    +	* @param {number} v
    +	* @param {number} k
    +	* @return {number} 
    +	*/
    +    linearInterpolation: function (v, k) {
    +
    +        var m = v.length - 1;
    +        var f = m * k;
    +        var i = Math.floor(f);
    +
    +        if (k < 0)
    +        {
    +            return this.linear(v[0], v[1], f);
    +        }
    +
    +        if (k > 1)
    +        {
    +            return this.linear(v[m], v[m - 1], m - f);
    +        }
    +
    +        return this.linear(v[i], v[i + 1 > m ? m : i + 1], f - i);
    +
    +    },
    +
    +	/**
    +	* Description.
    +	* @method Phaser.Math#bezierInterpolation
    +	* @param {number} v
    +	* @param {number} k
    +	* @return {number}
    +	*/
    +    bezierInterpolation: function (v, k) {
    +
    +        var b = 0;
    +        var n = v.length - 1;
    +
    +        for (var i = 0; i <= n; i++)
    +        {
    +            b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * this.bernstein(n, i);
    +        }
    +
    +        return b;
    +
    +    },
    +
    +	/**
    +	* Description.
    +	* @method Phaser.Math#catmullRomInterpolation
    +	* @param {number} v
    +	* @param {number} k
    +	* @return {number}
    +	*/
    +    catmullRomInterpolation: function (v, k) {
    +
    +        var m = v.length - 1;
    +        var f = m * k;
    +        var i = Math.floor(f);
    +
    +        if (v[0] === v[m])
    +        {
    +            if (k < 0)
    +            {
    +                i = Math.floor(f = m * (1 + k));
    +            }
    +
    +            return this.catmullRom(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i);
    +
    +        }
    +        else
    +        {
    +            if (k < 0)
    +            {
    +                return v[0] - (this.catmullRom(v[0], v[0], v[1], v[1], -f) - v[0]);
    +            }
    +
    +            if (k > 1)
    +            {
    +                return v[m] - (this.catmullRom(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]);
    +            }
    +
    +            return this.catmullRom(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i);
    +        }
    +
    +    },
    +
    +	/**
    +	* Description.
    +	* @method Phaser.Math#Linear
    +	* @param {number} p0
    +	* @param {number} p1
    +	* @param {number} t
    +	* @return {number}
    +	*/
    +    linear: function (p0, p1, t) {
    +        return (p1 - p0) * t + p0;
    +    },
    +
    +	/**
    +	* @method Phaser.Math#bernstein
    +	* @param {number} n
    +	* @param {number} i
    +	* @return {number}
    +	*/
    +    bernstein: function (n, i) {
    +        return this.factorial(n) / this.factorial(i) / this.factorial(n - i);
    +    },
    +
    +	/**
    +	* Description.
    +	* @method Phaser.Math#catmullRom
    +	* @param {number} p0
    +	* @param {number} p1
    +	* @param {number} p2
    +	* @param {number} p3
    +	* @param {number} t
    +	* @return {number} 
    +	*/
    +    catmullRom: function (p0, p1, p2, p3, t) {
    +
    +        var v0 = (p2 - p0) * 0.5, v1 = (p3 - p1) * 0.5, t2 = t * t, t3 = t * t2;
    +
    +        return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;
    +
    +    },
    +
    +    /**
    +    * @method Phaser.Math#difference
    +    * @param {number} a
    +    * @param {number} b
    +    * @return {number}
    +    */
    +    difference: function (a, b) {
    +        return Math.abs(a - b);
    +    },
    +
    +	/**
    +	* Fetch a random entry from the given array.
    +	* Will return null if random selection is missing, or array has no entries.
    +	*
    +	* @method Phaser.Math#getRandom
    +	* @param {array} objects - An array of objects.
    +	* @param {number} startIndex - Optional offset off the front of the array. Default value is 0, or the beginning of the array.
    +	* @param {number} length - Optional restriction on the number of values you want to randomly select from.
    +	* @return {object} The random object that was selected.
    +	*/
    +    getRandom: function (objects, startIndex, length) {
    +
    +        if (typeof startIndex === "undefined") { startIndex = 0; }
    +        if (typeof length === "undefined") { length = 0; }
    +        
    +        if (objects != null) {
    +
    +            var l = length;
    +
    +            if ((l == 0) || (l > objects.length - startIndex))
    +            {
    +                l = objects.length - startIndex;
    +            }
    +
    +            if (l > 0)
    +            {
    +                return objects[startIndex + Math.floor(Math.random() * l)];
    +            }
    +        }
    +
    +        return null;
    +
    +    },
    +
    +	/**
    +	* Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2.
    +	*
    +	* @method Phaser.Math#floor
    +	* @param {number} Value	Any number.
    +	* @return {number} The rounded value of that number.
    +	*/
    +    floor: function (value) {
    +
    +        var n = value | 0;
    +
    +        return (value > 0) ? (n) : ((n != value) ? (n - 1) : (n));
    +
    +    },
    +
    +	/**
    +	* Round up to the next whole number.  E.g. ceil(1.3) == 2, and ceil(-2.3) == -3.
    +	*
    +    * @method Phaser.Math#ceil
    +	* @param {number} value - Any number.
    +	* @return {number} The rounded value of that number.
    +	*/
    +    ceil: function (value) {
    +        var n = value | 0;
    +        return (value > 0) ? ((n != value) ? (n + 1) : (n)) : (n);
    +    },
    +
    +	/**
    +    * Generate a sine and cosine table simultaneously and extremely quickly. Based on research by Franky of scene.at
    +    * <p>
    +    * The parameters allow you to specify the length, amplitude and frequency of the wave. Once you have called this function
    +    * you should get the results via getSinTable() and getCosTable(). This generator is fast enough to be used in real-time.
    +    * </p>
    +    * @method Phaser.Math#sinCosGenerator
    +    * @param {number} length - The length of the wave
    +    * @param {number} sinAmplitude - The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value
    +    * @param {number} cosAmplitude - The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value
    +    * @param {number} frequency  - The frequency of the sine and cosine table data
    +    * @return {Array} Returns the sine table
    +    */
    +    sinCosGenerator: function (length, sinAmplitude, cosAmplitude, frequency) {
    +
    +        if (typeof sinAmplitude === "undefined") { sinAmplitude = 1.0; }
    +        if (typeof cosAmplitude === "undefined") { cosAmplitude = 1.0; }
    +        if (typeof frequency === "undefined") { frequency = 1.0; }
    +        
    +        var sin = sinAmplitude;
    +        var cos = cosAmplitude;
    +        var frq = frequency * Math.PI / length;
    +        
    +        var cosTable = [];
    +        var sinTable = [];
    +        
    +        for (var c = 0; c < length; c++) {
    +
    +            cos -= sin * frq;
    +            sin += cos * frq;
    +
    +            cosTable[c] = cos;
    +            sinTable[c] = sin;
    +
    +        }
    +
    +        return { sin: sinTable, cos: cosTable };
    +
    +    },
    +
    +	/**
    +	* Removes the top element from the stack and re-inserts it onto the bottom, then returns it.
    +	* The original stack is modified in the process. This effectively moves the position of the data from the start to the end of the table.
    +    * 
    +    * @method Phaser.Math#shift
    +    * @param {array} stack - The array to shift.
    +    * @return {any} The shifted value.
    +    */
    +    shift: function (stack) {
    +
    +    	var s = stack.shift();
    +    	stack.push(s);
    +
    +    	return s;
    +
    +    },
    +
    +	/**
    +    * Shuffles the data in the given array into a new order
    +    * @method Phaser.Math#shuffleArray
    +    * @param {array} array - The array to shuffle
    +    * @return {array} The array
    +    */
    +    shuffleArray: function (array) {
    +
    +        for (var i = array.length - 1; i > 0; i--) {
    +
    +            var j = Math.floor(Math.random() * (i + 1));
    +            var temp = array[i];
    +            array[i] = array[j];
    +            array[j] = temp;
    +        }
    +
    +        return array;
    +
    +    },
    +
    +	/**
    +    * Returns the distance between the two given set of coordinates.
    +    * 
    +    * @method Phaser.Math#distance
    +    * @param {number} x1
    +    * @param {number} y1
    +    * @param {number} x2
    +    * @param {number} y2
    +    * @return {number} The distance between this Point object and the destination Point object.
    +    **/
    +    distance: function (x1, y1, x2, y2) {
    +
    +        var dx = x1 - x2;
    +        var dy = y1 - y2;
    +
    +        return Math.sqrt(dx * dx + dy * dy);
    +
    +    },
    +
    +    /**
    +    * Returns the rounded distance between the two given set of coordinates.
    +    * 
    +    * @method Phaser.Math#distanceRounded
    +    * @param {number} x1
    +    * @param {number} y1
    +    * @param {number} x2
    +    * @param {number} y2
    +    * @return {number} The distance between this Point object and the destination Point object.
    +    **/
    +    distanceRounded: function (x1, y1, x2, y2) {
    +
    +    	return Math.round(Phaser.Math.distance(x1, y1, x2, y2));
    +
    +    },
    +
    +	/**
    +	* Force a value within the boundaries of two values.
    +	* Clamp value to range <a, b>
    +	* 
    +	* @method Phaser.Math#clamp
    +	* @param {number} x
    +	* @param {number} a
    +	* @param {number} b
    +    * @return {number}
    +	*/
    +	clamp: function ( x, a, b ) {
    +
    +		return ( x < a ) ? a : ( ( x > b ) ? b : x );
    +
    +	},
    + 
    +	/**
    +	* Clamp value to range <a, inf).
    +	* 
    +	* @method Phaser.Math#clampBottom
    +	* @param {number} x
    +	* @param {number} a
    +    * @return {number}
    +	*/
    +	clampBottom: function ( x, a ) {
    +
    +		return x < a ? a : x;
    +
    +	},
    +
    +    /**
    +    * Checks if two values are within the given tolerance of each other.
    +    * 
    +    * @method Phaser.Math#within
    +    * @param {number} a - The first number to check
    +    * @param {number} b - The second number to check
    +    * @param {number} tolerance - The tolerance. Anything equal to or less than this is considered within the range.
    +    * @return {boolean} True if a is <= tolerance of b.
    +    */
    +    within: function ( a, b, tolerance ) {
    +
    +        return (Math.abs(a - b) <= tolerance);
    +
    +    },
    + 
    +	/**
    +	* Linear mapping from range <a1, a2> to range <b1, b2>
    +	* 
    +	* @method Phaser.Math#mapLinear
    +	* @param {number} x
    +	* @param {number} a1
    +	* @param {number} a1
    +	* @param {number} a2
    +	* @param {number} b1
    +	* @param {number} b2
    +	* @return {number}
    +	*/
    +	mapLinear: function ( x, a1, a2, b1, b2 ) {
    +
    +		return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );
    +
    +	},
    +
    +	/**
    +	* Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep
    +	* 
    +	* @method Phaser.Math#smoothstep
    +	* @param {number} x
    +	* @param {number} min
    +	* @param {number} max
    +	* @return {number}
    +	*/
    +	smoothstep: function ( x, min, max ) {
    +
    +		if ( x <= min ) return 0;
    +		if ( x >= max ) return 1;
    +
    +		x = ( x - min )/( max - min );
    +
    +		return x*x*(3 - 2*x);
    +
    +	},
    +
    +	/**
    +    * Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep
    +	* 
    +	* @method Phaser.Math#smootherstep
    +	* @param {number} x
    +	* @param {number} min
    +	* @param {number} max
    +	* @return {number}
    +	*/
    +	smootherstep: function ( x, min, max ) {
    +
    +		if ( x <= min ) return 0;
    +		if ( x >= max ) return 1;
    +
    +		x = ( x - min )/( max - min );
    +
    +		return x*x*x*(x*(x*6 - 15) + 10);
    +
    +	},
    +
    +	/**
    +	* A value representing the sign of the value.
    +	* -1 for negative, +1 for positive, 0 if value is 0
    +	* 
    +	* @method Phaser.Math#sign
    +	* @param {number} x
    +	* @return {number}
    +	*/
    +	sign: function ( x ) {
    +
    +		return ( x < 0 ) ? -1 : ( ( x > 0 ) ? 1 : 0 );
    +
    +	},
    +
    +	/**
    +	* Convert degrees to radians.
    +	* 
    +	* @method Phaser.Math#degToRad
    +	* @return {function}
    +	*/
    +	degToRad: function() {
    +
    +		var degreeToRadiansFactor = Math.PI / 180;
    +
    +		return function ( degrees ) {
    +
    +			return degrees * degreeToRadiansFactor;
    +
    +		};
    +
    +	}(),
    +
    +	/**
    +	* Convert degrees to radians.
    +	* 
    +	* @method Phaser.Math#radToDeg
    +	* @return {function}
    +	*/
    +	radToDeg: function() {
    +
    +		var radianToDegreesFactor = 180 / Math.PI;
    +
    +		return function ( radians ) {
    +
    +			return radians * radianToDegreesFactor;
    +
    +		};
    +
    +	}()
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Mouse.js.html b/docs/Mouse.js.html new file mode 100644 index 00000000..88fde6ee --- /dev/null +++ b/docs/Mouse.js.html @@ -0,0 +1,703 @@ + + + + + + Phaser Source: input/Mouse.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: input/Mouse.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser - Mouse constructor.
    +*
    +* @class Phaser.Mouse
    +* @classdesc The Mouse class
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +*/
    +Phaser.Mouse = function (game) {
    +
    +	/**
    +	* @property {Phaser.Game} game - Local reference to game.
    +	*/
    +	this.game = game;
    +	
    +	/**
    +	* @property {Object} callbackContext - Description.
    +	*/
    +	this.callbackContext = this.game;
    +
    +	/**
    +	* @property {Description} mouseDownCallback - Description.
    +	* @default
    +	*/
    +	this.mouseDownCallback = null;
    +	
    +	/**
    +	* @property {Description} mouseMoveCallback - Description.
    +	* @default
    +	*/
    +	this.mouseMoveCallback = null;
    +	
    +	/**
    +	* @property {Description} mouseUpCallback - Description.
    +	* @default
    +	*/
    +	this.mouseUpCallback = null;
    +
    +    /**
    +    * You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
    +    * @property {boolean} disabled
    +    * @default
    +    */
    +    this.disabled = false;
    +
    +    /**
    +    * If the mouse has been Pointer Locked successfully this will be set to true.
    +    * @property {boolean} locked
    +    * @default
    +    */
    +    this.locked = false;
    +
    +};
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Mouse.LEFT_BUTTON = 0;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Mouse.MIDDLE_BUTTON = 1;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.Mouse.RIGHT_BUTTON = 2;
    +
    +Phaser.Mouse.prototype = {
    +
    +	/**
    +    * Starts the event listeners running.
    +    * @method Phaser.Mouse#start
    +    */
    +    start: function () {
    +
    +        var _this = this;
    +
    +        if (this.game.device.android && this.game.device.chrome == false)
    +        {
    +            //  Android stock browser fires mouse events even if you preventDefault on the touchStart, so ...
    +            return;
    +        }
    +
    +        this._onMouseDown = function (event) {
    +            return _this.onMouseDown(event);
    +        };
    +
    +        this._onMouseMove = function (event) {
    +            return _this.onMouseMove(event);
    +        };
    +
    +        this._onMouseUp = function (event) {
    +            return _this.onMouseUp(event);
    +        };
    +
    +        this.game.renderer.view.addEventListener('mousedown', this._onMouseDown, true);
    +        this.game.renderer.view.addEventListener('mousemove', this._onMouseMove, true);
    +        this.game.renderer.view.addEventListener('mouseup', this._onMouseUp, true);
    +
    +    },
    +
    +	/**
    +	* Description.
    +	* @method Phaser.Mouse#onMouseDown
    +    * @param {MouseEvent} event
    +    */
    +    onMouseDown: function (event) {
    +
    +        if (this.mouseDownCallback)
    +        {
    +            this.mouseDownCallback.call(this.callbackContext, event);
    +        }
    +
    +        if (this.game.input.disabled || this.disabled)
    +        {
    +            return;
    +        }
    +
    +        event['identifier'] = 0;
    +
    +        this.game.input.mousePointer.start(event);
    +
    +    },
    +
    +	/**
    +	* Description
    +	* @method Phaser.Mouse#onMouseMove
    +    * @param {MouseEvent} event
    +    */
    +    onMouseMove: function (event) {
    +
    +        if (this.mouseMoveCallback)
    +        {
    +            this.mouseMoveCallback.call(this.callbackContext, event);
    +        }
    +
    +        if (this.game.input.disabled || this.disabled)
    +        {
    +            return;
    +        }
    +
    +        event['identifier'] = 0;
    +
    +        this.game.input.mousePointer.move(event);
    +
    +    },
    +
    +	/**
    +	* Description.
    +	* @method Phaser.Mouse#onMouseUp
    +    * @param {MouseEvent} event
    +    */
    +    onMouseUp: function (event) {
    +
    +        if (this.mouseUpCallback)
    +        {
    +            this.mouseUpCallback.call(this.callbackContext, event);
    +        }
    +
    +        if (this.game.input.disabled || this.disabled)
    +        {
    +            return;
    +        }
    +
    +        event['identifier'] = 0;
    +
    +        this.game.input.mousePointer.stop(event);
    +
    +    },
    +
    +    /**
    +    * Description.
    +	* @method Phaser.Mouse#requestPointerLock
    +    */
    +    requestPointerLock: function () {
    +
    +        if (this.game.device.pointerLock)
    +        {
    +            var element = this.game.stage.canvas;
    +
    +            element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock;
    +
    +            element.requestPointerLock();
    +
    +            var _this = this;
    +
    +            this._pointerLockChange = function (event) {
    +                return _this.pointerLockChange(event);
    +            };
    +
    +            document.addEventListener('pointerlockchange', this._pointerLockChange, false);
    +            document.addEventListener('mozpointerlockchange', this._pointerLockChange, false);
    +            document.addEventListener('webkitpointerlockchange', this._pointerLockChange, false);
    +        }
    +
    +    },
    +
    +	/**
    +	* Description.
    +	* @method Phaser.Mouse#pointerLockChange
    +    * @param {MouseEvent} event
    +    */
    +    pointerLockChange: function (event) {
    +
    +        var element = this.game.stage.canvas;
    +
    +        if (document.pointerLockElement === element || document.mozPointerLockElement === element || document.webkitPointerLockElement === element)
    +        {
    +            //  Pointer was successfully locked
    +            this.locked = true;
    +        }
    +        else
    +        {
    +            //  Pointer was unlocked
    +            this.locked = false;
    +        }
    +
    +    },
    +
    +	/**
    +	* Description.
    +	* @method Phaser.Mouse#releasePointerLock
    +    */
    +    releasePointerLock: function () {
    +
    +        document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock;
    +
    +        document.exitPointerLock();
    +
    +        document.removeEventListener('pointerlockchange', this._pointerLockChange);
    +        document.removeEventListener('mozpointerlockchange', this._pointerLockChange);
    +        document.removeEventListener('webkitpointerlockchange', this._pointerLockChange);
    +
    +    },
    +
    +	/**
    +    * Stop the event listeners.
    +    * @method Phaser.Mouse#stop
    +    */
    +    stop: function () {
    +
    +        this.game.stage.canvas.removeEventListener('mousedown', this._onMouseDown);
    +        this.game.stage.canvas.removeEventListener('mousemove', this._onMouseMove);
    +        this.game.stage.canvas.removeEventListener('mouseup', this._onMouseUp);
    +
    +    }
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Net.js.html b/docs/Net.js.html new file mode 100644 index 00000000..a33221c2 --- /dev/null +++ b/docs/Net.js.html @@ -0,0 +1,613 @@ + + + + + + Phaser Source: net/Net.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: net/Net.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Description of Phaser.Net
    +*
    +* @class Phaser.Net
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +*/
    +Phaser.Net = function (game) {
    +	
    +	this.game = game;
    +
    +};
    +
    +Phaser.Net.prototype = {
    +
    +	/**
    +	* Returns the hostname given by the browser.
    +	* 
    +	* @method Phaser.Net#getHostName
    +	* @return {string}
    +	*/        
    +	getHostName: function () {
    +
    +		if (window.location && window.location.hostname) {
    +			return window.location.hostname;
    +		}
    +
    +		return null;
    +
    +	},
    +
    +	/**
    +	* Compares the given domain name against the hostname of the browser containing the game.
    +	* If the domain name is found it returns true.
    +	* You can specify a part of a domain, for example 'google' would match 'google.com', 'google.co.uk', etc.
    +	* Do not include 'http://' at the start.
    +	* 
    +	* @method Phaser.Net#checkDomainName
    +	* @param {string} domain
    +	* @return {boolean}
    +	*/        
    +	checkDomainName: function (domain) {
    +		return window.location.hostname.indexOf(domain) !== -1;
    +	},
    +
    +	/**
    +	* Updates a value on the Query String and returns it in full.
    +	* If the value doesn't already exist it is set.
    +	* If the value exists it is replaced with the new value given. If you don't provide a new value it is removed from the query string.
    +	* Optionally you can redirect to the new url, or just return it as a string.
    +	* 
    +	* @method Phaser.Net#updateQueryString
    +	* @param {string} key - The querystring key to update.
    +	* @param {string} value - The new value to be set. If it already exists it will be replaced.
    +	* @param {boolean} redirect - If true the browser will issue a redirect to the url with the new querystring.
    +	* @param {string} url - The URL to modify. If none is given it uses window.location.href.
    +	* @return {string} If redirect is false then the modified url and query string is returned.
    +	*/
    +	updateQueryString: function (key, value, redirect, url) {
    +
    +		if (typeof redirect === "undefined") { redirect = false; }
    +		if (typeof url === "undefined") { url = ''; }
    +
    +		if (url == '') {
    +			url = window.location.href;
    +		}
    +
    +		var output = '';
    +		var re = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi");
    +		
    +		if (re.test(url))
    +		{
    +			if (typeof value !== 'undefined' && value !== null)
    +			{
    +				output = url.replace(re, '$1' + key + "=" + value + '$2$3');
    +			}
    +			else
    +			{
    +				output = url.replace(re, '$1$3').replace(/(&|\?)$/, '');
    +			}
    +		}
    +		else
    +		{
    +			if (typeof value !== 'undefined' && value !== null)
    +			{
    +				var separator = url.indexOf('?') !== -1 ? '&' : '?';
    +				var hash = url.split('#');
    +				url = hash[0] + separator + key + '=' + value;
    +
    +				if (hash[1]) {
    +					url += '#' + hash[1];
    +				}
    +
    +				output = url;
    +
    +			}
    +			else
    +			{
    +				output = url;
    +			}
    +		}
    +
    +		if (redirect)
    +		{
    +			window.location.href = output;
    +		}
    +		else
    +		{
    +			return output;
    +		}
    +
    +	},
    +
    +	/**
    +	* Returns the Query String as an object.
    +	* If you specify a parameter it will return just the value of that parameter, should it exist.
    +	* 
    +	* @method Phaser.Net#getQueryString
    +	* @param {string} [parameter=''] - If specified this will return just the value for that key.
    +	* @return {string|object} An object containing the key value pairs found in the query string or just the value if a parameter was given.
    +	*/
    +	getQueryString: function (parameter) {
    +
    +		if (typeof parameter === "undefined") { parameter = ''; }
    +
    +		var output = {};
    +		var keyValues = location.search.substring(1).split('&');
    +
    +		for (var i in keyValues) {
    +
    +			var key = keyValues[i].split('=');
    +
    +			if (key.length > 1)
    +			{
    +				if (parameter && parameter == this.decodeURI(key[0]))
    +				{
    +					return this.decodeURI(key[1]);
    +				}
    +				else
    +				{
    +					output[this.decodeURI(key[0])] = this.decodeURI(key[1]);
    +				}
    +			}
    +		}
    +
    +		return output;
    +
    +	},
    +
    +	/**
    +	* Returns the Query String as an object.
    +	* If you specify a parameter it will return just the value of that parameter, should it exist.
    +	* 
    +	* @method Phaser.Net#decodeURI
    +	* @param {string} value - The URI component to be decoded.
    +	* @return {string} The decoded value.
    +	*/
    +	decodeURI: function (value) {
    +		return decodeURIComponent(value.replace(/\+/g, " "));
    +	}
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Particles.js.html b/docs/Particles.js.html new file mode 100644 index 00000000..62b93b8b --- /dev/null +++ b/docs/Particles.js.html @@ -0,0 +1,518 @@ + + + + + + Phaser Source: particles/Particles.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: particles/Particles.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser.Particles is the Particle Manager for the game. It is called during the game update loop and in turn updates any Emitters attached to it.
    +*
    +* @class Phaser.Particles
    +* @classdesc Phaser Particles
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +*/
    +Phaser.Particles = function (game) {
    +
    +	/**
    +    * @property {Description} emitters - Description.
    +	*/
    +	this.emitters = {};
    +
    +	/**
    +	* @property {number} ID - Description.
    +	* @default
    +	*/
    +	this.ID = 0;
    +
    +};
    +
    +Phaser.Particles.prototype = {
    +
    +	/**
    +	* Adds a new Particle Emitter to the Particle Manager.
    +	* @method Phaser.Particles#add
    +	* @param {Phaser.Emitter} emitter - Description.
    +	* @return {Phaser.Emitter} The emitter that was added.
    +	*/
    +	add: function (emitter) {
    +
    +		this.emitters[emitter.name] = emitter;
    +
    +		return emitter;
    +
    +	},
    +
    +	/**
    +	* Removes an existing Particle Emitter from the Particle Manager.
    +	* @method Phaser.Particles#remove
    +	* @param {Phaser.Emitter} emitter - The emitter to remove.
    +	*/
    +	remove: function (emitter) {
    +
    +		delete this.emitters[emitter.name];
    +
    +	},
    +
    +	/**
    +	* Called by the core game loop. Updates all Emitters who have their exists value set to true.
    +	* @method Phaser.Particles#update
    +	* @protected
    +	*/
    +	update: function () {
    +
    +		for (var key in this.emitters)
    +		{
    +			if (this.emitters[key].exists)
    +			{
    +				this.emitters[key].update();
    +			}
    +		}
    +
    +	}
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Phaser.Animation.html b/docs/Phaser.Animation.html new file mode 100644 index 00000000..60ce6940 --- /dev/null +++ b/docs/Phaser.Animation.html @@ -0,0 +1,2922 @@ + + + + + + Phaser Class: Animation + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Animation

    +
    + +
    +

    + Phaser. + + Animation +

    + +

    Phaser.Animation

    + +
    + +
    +
    + + + + +
    +

    new Animation(game, parent, name, frameData, frames, delay, looped)

    + + +
    +
    + + +
    +

    An Animation instance contains a single animation and the controls to play it. +It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    parent + + +Phaser.Sprite + + + +

    A reference to the owner of this Animation.

    name + + +string + + + +

    The unique name for this animation, used in playback commands.

    frameData + + +Phaser.FrameData + + + +

    The FrameData object that contains all frames used by this Animation.

    frames + + +Array.<number> +| + +Array.<string> + + + +

    An array of numbers or strings indicating which frames to play in which order.

    delay + + +number + + + +

    The time between each frame of the animation, given in ms.

    looped + + +boolean + + + +

    Should this animation loop or play through once.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    currentFrame

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    currentFrame + + +Phaser.Frame + + + +

    The currently displayed frame of the Animation.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    delay

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    delay + + +number + + + +

    The delay in ms between each frame of the Animation.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    frame

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    frame + + +number + + + +

    Gets or sets the current frame index and updates the Texture Cache for display.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> frameTotal

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    frameTotal + + +number + + + +

    The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isFinished

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isFinished + + +boolean + + + +

    The finished state of the Animation. Set to true once playback completes, false during playback.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isPaused

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isPaused + + +boolean + + + +

    The paused state of the Animation.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isPlaying

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isPlaying + + +boolean + + + +

    The playing state of the Animation. Set to false once playback completes, true during playback.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    killOnComplete

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    looped + + +boolean + + + +

    The loop state of the Animation.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    looped

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    looped + + +boolean + + + +

    The loop state of the Animation.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    name

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    The user defined name given to this Animation.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    paused

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    paused + + +boolean + + + +

    Gets and sets the paused state of this Animation.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    <static> generateFrameNames(prefix, start, stop, suffix, zeroPad)

    + + +
    +
    + + +
    +

    Really handy function for when you are creating arrays of animation data but it's using frame names and not numbers. +For example imagine you've got 30 frames named: 'explosion0001-large' to 'explosion_0030-large' +You could use this function to generate those by doing: Phaser.Animation.generateFrameNames('explosion', 1, 30, '-large', 4);

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    prefix + + +string + + + + + + + + + + + +

    The start of the filename. If the filename was 'explosion0001-large' the prefix would be 'explosion'.

    start + + +number + + + + + + + + + + + +

    The number to start sequentially counting from. If your frames are named 'explosion_0001' to 'explosion_0034' the start is 1.

    stop + + +number + + + + + + + + + + + +

    The number to count to. If your frames are named 'explosion_0001' to 'explosion_0034' the stop value is 34.

    suffix + + +string + + + + + + <optional>
    + + + + + +
    + + '' + +

    The end of the filename. If the filename was 'explosion_0001-large' the prefix would be '-large'.

    zeroPad + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The number of zeroes to pad the min and max values with. If your frames are named 'explosion_0001' to 'explosion_0034' then the zeroPad is 4.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Cleans up this animation ready for deletion. Nulls all values and references.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onComplete()

    + + +
    +
    + + +
    +

    Called internally when the animation finishes playback. Sets the isPlaying and isFinished states and dispatches the onAnimationComplete event if it exists on the parent.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    play(frameRate, loop, killOnComplete) → {Phaser.Animation}

    + + +
    +
    + + +
    +

    Plays this animation.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    frameRate + + +number + + + + + + <optional>
    + + + + + +
    + + null + +

    The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.

    loop + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.

    killOnComplete + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +
      +
    • A reference to this Animation instance.
    • +
    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Animation + + +
    +
    + + + + + +
    + + + +
    +

    restart()

    + + +
    +
    + + +
    +

    Sets this animation back to the first frame and restarts the animation.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stop(resetFrame)

    + + +
    +
    + + +
    +

    Stops playback of this animation and set it to a finished state. If a resetFrame is provided it will stop playback and set frame to the first in the animation.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    resetFrame + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If true after the animation stops the currentFrame value will be set to the first frame in this animation.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    update()

    + + +
    +
    + + +
    +

    Updates this animation. Called automatically by the AnimationManager.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.AnimationManager.html b/docs/Phaser.AnimationManager.html new file mode 100644 index 00000000..6c83538d --- /dev/null +++ b/docs/Phaser.AnimationManager.html @@ -0,0 +1,2831 @@ + + + + + + Phaser Class: AnimationManager + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: AnimationManager

    +
    + +
    +

    + Phaser. + + AnimationManager +

    + +

    Phaser.AnimationManager

    + +
    + +
    +
    + + + + +
    +

    new AnimationManager(sprite)

    + + +
    +
    + + +
    +

    The Animation Manager is used to add, play and update Phaser Animations. +Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sprite + + +Phaser.Sprite + + + +

    A reference to the Game Object that owns this AnimationManager.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    currentFrame

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    currentFrame + + +Phaser.Frame + + + +

    The currently displayed Frame of animation, if any.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    frame

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    frame + + +number + + + +

    Gets or sets the current frame index and updates the Texture Cache for display.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> frameData

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    frameData + + +Phaser.FrameData + + + +

    The current animations FrameData.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    frameName

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    frameName + + +string + + + +

    Gets or sets the current frame name and updates the Texture Cache for display.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> frameTotal

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    frameTotal + + +number + + + +

    The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isLoaded

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isLoaded + + +boolean + + + +

    Set to true once animation data has been loaded.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    paused

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    paused + + +boolean + + + +

    Gets and sets the paused state of the current animation.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    sprite

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sprite + + +Phaser.Sprite + + + +

    A reference to the parent Sprite that owns this AnimationManager.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    updateIfVisible

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    updateIfVisible + + +boolean + + + +

    Should the animation data continue to update even if the Sprite.visible is set to false.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    add(name, frames, frameRate, loop, useNumericIndex) → {Phaser.Animation}

    + + +
    +
    + + +
    +

    Adds a new animation under the given key. Optionally set the frames, frame rate and loop. +Animations added in this way are played back with the play function.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    name + + +string + + + + + + + + + + + +

    The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk".

    frames + + +Array + + + + + + <optional>
    + + + + + +
    + + null + +

    An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used.

    frameRate + + +number + + + + + + <optional>
    + + + + + +
    + + 60 + +

    The speed at which the animation should play. The speed is given in frames per second.

    loop + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Whether or not the animation is looped or just plays once.

    useNumericIndex + + +boolean + + + + + + <optional>
    + + + + + +
    + + true + +

    Are the given frames using numeric indexes (default) or strings?

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Animation object that was created.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Animation + + +
    +
    + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Destroys all references this AnimationManager contains. Sets the _anims to a new object and nulls the current animation.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    play(name, frameRate, loop, killOnComplete) → {Phaser.Animation}

    + + +
    +
    + + +
    +

    Play an animation based on the given key. The animation should previously have been added via sprite.animations.add() +If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    name + + +string + + + + + + + + + + + +

    The name of the animation to be played, e.g. "fire", "walk", "jump".

    frameRate + + +number + + + + + + <optional>
    + + + + + +
    + + null + +

    The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.

    loop + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.

    killOnComplete + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A reference to playing Animation instance.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Animation + + +
    +
    + + + + + +
    + + + +
    +

    refreshFrame()

    + + +
    +
    + + +
    +

    Refreshes the current frame data back to the parent Sprite and also resets the texture data.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stop(name, resetFrame)

    + + +
    +
    + + +
    +

    Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the current animation is stopped. +The currentAnim property of the AnimationManager is automatically set to the animation given.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    name + + +string + + + + + + <optional>
    + + + + + +
    + + null + +

    The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped.

    resetFrame + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false)

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> update() → {boolean}

    + + +
    +
    + + +
    +

    The main update function is called by the Sprites update loop. It's responsible for updating animation frames and firing related events.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if a new animation frame has been set, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    validateFrames(frames, useNumericIndex) → {boolean}

    + + +
    +
    + + +
    +

    Check whether the frames in the given array are valid and exist.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    frames + + +Array + + + + + + + + + + + +

    An array of frames to be validated.

    useNumericIndex + + +boolean + + + + + + <optional>
    + + + + + +
    + + true + +

    Validate the frames based on their numeric index (true) or string index (false)

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if all given Frames are valid, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:25 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.AnimationParser.html b/docs/Phaser.AnimationParser.html new file mode 100644 index 00000000..3ad56596 --- /dev/null +++ b/docs/Phaser.AnimationParser.html @@ -0,0 +1,1415 @@ + + + + + + Phaser Class: AnimationParser + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: AnimationParser

    +
    + +
    +

    + Phaser. + + AnimationParser +

    + +
    + +
    +
    + + + + +
    +

    new AnimationParser()

    + + +
    +
    + + +
    +

    Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    <static> JSONData(game, json, cacheKey) → {Phaser.FrameData}

    + + +
    +
    + + +
    +

    Parse the JSON data and extract the animation frame data from it.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    json + + +Object + + + +

    The JSON data from the Texture Atlas. Must be in Array format.

    cacheKey + + +string + + + +

    The Game.Cache asset key of the texture image.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A FrameData object containing the parsed frames.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.FrameData + + +
    +
    + + + + + +
    + + + +
    +

    <static> JSONDataHash(game, json, cacheKey) → {Phaser.FrameData}

    + + +
    +
    + + +
    +

    Parse the JSON data and extract the animation frame data from it.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    json + + +Object + + + +

    The JSON data from the Texture Atlas. Must be in JSON Hash format.

    cacheKey + + +string + + + +

    The Game.Cache asset key of the texture image.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A FrameData object containing the parsed frames.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.FrameData + + +
    +
    + + + + + +
    + + + +
    +

    <static> spriteSheet(game, key, frameWidth, frameHeight, frameMax) → {Phaser.FrameData}

    + + +
    +
    + + +
    +

    Parse a Sprite Sheet and extract the animation frame data from it.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    game + + +Phaser.Game + + + + + + + + + + + +

    A reference to the currently running game.

    key + + +string + + + + + + + + + + + +

    The Game.Cache asset key of the Sprite Sheet image.

    frameWidth + + +number + + + + + + + + + + + +

    The fixed width of each frame of the animation.

    frameHeight + + +number + + + + + + + + + + + +

    The fixed height of each frame of the animation.

    frameMax + + +number + + + + + + <optional>
    + + + + + +
    + + -1 + +

    The total number of animation frames to extact from the Sprite Sheet. The default value of -1 means "extract all frames".

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A FrameData object containing the parsed frames.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.FrameData + + +
    +
    + + + + + +
    + + + +
    +

    <static> XMLData(game, xml, cacheKey) → {Phaser.FrameData}

    + + +
    +
    + + +
    +

    Parse the XML data and extract the animation frame data from it.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    xml + + +Object + + + +

    The XML data from the Texture Atlas. Must be in Starling XML format.

    cacheKey + + +string + + + +

    The Game.Cache asset key of the texture image.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A FrameData object containing the parsed frames.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.FrameData + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:25 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.BitmapText.html b/docs/Phaser.BitmapText.html new file mode 100644 index 00000000..52fb8e8d --- /dev/null +++ b/docs/Phaser.BitmapText.html @@ -0,0 +1,1594 @@ + + + + + + Phaser Class: BitmapText + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: BitmapText

    +
    + +
    +

    + Phaser. + + BitmapText +

    + +

    Phaser.BitmapText

    + +
    + +
    +
    + + + + +
    +

    new BitmapText(game, x, y, text, style)

    + + +
    +
    + + +
    +

    Creates a new <code>BitmapText</code>.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    x + + +number + + + +

    X position of the new bitmapText object.

    y + + +number + + + +

    Y position of the new bitmapText object.

    text + + +string + + + +

    The actual text that will be written.

    style + + +object + + + +

    The style object containing style attributes like font, font size , etc.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    alive

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    alive + + +boolean + + + +

    This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    anchor

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    anchor + + +Phaser.Point + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    exists

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    exists + + +boolean + + + +

    If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    group

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    group + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    name

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    scale

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    scale + + +Phaser.Point + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    update()

    + + +
    +
    + + +
    +

    Automatically called by World.update

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:25 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Bullet.html b/docs/Phaser.Bullet.html new file mode 100644 index 00000000..7f9a640e --- /dev/null +++ b/docs/Phaser.Bullet.html @@ -0,0 +1,4085 @@ + + + + + + Phaser Class: Bullet + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Bullet

    +
    + +
    +

    + Phaser. + + Bullet +

    + +

    Phaser.Bullet

    + +
    + +
    +
    + + + + +
    +

    new Bullet(game, x, y, key, frame)

    + + +
    +
    + + +
    +

    Warning: Bullet is an experimental object that we don't advise using for now.

    +

    A Bullet is like a stripped-down Sprite, useful for when you just need to get something moving around the screen quickly with little of the extra +features that a Sprite supports. +Bullet is MISSING the following:

    +

    animation, all input events, crop support, health/damage, loadTexture

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Current game instance.

    x + + +number + + + +

    X position of the new bullet.

    y + + +number + + + +

    Y position of the new bullet.

    key + + +string +| + +Phaser.RenderTexture +| + +PIXI.Texture + + + +

    This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.

    frame + + +string +| + +number + + + +

    If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    alive

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    alive + + +boolean + + + +

    This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    anchor

    + + +
    +
    + +
    +

    The anchor sets the origin point of the texture. +The default is 0,0 this means the textures origin is the top left +Setting than anchor to 0.5,0.5 means the textures origin is centered +Setting the anchor to 1,1 would mean the textures origin points will be the bottom right

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    anchor + + +Phaser.Point + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    angle

    + + +
    +
    + +
    +

    Indicates the rotation of the Bullet, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. +Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90. +If you wish to work in radians instead of degrees use the property Bullet.rotation instead.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    angle + + +number + + + +

    Gets or sets the Bullets angle of rotation in degrees.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    autoCull

    + + +
    +
    + +
    +

    Should this Sprite be automatically culled if out of range of the camera? +A culled sprite has its visible property set to 'false'. +Note that this check doesn't look at this Sprites children, which may still be in camera range. +So you should set autoCull to false if the Sprite will have children likely to still be in camera range.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    autoCull + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    body

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    body + + +Phaser.Physics.Arcade.Body + + + +

    Set-up the physics body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bottomLeft

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bottomLeft + + +Phaser.Point + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bottomRight

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bottomRight + + +Phaser.Point + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bounds

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bounds + + +Phaser.Rectangle + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    center

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    center + + +Phaser.Point + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    events

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    events + + +Events + + + +

    The Signals you can subscribe to that are dispatched when certain things happen on this Sprite or its components

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    exists

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    exists + + +boolean + + + +

    If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    fixedToCamera

    + + +
    +
    + +
    +

    A Sprite that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    fixedToCamera + + +boolean + + + +

    Fixes this Sprite to the Camera.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    group

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    group + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    inWorld

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    inWorld + + +Description + + + +

    World bounds check.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    inWorldThreshold

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    inWorldThreshold + + +number + + + +

    World bounds check.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    key

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    lifespan

    + + +
    +
    + +
    +

    If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc. +The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    lifespan + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    name

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    The user defined name given to this Sprite.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    offset

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    offset + + +Phaser.Point + + + +

    Corner point defaults.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    outOfBoundsKill

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    outOfBoundsKill + + +boolean + + + +

    Kills this sprite as soon as it goes outside of the World bounds.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    renderOrderID

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    renderOrderID + + +number + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    scale

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    scale + + +Phaser.Point + + + +

    Replaces the PIXI.Point with a slightly more flexible one.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    topLeft

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    topLeft + + +Phaser.Point + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    topRight

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    topRight + + +Phaser.Point + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    bringToTop()

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    getLocalPosition(p, x, y) → {Description}

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    p + + +Description + + + +

    Description.

    x + + +number + + + +

    Description.

    y + + +number + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Description.

    +
    + + + +
    +
    + Type +
    +
    + +Description + + +
    +
    + + + + + +
    + + + +
    +

    kill()

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    revive()

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:25 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Button.html b/docs/Phaser.Button.html new file mode 100644 index 00000000..d4a40ef8 --- /dev/null +++ b/docs/Phaser.Button.html @@ -0,0 +1,2079 @@ + + + + + + Phaser Class: Button + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Button

    +
    + +
    +

    + Phaser. + + Button +

    + +

    Phaser.Button

    + +
    + +
    +
    + + + + +
    +

    new Button(game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame)

    + + +
    +
    + + +
    +

    Create a new <code>Button</code> object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    game + + +Phaser.Game + + + + + + + + + +

    Current game instance.

    x + + +number + + + + + + <optional>
    + + + + + +

    X position of the button.

    y + + +number + + + + + + <optional>
    + + + + + +

    Y position of the button.

    key + + +string + + + + + + <optional>
    + + + + + +

    The image key as defined in the Game.Cache to use as the texture for this button.

    callback + + +function + + + + + + <optional>
    + + + + + +

    The function to call when this button is pressed

    callbackContext + + +object + + + + + + <optional>
    + + + + + +

    The context in which the callback will be called (usually 'this')

    overFrame + + +string +| + +number + + + + + + <optional>
    + + + + + +

    This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.

    outFrame + + +string +| + +number + + + + + + <optional>
    + + + + + +

    This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.

    downFrame + + +string +| + +number + + + + + + <optional>
    + + + + + +

    This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    onInputDown

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onInputDown + + +Phaser.Signal + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onInputOut

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onInputOut + + +Phaser.Signal + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onInputOver

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onInputOver + + +Phaser.Signal + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onInputUp

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onInputUp + + +Phaser.Signal + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    onInputDownHandler(pointer)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Description + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onInputOutHandler(pointer)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Description + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onInputOverHandler(pointer)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Description + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onInputUpHandler(pointer)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Description + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setFrames(overFrame, outFrame, downFrame)

    + + +
    +
    + + +
    +

    Used to manually set the frames that will be used for the different states of the button +exactly like setting them in the constructor.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    overFrame + + +string +| + +number + + + + + + <optional>
    + + + + + +

    This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.

    outFrame + + +string +| + +number + + + + + + <optional>
    + + + + + +

    This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.

    downFrame + + +string +| + +number + + + + + + <optional>
    + + + + + +

    This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:25 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Cache.html b/docs/Phaser.Cache.html new file mode 100644 index 00000000..6aec7bce --- /dev/null +++ b/docs/Phaser.Cache.html @@ -0,0 +1,6921 @@ + + + + + + Phaser Class: Cache + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Cache

    +
    + +
    +

    + Phaser. + + Cache +

    + +

    A game only has one instance of a Cache and it is used to store all externally loaded assets such +as images, sounds and data files as a result of Loader calls. Cache items use string based keys for look-up.

    + +
    + +
    +
    + + + + +
    +

    new Cache(game)

    + + +
    +
    + + +
    +

    Phaser.Cache constructor.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onSoundUnlock

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onSoundUnlock + + +Phaser.Signal + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    addBitmapFont(key, url, data, xmlData)

    + + +
    +
    + + +
    +

    Add a new Bitmap Font.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    The unique key by which you will reference this object.

    url + + +string + + + +

    URL of this font xml file.

    data + + +object + + + +

    Extra font data.

    xmlData + + +object + + + +

    Texture atlas frames data.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addCanvas(key, canvas, context)

    + + +
    +
    + + +
    +

    Add a new canvas object in to the cache.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key for this canvas.

    canvas + + +HTMLCanvasElement + + + +

    Canvas DOM element.

    context + + +CanvasRenderingContext2D + + + +

    Render context of this canvas.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addDefaultImage()

    + + +
    +
    + + +
    +

    Adds a default image to be used when a key is wrong / missing. Is mapped to the key __default.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addImage(key, url, data)

    + + +
    +
    + + +
    +

    Add a new image.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    The unique key by which you will reference this object.

    url + + +string + + + +

    URL of this image file.

    data + + +object + + + +

    Extra image data.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addRenderTexture(key, textue)

    + + +
    +
    + + +
    +

    Add a new Phaser.RenderTexture in to the cache.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    The unique key by which you will reference this object.

    textue + + +Phaser.Texture + + + +

    The texture to use as the base of the RenderTexture.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addSound(key, url, data, webAudio, audioTag)

    + + +
    +
    + + +
    +

    Add a new sound.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key for the sound.

    url + + +string + + + +

    URL of this sound file.

    data + + +object + + + +

    Extra sound data.

    webAudio + + +boolean + + + +

    True if the file is using web audio.

    audioTag + + +boolean + + + +

    True if the file is using legacy HTML audio.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addSpriteSheet(key, url, data, frameWidth, frameHeight, frameMax)

    + + +
    +
    + + +
    +

    Add a new sprite sheet in to the cache.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    The unique key by which you will reference this object.

    url + + +string + + + +

    URL of this sprite sheet file.

    data + + +object + + + +

    Extra sprite sheet data.

    frameWidth + + +number + + + +

    Width of the sprite sheet.

    frameHeight + + +number + + + +

    Height of the sprite sheet.

    frameMax + + +number + + + +

    How many frames stored in the sprite sheet.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addText(key, url, data)

    + + +
    +
    + + +
    +

    Add a new text data.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key for the text data.

    url + + +string + + + +

    URL of this text data file.

    data + + +object + + + +

    Extra text data.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addTextureAtlas(key, url, data, atlasData, format)

    + + +
    +
    + + +
    +

    Add a new texture atlas.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    The unique key by which you will reference this object.

    url + + +string + + + +

    URL of this texture atlas file.

    data + + +object + + + +

    Extra texture atlas data.

    atlasData + + +object + + + +

    Texture atlas frames data.

    format + + +number + + + +

    The format of the texture atlas.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addTilemap(key, url, mapData, format)

    + + +
    +
    + + +
    +

    Add a new tilemap.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    The unique key by which you will reference this object.

    url + + +string + + + +

    URL of the tilemap image.

    mapData + + +object + + + +

    The tilemap data object.

    format + + +number + + + +

    The format of the tilemap data.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addTileset(key, url, data, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing)

    + + +
    +
    + + +
    +

    Add a new tile set in to the cache.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    key + + +string + + + + + + + + + + + +

    The unique key by which you will reference this object.

    url + + +string + + + + + + + + + + + +

    URL of this tile set file.

    data + + +object + + + + + + + + + + + +

    Extra tile set data.

    tileWidth + + +number + + + + + + + + + + + +

    Width of the sprite sheet.

    tileHeight + + +number + + + + + + + + + + + +

    Height of the sprite sheet.

    tileMax + + +number + + + + + + + + + + + +

    How many tiles stored in the sprite sheet.

    tileMargin + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    If the tiles have been drawn with a margin, specify the amount here.

    tileSpacing + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    If the tiles have been drawn with spacing between them, specify the amount here.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    checkImageKey(key) → {boolean}

    + + +
    +
    + + +
    +

    Checks if an image key exists.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the image you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the key exists, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    decodedSound(key, data)

    + + +
    +
    + + +
    +

    Add a new decoded sound.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key for the sound.

    data + + +object + + + +

    Extra sound data.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Clears the cache. Removes every local cache object reference.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    getCanvas(key) → {object}

    + + +
    +
    + + +
    +

    Get acanvas object from the cache by its key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the canvas you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The canvas you want.

    +
    + + + +
    +
    + Type +
    +
    + +object + + +
    +
    + + + + + +
    + + + +
    +

    getFrame(key) → {Phaser.Frame}

    + + +
    +
    + + +
    +

    Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the frame data you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The frame data you want.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Frame + + +
    +
    + + + + + +
    + + + +
    +

    getFrameByIndex(key) → {Phaser.Frame}

    + + +
    +
    + + +
    +

    Get a single frame out of a frameData set by key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the frame data you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The frame data you want.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Frame + + +
    +
    + + + + + +
    + + + +
    +

    getFrameByName(key) → {Phaser.Frame}

    + + +
    +
    + + +
    +

    Get a single frame out of a frameData set by key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the frame data you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The frame data you want.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Frame + + +
    +
    + + + + + +
    + + + +
    +

    getFrameData(key) → {Phaser.FrameData}

    + + +
    +
    + + +
    +

    Get frame data by key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the frame data you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The frame data you want.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.FrameData + + +
    +
    + + + + + +
    + + + +
    +

    getImage(key) → {object}

    + + +
    +
    + + +
    +

    Get image data by key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the image you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The image data you want.

    +
    + + + +
    +
    + Type +
    +
    + +object + + +
    +
    + + + + + +
    + + + +
    +

    getImageKeys() → {Array}

    + + +
    +
    + + +
    +

    Returns an array containing all of the keys of Images in the Cache.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The string based keys in the Cache.

    +
    + + + +
    +
    + Type +
    +
    + +Array + + +
    +
    + + + + + +
    + + + +
    +

    getKeys(array) → {Array}

    + + +
    +
    + + +
    +

    Get the cache keys from a given array of objects. +Normally you don't call this directly but instead use getImageKeys, getSoundKeys, etc.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    array + + +Array + + + +

    An array of items to return the keys for.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The array of item keys.

    +
    + + + +
    +
    + Type +
    +
    + +Array + + +
    +
    + + + + + +
    + + + +
    +

    getSound(key) → {Phaser.Sound}

    + + +
    +
    + + +
    +

    Get sound by key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the sound you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The sound you want.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Sound + + +
    +
    + + + + + +
    + + + +
    +

    getSoundData(key) → {object}

    + + +
    +
    + + +
    +

    Get sound data by key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the sound you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The sound data you want.

    +
    + + + +
    +
    + Type +
    +
    + +object + + +
    +
    + + + + + +
    + + + +
    +

    getSoundKeys() → {Array}

    + + +
    +
    + + +
    +

    Returns an array containing all of the keys of Sounds in the Cache.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The string based keys in the Cache.

    +
    + + + +
    +
    + Type +
    +
    + +Array + + +
    +
    + + + + + +
    + + + +
    +

    getText(key) → {object}

    + + +
    +
    + + +
    +

    Get text data by key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the text data you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The text data you want.

    +
    + + + +
    +
    + Type +
    +
    + +object + + +
    +
    + + + + + +
    + + + +
    +

    getTextKeys() → {Array}

    + + +
    +
    + + +
    +

    Returns an array containing all of the keys of Text Files in the Cache.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The string based keys in the Cache.

    +
    + + + +
    +
    + Type +
    +
    + +Array + + +
    +
    + + + + + +
    + + + +
    +

    getTexture(key) → {Phaser.RenderTexture}

    + + +
    +
    + + +
    +

    Get a RenderTexture by key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the RenderTexture you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The RenderTexture you want.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.RenderTexture + + +
    +
    + + + + + +
    + + + +
    +

    getTextureFrame(key) → {Phaser.Frame}

    + + +
    +
    + + +
    +

    Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the frame data you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The frame data you want.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Frame + + +
    +
    + + + + + +
    + + + +
    +

    getTilemap(key) → {Object}

    + + +
    +
    + + +
    +

    Get tilemap data by key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the tilemap you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tilemap data. The tileset image is in the data property, the map data in mapData.

    +
    + + + +
    +
    + Type +
    +
    + +Object + + +
    +
    + + + + + +
    + + + +
    +

    getTileset(key) → {Phaser.Tileset}

    + + +
    +
    + + +
    +

    Get tile set image data by key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the image you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tileset data. The tileset image is in the data property, the tile data in tileData.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tileset + + +
    +
    + + + + + +
    + + + +
    +

    getTileSetImage(key) → {object}

    + + +
    +
    + + +
    +

    Get tile set image data by key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the image you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The image data you want.

    +
    + + + +
    +
    + Type +
    +
    + +object + + +
    +
    + + + + + +
    + + + +
    +

    isSoundDecoded(key) → {boolean}

    + + +
    +
    + + +
    +

    Check if the given sound has finished decoding.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the sound you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The decoded state of the Sound object.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    isSoundReady(key) → {boolean}

    + + +
    +
    + + +
    +

    Check if the given sound is ready for playback. A sound is considered ready when it has finished decoding and the device is no longer touch locked.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the sound you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the sound is decoded and the device is not touch locked.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    isSpriteSheet(key) → {boolean}

    + + +
    +
    + + +
    +

    Check whether an image asset is sprite sheet or not.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key of the sprite sheet you want.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the image is a sprite sheet.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    reloadSound(key)

    + + +
    +
    + + +
    +

    Reload a sound.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key for the sound.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    reloadSoundComplete(key)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key for the sound.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeCanvas(key)

    + + +
    +
    + + +
    +

    Removes a canvas from the cache.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Key of the asset you want to remove.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeImage(key)

    + + +
    +
    + + +
    +

    Removes an image from the cache.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Key of the asset you want to remove.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeSound(key)

    + + +
    +
    + + +
    +

    Removes a sound from the cache.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Key of the asset you want to remove.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeText(key)

    + + +
    +
    + + +
    +

    Removes a text from the cache.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Key of the asset you want to remove.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    updateSound(key)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key for the sound.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:25 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Camera.html b/docs/Phaser.Camera.html new file mode 100644 index 00000000..95033a23 --- /dev/null +++ b/docs/Phaser.Camera.html @@ -0,0 +1,3271 @@ + + + + + + Phaser Class: Camera + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Camera

    +
    + +
    +

    + Phaser. + + Camera +

    + +

    Phaser.Camera

    + +
    + +
    +
    + + + + +
    +

    new Camera(game, id, x, y, width, height)

    + + +
    +
    + + +
    +

    A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view. +The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Game reference to the currently running game.

    id + + +number + + + +

    Not being used at the moment, will be when Phaser supports multiple camera

    x + + +number + + + +

    Position of the camera on the X axis

    y + + +number + + + +

    Position of the camera on the Y axis

    width + + +number + + + +

    The width of the view rectangle

    height + + +number + + + +

    The height of the view rectangle

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    <static, constant> FOLLOW_LOCKON :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> FOLLOW_PLATFORMER :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> FOLLOW_TOPDOWN :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> FOLLOW_TOPDOWN_TIGHT :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    atLimit

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    atLimit + + +boolean + + + +

    Whether this camera is flush with the World Bounds or not.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bounds

    + + +
    +
    + +
    +

    The Camera is bound to this Rectangle and cannot move outside of it. By default it is enabled and set to the size of the World. +The Rectangle can be located anywhere in the world and updated as often as you like. If you don't wish the Camera to be bound +at all then set this to null. The values can be anything and are in World coordinates, with 0,0 being the center of the world.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bounds + + +Phaser.Rectangle + + + +

    The Rectangle in which the Camera is bounded. Set to null to allow for movement anywhere.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    deadzone

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    deadzone + + +Phaser.Rectangle + + + +

    Moving inside this Rectangle will not cause camera moving.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    height

    + + +
    +
    + +
    +

    The Cameras height. By default this is the same as the Game size and should not be adjusted for now.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    height + + +number + + + +

    Gets or sets the cameras height.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    id

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    id + + +number + + + +

    Reserved for future multiple camera set-ups.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    screenView

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    screenView + + +Phaser.Rectangle + + + +

    Used by Sprites to work out Camera culling.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    target

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    target + + +Phaser.Sprite + + + +

    If the camera is tracking a Sprite, this is a reference to it, otherwise null.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    view

    + + +
    +
    + +
    +

    Camera view. +The view into the world we wish to render (by default the game dimensions). +The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render. +Objects outside of this view are not rendered (unless set to ignore the Camera, i.e. UI?).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    view + + +Phaser.Rectangle + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    visible

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    visible + + +boolean + + + +

    Whether this camera is visible or not.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    width

    + + +
    +
    + +
    +

    The Cameras width. By default this is the same as the Game size and should not be adjusted for now.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    Gets or sets the cameras width.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    world

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    world + + +Phaser.World + + + +

    A reference to the game world.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + +
    +

    The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Gets or sets the cameras x position.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + +
    +

    The Cameras y coordinate. This value is automatically clamped if it falls outside of the World bounds.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    Gets or sets the cameras y position.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    checkWorldBounds()

    + + +
    +
    + + +
    +

    Method called to ensure the camera doesn't venture outside of the game world.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    focusOn(displayObject)

    + + +
    +
    + + +
    +

    Move the camera focus on a display object instantly.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    displayObject + + +any + + + +

    The display object to focus the camera on. Must have visible x/y properties.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    focusOnXY(x, y)

    + + +
    +
    + + +
    +

    Move the camera focus on a location instantly.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    X position.

    y + + +number + + + +

    Y position.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    follow(target, style)

    + + +
    +
    + + +
    +

    Tells this camera which sprite to follow.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    target + + +Phaser.Sprite + + + + + + + + + +

    The object you want the camera to track. Set to null to not follow anything.

    style + + +number + + + + + + <optional>
    + + + + + +

    Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setPosition(x, y)

    + + +
    +
    + + +
    +

    A helper function to set both the X and Y properties of the camera at once +without having to use game.camera.x and game.camera.y.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    X position.

    y + + +number + + + +

    Y position.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setSize(width, height)

    + + +
    +
    + + +
    +

    Sets the size of the view rectangle given the width and height in parameters.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    The desired width.

    height + + +number + + + +

    The desired height.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    update()

    + + +
    +
    + + +
    +

    Update focusing and scrolling.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:25 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Canvas.html b/docs/Phaser.Canvas.html new file mode 100644 index 00000000..21134891 --- /dev/null +++ b/docs/Phaser.Canvas.html @@ -0,0 +1,2515 @@ + + + + + + Phaser Class: Canvas + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Canvas

    +
    + +
    +

    + Phaser. + + Canvas +

    + +
    + +
    +
    + + + + +
    +

    new Canvas()

    + + +
    +
    + + +
    +

    The Canvas class handles everything related to the <canvas> tag as a DOM Element, like styles, offset, aspect ratio

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    <static> addToDOM(canvas, parent, overflowHidden) → {HTMLCanvasElement}

    + + +
    +
    + + +
    +

    Adds the given canvas element to the DOM. The canvas will be added as a child of the given parent. +If no parent is given it will be added as a child of the document.body.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    canvas + + +HTMLCanvasElement + + + +

    The canvas to set the touch action on.

    parent + + +string + + + +

    The DOM element to add the canvas to. Defaults to ''.

    overflowHidden + + +boolean + + + +

    If set to true it will add the overflow='hidden' style to the parent DOM element.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns the source canvas.

    +
    + + + +
    +
    + Type +
    +
    + +HTMLCanvasElement + + +
    +
    + + + + + +
    + + + +
    +

    <static> create(width, height) → {HTMLCanvasElement}

    + + +
    +
    + + +
    +

    Creates the <canvas> tag

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    The desired width.

    height + + +number + + + +

    The desired height.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created <canvas> tag.

    +
    + + + +
    +
    + Type +
    +
    + +HTMLCanvasElement + + +
    +
    + + + + + +
    + + + +
    +

    <static> getAspectRatio(canvas) → {number}

    + + +
    +
    + + +
    +

    Returns the aspect ratio of the given canvas.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    canvas + + +HTMLCanvasElement + + + +

    The canvas to get the aspect ratio from.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The ratio between canvas' width and height.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> getOffset(element, point) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Get the DOM offset values of any given element

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    element + + +HTMLElement + + + + + + + + + +

    The targeted element that we want to retrieve the offset.

    point + + +Phaser.Point + + + + + + <optional>
    + + + + + +

    The point we want to take the x/y values of the offset.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +
      +
    • A point objet with the offsetX and Y as its properties.
    • +
    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    <static> setBackgroundColor(canvas, color) → {HTMLCanvasElement}

    + + +
    +
    + + +
    +

    Sets the background color behind the canvas. This changes the canvas style property.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    canvas + + +HTMLCanvasElement + + + + + + + + + +

    The canvas to set the background color on.

    color + + +string + + + + + + <optional>
    + + + + + +

    The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns the source canvas.

    +
    + + + +
    +
    + Type +
    +
    + +HTMLCanvasElement + + +
    +
    + + + + + +
    + + + +
    +

    <static> setImageRenderingBicubic(canvas) → {HTMLCanvasElement}

    + + +
    +
    + + +
    +

    Sets the CSS image-rendering property on the given canvas to be 'bicubic' (aka 'auto'). +Note that if this doesn't given the desired result then see the CanvasUtils.setSmoothingEnabled method.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    canvas + + +HTMLCanvasElement + + + +

    The canvas to set image-rendering bicubic on.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns the source canvas.

    +
    + + + +
    +
    + Type +
    +
    + +HTMLCanvasElement + + +
    +
    + + + + + +
    + + + +
    +

    <static> setImageRenderingCrisp(canvas) → {HTMLCanvasElement}

    + + +
    +
    + + +
    +

    Sets the CSS image-rendering property on the given canvas to be 'crisp' (aka 'optimize contrast on webkit'). +Note that if this doesn't given the desired result then see the setSmoothingEnabled.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    canvas + + +HTMLCanvasElement + + + +

    The canvas to set image-rendering crisp on.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns the source canvas.

    +
    + + + +
    +
    + Type +
    +
    + +HTMLCanvasElement + + +
    +
    + + + + + +
    + + + +
    +

    <static> setSmoothingEnabled(context, value) → {CanvasRenderingContext2D}

    + + +
    +
    + + +
    +

    Sets the Image Smoothing property on the given context. Set to false to disable image smoothing. +By default browsers have image smoothing enabled, which isn't always what you visually want, especially +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.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    context + + +CanvasRenderingContext2D + + + +

    The context to enable or disable the image smoothing on.

    value + + +boolean + + + +

    If set to true it will enable image smoothing, false will disable it.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns the source context.

    +
    + + + +
    +
    + Type +
    +
    + +CanvasRenderingContext2D + + +
    +
    + + + + + +
    + + + +
    +

    <static> setTouchAction(canvas, value) → {HTMLCanvasElement}

    + + +
    +
    + + +
    +

    Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    canvas + + +HTMLCanvasElement + + + + + + + + + +

    The canvas to set the touch action on.

    value + + +String + + + + + + <optional>
    + + + + + +

    The touch action to set. Defaults to 'none'.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The source canvas.

    +
    + + + +
    +
    + Type +
    +
    + +HTMLCanvasElement + + +
    +
    + + + + + +
    + + + +
    +

    <static> setTransform(context, translateX, translateY, scaleX, scaleY, skewX, skewY) → {CanvasRenderingContext2D}

    + + +
    +
    + + +
    +

    Sets the transform of the given canvas to the matrix values provided.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    context + + +CanvasRenderingContext2D + + + +

    The context to set the transform on.

    translateX + + +number + + + +

    The value to translate horizontally by.

    translateY + + +number + + + +

    The value to translate vertically by.

    scaleX + + +number + + + +

    The value to scale horizontally by.

    scaleY + + +number + + + +

    The value to scale vertically by.

    skewX + + +number + + + +

    The value to skew horizontaly by.

    skewY + + +number + + + +

    The value to skew vertically by.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns the source context.

    +
    + + + +
    +
    + Type +
    +
    + +CanvasRenderingContext2D + + +
    +
    + + + + + +
    + + + +
    +

    <static> setUserSelect(canvas, value) → {HTMLCanvasElement}

    + + +
    +
    + + +
    +

    Sets the user-select property on the canvas style. Can be used to disable default browser selection actions.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    canvas + + +HTMLCanvasElement + + + + + + + + + +

    The canvas to set the touch action on.

    value + + +String + + + + + + <optional>
    + + + + + +

    The touch action to set. Defaults to 'none'.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The source canvas.

    +
    + + + +
    +
    + Type +
    +
    + +HTMLCanvasElement + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:25 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Circle.html b/docs/Phaser.Circle.html new file mode 100644 index 00000000..eb4cbec6 --- /dev/null +++ b/docs/Phaser.Circle.html @@ -0,0 +1,4295 @@ + + + + + + Phaser Class: Circle + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Circle

    +
    + +
    +

    + Phaser. + + Circle +

    + +

    Phaser - Circle

    + +
    + +
    +
    + + + + +
    +

    new Circle(x, y, diameter) → {Phaser.Circle}

    + + +
    +
    + + +
    +

    Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    x + + +number + + + + + + <optional>
    + + + + + +

    The x coordinate of the center of the circle.

    y + + +number + + + + + + <optional>
    + + + + + +

    The y coordinate of the center of the circle.

    diameter + + +number + + + + + + <optional>
    + + + + + +

    The diameter of the circle.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This circle object

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Circle + + +
    +
    + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    <readonly> area

    + + +
    +
    + +
    +

    The area of this Circle.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    area + + +number + + + +

    The area of this circle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bottom

    + + +
    +
    + +
    +

    The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bottom + + +number + + + +

    Gets or sets the bottom of the circle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    diameter

    + + +
    +
    + +
    +

    The largest distance between any two points on the circle. The same as the radius * 2.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    diameter + + +number + + + +

    Gets or sets the diameter of the circle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    empty

    + + +
    +
    + +
    +

    Determines whether or not this Circle object is empty. Will return a value of true if the Circle objects diameter is less than or equal to 0; otherwise false. +If set to true it will reset all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    empty + + +boolean + + + +

    Gets or sets the empty state of the circle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    left

    + + +
    +
    + +
    +

    The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.

    +
    + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    radius

    + + +
    +
    + +
    +

    The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    radius + + +number + + + +

    Gets or sets the radius of the circle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    + + + +
    +
    + +
    +

    The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    right + + +number + + + +

    Gets or sets the value of the rightmost point of the circle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    top

    + + +
    +
    + +
    +

    The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    top + + +number + + + +

    Gets or sets the top of the circle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The x coordinate of the center of the circle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    The y coordinate of the center of the circle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    <static> circumferencePoint(a, angle, asDegrees, out) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    a + + +Phaser.Circle + + + + + + + + + +

    The first Circle object.

    angle + + +number + + + + + + + + + +

    The angle in radians (unless asDegrees is true) to return the point from.

    asDegrees + + +boolean + + + + + + + + + +

    Is the given angle in radians (false) or degrees (true)?

    out + + +Phaser.Point + + + + + + <optional>
    + + + + + +

    An optional Point object to put the result in to. If none specified a new Point object will be created.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Point object holding the result.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    <static> contains(a, x, y) → {boolean}

    + + +
    +
    + + +
    +

    Return true if the given x/y coordinates are within the Circle object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Circle + + + +

    The Circle to be checked.

    x + + +number + + + +

    The X value of the coordinate to test.

    y + + +number + + + +

    The Y value of the coordinate to test.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the coordinates are within this circle, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <static> equals(a, b) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the two Circle objects match. This method compares the x, y and diameter properties.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Circle + + + +

    The first Circle object.

    b + + +Phaser.Circle + + + +

    The second Circle object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <static> intersects(a, b) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the two Circle objects intersect. +This method checks the radius distances between the two Circle objects to see if they intersect.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Circle + + + +

    The first Circle object.

    b + + +Phaser.Circle + + + +

    The second Circle object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the specified object intersects with this Circle object; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <static> intersectsRectangle(c, r) → {boolean}

    + + +
    +
    + + +
    +

    Checks if the given Circle and Rectangle objects intersect.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    c + + +Phaser.Circle + + + +

    The Circle object to test.

    r + + +Phaser.Rectangle + + + +

    The Rectangle object to test.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the two objects intersect, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    circumference() → {number}

    + + +
    +
    + + +
    +

    The circumference of the circle.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    circumferencePoint(angle, asDegrees, out) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    angle + + +number + + + + + + + + + +

    The angle in radians (unless asDegrees is true) to return the point from.

    asDegrees + + +boolean + + + + + + + + + +

    Is the given angle in radians (false) or degrees (true)?

    out + + +Phaser.Point + + + + + + <optional>
    + + + + + +

    An optional Point object to put the result in to. If none specified a new Point object will be created.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Point object holding the result.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    clone(out) → {Phaser.Circle}

    + + +
    +
    + + +
    +

    Returns a new Circle object with the same values for the x, y, width, and height properties as this Circle object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    out + + +Phaser.Circle + + + +

    Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The cloned Circle object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Circle + + +
    +
    + + + + + +
    + + + +
    +

    contains(x, y) → {boolean}

    + + +
    +
    + + +
    +

    Return true if the given x/y coordinates are within this Circle object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The X value of the coordinate to test.

    y + + +number + + + +

    The Y value of the coordinate to test.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the coordinates are within this circle, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    copyFrom(source) → {Circle}

    + + +
    +
    + + +
    +

    Copies the x, y and diameter properties from any given object to this Circle.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    source + + +any + + + +

    The object to copy from.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Circle object.

    +
    + + + +
    +
    + Type +
    +
    + +Circle + + +
    +
    + + + + + +
    + + + +
    +

    copyTo(dest) → {Object}

    + + +
    +
    + + +
    +

    Copies the x, y and diameter properties from this Circle to any given object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    dest + + +any + + + +

    The object to copy to.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This dest object.

    +
    + + + +
    +
    + Type +
    +
    + +Object + + +
    +
    + + + + + +
    + + + +
    +

    distance(dest, round) → {number}

    + + +
    +
    + + +
    +

    Returns the distance from the center of the Circle object to the given object +(can be Circle, Point or anything with x/y properties)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    dest + + +object + + + + + + + + + +

    The target object. Must have visible x and y properties that represent the center of the object.

    round + + +boolean + + + + + + <optional>
    + + + + + +

    Round the distance to the nearest integer (default false).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The distance between this Point object and the destination Point object.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    offset(dx, dy) → {Circle}

    + + +
    +
    + + +
    +

    Adjusts the location of the Circle object, as determined by its center coordinate, by the specified amounts.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    dx + + +number + + + +

    Moves the x value of the Circle object by this amount.

    dy + + +number + + + +

    Moves the y value of the Circle object by this amount.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Circle object.

    +
    + + + +
    +
    + Type +
    +
    + +Circle + + +
    +
    + + + + + +
    + + + +
    +

    offsetPoint(point) → {Circle}

    + + +
    +
    + + +
    +

    Adjusts the location of the Circle object using a Point object as a parameter. This method is similar to the Circle.offset() method, except that it takes a Point object as a parameter.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    point + + +Point + + + +

    A Point object to use to offset this Circle object (or any valid object with exposed x and y properties).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Circle object.

    +
    + + + +
    +
    + Type +
    +
    + +Circle + + +
    +
    + + + + + +
    + + + +
    +

    setTo(x, y, diameter) → {Circle}

    + + +
    +
    + + +
    +

    Sets the members of Circle to the specified values.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The x coordinate of the center of the circle.

    y + + +number + + + +

    The y coordinate of the center of the circle.

    diameter + + +number + + + +

    The diameter of the circle in pixels.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This circle object.

    +
    + + + +
    +
    + Type +
    +
    + +Circle + + +
    +
    + + + + + +
    + + + +
    +

    toString() → {string}

    + + +
    +
    + + +
    +

    Returns a string representation of this object.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    a string representation of the instance.

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:25 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Color.html b/docs/Phaser.Color.html new file mode 100644 index 00000000..9edef0f4 --- /dev/null +++ b/docs/Phaser.Color.html @@ -0,0 +1,3624 @@ + + + + + + Phaser Class: Color + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Color

    +
    + +
    +

    + Phaser. + + Color +

    + +
    + +
    +
    + + + + +
    +

    new Color()

    + + +
    +
    + + +
    +

    A collection of methods useful for manipulating and comparing colors.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    <static> colorToHexstring(color) → {string}

    + + +
    +
    + + +
    +

    Return a string containing a hex representation of the given color.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color + + +number + + + +

    The color channel to get the hex value for, must be a value between 0 and 255).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A string of length 2 characters, i.e. 255 = FF, 0 = 00.

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + + + +
    +

    <static> getAlpha(color) → {number}

    + + +
    +
    + + +
    +

    Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component, as a value between 0 and 255.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color + + +number + + + +

    In the format 0xAARRGGBB.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)).

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> getAlphaFloat(color) → {number}

    + + +
    +
    + + +
    +

    Given a native color value (in the format 0xAARRGGBB) this will return the Alpha component as a value between 0 and 1.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color + + +number + + + +

    In the format 0xAARRGGBB.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Alpha component of the color, will be between 0 and 1 (0 being no Alpha (opaque), 1 full Alpha (transparent)).

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> getBlue(color) → {number}

    + + +
    +
    + + +
    +

    Given a native color value (in the format 0xAARRGGBB) this will return the Blue component, as a value between 0 and 255.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color + + +number + + + +

    In the format 0xAARRGGBB.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Blue component of the color, will be between 0 and 255 (0 being no color, 255 full Blue).

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> getColor(red, green, blue) → {number}

    + + +
    +
    + + +
    +

    Given 3 color values this will return an integer representation of it.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    red + + +number + + + +

    The Red channel value (between 0 and 255).

    green + + +number + + + +

    The Green channel value (between 0 and 255).

    blue + + +number + + + +

    The Blue channel value (between 0 and 255).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A native color value integer (format: 0xRRGGBB).

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> getColor32(alpha, red, green, blue) → {number}

    + + +
    +
    + + +
    +

    Given an alpha and 3 color values this will return an integer representation of it.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    alpha + + +number + + + +

    The Alpha value (between 0 and 255).

    red + + +number + + + +

    The Red channel value (between 0 and 255).

    green + + +number + + + +

    The Green channel value (between 0 and 255).

    blue + + +number + + + +

    The Blue channel value (between 0 and 255).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A native color value integer (format: 0xAARRGGBB).

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> getColorInfo(color) → {string}

    + + +
    +
    + + +
    +

    Returns a string containing handy information about the given color including string hex value, +RGB format information and HSL information. Each section starts on a newline, 3 lines in total.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color + + +number + + + +

    A color value in the format 0xAARRGGBB.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    String containing the 3 lines of information.

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + + + +
    +

    <static> getGreen(color) → {number}

    + + +
    +
    + + +
    +

    Given a native color value (in the format 0xAARRGGBB) this will return the Green component, as a value between 0 and 255.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color + + +number + + + +

    In the format 0xAARRGGBB.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Green component of the color, will be between 0 and 255 (0 being no color, 255 full Green).

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> getRandomColor(min, max, alpha) → {number}

    + + +
    +
    + + +
    +

    Returns a random color value between black and white

    +

    <p>Set the min value to start each channel from the given offset.</p> +<p>Set the max value to restrict the maximum color used per channel</p>

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    min + + +number + + + +

    The lowest value to use for the color.

    max + + +number + + + +

    The highest value to use for the color.

    alpha + + +number + + + +

    The alpha value of the returning color (default 255 = fully opaque).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    32-bit color value with alpha.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> getRed(color) → {number}

    + + +
    +
    + + +
    +

    Given a native color value (in the format 0xAARRGGBB) this will return the Red component, as a value between 0 and 255.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color + + +number + + + +

    In the format 0xAARRGGBB.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Red component of the color, will be between 0 and 255 (0 being no color, 255 full Red).

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> getRGB(color) → {object}

    + + +
    +
    + + +
    +

    Return the component parts of a color as an Object with the properties alpha, red, green, blue

    +

    <p>Alpha will only be set if it exist in the given color (0xAARRGGBB)</p>

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color + + +number + + + +

    Color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    An Object with properties: alpha, red, green, blue.

    +
    + + + +
    +
    + Type +
    +
    + +object + + +
    +
    + + + + + +
    + + + +
    +

    <static> getWebRGB(color) → {string}

    + + +
    +
    + + +
    +

    Returns a CSS friendly string value from the given color.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A string in the format: 'rgba(r,g,b,a)'

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + + + +
    +

    <static> hexToRGB(h) → {object}

    + + +
    +
    + + +
    +

    Converts the given hex string into an object containing the RGB values.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    h + + +string + + + +

    The string hex color to convert.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    An object with 3 properties: r,g and b.

    +
    + + + +
    +
    + Type +
    +
    + +object + + +
    +
    + + + + + +
    + + + +
    +

    <static> interpolateColor(color1, color2, steps, currentStep, alpha) → {number}

    + + +
    +
    + + +
    +

    Interpolates the two given colours based on the supplied step and currentStep properties.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color1 + + +number + + + +

    Description.

    color2 + + +number + + + +

    Description.

    steps + + +number + + + +

    Description.

    currentStep + + +number + + + +

    Description.

    alpha + + +number + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The interpolated color value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> interpolateColorWithRGB(color, r, g, b, steps, currentStep) → {number}

    + + +
    +
    + + +
    +

    Interpolates the two given colours based on the supplied step and currentStep properties.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color + + +number + + + +

    Description.

    r + + +number + + + +

    Description.

    g + + +number + + + +

    Description.

    b + + +number + + + +

    Description.

    steps + + +number + + + +

    Description.

    currentStep + + +number + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The interpolated color value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> interpolateRGB(r1, g1, b1, r2, g2, b2, steps, currentStep) → {number}

    + + +
    +
    + + +
    +

    Interpolates the two given colours based on the supplied step and currentStep properties.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    r1 + + +number + + + +

    Description.

    g1 + + +number + + + +

    Description.

    b1 + + +number + + + +

    Description.

    r2 + + +number + + + +

    Description.

    g2 + + +number + + + +

    Description.

    b2 + + +number + + + +

    Description.

    steps + + +number + + + +

    Description.

    currentStep + + +number + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The interpolated color value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> RGBtoHexstring(color) → {string}

    + + +
    +
    + + +
    +

    Return a string representation of the color in the format 0xAARRGGBB.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color + + +number + + + +

    The color to get the string representation for

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A string of length 10 characters in the format 0xAARRGGBB

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + + + +
    +

    <static> RGBtoWebstring(color) → {string}

    + + +
    +
    + + +
    +

    Return a string representation of the color in the format #RRGGBB.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    color + + +number + + + +

    The color to get the string representation for.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A string of length 10 characters in the format 0xAARRGGBB.

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Device.html b/docs/Phaser.Device.html new file mode 100644 index 00000000..015dd01b --- /dev/null +++ b/docs/Phaser.Device.html @@ -0,0 +1,5000 @@ + + + + + + Phaser Class: Device + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Device

    +
    + +
    +

    + Phaser. + + Device +

    + +

    Phaser.Device

    + +
    + +
    +
    + + + + +
    +

    new Device()

    + + +
    +
    + + +
    +

    Detects device support capabilities. Using some elements from System.js by MrDoob and Modernizr

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    android

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    android + + +boolean + + + +

    Is running on android?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    arora

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    arora + + +boolean + + + +

    Is running in arora?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    audioData

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    audioData + + +boolean + + + +

    Are Audio tags available?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    canvas

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    canvas + + +boolean + + + +

    Is canvas available?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    chrome

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    chrome + + +boolean + + + +

    Is running in chrome?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    chromeOS

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    chromeOS + + +boolean + + + +

    Is running on chromeOS?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    css3D

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    css3D + + +boolean + + + +

    Is css3D available?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    desktop

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    desktop + + +boolean + + + +

    Is running desktop?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    epiphany

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    epiphany + + +boolean + + + +

    Is running in epiphany?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    file

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    file + + +boolean + + + +

    Is file available?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    fileSystem

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    fileSystem + + +boolean + + + +

    Is fileSystem available?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    firefox

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    firefox + + +boolean + + + +

    Is running in firefox?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    ie

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    ie + + +boolean + + + +

    Is running in ie?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    ieVersion

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    ieVersion + + +number + + + +

    Version of ie?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    iOS

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    iOS + + +boolean + + + +

    Is running on iOS?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    iPad

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    iPad + + +boolean + + + +

    Is running on iPad?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    iPhone

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    iPhone + + +boolean + + + +

    Is running on iPhone?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    iPhone4

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    iPhone4 + + +boolean + + + +

    Is running on iPhone4?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    linux

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    linux + + +boolean + + + +

    Is running on linux?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    localStorage

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    localStorage + + +boolean + + + +

    Is localStorage available?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    m4a

    + + +
    +
    + +
    +

    Can this device play m4a files?

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    m4a + + +boolean + + + +

    True if this device can play m4a files.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    macOS

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    macOS + + +boolean + + + +

    Is running on macOS?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    midori

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    midori + + +boolean + + + +

    Is running in midori?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mobileSafari

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mobileSafari + + +boolean + + + +

    Is running in mobileSafari?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mp3

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mp3 + + +boolean + + + +

    Can this device play mp3 files?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mspointer

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mspointer + + +boolean + + + +

    Is mspointer available?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    ogg

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    ogg + + +boolean + + + +

    Can this device play ogg files?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    opera

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    opera + + +boolean + + + +

    Is running in opera?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    opus

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    opus + + +boolean + + + +

    Can this device play opus files?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    patchAndroidClearRectBug

    + + +
    +
    + +
    +

    An optional 'fix' for the horrendous Android stock browser bug https://code.google.com/p/android/issues/detail?id=39247

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    patchAndroidClearRectBug + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pixelRatio

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pixelRatio + + +number + + + +

    PixelRatio of the host device?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointerLock

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointerLock + + +boolean + + + +

    Is Pointer Lock available?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    safari

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    safari + + +boolean + + + +

    Is running in safari?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    touch

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    touch + + +boolean + + + +

    Is touch available?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    wav

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    wav + + +boolean + + + +

    Can this device play wav files?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    webAudio

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    webAudio + + +boolean + + + +

    Is the WebAudio API available?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    webGL

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    webGL + + +boolean + + + +

    Is webGL available?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    webm

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    webm + + +boolean + + + +

    Can this device play webm files?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    windows

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    windows + + +boolean + + + +

    Is running on windows?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    worker

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    worker + + +boolean + + + +

    Is worker available?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    canPlayAudio(type) → {boolean}

    + + +
    +
    + + +
    +

    Check whether the host environment can play audio.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +string + + + +

    One of 'mp3, 'ogg', 'm4a', 'wav', 'webm'.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the given file type is supported by the browser, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    isConsoleOpen() → {boolean}

    + + +
    +
    + + +
    +

    Check whether the console is open.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the browser dev console is open.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Easing.Back.html b/docs/Phaser.Easing.Back.html new file mode 100644 index 00000000..86200495 --- /dev/null +++ b/docs/Phaser.Easing.Back.html @@ -0,0 +1,976 @@ + + + + + + Phaser Class: Back + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Back

    +
    + +
    +

    + Phaser.Easing. + + Back +

    + +
    + +
    +
    + + + + +
    +

    new Back()

    + + +
    +
    + + +
    +

    Back easing.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    In(k) → {number}

    + + +
    +
    + + +
    +

    Back ease-in.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    InOut(k) → {number}

    + + +
    +
    + + +
    +

    Back ease-in/out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    Out(k) → {number}

    + + +
    +
    + + +
    +

    Back ease-out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Easing.Bounce.html b/docs/Phaser.Easing.Bounce.html new file mode 100644 index 00000000..fb46f648 --- /dev/null +++ b/docs/Phaser.Easing.Bounce.html @@ -0,0 +1,976 @@ + + + + + + Phaser Class: Bounce + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Bounce

    +
    + +
    +

    + Phaser.Easing. + + Bounce +

    + +
    + +
    +
    + + + + +
    +

    new Bounce()

    + + +
    +
    + + +
    +

    Bounce easing.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    In(k) → {number}

    + + +
    +
    + + +
    +

    Bounce ease-in.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    InOut(k) → {number}

    + + +
    +
    + + +
    +

    Bounce ease-in/out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    Out(k) → {number}

    + + +
    +
    + + +
    +

    Bounce ease-out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Easing.Circular.html b/docs/Phaser.Easing.Circular.html new file mode 100644 index 00000000..eb7993aa --- /dev/null +++ b/docs/Phaser.Easing.Circular.html @@ -0,0 +1,976 @@ + + + + + + Phaser Class: Circular + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Circular

    +
    + +
    +

    + Phaser.Easing. + + Circular +

    + +
    + +
    +
    + + + + +
    +

    new Circular()

    + + +
    +
    + + +
    +

    Circular easing.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    In(k) → {number}

    + + +
    +
    + + +
    +

    Circular ease-in.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    InOut(k) → {number}

    + + +
    +
    + + +
    +

    Circular ease-in/out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    Out(k) → {number}

    + + +
    +
    + + +
    +

    Circular ease-out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Easing.Cubic.html b/docs/Phaser.Easing.Cubic.html new file mode 100644 index 00000000..58a825f4 --- /dev/null +++ b/docs/Phaser.Easing.Cubic.html @@ -0,0 +1,976 @@ + + + + + + Phaser Class: Cubic + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Cubic

    +
    + +
    +

    + Phaser.Easing. + + Cubic +

    + +
    + +
    +
    + + + + +
    +

    new Cubic()

    + + +
    +
    + + +
    +

    Cubic easing.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    In(k) → {number}

    + + +
    +
    + + +
    +

    Cubic ease-in.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    InOut(k) → {number}

    + + +
    +
    + + +
    +

    Cubic ease-in/out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    Out(k) → {number}

    + + +
    +
    + + +
    +

    Cubic ease-out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Easing.Elastic.html b/docs/Phaser.Easing.Elastic.html new file mode 100644 index 00000000..53e68bef --- /dev/null +++ b/docs/Phaser.Easing.Elastic.html @@ -0,0 +1,976 @@ + + + + + + Phaser Class: Elastic + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Elastic

    +
    + +
    +

    + Phaser.Easing. + + Elastic +

    + +
    + +
    +
    + + + + +
    +

    new Elastic()

    + + +
    +
    + + +
    +

    Elastic easing.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    In(k) → {number}

    + + +
    +
    + + +
    +

    Elastic ease-in.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    InOut(k) → {number}

    + + +
    +
    + + +
    +

    Elastic ease-in/out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    Out(k) → {number}

    + + +
    +
    + + +
    +

    Elastic ease-out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Easing.Exponential.html b/docs/Phaser.Easing.Exponential.html new file mode 100644 index 00000000..5a729b14 --- /dev/null +++ b/docs/Phaser.Easing.Exponential.html @@ -0,0 +1,976 @@ + + + + + + Phaser Class: Exponential + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Exponential

    +
    + +
    +

    + Phaser.Easing. + + Exponential +

    + +
    + +
    +
    + + + + +
    +

    new Exponential()

    + + +
    +
    + + +
    +

    Exponential easing.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    In(k) → {number}

    + + +
    +
    + + +
    +

    Exponential ease-in.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    InOut(k) → {number}

    + + +
    +
    + + +
    +

    Exponential ease-in/out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    Out(k) → {number}

    + + +
    +
    + + +
    +

    Exponential ease-out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Easing.Linear.html b/docs/Phaser.Easing.Linear.html new file mode 100644 index 00000000..856c1c24 --- /dev/null +++ b/docs/Phaser.Easing.Linear.html @@ -0,0 +1,694 @@ + + + + + + Phaser Class: Linear + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Linear

    +
    + +
    +

    + Phaser.Easing. + + Linear +

    + +
    + +
    +
    + + + + +
    +

    new Linear()

    + + +
    +
    + + +
    +

    Linear easing.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    In(k) → {number}

    + + +
    +
    + + +
    +

    Ease-in.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    k^2.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Easing.Quadratic.html b/docs/Phaser.Easing.Quadratic.html new file mode 100644 index 00000000..affa1c27 --- /dev/null +++ b/docs/Phaser.Easing.Quadratic.html @@ -0,0 +1,976 @@ + + + + + + Phaser Class: Quadratic + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Quadratic

    +
    + +
    +

    + Phaser.Easing. + + Quadratic +

    + +
    + +
    +
    + + + + +
    +

    new Quadratic()

    + + +
    +
    + + +
    +

    Quadratic easing.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    In(k) → {number}

    + + +
    +
    + + +
    +

    Ease-in.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    k^2.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    InOut(k) → {number}

    + + +
    +
    + + +
    +

    Ease-in/out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    Out(k) → {number}

    + + +
    +
    + + +
    +

    Ease-out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    k* (2-k).

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Easing.Quartic.html b/docs/Phaser.Easing.Quartic.html new file mode 100644 index 00000000..7a7eaeba --- /dev/null +++ b/docs/Phaser.Easing.Quartic.html @@ -0,0 +1,976 @@ + + + + + + Phaser Class: Quartic + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Quartic

    +
    + +
    +

    + Phaser.Easing. + + Quartic +

    + +
    + +
    +
    + + + + +
    +

    new Quartic()

    + + +
    +
    + + +
    +

    Quartic easing.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    In(k) → {number}

    + + +
    +
    + + +
    +

    Quartic ease-in.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    InOut(k) → {number}

    + + +
    +
    + + +
    +

    Quartic ease-in/out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    Out(k) → {number}

    + + +
    +
    + + +
    +

    Quartic ease-out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Easing.Quintic.html b/docs/Phaser.Easing.Quintic.html new file mode 100644 index 00000000..fad75ff0 --- /dev/null +++ b/docs/Phaser.Easing.Quintic.html @@ -0,0 +1,976 @@ + + + + + + Phaser Class: Quintic + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Quintic

    +
    + +
    +

    + Phaser.Easing. + + Quintic +

    + +
    + +
    +
    + + + + +
    +

    new Quintic()

    + + +
    +
    + + +
    +

    Quintic easing.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    In(k) → {number}

    + + +
    +
    + + +
    +

    Quintic ease-in.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    InOut(k) → {number}

    + + +
    +
    + + +
    +

    Quintic ease-in/out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    Out(k) → {number}

    + + +
    +
    + + +
    +

    Quintic ease-out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:27 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Easing.Sinusoidal.html b/docs/Phaser.Easing.Sinusoidal.html new file mode 100644 index 00000000..2d66c0a5 --- /dev/null +++ b/docs/Phaser.Easing.Sinusoidal.html @@ -0,0 +1,976 @@ + + + + + + Phaser Class: Sinusoidal + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Sinusoidal

    +
    + +
    +

    + Phaser.Easing. + + Sinusoidal +

    + +
    + +
    +
    + + + + +
    +

    new Sinusoidal()

    + + +
    +
    + + +
    +

    Sinusoidal easing.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    In(k) → {number}

    + + +
    +
    + + +
    +

    Sinusoidal ease-in.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    InOut(k) → {number}

    + + +
    +
    + + +
    +

    Sinusoidal ease-in/out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    Out(k) → {number}

    + + +
    +
    + + +
    +

    Sinusoidal ease-out.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    k + + +number + + + +

    The value to be tweened.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tweened value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:27 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Easing.html b/docs/Phaser.Easing.html new file mode 100644 index 00000000..8880d9cd --- /dev/null +++ b/docs/Phaser.Easing.html @@ -0,0 +1,586 @@ + + + + + + Phaser Class: Easing + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Easing

    +
    + +
    +

    + Phaser. + + Easing +

    + +
    + + + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:26 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Events.html b/docs/Phaser.Events.html new file mode 100644 index 00000000..dbb10d0c --- /dev/null +++ b/docs/Phaser.Events.html @@ -0,0 +1,600 @@ + + + + + + Phaser Class: Events + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Events

    +
    + +
    +

    + Phaser. + + Events +

    + +

    Phaser.Events

    + +
    + +
    +
    + + + + +
    +

    new Events(sprite)

    + + +
    +
    + + +
    +

    The Events component is a collection of events fired by the parent game object and its components.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sprite + + +Phaser.Sprite + + + +

    A reference to Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:27 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Frame.html b/docs/Phaser.Frame.html new file mode 100644 index 00000000..52ed0839 --- /dev/null +++ b/docs/Phaser.Frame.html @@ -0,0 +1,2961 @@ + + + + + + Phaser Class: Frame + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Frame

    +
    + +
    +

    + Phaser. + + Frame +

    + +

    Phaser.Frame

    + +
    + +
    +
    + + + + +
    +

    new Frame(index, x, y, width, height, name, uuid)

    + + +
    +
    + + +
    +

    A Frame is a single frame of an animation and is part of a FrameData collection.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    index + + +number + + + +

    The index of this Frame within the FrameData set it is being added to.

    x + + +number + + + +

    X position of the frame within the texture image.

    y + + +number + + + +

    Y position of the frame within the texture image.

    width + + +number + + + +

    Width of the frame within the texture image.

    height + + +number + + + +

    Height of the frame within the texture image.

    name + + +string + + + +

    The name of the frame. In Texture Atlas data this is usually set to the filename.

    uuid + + +string + + + +

    Internal UUID key.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    centerX

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    centerX + + +number + + + +

    Center X position within the image to cut from.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    centerY

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    centerY + + +number + + + +

    Center Y position within the image to cut from.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    distance

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    distance + + +number + + + +

    The distance from the top left to the bottom-right of this Frame.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    height

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    height + + +number + + + +

    Height of the frame.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    index

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    index + + +number + + + +

    The index of this Frame within the FrameData set it is being added to.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    name

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    Useful for Texture Atlas files (is set to the filename value).

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    rotated

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    rotated + + +boolean + + + +

    Rotated? (not yet implemented)

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    rotationDirection

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    rotationDirection + + +string + + + +

    Either 'cw' or 'ccw', rotation is always 90 degrees.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 'cw'
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    sourceSizeH

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sourceSizeH + + +number + + + +

    Height of the original sprite.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    sourceSizeW

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sourceSizeW + + +number + + + +

    Width of the original sprite.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    spriteSourceSizeH

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    spriteSourceSizeH + + +number + + + +

    Height of the trimmed sprite.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    spriteSourceSizeW

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    spriteSourceSizeW + + +number + + + +

    Width of the trimmed sprite.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    spriteSourceSizeX

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    spriteSourceSizeX + + +number + + + +

    X position of the trimmed sprite inside original sprite.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    spriteSourceSizeY

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    spriteSourceSizeY + + +number + + + +

    Y position of the trimmed sprite inside original sprite.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    trimmed

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    trimmed + + +boolean + + + +

    Was it trimmed when packed?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    uuid

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    uuid + + +string + + + +

    A link to the PIXI.TextureCache entry.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    width

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    Width of the frame.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    X position within the image to cut from.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    Y position within the image to cut from.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    setTrim(trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight)

    + + +
    +
    + + +
    +

    If the frame was trimmed when added to the Texture Atlas this records the trim and source data.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    trimmed + + +boolean + + + +

    If this frame was trimmed or not.

    actualWidth + + +number + + + +

    The width of the frame before being trimmed.

    actualHeight + + +number + + + +

    The height of the frame before being trimmed.

    destX + + +number + + + +

    The destination X position of the trimmed frame for display.

    destY + + +number + + + +

    The destination Y position of the trimmed frame for display.

    destWidth + + +number + + + +

    The destination width of the trimmed frame for display.

    destHeight + + +number + + + +

    The destination height of the trimmed frame for display.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:27 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.FrameData.html b/docs/Phaser.FrameData.html new file mode 100644 index 00000000..ef906ea0 --- /dev/null +++ b/docs/Phaser.FrameData.html @@ -0,0 +1,1908 @@ + + + + + + Phaser Class: FrameData + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: FrameData

    +
    + +
    +

    + Phaser. + + FrameData +

    + +

    Phaser.FrameData

    + +
    + +
    +
    + + + + +
    +

    new FrameData()

    + + +
    +
    + + +
    +

    FrameData is a container for Frame objects, which are the internal representation of animation data in Phaser.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    <readonly> total

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    total + + +number + + + +

    The total number of frames in this FrameData set.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    addFrame(frame) → {Phaser.Frame}

    + + +
    +
    + + +
    +

    Adds a new Frame to this FrameData collection. Typically called by the Animation.Parser and not directly.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    frame + + +Phaser.Frame + + + +

    The frame to add to this FrameData set.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The frame that was just added.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Frame + + +
    +
    + + + + + +
    + + + +
    +

    checkFrameName(name) → {boolean}

    + + +
    +
    + + +
    +

    Check if there is a Frame with the given name.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    The name of the frame you want to check.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the frame is found, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    getFrame(index) → {Phaser.Frame}

    + + +
    +
    + + +
    +

    Get a Frame by its numerical index.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    index + + +number + + + +

    The index of the frame you want to get.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The frame, if found.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Frame + + +
    +
    + + + + + +
    + + + +
    +

    getFrameByName(name) → {Phaser.Frame}

    + + +
    +
    + + +
    +

    Get a Frame by its frame name.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    The name of the frame you want to get.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The frame, if found.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Frame + + +
    +
    + + + + + +
    + + + +
    +

    getFrameIndexes(frames, useNumericIndex, output) → {Array}

    + + +
    +
    + + +
    +

    Returns all of the Frame indexes in this FrameData set. +The frames indexes are returned in the output array, or if none is provided in a new Array object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    frames + + +Array + + + + + + + + + + + +

    An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.

    useNumericIndex + + +boolean + + + + + + <optional>
    + + + + + +
    + + true + +

    Are the given frames using numeric indexes (default) or strings? (false)

    output + + +Array + + + + + + <optional>
    + + + + + +
    + +

    If given the results will be appended to the end of this array otherwise a new array will be created.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    An array of all Frame indexes matching the given names or IDs.

    +
    + + + +
    +
    + Type +
    +
    + +Array + + +
    +
    + + + + + +
    + + + +
    +

    getFrameRange(start, end, output) → {Array}

    + + +
    +
    + + +
    +

    Returns a range of frames based on the given start and end frame indexes and returns them in an Array.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    start + + +number + + + + + + + + + +

    The starting frame index.

    end + + +number + + + + + + + + + +

    The ending frame index.

    output + + +Array + + + + + + <optional>
    + + + + + +

    If given the results will be appended to the end of this array otherwise a new array will be created.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    An array of Frames between the start and end index values, or an empty array if none were found.

    +
    + + + +
    +
    + Type +
    +
    + +Array + + +
    +
    + + + + + +
    + + + +
    +

    getFrames(frames, useNumericIndex, output) → {Array}

    + + +
    +
    + + +
    +

    Returns all of the Frames in this FrameData set where the frame index is found in the input array. +The frames are returned in the output array, or if none is provided in a new Array object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    frames + + +Array + + + + + + + + + + + +

    An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.

    useNumericIndex + + +boolean + + + + + + <optional>
    + + + + + +
    + + true + +

    Are the given frames using numeric indexes (default) or strings? (false)

    output + + +Array + + + + + + <optional>
    + + + + + +
    + +

    If given the results will be appended to the end of this array otherwise a new array will be created.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    An array of all Frames in this FrameData set matching the given names or IDs.

    +
    + + + +
    +
    + Type +
    +
    + +Array + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:27 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Game.html b/docs/Phaser.Game.html new file mode 100644 index 00000000..39565132 --- /dev/null +++ b/docs/Phaser.Game.html @@ -0,0 +1,4482 @@ + + + + + + Phaser Class: Game + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Game

    +
    + +
    +

    + Phaser. + + Game +

    + +

    This is where the magic happens. The Game object is the heart of your game, +providing quick access to common functions and handling the boot process.

    +

    <p>"Hell, there are no rules here - we're trying to accomplish something."</p><br> + Thomas A. Edison

    + +
    + +
    +
    + + + + +
    +

    new Game(width, height, renderer, parent, state, transparent, antialias)

    + + +
    +
    + + +
    +

    Game constructor

    +

    Instantiate a new <code>Phaser.Game</code> object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    The width of your game in game pixels.

    height + + +number + + + +

    The height of your game in game pixels.

    renderer + + +number + + + +

    Which renderer to use (canvas or webgl)

    parent + + +HTMLElement + + + +

    The Games DOM parent.

    state + + +Description + + + +

    Description.

    transparent + + +boolean + + + +

    Use a transparent canvas background or not.

    antialias + + +boolean + + + +

    Anti-alias graphics.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    add

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    add + + +Phaser.GameObjectFactory + + + +

    Reference to the GameObject Factory.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    antialias

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    antialias + + +boolean + + + +

    Anti-alias graphics (in WebGL this helps with edges, in Canvas2D it retains pixel-art quality).

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    cache

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    cache + + +Phaser.Cache + + + +

    Reference to the assets cache.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    camera

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    camera + + +Phaser.Physics.PhysicsManager + + + +

    A handy reference to world.camera.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    canvas

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    canvas + + +HTMLCanvasElement + + + +

    A handy reference to renderer.view.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    context

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    context + + +Context + + + +

    A handy reference to renderer.context (only set for CANVAS games)

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    debug

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    debug + + +Phaser.Utils.Debug + + + +

    A set of useful debug utilitie.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    device

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    device + + +Phaser.Device + + + +

    Contains device information and capabilities.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    height

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    height + + +number + + + +

    The Game height (in pixels).

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    id

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    id + + +number + + + +

    Phaser Game ID (for when Pixi supports multiple instances).

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    input

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    input + + +Phaser.Input + + + +

    Reference to the input manager

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isBooted

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isBooted + + +boolean + + + +

    Whether the game engine is booted, aka available.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isRunning

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    id + + +boolean + + + +

    Is game running or paused?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    load

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    load + + +Phaser.Loader + + + +

    Reference to the assets loader.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    math

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    math + + +Phaser.GameMath + + + +

    Reference to the math helper.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    net

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    net + + +Phaser.Net + + + +

    Reference to the network class.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    parent

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    parent + + +HTMLElement + + + +

    The Games DOM parent.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    particles

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    particles + + +Phaser.Particles + + + +

    The Particle Manager.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    paused

    + + +
    +
    + +
    +

    The paused state of the Game. A paused game doesn't update any of its subsystems. +When a game is paused the onPause event is dispatched. When it is resumed the onResume event is dispatched.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    paused + + +boolean + + + +

    Gets and sets the paused state of the Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    physics

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    physics + + +Phaser.Physics.PhysicsManager + + + +

    Reference to the physics manager.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    raf

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    raf + + +Phaser.RequestAnimationFrame + + + +

    Automatically handles the core game loop via requestAnimationFrame or setTimeout

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    renderer

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    renderer + + +number + + + +

    The Pixi Renderer

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    renderType

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    renderType + + +number + + + +

    The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    rnd

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    rnd + + +Phaser.RandomDataGenerator + + + +

    Instance of repeatable random data generator helper.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    sound

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sound + + +Phaser.SoundManager + + + +

    Reference to the sound manager.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    stage

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    stage + + +Phaser.Stage + + + +

    Reference to the stage.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    state

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    state + + +number + + + +

    The StateManager.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    time

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    time + + +Phaser.TimeManager + + + +

    Reference to game clock.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    transparent

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    transparent + + +boolean + + + +

    Use a transparent canvas background or not.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    tweens

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    tweens + + +Phaser.TweenManager + + + +

    Reference to the tween manager.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    width

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    The Game width (in pixels).

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    world

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    world + + +Phaser.World + + + +

    Reference to the world.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    <protected> boot()

    + + +
    +
    + + +
    +

    Initialize engine sub modules and start the game.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Nuke the entire game from orbit

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> loadComplete()

    + + +
    +
    + + +
    +

    Called when the load has finished, after preload was run.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> setUpRenderer()

    + + +
    +
    + + +
    +

    Checks if the device is capable of using the requested renderer and sets it up or an alternative if not.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> update(time)

    + + +
    +
    + + +
    +

    The core game loop.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    time + + +number + + + +

    The current time as provided by RequestAnimationFrame.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:27 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.GameObjectFactory.html b/docs/Phaser.GameObjectFactory.html new file mode 100644 index 00000000..d102bee4 --- /dev/null +++ b/docs/Phaser.GameObjectFactory.html @@ -0,0 +1,4181 @@ + + + + + + Phaser Class: GameObjectFactory + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: GameObjectFactory

    +
    + +
    +

    + Phaser. + + GameObjectFactory +

    + +

    Phaser.GameObjectFactory

    + +
    + +
    +
    + + + + +
    +

    new GameObjectFactory(game)

    + + +
    +
    + + +
    +

    The Game Object Factory is a quick way to create all of the different sorts of core objects that Phaser uses.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    world

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    world + + +Phaser.World + + + +

    A reference to the game world.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    audio(key, volume, loop) → {Phaser.Sound}

    + + +
    +
    + + +
    +

    Creates a new instance of the Sound class.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    The Game.cache key of the sound that this object will use.

    volume + + +number + + + +

    The volume at which the sound will be played.

    loop + + +boolean + + + +

    Whether or not the sound will loop.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created text object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Sound + + +
    +
    + + + + + +
    + + + +
    +

    bitmapText(x, y, text, style) → {Phaser.BitmapText}

    + + +
    +
    + + +
    +
      +
    • Create a new <code>BitmapText</code>.
    • +
    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    X position of the new bitmapText object.

    y + + +number + + + +

    Y position of the new bitmapText object.

    text + + +string + + + +

    The actual text that will be written.

    style + + +object + + + +

    The style object containing style attributes like font, font size , etc.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created bitmapText object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.BitmapText + + +
    +
    + + + + + +
    + + + +
    +

    button(x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) → {Phaser.Button}

    + + +
    +
    + + +
    +

    Creates a new <code>Button</code> object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    x + + +number + + + + + + <optional>
    + + + + + +

    X position of the new button object.

    y + + +number + + + + + + <optional>
    + + + + + +

    Y position of the new button object.

    key + + +string + + + + + + <optional>
    + + + + + +

    The image key as defined in the Game.Cache to use as the texture for this button.

    callback + + +function + + + + + + <optional>
    + + + + + +

    The function to call when this button is pressed

    callbackContext + + +object + + + + + + <optional>
    + + + + + +

    The context in which the callback will be called (usually 'this')

    overFrame + + +string +| + +number + + + + + + <optional>
    + + + + + +

    This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name.

    outFrame + + +string +| + +number + + + + + + <optional>
    + + + + + +

    This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name.

    downFrame + + +string +| + +number + + + + + + <optional>
    + + + + + +

    This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created button object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Button + + +
    +
    + + + + + +
    + + + +
    +

    child(group, x, y, key, frame) → {Phaser.Sprite}

    + + +
    +
    + + +
    +

    Create a new Sprite with specific position and sprite sheet key that will automatically be added as a child of the given parent.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    group + + +Phaser.Group + + + + + + + + + +

    The Group to add this child to.

    x + + +number + + + + + + + + + +

    X position of the new sprite.

    y + + +number + + + + + + + + + +

    Y position of the new sprite.

    key + + +string +| + +RenderTexture + + + + + + <optional>
    + + + + + +

    The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture.

    frame + + +string +| + +number + + + + + + <optional>
    + + + + + +

    If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    the newly created sprite object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Sprite + + +
    +
    + + + + + +
    + + + +
    +

    emitter(x, y, maxParticles) → {Phaser.Emitter}

    + + +
    +
    + + +
    +

    Emitter is a lightweight particle emitter. It can be used for one-time explosions or for +continuous effects like rain and fire. All it really does is launch Particle objects out +at set intervals, and fixes their positions and velocities accorindgly.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    x + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The x coordinate within the Emitter that the particles are emitted from.

    y + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The y coordinate within the Emitter that the particles are emitted from.

    maxParticles + + +number + + + + + + <optional>
    + + + + + +
    + + 50 + +

    The total number of particles in this emitter.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created emitter object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Emitter + + +
    +
    + + + + + +
    + + + +
    +

    existing(object) → {*}

    + + +
    +
    + + +
    +

    Adds an existing object to the game world.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    object + + +* + + + +

    An instance of Phaser.Sprite, Phaser.Button or any other display object..

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The child that was added to the Group.

    +
    + + + +
    +
    + Type +
    +
    + +* + + +
    +
    + + + + + +
    + + + +
    +

    graphics(x, y) → {Phaser.Graphics}

    + + +
    +
    + + +
    +

    Creates a new <code>Graphics</code> object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    X position of the new graphics object.

    y + + +number + + + +

    Y position of the new graphics object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created graphics object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Graphics + + +
    +
    + + + + + +
    + + + +
    +

    group(parent, name) → {Phaser.Group}

    + + +
    +
    + + +
    +

    A Group is a container for display objects that allows for fast pooling, recycling and collision checks.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    parent + + +* + + + + + + + + + + + +

    The parent Group or DisplayObjectContainer that will hold this group, if any.

    name + + +string + + + + + + <optional>
    + + + + + +
    + + group + +

    A name for this Group. Not used internally but useful for debugging.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created group.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Group + + +
    +
    + + + + + +
    + + + +
    +

    renderTexture(key, width, height) → {Phaser.RenderTexture}

    + + +
    +
    + + +
    +

    A dynamic initially blank canvas to which images can be drawn.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key for the render texture.

    width + + +number + + + +

    the width of the render texture.

    height + + +number + + + +

    the height of the render texture.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created renderTexture object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.RenderTexture + + +
    +
    + + + + + +
    + + + +
    +

    sprite(x, y, key, frame) → {Phaser.Sprite}

    + + +
    +
    + + +
    +

    Create a new Sprite with specific position and sprite sheet key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    x + + +number + + + + + + + + + +

    X position of the new sprite.

    y + + +number + + + + + + + + + +

    Y position of the new sprite.

    key + + +string +| + +Phaser.RenderTexture +| + +PIXI.Texture + + + + + + + + + +

    This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.

    frame + + +string +| + +number + + + + + + <optional>
    + + + + + +

    If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    the newly created sprite object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Sprite + + +
    +
    + + + + + +
    + + + +
    +

    text(x, y, text, style) → {Phaser.Text}

    + + +
    +
    + + +
    +

    Creates a new <code>Text</code>.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    X position of the new text object.

    y + + +number + + + +

    Y position of the new text object.

    text + + +string + + + +

    The actual text that will be written.

    style + + +object + + + +

    The style object containing style attributes like font, font size , etc.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created text object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Text + + +
    +
    + + + + + +
    + + + +
    +

    tilemap(key) → {Phaser.Tilemap}

    + + +
    +
    + + +
    +

    Creates a new Tilemap object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Asset key for the JSON file.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created tilemap object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tilemap + + +
    +
    + + + + + +
    + + + +
    +

    tilemapLayer(x, y, width, height) → {Phaser.TilemapLayer}

    + + +
    +
    + + +
    +

    Creates a new Tilemap Layer object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    X position of the new tilemapLayer.

    y + + +number + + + +

    Y position of the new tilemapLayer.

    width + + +number + + + +

    the width of the tilemapLayer.

    height + + +number + + + +

    the height of the tilemapLayer.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created tilemaplayer object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.TilemapLayer + + +
    +
    + + + + + +
    + + + +
    +

    tileset(key) → {Phaser.Tileset}

    + + +
    +
    + + +
    +

    Creates a new Tileset object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    The image key as defined in the Game.Cache to use as the tileset.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created tileset object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tileset + + +
    +
    + + + + + +
    + + + +
    +

    tileSprite(x, y, width, height, key, frame) → {Phaser.TileSprite}

    + + +
    +
    + + +
    +

    Creates a new <code>TileSprite</code>.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    X position of the new tileSprite.

    y + + +number + + + +

    Y position of the new tileSprite.

    width + + +number + + + +

    the width of the tilesprite.

    height + + +number + + + +

    the height of the tilesprite.

    key + + +string +| + +Phaser.RenderTexture +| + +PIXI.Texture + + + +

    This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.

    frame + + +string +| + +number + + + +

    If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created tileSprite object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.TileSprite + + +
    +
    + + + + + +
    + + + +
    +

    tween(obj) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    obj + + +object + + + +

    Object the tween will be run on.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Description.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:27 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Graphics.html b/docs/Phaser.Graphics.html new file mode 100644 index 00000000..98f028da --- /dev/null +++ b/docs/Phaser.Graphics.html @@ -0,0 +1,752 @@ + + + + + + Phaser Class: Graphics + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Graphics

    +
    + +
    +

    + Phaser. + + Graphics +

    + +

    Phaser.Graphics

    + +
    + +
    +
    + + + + +
    +

    new Graphics(game, x, y)

    + + +
    +
    + + +
    +

    Creates a new <code>Graphics</code> object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Current game instance.

    x + + +number + + + +

    X position of the new graphics object.

    y + + +number + + + +

    Y position of the new graphics object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:27 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Group.html b/docs/Phaser.Group.html new file mode 100644 index 00000000..9766f953 --- /dev/null +++ b/docs/Phaser.Group.html @@ -0,0 +1,6988 @@ + + + + + + Phaser Class: Group + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Group

    +
    + +
    +

    + Phaser. + + Group +

    + +

    A Group is a container for display objects that allows for fast pooling, recycling and collision checks.

    + +
    + +
    +
    + + + + +
    +

    new Group(game, parent, name, useStage)

    + + +
    +
    + + +
    +

    Phaser Group constructor.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    game + + +Phaser.Game + + + + + + + + + + + +

    A reference to the currently running game.

    parent + + +* + + + + + + + + + + + +

    The parent Group or DisplayObjectContainer that will hold this group, if any.

    name + + +string + + + + + + <optional>
    + + + + + +
    + + group + +

    A name for this Group. Not used internally but useful for debugging.

    useStage + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Should the DisplayObjectContainer this Group creates be added to the World (default, false) or direct to the Stage (true).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    alpha

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    alpha + + +number + + + +

    The alpha value of the Group container.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    angle

    + + +
    +
    + +
    +

    The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation. +This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    angle + + +number + + + +

    The angle of rotation given in degrees, where 0 degrees = to the right.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    exists

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    exists + + +boolean + + + +

    If exists is true the the Group is updated, otherwise it is skipped.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> length

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    length + + +number + + + +

    The number of children in this Group.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    name

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    A name for this Group. Not used internally but useful for debugging.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    rotation

    + + +
    +
    + +
    +

    The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation. +This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    rotation + + +number + + + +

    The angle of rotation given in radians.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    scale

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    scale + + +Phaser.Point + + + +

    Replaces the PIXI.Point with a slightly more flexible one.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> total

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    total + + +number + + + +

    The total number of children in this Group, regardless of their alive state.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <protected> type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +number + + + +

    Internal Phaser Type value.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    visible

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    visible + + +boolean + + + +

    The visible state of the Group. Non-visible Groups and all of their children are not rendered.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + +
    +

    The x coordinate of the Group container. You can adjust the Group container itself by modifying its coordinates. +This will have no impact on the x/y coordinates of its children, but it will update their worldTransform and on-screen position.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The x coordinate of the Group container.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + +
    +

    The y coordinate of the Group container. You can adjust the Group container itself by modifying its coordinates. +This will have no impact on the x/y coordinates of its children, but it will update their worldTransform and on-screen position.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    The y coordinate of the Group container.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    add(child) → {*}

    + + +
    +
    + + +
    +

    Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object. +The child is automatically added to the top of the Group, so renders on-top of everything else within the Group. If you need to control +that then see the addAt method.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child + + +* + + + +

    An instance of Phaser.Sprite, Phaser.Button or any other display object..

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + +
    See:
    +
    + +
    + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The child that was added to the Group.

    +
    + + + +
    +
    + Type +
    +
    + +* + + +
    +
    + + + + + +
    + + + +
    +

    addAll(property, amount, checkAlive, checkVisible)

    + + +
    +
    + + +
    +

    Adds the amount to the given property on all children in this Group. +Group.addAll('x', 10) will add 10 to the child.x value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    property + + +string + + + +

    The property to increment, for example 'body.velocity.x' or 'angle'.

    amount + + +number + + + +

    The amount to increment the property by. If child.x = 10 then addAll('x', 40) would make child.x = 50.

    checkAlive + + +boolean + + + +

    If true the property will only be changed if the child is alive.

    checkVisible + + +boolean + + + +

    If true the property will only be changed if the child is visible.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addAt(child, index) → {*}

    + + +
    +
    + + +
    +

    Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object. +The child is added to the Group at the location specified by the index value, this allows you to control child ordering.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child + + +* + + + +

    An instance of Phaser.Sprite, Phaser.Button or any other display object..

    index + + +number + + + +

    The index within the Group to insert the child to.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The child that was added to the Group.

    +
    + + + +
    +
    + Type +
    +
    + +* + + +
    +
    + + + + + +
    + + + +
    +

    bringToTop(child) → {*}

    + + +
    +
    + + +
    +

    Brings the given child to the top of this Group so it renders above all other children.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child + + +* + + + +

    The child to bring to the top of this Group.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The child that was moved.

    +
    + + + +
    +
    + Type +
    +
    + +* + + +
    +
    + + + + + +
    + + + +
    +

    callAll(callback, parameter)

    + + +
    +
    + + +
    +

    Calls a function on all of the children regardless if they are dead or alive (see callAllExists if you need control over that) +After the callback parameter you can add as many extra parameters as you like, which will all be passed to the child.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    callback + + +function + + + + + + + + + +

    The function that exists on the children that will be called.

    parameter + + +* + + + + + + + + + + <repeatable>
    + +

    Additional parameters that will be passed to the callback.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    callAllExists(callback, existsValue, parameter)

    + + +
    +
    + + +
    +

    Calls a function on all of the children that have exists=true in this Group. +After the existsValue parameter you can add as many parameters as you like, which will all be passed to the child callback.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    callback + + +function + + + + + + + + + +

    The function that exists on the children that will be called.

    existsValue + + +boolean + + + + + + + + + +

    Only children with exists=existsValue will be called.

    parameter + + +* + + + + + + + + + + <repeatable>
    + +

    Additional parameters that will be passed to the callback.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    countDead() → {number}

    + + +
    +
    + + +
    +

    Call this function to find out how many members of the group are dead.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The number of children flagged as dead. Returns -1 if Group is empty.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    countLiving() → {number}

    + + +
    +
    + + +
    +

    Call this function to find out how many members of the group are alive.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The number of children flagged as alive. Returns -1 if Group is empty.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    create(x, y, key, frame, exists) → {Phaser.Sprite}

    + + +
    +
    + + +
    +

    Automatically creates a new Phaser.Sprite object and adds it to the top of this Group. +Useful if you don't need to create the Sprite instances before-hand.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    x + + +number + + + + + + + + + + + +

    The x coordinate to display the newly created Sprite at. The value is in relation to the Group.x point.

    y + + +number + + + + + + + + + + + +

    The y coordinate to display the newly created Sprite at. The value is in relation to the Group.y point.

    key + + +string + + + + + + + + + + + +

    The Game.cache key of the image that this Sprite will use.

    frame + + +number +| + +string + + + + + + <optional>
    + + + + + +
    + +

    If the Sprite image contains multiple frames you can specify which one to use here.

    exists + + +boolean + + + + + + <optional>
    + + + + + +
    + + true + +

    The default exists state of the Sprite.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The child that was created.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Sprite + + +
    +
    + + + + + +
    + + + +
    +

    createMultiple(quantity, key, frame, exists)

    + + +
    +
    + + +
    +

    Automatically creates multiple Phaser.Sprite objects and adds them to the top of this Group. +Useful if you need to quickly generate a pool of identical sprites, such as bullets. By default the sprites will be set to not exist +and will be positioned at 0, 0 (relative to the Group.x/y)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    quantity + + +number + + + + + + + + + + + +

    The number of Sprites to create.

    key + + +string + + + + + + + + + + + +

    The Game.cache key of the image that this Sprite will use.

    frame + + +number +| + +string + + + + + + <optional>
    + + + + + +
    + +

    If the Sprite image contains multiple frames you can specify which one to use here.

    exists + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    The default exists state of the Sprite.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Destroys this Group. Removes all children, then removes the container from the display list and nulls references.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    divideAll(property, amount, checkAlive, checkVisible)

    + + +
    +
    + + +
    +

    Divides the given property by the amount on all children in this Group. +Group.divideAll('x', 2) will half the child.x value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    property + + +string + + + +

    The property to divide, for example 'body.velocity.x' or 'angle'.

    amount + + +number + + + +

    The amount to divide the property by. If child.x = 100 then divideAll('x', 2) would make child.x = 50.

    checkAlive + + +boolean + + + +

    If true the property will only be changed if the child is alive.

    checkVisible + + +boolean + + + +

    If true the property will only be changed if the child is visible.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    dump(full)

    + + +
    +
    + + +
    +

    Dumps out a list of Group children and their index positions to the browser console. Useful for group debugging.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    full + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If full the dump will include the entire display list, start from the Stage. Otherwise it will only include this container.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    forEach(callback, callbackContext, checkExists)

    + + +
    +
    + + +
    +

    Allows you to call your own function on each member of this Group. You must pass the callback and context in which it will run. +After the checkExists parameter you can add as many parameters as you like, which will all be passed to the callback along with the child. +For example: Group.forEach(awardBonusGold, this, true, 100, 500)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callback + + +function + + + +

    The function that will be called. Each child of the Group will be passed to it as its first parameter.

    callbackContext + + +Object + + + +

    The context in which the function should be called (usually 'this').

    checkExists + + +boolean + + + +

    If set only children with exists=true will be passed to the callback, otherwise all children will be passed.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    forEachAlive(callback, callbackContext)

    + + +
    +
    + + +
    +

    Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run. +You can add as many parameters as you like, which will all be passed to the callback along with the child. +For example: Group.forEachAlive(causeDamage, this, 500)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callback + + +function + + + +

    The function that will be called. Each child of the Group will be passed to it as its first parameter.

    callbackContext + + +Object + + + +

    The context in which the function should be called (usually 'this').

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    forEachDead(callback, callbackContext)

    + + +
    +
    + + +
    +

    Allows you to call your own function on each dead member of this Group (where alive=false). You must pass the callback and context in which it will run. +You can add as many parameters as you like, which will all be passed to the callback along with the child. +For example: Group.forEachDead(bringToLife, this)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callback + + +function + + + +

    The function that will be called. Each child of the Group will be passed to it as its first parameter.

    callbackContext + + +Object + + + +

    The context in which the function should be called (usually 'this').

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    getAt(index) → {*}

    + + +
    +
    + + +
    +

    Returns the child found at the given index within this Group.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    index + + +number + + + +

    The index to return the child from.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The child that was found at the given index.

    +
    + + + +
    +
    + Type +
    +
    + +* + + +
    +
    + + + + + +
    + + + +
    +

    getFirstAlive() → {Any}

    + + +
    +
    + + +
    +

    Call this function to retrieve the first object with alive == true in the group. +This is handy for checking if everything has been wiped out, or choosing a squad leader, etc.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The first alive child, or null if none found.

    +
    + + + +
    +
    + Type +
    +
    + +Any + + +
    +
    + + + + + +
    + + + +
    +

    getFirstDead() → {Any}

    + + +
    +
    + + +
    +

    Call this function to retrieve the first object with alive == false in the group. +This is handy for checking if everything has been wiped out, or choosing a squad leader, etc.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The first dead child, or null if none found.

    +
    + + + +
    +
    + Type +
    +
    + +Any + + +
    +
    + + + + + +
    + + + +
    +

    getFirstExists(state) → {Any}

    + + +
    +
    + + +
    +

    Call this function to retrieve the first object with exists == (the given state) in the Group.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    state + + +boolean + + + +

    True or false.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The first child, or null if none found.

    +
    + + + +
    +
    + Type +
    +
    + +Any + + +
    +
    + + + + + +
    + + + +
    +

    getIndex(child) → {number}

    + + +
    +
    + + +
    +

    Get the index position of the given child in this Group.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child + + +* + + + +

    The child to get the index for.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The index of the child or -1 if it's not a member of this Group.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    getRandom(startIndex, length) → {Any}

    + + +
    +
    + + +
    +

    Returns a member at random from the group.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    startIndex + + +number + + + +

    Optional offset off the front of the array. Default value is 0, or the beginning of the array.

    length + + +number + + + +

    Optional restriction on the number of values you want to randomly select from.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A random child of this Group.

    +
    + + + +
    +
    + Type +
    +
    + +Any + + +
    +
    + + + + + +
    + + + +
    +

    multiplyAll(property, amount, checkAlive, checkVisible)

    + + +
    +
    + + +
    +

    Multiplies the given property by the amount on all children in this Group. +Group.multiplyAll('x', 2) will x2 the child.x value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    property + + +string + + + +

    The property to multiply, for example 'body.velocity.x' or 'angle'.

    amount + + +number + + + +

    The amount to multiply the property by. If child.x = 10 then multiplyAll('x', 2) would make child.x = 20.

    checkAlive + + +boolean + + + +

    If true the property will only be changed if the child is alive.

    checkVisible + + +boolean + + + +

    If true the property will only be changed if the child is visible.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    remove(child)

    + + +
    +
    + + +
    +

    Removes the given child from this Group and sets its group property to null.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child + + +Any + + + +

    The child to remove.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeAll()

    + + +
    +
    + + +
    +

    Removes all children from this Group, setting all group properties to null. +The Group container remains on the display list.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeBetween(startIndex, endIndex)

    + + +
    +
    + + +
    +

    Removes all children from this Group whos index falls beteen the given startIndex and endIndex values.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    startIndex + + +number + + + +

    The index to start removing children from.

    endIndex + + +number + + + +

    The index to stop removing children from. Must be higher than startIndex and less than the length of the Group.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    replace(oldChild, newChild)

    + + +
    +
    + + +
    +

    Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    oldChild + + +* + + + +

    The child in this Group that will be replaced.

    newChild + + +* + + + +

    The child to be inserted into this group.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setAll(key, value, checkAlive, checkVisible, operation)

    + + +
    +
    + + +
    +

    This function allows you to quickly set the same property across all children of this Group to a new value. +The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    key + + +string + + + + + + + + + + + +

    The property, as a string, to be set. For example: 'body.velocity.x'

    value + + +* + + + + + + + + + + + +

    The value that will be set.

    checkAlive + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If set then only children with alive=true will be updated.

    checkVisible + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If set then only children with visible=true will be updated.

    operation + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setProperty(child, key, value, operation)

    + + +
    +
    + + +
    +

    Sets the given property to the given value on the child. The operation controls the assignment of the value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    child + + +* + + + + + + + + + + + +

    The child to set the property value on.

    key + + +array + + + + + + + + + + + +

    An array of strings that make up the property that will be set.

    value + + +* + + + + + + + + + + + +

    The value that will be set.

    operation + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    subAll(property, amount, checkAlive, checkVisible)

    + + +
    +
    + + +
    +

    Subtracts the amount from the given property on all children in this Group. +Group.subAll('x', 10) will minus 10 from the child.x value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    property + + +string + + + +

    The property to decrement, for example 'body.velocity.x' or 'angle'.

    amount + + +number + + + +

    The amount to subtract from the property. If child.x = 50 then subAll('x', 40) would make child.x = 10.

    checkAlive + + +boolean + + + +

    If true the property will only be changed if the child is alive.

    checkVisible + + +boolean + + + +

    If true the property will only be changed if the child is visible.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    swap(child1, child2) → {boolean}

    + + +
    +
    + + +
    +

    Swaps the position of two children in this Group.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child1 + + +* + + + +

    The first child to swap.

    child2 + + +* + + + +

    The second child to swap.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the swap was successful, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:27 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Input.html b/docs/Phaser.Input.html new file mode 100644 index 00000000..2baf067d --- /dev/null +++ b/docs/Phaser.Input.html @@ -0,0 +1,7321 @@ + + + + + + Phaser Class: Input + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Input

    +
    + +
    +

    + Phaser. + + Input +

    + +

    A game specific Input manager that looks after the mouse, keyboard and touch objects. +This is updated by the core game loop.

    + +
    + +
    +
    + + + + +
    +

    new Input(game)

    + + +
    +
    + + +
    +

    Constructor for Phaser Input.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Current game instance.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    <static, constant> MOUSE_OVERRIDES_TOUCH :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> MOUSE_TOUCH_COMBINE :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> TOUCH_OVERRIDES_MOUSE :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    activePointer

    + + +
    +
    + +
    +

    The most recently active Pointer object. +When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    activePointer + + +Phaser.Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    circle

    + + +
    +
    + +
    +

    A Circle object centered on the x/y screen coordinates of the Input. +Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    circle + + +Phaser.Circle + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    currentPointers

    + + +
    +
    + +
    +

    The current number of active Pointers.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    currentPointers + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    disabled

    + + +
    +
    + +
    +

    You can disable all Input by setting Input.disabled: true. While set all new input related events will be ignored. +If you need to disable just one type of input, for example mouse, use Input.mouse.disabled: true instead

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    disabled + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    doubleTapRate

    + + +
    +
    + +
    +

    The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    doubleTapRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 300
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    hitCanvas

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hitCanvas + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    hitContext

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hitContext + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    holdRate

    + + +
    +
    + +
    +

    The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    holdRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 2000
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    interactiveItems

    + + +
    +
    + +
    +

    A linked list of interactive objects, the InputHandler components (belonging to Sprites) register themselves with this.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    interactiveItems + + +Phaser.LinkedList + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    justPressedRate

    + + +
    +
    + +
    +

    The number of milliseconds below which the Pointer is considered justPressed

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    justPressedRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 200
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    justReleasedRate

    + + +
    +
    + +
    +

    The number of milliseconds below which the Pointer is considered justReleased

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    justReleasedRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 200
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    keyboard

    + + +
    +
    + +
    +

    The Keyboard Input manager.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    keyboard + + +Phaser.Keyboard + + + +

    The Keyboard Input manager.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxPointers

    + + +
    +
    + +
    +

    The maximum number of Pointers allowed to be active at any one time. +For lots of games it's useful to set this to 1.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxPointers + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 10
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mouse

    + + +
    +
    + +
    +

    The Mouse Input manager.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mouse + + +Phaser.Mouse + + + +

    The Mouse Input manager.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mousePointer

    + + +
    +
    + +
    +

    The mouse has its own unique Phaser.Pointer object which you can use if making a desktop specific game.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mousePointer + + +Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mspointer

    + + +
    +
    + +
    +

    The MSPointer Input manager.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mspointer + + +Phaser.MSPointer + + + +

    The MSPointer Input manager.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    multiInputOverride

    + + +
    +
    + +
    +

    Controls the expected behaviour when using a mouse and touch together on a multi-input device.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    multiInputOverride + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onDown

    + + +
    +
    + +
    +

    A Signal that is dispatched each time a pointer is pressed down.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onDown + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onHold

    + + +
    +
    + +
    +

    A Signal that is dispatched each time a pointer is held down.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onHold + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onTap

    + + +
    +
    + +
    +

    A Signal that is dispatched each time a pointer is tapped.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onTap + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onUp

    + + +
    +
    + +
    +

    A Signal that is dispatched each time a pointer is released.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onUp + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer1

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer1 + + +Phaser.Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer2

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer2 + + +Phaser.Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer3

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer3 + + +Phaser.Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer4

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer4 + + +Phaser.Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer5

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer5 + + +Phaser.Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer6

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer6 + + +Phaser.Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer7

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer7 + + +Phaser.Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer8

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer8 + + +Phaser.Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer9

    + + +
    +
    + +
    +

    A Pointer object

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer9 + + +Phaser.Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pointer10

    + + +
    +
    + +
    +

    A Pointer object.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer10 + + +Phaser.Pointer + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> pollLocked

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pollLocked + + +boolean + + + +

    True if the Input is currently poll rate locked.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pollRate

    + + +
    +
    + +
    +

    How often should the input pointers be checked for updates? +A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pollRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    position

    + + +
    +
    + +
    +

    A vector object representing the current position of the Pointer.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    position + + +Phaser.Point + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    recordLimit

    + + +
    +
    + +
    +

    The total number of entries that can be recorded into the Pointer objects tracking history. +If the Pointer is tracking one event every 100ms, then a trackLimit of 100 would store the last 10 seconds worth of history.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    recordLimit + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 100
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    recordPointerHistory

    + + +
    +
    + +
    +

    Sets if the Pointer objects should record a history of x/y coordinates they have passed through. +The history is cleared each time the Pointer is pressed down. +The history is updated at the rate specified in Input.pollRate

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    recordPointerHistory + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    recordRate

    + + +
    +
    + +
    +

    The rate in milliseconds at which the Pointer objects should update their tracking history

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    recordRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 100
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    scale

    + + +
    +
    + +
    +

    The scale by which all input coordinates are multiplied, calculated by the StageScaleMode. +In an un-scaled game the values will be x: 1 and y: 1.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    scale + + +Phaser.Point + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    speed

    + + +
    +
    + +
    +

    A vector object representing the speed of the Pointer. Only really useful in single Pointer games, +otherwise see the Pointer objects directly.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    speed + + +Phaser.Point + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    tapRate

    + + +
    +
    + +
    +

    The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or clicke

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    tapRate + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 200
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> totalActivePointers

    + + +
    +
    + +
    +

    The total number of active Pointers

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    totalActivePointers + + +number + + + +

    The total number of active Pointers.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> totalInactivePointers

    + + +
    +
    + +
    +

    The total number of inactive Pointers

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    totalInactivePointers + + +number + + + +

    The total number of inactive Pointers.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    touch

    + + +
    +
    + +
    +

    The Touch Input manager.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    touch + + +Phaser.Touch + + + +

    the Touch Input manager.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    worldX

    + + +
    +
    + +
    +

    The world X coordinate of the most recently active pointer.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    worldX + + +number + + + +

    The world X coordinate of the most recently active pointer.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    worldY

    + + +
    +
    + +
    +

    The world Y coordinate of the most recently active pointer.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    worldY + + +number + + + +

    The world Y coordinate of the most recently active pointer.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + +
    +

    The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The X coordinate of the most recently active pointer.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + +
    +

    The Y coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    The Y coordinate of the most recently active pointer.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    addPointer() → {Phaser.Pointer}

    + + +
    +
    + + +
    +

    Add a new Pointer object to the Input Manager. By default Input creates 3 pointer objects: mousePointer, pointer1 and pointer2. +If you need more then use this to create a new one, up to a maximum of 10.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A reference to the new Pointer object that was created.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Pointer + + +
    +
    + + + + + +
    + + + +
    +

    <protected> boot()

    + + +
    +
    + + +
    +

    Starts the Input Manager running.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Stops all of the Input Managers from running.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    getPointer(state) → {Phaser.Pointer}

    + + +
    +
    + + +
    +

    Get the next Pointer object whos active property matches the given state

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    state + + +boolean + + + +

    The state the Pointer should be in (false for inactive, true for active).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A Pointer object or null if no Pointer object matches the requested state.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Pointer + + +
    +
    + + + + + +
    + + + +
    +

    getPointerFromIdentifier(identifier) → {Phaser.Pointer}

    + + +
    +
    + + +
    +

    Get the Pointer object whos identified property matches the given identifier value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    identifier + + +number + + + +

    The Pointer.identifier value to search for.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A Pointer object or null if no Pointer object matches the requested identifier.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Pointer + + +
    +
    + + + + + +
    + + + +
    +

    reset(hard)

    + + +
    +
    + + +
    +

    Reset all of the Pointers and Input states

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hard + + +boolean + + + +

    A soft reset (hard = false) won't reset any Signals that might be bound. A hard reset will.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    resetSpeed(x, y)

    + + +
    +
    + + +
    +

    Resets the speed and old position properties.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Sets the oldPosition.x value.

    y + + +number + + + +

    Sets the oldPosition.y value.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    startPointer(event) → {Phaser.Pointer}

    + + +
    +
    + + +
    +

    Find the first free Pointer object and start it, passing in the event data. This is called automatically by Phaser.Touch and Phaser.MSPointer.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +

    The event data from the Touch event.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Pointer object that was started or null if no Pointer object is available.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Pointer + + +
    +
    + + + + + +
    + + + +
    +

    stopPointer(event) → {Phaser.Pointer}

    + + +
    +
    + + +
    +

    Stops the matching Pointer object, passing in the event data.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +

    The event data from the Touch event.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Pointer object that was stopped or null if no Pointer object is available.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Pointer + + +
    +
    + + + + + +
    + + + +
    +

    <protected> update()

    + + +
    +
    + + +
    +

    Updates the Input Manager. Called by the core Game loop.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    updatePointer(event) → {Phaser.Pointer}

    + + +
    +
    + + +
    +

    Updates the matching Pointer object, passing in the event data. This is called automatically and should not normally need to be invoked.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +

    The event data from the Touch event.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Pointer object that was updated or null if no Pointer object is available.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Pointer + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:27 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.InputHandler.html b/docs/Phaser.InputHandler.html new file mode 100644 index 00000000..c167475d --- /dev/null +++ b/docs/Phaser.InputHandler.html @@ -0,0 +1,7496 @@ + + + + + + Phaser Class: InputHandler + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: InputHandler

    +
    + +
    +

    + Phaser. + + InputHandler +

    + +

    Description.

    + +
    + +
    +
    + + + + +
    +

    new InputHandler(game)

    + + +
    +
    + + +
    +

    Constructor for Phaser InputHandler.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Sprite + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    allowHorizontalDrag

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    allowHorizontalDrag + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    allowVerticalDrag

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    allowVerticalDrag + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    boundsRect

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    boundsRect + + +Description + + + +

    A region of the game world within which the sprite is restricted during drag.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    boundsSprite

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    boundsSprite + + +Description + + + +

    A Sprite the bounds of which this sprite is restricted during drag.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bringToTop

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bringToTop + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    consumePointerEvent

    + + +
    +
    + +
    +

    If this object is set to consume the pointer event then it will stop all propogation from this object on. +For example if you had a stack of 6 sprites with the same priority IDs and one consumed the event, none of the others would receive it.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    consumePointerEvent + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    draggable

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    draggable + + +boolean + + + +

    Is this sprite allowed to be dragged by the mouse? true = yes, false = no

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    enabled

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    enabled + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    first

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    first + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isDragged

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isDragged + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    last

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    last + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    next

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    next + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    parent

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    parent + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pixelPerfect

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pixelPerfect + + +number + + + +

    Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it!

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pixelPerfectAlpha

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pixelPerfectAlpha + + +number + + + +

    The alpha tolerance threshold. If the alpha value of the pixel matches or is above this value, it's considered a hit.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 255
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    prev

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    prev + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    priorityID

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    priorityID + + +number + + + +

    The PriorityID controls which Sprite receives an Input event first if they should overlap.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    snapOffset

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    snapOffset + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    snapOnDrag

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    snapOnDrag + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    snapOnRelease

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    snapOnRelease + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    snapX

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    snapX + + +number + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    snapY

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    snapY + + +number + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    sprite

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sprite + + +Phaser.Sprite + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    useHandCursor

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    useHandCursor + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    checkBoundsRect()

    + + +
    +
    + + +
    +

    Bounds Rect check for the sprite drag

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    checkBoundsSprite()

    + + +
    +
    + + +
    +

    Parent Sprite Bounds check for the sprite drag.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    checkPixel(x, y) → {boolean}

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +Description + + + +

    Description.

    y + + +Description + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    checkPointerOver(pointer) → {boolean}

    + + +
    +
    + + +
    +

    Checks if the given pointer is over this Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Clean up memory.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    disableDrag()

    + + +
    +
    + + +
    +

    Stops this sprite from being able to be dragged. If it is currently the target of an active drag it will be stopped immediately. Also disables any set callbacks.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    disableSnap()

    + + +
    +
    + + +
    +

    Stops the sprite from snapping to a grid during drag or release.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    downDuration(pointer) → {number}

    + + +
    +
    + + +
    +

    If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    enableDrag(lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite)

    + + +
    +
    + + +
    +

    Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    lockCenter + +

    If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer.

    bringToTop + +

    If true the Sprite will be bought to the top of the rendering list in its current Group.

    pixelPerfect + +

    If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box.

    alphaThreshold + +

    If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255)

    boundsRect + +

    If you want to restrict the drag of this sprite to a specific FlxRect, pass the FlxRect here, otherwise it's free to drag anywhere

    boundsSprite + +

    If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    enableSnap(snapX, snapY, onDrag, onRelease)

    + + +
    +
    + + +
    +

    Make this Sprite snap to the given grid either during drag or when it's released. +For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    snapX + +

    The width of the grid cell in pixels

    snapY + +

    The height of the grid cell in pixels

    onDrag + +

    If true the sprite will snap to the grid while being dragged

    onRelease + +

    If true the sprite will snap to the grid when released

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    justOut(pointer, delay) → {boolean}

    + + +
    +
    + + +
    +

    Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    delay + + +number + + + +

    The time below which the pointer is considered as just out.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    justOver(pointer, delay) → {boolean}

    + + +
    +
    + + +
    +

    Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    delay + + +number + + + +

    The time below which the pointer is considered as just over.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    justPressed(pointer, delay) → {boolean}

    + + +
    +
    + + +
    +

    Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    delay + + +number + + + +

    The time below which the pointer is considered as just over.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    justReleased(pointer, delay) → {boolean}

    + + +
    +
    + + +
    +

    Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    delay + + +number + + + +

    The time below which the pointer is considered as just out.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    overDuration(pointer) → {number}

    + + +
    +
    + + +
    +

    If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The number of milliseconds the pointer has been over the Sprite, or -1 if not over.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    pointerDown(pointer) → {boolean}

    + + +
    +
    + + +
    +

    If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    pointerOut(pointer) → {boolean}

    + + +
    +
    + + +
    +

    Is the Pointer outside of this Sprite?

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    pointerOver(pointer)

    + + +
    +
    + + +
    +

    Is the Pointer over this Sprite?

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    {bool

    +
    + + + + + + + +
    + + + +
    +

    pointerTimeDown(pointer) → {number}

    + + +
    +
    + + +
    +

    A timestamp representing when the Pointer first touched the touchscreen.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    pointerTimeOut(pointer) → {number}

    + + +
    +
    + + +
    +

    A timestamp representing when the Pointer left the touchscreen.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    pointerTimeOut(pointer) → {number}

    + + +
    +
    + + +
    +

    Is this sprite being dragged by the mouse or not?

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    pointerTimeOver(pointer) → {number}

    + + +
    +
    + + +
    +

    A timestamp representing when the Pointer first touched the touchscreen.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    pointerTimeUp(pointer) → {number}

    + + +
    +
    + + +
    +

    A timestamp representing when the Pointer left the touchscreen.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    pointerUp(pointer) → {boolean}

    + + +
    +
    + + +
    +

    If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    pointerX(pointer) → {number}

    + + +
    +
    + + +
    +

    The x coordinate of the Input pointer, relative to the top-left of the parent Sprite. +This value is only set when the pointer is over this Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The x coordinate of the Input pointer.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    pointerY(pointer) → {number}

    + + +
    +
    + + +
    +

    The y coordinate of the Input pointer, relative to the top-left of the parent Sprite +This value is only set when the pointer is over this Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The y coordinate of the Input pointer.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    reset()

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setDragLock(allowHorizontal, allowVertical)

    + + +
    +
    + + +
    +

    Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move!

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    allowHorizontal + +

    To enable the sprite to be dragged horizontally set to true, otherwise false

    allowVertical + +

    To enable the sprite to be dragged vertically set to true, otherwise false

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    start(priority, useHandCursor) → {Phaser.Sprite}

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    priority + + +number + + + +

    Description.

    useHandCursor + + +boolean + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Description.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Sprite + + +
    +
    + + + + + +
    + + + +
    +

    startDrag()

    + + +
    +
    + + +
    +

    Called by Pointer when drag starts on this Sprite. Should not usually be called directly.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stop()

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stopDrag()

    + + +
    +
    + + +
    +

    Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    update(pointer)

    + + +
    +
    + + +
    +

    Update.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    updateDrag(pointer) → {boolean}

    + + +
    +
    + + +
    +

    Updates the Pointer drag on this Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pointer + + +Pointer + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:28 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Key.html b/docs/Phaser.Key.html new file mode 100644 index 00000000..13da50af --- /dev/null +++ b/docs/Phaser.Key.html @@ -0,0 +1,2543 @@ + + + + + + Phaser Class: Key + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Key

    +
    + +
    +

    + Phaser. + + Key +

    + +

    If you need more fine-grained control over the handling of specific keys you can create and use Phaser.Key objects.

    + +
    + +
    +
    + + + + +
    +

    new Key(game, keycode)

    + + +
    +
    + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Current game instance.

    keycode + + +number + + + +

    The key code this Key is responsible for.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    altKey

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    altKey + + +boolean + + + +

    The down state of the ALT key, if pressed at the same time as this key.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    ctrlKey

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    ctrlKey + + +boolean + + + +

    The down state of the CTRL key, if pressed at the same time as this key.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    duration

    + + +
    +
    + +
    +

    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.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    duration + + +number + + + +

    The number of milliseconds this key has been held down for.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isDown

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isDown + + +boolean + + + +

    The "down" state of the key.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isUp

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isUp + + +boolean + + + +

    The "up" state of the key.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    keyCode

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    keyCode + + +number + + + +

    The keycode of this key.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onDown

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onDown + + +Phaser.Signal + + + +

    This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again).

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onUp

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onUp + + +Phaser.Signal + + + +

    This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again).

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    repeats

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    repeats + + +number + + + +

    If a key is held down this holds down the number of times the key has 'repeated'.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    shiftKey

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    shiftKey + + +boolean + + + +

    The down state of the SHIFT key, if pressed at the same time as this key.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    timeDown

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    timeDown + + +number + + + +

    The timestamp when the key was last pressed down.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    timeUp

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    timeUp + + +number + + + +

    The timestamp when the key was last released.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    justPressed(duration) → {boolean}

    + + +
    +
    + + +
    +

    Returns the "just pressed" state of the Key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    duration + + +number + + + + + + <optional>
    + + + + + +
    + + 250 + +

    The duration below which the key is considered as being just pressed.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the key is just pressed otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    justPressed(duration) → {boolean}

    + + +
    +
    + + +
    +

    Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    duration + + +number + + + + + + <optional>
    + + + + + +
    + + 250 + +

    The duration below which the key is considered as being just released.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the key is just released otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <protected> processKeyDown()

    + + +
    +
    + + +
    +

    Called automatically by Phaser.Keyboard.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event. + + +KeyboardEvent + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> processKeyUp()

    + + +
    +
    + + +
    +

    Called automatically by Phaser.Keyboard.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event. + + +KeyboardEvent + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:28 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Keyboard.html b/docs/Phaser.Keyboard.html new file mode 100644 index 00000000..d9b3b6df --- /dev/null +++ b/docs/Phaser.Keyboard.html @@ -0,0 +1,2970 @@ + + + + + + Phaser Class: Keyboard + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Keyboard

    +
    + +
    +

    + Phaser. + + Keyboard +

    + +

    A Keyboard object Description.

    + +
    + +
    +
    + + + + +
    +

    new Keyboard(game)

    + + +
    +
    + + +
    +

    Phaser - Keyboard constructor.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    callbackContext

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callbackContext + + +Object + + + +

    The context under which the callbacks are run.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    disabled

    + + +
    +
    + +
    +

    You can disable all Keyboard Input by setting disabled to true. While true all new input related events will be ignored.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    disabled + + +boolean + + + +

    The disabled state of the Keyboard.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onDownCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onDownCallback + + +function + + + +

    This callback is invoked every time a key is pressed down.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onUpCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onUpCallback + + +function + + + +

    This callback is invoked every time a key is released.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    addCallbacks(context, onDown, onUp)

    + + +
    +
    + + +
    +

    Add callbacks to the Keyboard handler so that each time a key is pressed down or releases the callbacks are activated.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    context + + +Object + + + + + + + + + + + +

    The context under which the callbacks are run.

    onDown + + +function + + + + + + + + + + + +

    This callback is invoked every time a key is pressed down.

    onUp + + +function + + + + + + <optional>
    + + + + + +
    + + null + +

    This callback is invoked every time a key is released.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addKey(keycode) → {Phaser.Key}

    + + +
    +
    + + +
    +

    If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method. +The Key object can then be polled, have events attached to it, etc.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    keycode + + +number + + + +

    The keycode of the key, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Key object which you can store locally and reference directly.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Key + + +
    +
    + + + + + +
    + + + +
    +

    addKeyCapture(keycode)

    + + +
    +
    + + +
    +

    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. +You can use addKeyCapture to consume the keyboard event for specific keys so it doesn't bubble up to the the browser. +Pass in either a single keycode or an array/hash of keycodes.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    keycode + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    clearCaptures()

    + + +
    +
    + + +
    +

    Clear all set key captures.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    createCursorKeys() → {object}

    + + +
    +
    + + +
    +

    Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    An object containing properties: up, down, left and right. Which can be polled like any other Phaser.Key object.

    +
    + + + +
    +
    + Type +
    +
    + +object + + +
    +
    + + + + + +
    + + + +
    +

    isDown(keycode) → {boolean}

    + + +
    +
    + + +
    +

    Returns true of the key is currently pressed down. Note that it can only detect key presses on the web browser.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    keycode + + +number + + + +

    The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the key is currently down.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    justPressed(keycode, duration) → {boolean}

    + + +
    +
    + + +
    +

    Returns the "just pressed" state of the key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    keycode + + +number + + + + + + + + + + + +

    The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR

    duration + + +number + + + + + + <optional>
    + + + + + +
    + + 250 + +

    The duration below which the key is considered as being just pressed.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the key is just pressed otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    justPressed(keycode, duration) → {boolean}

    + + +
    +
    + + +
    +

    Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    keycode + + +number + + + + + + + + + + + +

    The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR

    duration + + +number + + + + + + <optional>
    + + + + + +
    + + 250 + +

    The duration below which the key is considered as being just released.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the key is just released otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <protected> processKeyDown(event)

    + + +
    +
    + + +
    +

    Process the keydown event.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +KeyboardEvent + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> processKeyUp(event)

    + + +
    +
    + + +
    +

    Process the keyup event.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +KeyboardEvent + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeKey(keycode)

    + + +
    +
    + + +
    +

    Removes a Key object from the Keyboard manager.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    keycode + + +number + + + +

    The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeKeyCapture(keycode)

    + + +
    +
    + + +
    +

    Removes an existing key capture.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    keycode + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    reset()

    + + +
    +
    + + +
    +

    Reset the "isDown" state of all keys.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    start()

    + + +
    +
    + + +
    +

    Starts the Keyboard event listeners running (keydown and keyup). They are attached to the document.body. +This is called automatically by Phaser.Input and should not normally be invoked directly.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stop()

    + + +
    +
    + + +
    +

    Stops the Keyboard event listeners from running (keydown and keyup). They are removed from the document.body.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:28 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.LinkedList.html b/docs/Phaser.LinkedList.html new file mode 100644 index 00000000..b89ef281 --- /dev/null +++ b/docs/Phaser.LinkedList.html @@ -0,0 +1,1462 @@ + + + + + + Phaser Class: LinkedList + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: LinkedList

    +
    + +
    +

    + Phaser. + + LinkedList +

    + +

    Phaser.LinkedList

    + +
    + +
    +
    + + + + +
    +

    new LinkedList()

    + + +
    +
    + + +
    +

    A basic linked list data structure.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    first

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    first + + +object + + + +

    First element in the list.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    last

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    last + + +object + + + +

    Last element in the list.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    next

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    next + + +object + + + +

    Next element in the list.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    prev

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    prev + + +object + + + +

    Previous element in the list.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    total

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +object + + + +

    Number of elements in the list.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    add(child) → {object}

    + + +
    +
    + + +
    +

    Adds a new element to this linked list.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child + + +object + + + +

    The element to add to this list. Can be a Phaser.Sprite or any other object you need to quickly iterate through.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The child that was added.

    +
    + + + +
    +
    + Type +
    +
    + +object + + +
    +
    + + + + + +
    + + + +
    +

    callAll(callback)

    + + +
    +
    + + +
    +

    Calls a function on all members of this list, using the member as the context for the callback. +The function must exist on the member.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callback + + +function + + + +

    The function to call.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    remove(child)

    + + +
    +
    + + +
    +

    Removes the given element from this linked list if it exists.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child + + +object + + + +

    The child to be removed from the list.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:28 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Loader.html b/docs/Phaser.Loader.html new file mode 100644 index 00000000..42edd6b3 --- /dev/null +++ b/docs/Phaser.Loader.html @@ -0,0 +1,5932 @@ + + + + + + Phaser Class: Loader + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Loader

    +
    + +
    +

    + Phaser. + + Loader +

    + +

    The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. +It uses a combination of Image() loading and xhr and provides progress and completion callbacks.

    + +
    + +
    +
    + + + + +
    +

    new Loader(game)

    + + +
    +
    + + +
    +

    Phaser loader constructor. +The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. +It uses a combination of Image() loading and xhr and provides progress and completion callbacks.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    <static, constant> TEXTURE_ATLAS_JSON_ARRAY :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> TEXTURE_ATLAS_JSON_HASH :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> TEXTURE_ATLAS_XML_STARLING :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    baseURL

    + + +
    +
    + +
    +

    If you want to append a URL before the path of any asset you can set this here. +Useful if you need to allow an asset url to be configured outside of the game code. +MUST have / on the end of it!

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    baseURL + + +string + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    crossOrigin

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    crossOrigin + + +string + + + +

    The crossOrigin value applied to loaded images

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    hasLoaded

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hasLoaded + + +boolean + + + +

    True if all assets in the queue have finished loading.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isLoading

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isLoading + + +boolean + + + +

    True if the Loader is in the process of loading the queue.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onFileComplete

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onFileComplete + + +Phaser.Signal + + + +

    Event signal.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onFileError

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onFileError + + +Phaser.Signal + + + +

    Event signal.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onLoadComplete

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onLoadComplete + + +Phaser.Signal + + + +

    Event signal.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onLoadStart

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onLoadStart + + +Phaser.Signal + + + +

    Event signal.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    preloadSprite

    + + +
    +
    + +
    +

    You can optionally link a sprite to the preloader. +If you do so the Sprite's width or height will be cropped based on the percentage loaded.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    preloadSprite + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    progress

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    progress + + +number + + + +

    The Load progress percentage value (from 0 to 100)

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    queueSize

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    TypeDescription
    + + +number + + + +

    Length of assets queue.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    <protected> addToFileList(type, key, url, properties)

    + + +
    +
    + + +
    +

    Internal function that adds a new entry to the file list. Do not call directly.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +Description + + + +

    Description.

    key + + +string + + + +

    Description.

    url + + +string + + + +

    URL of Description.

    properties + + +Description + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    atlas(key, textureURL, atlasURL, atlasData, format)

    + + +
    +
    + + +
    +

    Add a new texture atlas to the loader.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    key + + +string + + + + + + + + + +

    Unique asset key of the texture atlas file.

    textureURL + + +string + + + + + + + + + +

    The url of the texture atlas image file.

    atlasURL + + +string + + + + + + <optional>
    + + + + + +

    The url of the texture atlas data file (json/xml). You don't need this if you are passing an atlasData object instead.

    atlasData + + +object + + + + + + <optional>
    + + + + + +

    A JSON or XML data object. You don't need this if the data is being loaded from a URL.

    format + + +number + + + + + + <optional>
    + + + + + +

    A value describing the format of the data, the default is Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    atlasJSONArray(key, atlasURL, atlasData)

    + + +
    +
    + + +
    +

    Add a new texture atlas to the loader. This atlas uses the JSON Array data format.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Unique asset key of the bitmap font.

    atlasURL + + +Description + + + +

    The url of the Description.

    atlasData + + +Description + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    atlasJSONHash(key, atlasURL, atlasData)

    + + +
    +
    + + +
    +

    Add a new texture atlas to the loader. This atlas uses the JSON Hash data format.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Unique asset key of the bitmap font.

    atlasURL + + +Description + + + +

    The url of the Description.

    atlasData + + +Description + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    atlasXML(key, atlasURL, atlasData)

    + + +
    +
    + + +
    +

    Add a new texture atlas to the loader. This atlas uses the Starling XML data format.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Unique asset key of the bitmap font.

    atlasURL + + +Description + + + +

    The url of the Description.

    atlasData + + +Description + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    audio(key, urls, autoDecode)

    + + +
    +
    + + +
    +

    Add a new audio file to the loader.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Unique asset key of the audio file.

    urls + + +Array + + + +

    An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ].

    autoDecode + + +boolean + + + +

    When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    bitmapFont(key, textureURL, xmlURL, xmlData)

    + + +
    +
    + + +
    +

    Add a new bitmap font loading request.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    key + + +string + + + + + + + + + +

    Unique asset key of the bitmap font.

    textureURL + + +string + + + + + + + + + +

    The url of the font image file.

    xmlURL + + +string + + + + + + <optional>
    + + + + + +

    The url of the font data file (xml/fnt)

    xmlData + + +object + + + + + + <optional>
    + + + + + +

    An optional XML data object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    checkKeyExists(key) → {boolean}

    + + +
    +
    + + +
    +

    Check whether asset exists with a specific key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Key of the asset you want to check.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Return true if exists, otherwise return false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    csvLoadComplete(key)

    + + +
    +
    + + +
    +

    Successfully loaded a CSV file.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Key of the loaded CSV file.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    dataLoadError(key)

    + + +
    +
    + + +
    +

    Error occured when load a JSON.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Key of the error loading JSON file.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    fileComplete(key)

    + + +
    +
    + + +
    +

    Called when a file is successfully loaded.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Key of the successfully loaded file.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    fileError(key)

    + + +
    +
    + + +
    +

    Error occured when load a file.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Key of the error loading file.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    image(key, url, overwrite)

    + + +
    +
    + + +
    +

    Add an image to the Loader.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Unique asset key of this image file.

    url + + +string + + + +

    URL of image file.

    overwrite + + +boolean + + + +

    If an entry with a matching key already exists this will over-write it

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    jsonLoadComplete(key)

    + + +
    +
    + + +
    +

    Successfully loaded a JSON file.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Key of the loaded JSON file.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeAll()

    + + +
    +
    + + +
    +

    Remove all file loading requests.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeFile(key)

    + + +
    +
    + + +
    +

    Remove loading request of a file.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Key of the file you want to remove.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    reset()

    + + +
    +
    + + +
    +

    Reset loader, this will remove all loaded assets.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setPreloadSprite(sprite, direction)

    + + +
    +
    + + +
    +

    You can set a Sprite to be a "preload" sprite by passing it to this method. +A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time. +This allows you to easily make loading bars for games.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    sprite + + +Phaser.Sprite + + + + + + + + + + + +

    The sprite that will be cropped during the load.

    direction + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    A value of zero means the sprite width will be cropped, a value of 1 means its height will be cropped.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    spritesheet(key, url, frameWidth, frameHeight, frameMax)

    + + +
    +
    + + +
    +

    Add a new sprite sheet to the loader.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    key + + +string + + + + + + + + + + + +

    Unique asset key of the sheet file.

    url + + +string + + + + + + + + + + + +

    URL of the sheet file.

    frameWidth + + +number + + + + + + + + + + + +

    Width of each single frame.

    frameHeight + + +number + + + + + + + + + + + +

    Height of each single frame.

    frameMax + + +number + + + + + + <optional>
    + + + + + +
    + + -1 + +

    How many frames in this sprite sheet. If not specified it will divide the whole image into frames.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    start()

    + + +
    +
    + + +
    +

    Start loading the assets. Normally you don't need to call this yourself as the StateManager will do so.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    text(key, url, overwrite)

    + + +
    +
    + + +
    +

    Add a text file to the Loader.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Unique asset key of the text file.

    url + + +string + + + +

    URL of the text file.

    overwrite + + +boolean + + + +

    True if Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    tilemap(key, tilesetURL, mapDataURL, mapData, format)

    + + +
    +
    + + +
    +

    Add a new tilemap loading request.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    key + + +string + + + + + + + + + +

    Unique asset key of the tilemap data.

    tilesetURL + + +string + + + + + + + + + +

    The url of the tile set image file.

    mapDataURL + + +string + + + + + + <optional>
    + + + + + +

    The url of the map data file (csv/json)

    mapData + + +object + + + + + + <optional>
    + + + + + +

    An optional JSON data object (can be given in place of a URL).

    format + + +string + + + + + + <optional>
    + + + + + +

    The format of the map data.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    tileset(key, url, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing)

    + + +
    +
    + + +
    +

    Add a new tile set to the loader. These are used in the rendering of tile maps.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    key + + +string + + + + + + + + + + + +

    Unique asset key of the tileset file.

    url + + +string + + + + + + + + + + + +

    URL of the tileset.

    tileWidth + + +number + + + + + + + + + + + +

    Width of each single tile in pixels.

    tileHeight + + +number + + + + + + + + + + + +

    Height of each single tile in pixels.

    tileMax + + +number + + + + + + <optional>
    + + + + + +
    + + -1 + +

    How many tiles in this tileset. If not specified it will divide the whole image into tiles.

    tileMargin + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    If the tiles have been drawn with a margin, specify the amount here.

    tileSpacing + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    If the tiles have been drawn with spacing between them, specify the amount here.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    xmlLoadComplete(key)

    + + +
    +
    + + +
    +

    Successfully loaded an XML file.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Key of the loaded XML file.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:28 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.LoaderParser.html b/docs/Phaser.LoaderParser.html new file mode 100644 index 00000000..e5441e1f --- /dev/null +++ b/docs/Phaser.LoaderParser.html @@ -0,0 +1,694 @@ + + + + + + Phaser Class: LoaderParser + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: LoaderParser

    +
    + +
    +

    + Phaser. + + LoaderParser +

    + +
    + +
    +
    + + + + +
    +

    new LoaderParser()

    + + +
    +
    + + +
    +

    Phaser.LoaderParser parses data objects from Phaser.Loader that need more preparation before they can be inserted into the Cache.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    <static> bitmapFont(xml) → {FrameData}

    + + +
    +
    + + +
    +

    Parse frame data from an XML file.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    xml + + +object + + + +

    XML data you want to parse.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Generated FrameData object.

    +
    + + + +
    +
    + Type +
    +
    + +FrameData + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:28 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.MSPointer.html b/docs/Phaser.MSPointer.html new file mode 100644 index 00000000..b920a31e --- /dev/null +++ b/docs/Phaser.MSPointer.html @@ -0,0 +1,1727 @@ + + + + + + Phaser Class: MSPointer + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: MSPointer

    +
    + +
    +

    + Phaser. + + MSPointer +

    + +

    The MSPointer class handles touch interactions with the game and the resulting Pointer objects. +It will work only in Internet Explorer 10 and Windows Store or Windows Phone 8 apps using JavaScript. +http://msdn.microsoft.com/en-us/library/ie/hh673557(v=vs.85).aspx

    + +
    + +
    +
    + + + + +
    +

    new MSPointer(game)

    + + +
    +
    + + +
    +

    Phaser - MSPointer constructor.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    callbackContext

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callbackContext + + +Phaser.Game + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    disabled

    + + +
    +
    + +
    +

    You can disable all Input by setting disabled = true. While set all new input related events will be ignored.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    disabled + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mouseDownCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mouseDownCallback + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mouseMoveCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mouseMoveCallback + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mouseUpCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mouseUpCallback + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    onPointerDown(event)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onPointerMove(event)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onPointerUp(event)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    start()

    + + +
    +
    + + +
    +

    Starts the event listeners running.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stop()

    + + +
    +
    + + +
    +

    Stop the event listeners.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:29 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Math.html b/docs/Phaser.Math.html new file mode 100644 index 00000000..eb7286c6 --- /dev/null +++ b/docs/Phaser.Math.html @@ -0,0 +1,10193 @@ + + + + + + Phaser Class: Math + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Math

    +
    + +
    +

    + Phaser. + + Math +

    + +
    + +
    +
    + + + + +
    +

    new Math()

    + + +
    +
    + + +
    +

    A collection of mathematical methods.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    angleBetween(x1, y1, x2, y2) → {number}

    + + +
    +
    + + +
    +

    Find the angle of a segment from (x1, y1) -> (x2, y2 ).

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x1 + + +number + + + +
    y1 + + +number + + + +
    x2 + + +number + + + +
    y2 + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    angleLimit(angle, min, max) → {number}

    + + +
    +
    + + +
    +

    Keeps an angle value between the given min and max values.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    angle + + +number + + + +

    The angle value to check. Must be between -180 and +180.

    min + + +number + + + +

    The minimum angle that is allowed (must be -180 or greater).

    max + + +number + + + +

    The maximum angle that is allowed (must be 180 or less).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The new angle value, returns the same as the input angle if it was within bounds

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    average() → {number}

    + + +
    +
    + + +
    +

    Averages all values passed to the function and returns the result. You can pass as many parameters as you like.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The average of all given values.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    bernstein(n, i) → {number}

    + + +
    +
    + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    n + + +number + + + +
    i + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    bezierInterpolation(v, k) → {number}

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    v + + +number + + + +
    k + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    catmullRom(p0, p1, p2, p3, t) → {number}

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    p0 + + +number + + + +
    p1 + + +number + + + +
    p2 + + +number + + + +
    p3 + + +number + + + +
    t + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    catmullRomInterpolation(v, k) → {number}

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    v + + +number + + + +
    k + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    ceil(value) → {number}

    + + +
    +
    + + +
    +

    Round up to the next whole number. E.g. ceil(1.3) == 2, and ceil(-2.3) == -3.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    value + + +number + + + +

    Any number.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The rounded value of that number.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    ceilTo(value, place, base) → {number}

    + + +
    +
    + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    value + + +number + + + +

    The value to round.

    place + + +number + + + +

    The place to round to.

    base + + +number + + + +

    The base to round in... default is 10 for decimal.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    chanceRoll(chance) → {boolean}

    + + +
    +
    + + +
    +

    Generate a random bool result based on the chance value.

    +

    <p> +Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance +of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed. +</p>

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    chance + + +number + + + +

    The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the roll passed, or false otherwise.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    clamp(x, a, b) → {number}

    + + +
    +
    + + +
    +

    Force a value within the boundaries of two values. +Clamp value to range <a, b>

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +
    a + + +number + + + +
    b + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    clampBottom(x, a) → {number}

    + + +
    +
    + + +
    +

    Clamp value to range <a, inf).

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +
    a + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    degToRad() → {function}

    + + +
    +
    + + +
    +

    Convert degrees to radians.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +function + + +
    +
    + + + + + +
    + + + +
    +

    difference(a, b) → {number}

    + + +
    +
    + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +number + + + +
    b + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    distance(x1, y1, x2, y2) → {number}

    + + +
    +
    + + +
    +

    Returns the distance between the two given set of coordinates.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x1 + + +number + + + +
    y1 + + +number + + + +
    x2 + + +number + + + +
    y2 + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The distance between this Point object and the destination Point object.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    distanceRounded(x1, y1, x2, y2) → {number}

    + + +
    +
    + + +
    +

    Returns the rounded distance between the two given set of coordinates.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x1 + + +number + + + +
    y1 + + +number + + + +
    x2 + + +number + + + +
    y2 + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The distance between this Point object and the destination Point object.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    floor(Value) → {number}

    + + +
    +
    + + +
    +

    Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    Value + + +number + + + +

    Any number.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The rounded value of that number.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    floorTo(value, place, base) → {number}

    + + +
    +
    + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    value + + +number + + + +

    The value to round.

    place + + +number + + + +

    The place to round to.

    base + + +number + + + +

    The base to round in... default is 10 for decimal.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    fuzzyCeil(val, epsilon) → {boolean}

    + + +
    +
    + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    val + + +number + + + +
    epsilon + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    ceiling(val-ε)

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    fuzzyEqual(a, b, epsilon) → {boolean}

    + + +
    +
    + + +
    +

    Two number are fuzzyEqual if their difference is less than ε.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +number + + + +
    b + + +number + + + +
    epsilon + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if |a-b|<ε

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    fuzzyEqual(a, b, epsilon) → {boolean}

    + + +
    +
    + + +
    +

    a is fuzzyLessThan b if it is less than b + ε.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +number + + + +
    b + + +number + + + +
    epsilon + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if a<b+ε

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    fuzzyFloor(val, epsilon) → {boolean}

    + + +
    +
    + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    val + + +number + + + +
    epsilon + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    floor(val-ε)

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    fuzzyGreaterThan(a, b, epsilon) → {boolean}

    + + +
    +
    + + +
    +

    a is fuzzyGreaterThan b if it is more than b - ε.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +number + + + +
    b + + +number + + + +
    epsilon + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if a>b+ε

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    getRandom(objects, startIndex, length) → {object}

    + + +
    +
    + + +
    +

    Fetch a random entry from the given array. +Will return null if random selection is missing, or array has no entries.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    objects + + +array + + + +

    An array of objects.

    startIndex + + +number + + + +

    Optional offset off the front of the array. Default value is 0, or the beginning of the array.

    length + + +number + + + +

    Optional restriction on the number of values you want to randomly select from.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The random object that was selected.

    +
    + + + +
    +
    + Type +
    +
    + +object + + +
    +
    + + + + + +
    + + + +
    +

    interpolateAngles(a1, a2, weight, radians, ease) → {number}

    + + +
    +
    + + +
    +

    Interpolate across the shortest arc between two angles.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a1 + + +number + + + +

    Description.

    a2 + + +number + + + +

    Description.

    weight + + +number + + + +

    Description.

    radians + + +boolean + + + +

    True if angle sizes are expressed in radians.

    ease + + +Description + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    interpolateFloat(a, b, weight) → {number}

    + + +
    +
    + + +
    +

    A one dimensional linear interpolation of a value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +number + + + +
    b + + +number + + + +
    weight + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    isEven(n) → {boolean}

    + + +
    +
    + + +
    +

    Returns true if the number given is even.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    n + + +number + + + +

    The number to check.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the given number is even. False if the given number is odd.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    isOdd(n) → {boolean}

    + + +
    +
    + + +
    +

    Returns true if the number given is odd.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    n + + +number + + + +

    The number to check.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the given number is odd. False if the given number is even.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    Linear(p0, p1, t) → {number}

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    p0 + + +number + + + +
    p1 + + +number + + + +
    t + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    linearInterpolation(v, k) → {number}

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    v + + +number + + + +
    k + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    mapLinear(x, a1, a1, a2, b1, b2) → {number}

    + + +
    +
    + + +
    +

    Linear mapping from range <a1, a2> to range <b1, b2>

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +
    a1 + + +number + + + +
    a1 + + +number + + + +
    a2 + + +number + + + +
    b1 + + +number + + + +
    b2 + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    max() → {number}

    + + +
    +
    + + +
    +

    Significantly faster version of Math.max +See http://jsperf.com/math-s-min-max-vs-homemade/5

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The highest value from those given.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    maxAdd(value, amount, max-) → {number}

    + + +
    +
    + + +
    +

    Adds the given amount to the value, but never lets the value go over the specified maximum.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    value + + +number + + + +

    The value to add the amount to.

    amount + + +number + + + +

    The amount to add to the value.

    max- + + +number + + + +

    The maximum the value is allowed to be.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    min() → {number}

    + + +
    +
    + + +
    +

    Significantly faster version of Math.min +See http://jsperf.com/math-s-min-max-vs-homemade/5

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The lowest value from those given.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    minSub(value, amount, min) → {number}

    + + +
    +
    + + +
    +

    Subtracts the given amount from the value, but never lets the value go below the specified minimum.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    value + + +number + + + +

    The base value.

    amount + + +number + + + +

    The amount to subtract from the base value.

    min + + +number + + + +

    The minimum the value is allowed to be.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The new value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    nearestAngleBetween(a1, a2, radians) → {number}

    + + +
    +
    + + +
    +

    Closest angle between two angles from a1 to a2 +absolute value the return for exact angle

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a1 + + +number + + + +
    a2 + + +number + + + +
    radians + + +boolean + + + +

    True if angle sizes are expressed in radians.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    normalizeAngle(angle, radians) → {number}

    + + +
    +
    + + +
    +

    Set an angle within the bounds of -π toπ.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    angle + + +number + + + +
    radians + + +boolean + + + +

    True if angle size is expressed in radians.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    numberArray(min, max) → {array}

    + + +
    +
    + + +
    +

    Returns an Array containing the numbers from min to max (inclusive).

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    min + + +number + + + +

    The minimum value the array starts with.

    max + + +number + + + +

    The maximum value the array contains.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The array of number values.

    +
    + + + +
    +
    + Type +
    +
    + +array + + +
    +
    + + + + + +
    + + + +
    +

    PI2()

    + + +
    +
    + + +
    +

    = 2 π

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    radToDeg() → {function}

    + + +
    +
    + + +
    +

    Convert degrees to radians.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +function + + +
    +
    + + + + + +
    + + + +
    +

    randomSign() → {number}

    + + +
    +
    + + +
    +

    Randomly returns either a 1 or -1.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    1 or -1

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    roundTo(value, place, base) → {number}

    + + +
    +
    + + +
    +

    Round to some place comparative to a 'base', default is 10 for decimal place.

    +

    'place' is represented by the power applied to 'base' to get that place +e.g. +2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011

    +

    roundTo(2000/7,3) == 0 +roundTo(2000/7,2) == 300 +roundTo(2000/7,1) == 290 +roundTo(2000/7,0) == 286 +roundTo(2000/7,-1) == 285.7 +roundTo(2000/7,-2) == 285.71 +roundTo(2000/7,-3) == 285.714 +roundTo(2000/7,-4) == 285.7143 +roundTo(2000/7,-5) == 285.71429

    +

    roundTo(2000/7,3,2) == 288 -- 100100000 +roundTo(2000/7,2,2) == 284 -- 100011100 +roundTo(2000/7,1,2) == 286 -- 100011110 +roundTo(2000/7,0,2) == 286 -- 100011110 +roundTo(2000/7,-1,2) == 285.5 -- 100011101.1 +roundTo(2000/7,-2,2) == 285.75 -- 100011101.11 +roundTo(2000/7,-3,2) == 285.75 -- 100011101.11 +roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011 +roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111

    +

    Note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed +because we are rounding 100011.1011011011011011 which rounds up.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    value + + +number + + + +

    The value to round.

    place + + +number + + + +

    The place to round to.

    base + + +number + + + +

    The base to round in... default is 10 for decimal.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    shear(n) → {number}

    + + +
    +
    + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    n + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    n mod 1

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    shift(stack) → {any}

    + + +
    +
    + + +
    +

    Removes the top element from the stack and re-inserts it onto the bottom, then returns it. +The original stack is modified in the process. This effectively moves the position of the data from the start to the end of the table.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    stack + + +array + + + +

    The array to shift.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The shifted value.

    +
    + + + +
    +
    + Type +
    +
    + +any + + +
    +
    + + + + + +
    + + + +
    +

    shuffleArray(array) → {array}

    + + +
    +
    + + +
    +

    Shuffles the data in the given array into a new order

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    array + + +array + + + +

    The array to shuffle

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The array

    +
    + + + +
    +
    + Type +
    +
    + +array + + +
    +
    + + + + + +
    + + + +
    +

    sign(x) → {number}

    + + +
    +
    + + +
    +

    A value representing the sign of the value. +-1 for negative, +1 for positive, 0 if value is 0

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    sinCosGenerator(length, sinAmplitude, cosAmplitude, frequency) → {Array}

    + + +
    +
    + + +
    +

    Generate a sine and cosine table simultaneously and extremely quickly. Based on research by Franky of scene.at

    +

    <p> +The parameters allow you to specify the length, amplitude and frequency of the wave. Once you have called this function +you should get the results via getSinTable() and getCosTable(). This generator is fast enough to be used in real-time. +</p>

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    length + + +number + + + +

    The length of the wave

    sinAmplitude + + +number + + + +

    The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value

    cosAmplitude + + +number + + + +

    The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value

    frequency + + +number + + + +

    The frequency of the sine and cosine table data

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns the sine table

    +
    + + + +
    +
    + Type +
    +
    + +Array + + +
    +
    + + + + + +
    + + + +
    +

    smootherstep(x, min, max) → {number}

    + + +
    +
    + + +
    +

    Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +
    min + + +number + + + +
    max + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    smoothstep(x, min, max) → {number}

    + + +
    +
    + + +
    +

    Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +
    min + + +number + + + +
    max + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    snapTo(input, gap, start) → {number}

    + + +
    +
    + + +
    +

    Snap a value to nearest grid slice, using rounding.

    +

    Example: if you have an interval gap of 5 and a position of 12... you will snap to 10 whereas 14 will snap to 15.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    input + + +number + + + + + + + + + +

    The value to snap.

    gap + + +number + + + + + + + + + +

    The interval gap of the grid.

    start + + +number + + + + + + <optional>
    + + + + + +

    Optional starting offset for gap.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    snapToCeil(input, gap, start) → {number}

    + + +
    +
    + + +
    +

    Snap a value to nearest grid slice, using ceil.

    +

    Example: if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    input + + +number + + + + + + + + + +

    The value to snap.

    gap + + +number + + + + + + + + + +

    The interval gap of the grid.

    start + + +number + + + + + + <optional>
    + + + + + +

    Optional starting offset for gap.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    snapToFloor(input, gap, start) → {number}

    + + +
    +
    + + +
    +

    Snap a value to nearest grid slice, using floor.

    +

    Example: if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    input + + +number + + + + + + + + + +

    The value to snap.

    gap + + +number + + + + + + + + + +

    The interval gap of the grid.

    start + + +number + + + + + + <optional>
    + + + + + +

    Optional starting offset for gap.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    snapToInArray(input, arr, sort) → {number}

    + + +
    +
    + + +
    +

    Snaps a value to the nearest value in an array.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    input + + +number + + + +
    arr + + +array + + + +
    sort + + +boolean + + + +

    True if the array needs to be sorted.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    truncate(n) → {number}

    + + +
    +
    + + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    n + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    within(a, b, tolerance) → {boolean}

    + + +
    +
    + + +
    +

    Checks if two values are within the given tolerance of each other.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +number + + + +

    The first number to check

    b + + +number + + + +

    The second number to check

    tolerance + + +number + + + +

    The tolerance. Anything equal to or less than this is considered within the range.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if a is <= tolerance of b.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    wrap(value, min, max) → {number}

    + + +
    +
    + + +
    +

    Ensures that the value always stays between min and max, by wrapping the value around.

    +

    <p>max should be larger than min, or the function will return 0</p>

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    value + +

    The value to wrap

    min + +

    The minimum the value is allowed to be

    max + +

    The maximum the value is allowed to be

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The wrapped value

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    wrapAngle(angle) → {number}

    + + +
    +
    + + +
    +

    Keeps an angle value between -180 and +180<br> +Should be called whenever the angle is updated on the Sprite to stop it from going insane.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    angle + + +number + + + +

    The angle value to check

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The new angle value, returns the same as the input angle if it was within bounds.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    wrapValue(value, amount, max) → {number}

    + + +
    +
    + + +
    +

    Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.

    +

    <p>Values must be positive integers, and are passed through Math.abs</p>

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    value + + +number + + + +

    The value to add the amount to.

    amount + + +number + + + +

    The amount to add to the value.

    max + + +number + + + +

    The maximum the value is allowed to be.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The wrapped value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:28 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Mouse.html b/docs/Phaser.Mouse.html new file mode 100644 index 00000000..dc517497 --- /dev/null +++ b/docs/Phaser.Mouse.html @@ -0,0 +1,2273 @@ + + + + + + Phaser Class: Mouse + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Mouse

    +
    + +
    +

    + Phaser. + + Mouse +

    + +

    The Mouse class

    + +
    + +
    +
    + + + + +
    +

    new Mouse(game)

    + + +
    +
    + + +
    +

    Phaser - Mouse constructor.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    <static, constant> LEFT_BUTTON :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> MIDDLE_BUTTON :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> RIGHT_BUTTON :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    callbackContext

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callbackContext + + +Object + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    disabled

    + + +
    +
    + +
    +

    You can disable all Input by setting disabled = true. While set all new input related events will be ignored.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    disabled + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    locked

    + + +
    +
    + +
    +

    If the mouse has been Pointer Locked successfully this will be set to true.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    locked + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mouseDownCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mouseDownCallback + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mouseMoveCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mouseMoveCallback + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mouseUpCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mouseUpCallback + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    onMouseDown(event)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +MouseEvent + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onMouseMove(event)

    + + +
    +
    + + +
    +

    Description

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +MouseEvent + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onMouseUp(event)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +MouseEvent + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    pointerLockChange(event)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +MouseEvent + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    releasePointerLock()

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    requestPointerLock()

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    start()

    + + +
    +
    + + +
    +

    Starts the event listeners running.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stop()

    + + +
    +
    + + +
    +

    Stop the event listeners.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:28 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Net.html b/docs/Phaser.Net.html new file mode 100644 index 00000000..585f35c7 --- /dev/null +++ b/docs/Phaser.Net.html @@ -0,0 +1,1352 @@ + + + + + + Phaser Class: Net + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Net

    +
    + +
    +

    + Phaser. + + Net +

    + +

    Phaser.Net

    + +
    + +
    +
    + + + + +
    +

    new Net(game)

    + + +
    +
    + + +
    +

    Description of Phaser.Net

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    checkDomainName(domain) → {boolean}

    + + +
    +
    + + +
    +

    Compares the given domain name against the hostname of the browser containing the game. +If the domain name is found it returns true. +You can specify a part of a domain, for example 'google' would match 'google.com', 'google.co.uk', etc. +Do not include 'http://' at the start.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    domain + + +string + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    decodeURI(value) → {string}

    + + +
    +
    + + +
    +

    Returns the Query String as an object. +If you specify a parameter it will return just the value of that parameter, should it exist.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    value + + +string + + + +

    The URI component to be decoded.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The decoded value.

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + + + +
    +

    getHostName() → {string}

    + + +
    +
    + + +
    +

    Returns the hostname given by the browser.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + + + +
    +

    getQueryString(parameter) → {string|object}

    + + +
    +
    + + +
    +

    Returns the Query String as an object. +If you specify a parameter it will return just the value of that parameter, should it exist.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    parameter + + +string + + + + + + <optional>
    + + + + + +
    + + '' + +

    If specified this will return just the value for that key.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    An object containing the key value pairs found in the query string or just the value if a parameter was given.

    +
    + + + +
    +
    + Type +
    +
    + +string +| + +object + + +
    +
    + + + + + +
    + + + +
    +

    updateQueryString(key, value, redirect, url) → {string}

    + + +
    +
    + + +
    +

    Updates a value on the Query String and returns it in full. +If the value doesn't already exist it is set. +If the value exists it is replaced with the new value given. If you don't provide a new value it is removed from the query string. +Optionally you can redirect to the new url, or just return it as a string.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    The querystring key to update.

    value + + +string + + + +

    The new value to be set. If it already exists it will be replaced.

    redirect + + +boolean + + + +

    If true the browser will issue a redirect to the url with the new querystring.

    url + + +string + + + +

    The URL to modify. If none is given it uses window.location.href.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    If redirect is false then the modified url and query string is returned.

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:29 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Particles.Arcade.Emitter.html b/docs/Phaser.Particles.Arcade.Emitter.html new file mode 100644 index 00000000..e1128e2a --- /dev/null +++ b/docs/Phaser.Particles.Arcade.Emitter.html @@ -0,0 +1,11219 @@ + + + + + + Phaser Class: Emitter + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Emitter

    +
    + +
    +

    + Emitter +

    + +

    Emitter is a lightweight particle emitter. It can be used for one-time explosions or for +continuous effects like rain and fire. All it really does is launch Particle objects out +at set intervals, and fixes their positions and velocities accorindgly.

    + +
    + +
    +
    + + + + +
    +

    new Emitter(game, x, y, maxParticles)

    + + +
    +
    + + +
    +

    Phaser - ArcadeEmitter

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    game + + +Phaser.Game + + + + + + + + + + + +

    Current game instance.

    x + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The x coordinate within the Emitter that the particles are emitted from.

    y + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The y coordinate within the Emitter that the particles are emitted from.

    maxParticles + + +number + + + + + + <optional>
    + + + + + +
    + + 50 + +

    The total number of particles in this emitter..

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + +

    Extends

    + + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    alpha

    + + +
    +
    + +
    +

    The emitters alpha value.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    alpha + + +number + + + +

    Gets or sets the alpha value of the Emitter.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    angle

    + + +
    +
    + +
    +

    The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation. +This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    angle + + +number + + + +

    The angle of rotation given in degrees, where 0 degrees = to the right.

    +
    + + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    angularDrag

    + + +
    +
    + +
    +

    The angular drag component of particles launched from the emitter if they are rotating.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    angularDrag + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> bottom

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bottom + + +number + + + +

    Gets the bottom position of the Emitter.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bounce

    + + +
    +
    + +
    +

    How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bounce + + +Phaser.Point + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    emitX

    + + +
    +
    + +
    +

    The point the particles are emitted from. +Emitter.x and Emitter.y control the containers location, which updates all current particles +Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    emitX + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    emitY

    + + +
    +
    + +
    +

    The point the particles are emitted from. +Emitter.x and Emitter.y control the containers location, which updates all current particles +Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    emitY + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    exists

    + + +
    +
    + +
    +

    Determines whether the emitter is being updated by the core game loop.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    exists + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    frequency

    + + +
    +
    + +
    +

    How often a particle is emitted in ms (if emitter is started with Explode == false).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    frequency + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 100
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    gravity

    + + +
    +
    + +
    +

    Sets the <code>gravity.y</code> of each particle to this value on launch.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    gravity + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 2
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    height

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    height + + +number + + + +

    The height of the emitter. Particles can be randomly generated from anywhere within this box.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 1
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> left

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    left + + +number + + + +

    Gets the left position of the Emitter.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> length

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    length + + +number + + + +

    The number of children in this Group.

    +
    + + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    lifespan

    + + +
    +
    + +
    +

    How long each particle lives once it is emitted in ms. Default is 2 seconds. +Set lifespan to 'zero' for particles to live forever.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    lifespan + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 2000
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxParticles

    + + +
    +
    + +
    +

    The total number of particles in this emitter.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxParticles + + +number + + + +

    The total number of particles in this emitter..

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxParticleScale

    + + +
    +
    + +
    +

    The maximum possible scale of a particle. +The default value is 1.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxParticleScale + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 1
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxParticleSpeed

    + + +
    +
    + +
    +

    The maximum possible velocity of a particle. +The default value is (100,100).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxParticleSpeed + + +Phaser.Point + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxRotation

    + + +
    +
    + +
    +

    The maximum possible angular velocity of a particle. The default value is 360.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxRotation + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 360
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    minParticleScale

    + + +
    +
    + +
    +

    The minimum possible scale of a particle. +The default value is 1.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    minParticleScale + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 1
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    minParticleSpeed

    + + +
    +
    + +
    +

    The minimum possible velocity of a particle. +The default value is (-100,-100).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    minParticleSpeed + + +Phaser.Point + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    minRotation

    + + +
    +
    + +
    +

    The minimum possible angular velocity of a particle. The default value is -360.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    minRotation + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    name

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    on

    + + +
    +
    + +
    +

    Determines whether the emitter is currently emitting particles. +It is totally safe to directly toggle this.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    on + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    particleClass

    + + +
    +
    + +
    +

    Set your own particle class type here.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    particleClass + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    particleDrag

    + + +
    +
    + +
    +

    The X and Y drag component of particles launched from the emitter.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    particleDrag + + +Phaser.Point + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    + + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    right + + +number + + + +

    Gets the right position of the Emitter.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    rotation

    + + +
    +
    + +
    +

    The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation. +This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    rotation + + +number + + + +

    The angle of rotation given in radians.

    +
    + + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    scale

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    scale + + +Phaser.Point + + + +

    Replaces the PIXI.Point with a slightly more flexible one.

    +
    + + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> top

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    top + + +number + + + +

    Gets the top position of the Emitter.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> total

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    total + + +number + + + +

    The total number of children in this Group, regardless of their alive state.

    +
    + + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    visible

    + + +
    +
    + +
    +

    The emitter visible state.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    visible + + +boolean + + + +

    Gets or sets the Emitter visible state.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    width

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    The width of the emitter. Particles can be randomly generated from anywhere within this box.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 1
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Gets or sets the x position of the Emitter.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The X position of the top left corner of the emitter in world space.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    Gets or sets the y position of the Emitter.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    The Y position of the top left corner of emitter in world space.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    add(child) → {*}

    + + +
    +
    + + +
    +

    Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object. +The child is automatically added to the top of the Group, so renders on-top of everything else within the Group. If you need to control +that then see the addAt method.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child + + +* + + + +

    An instance of Phaser.Sprite, Phaser.Button or any other display object..

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + +
    See:
    +
    + +
    + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The child that was added to the Group.

    +
    + + + +
    +
    + Type +
    +
    + +* + + +
    +
    + + + + + +
    + + + +
    +

    addAll(property, amount, checkAlive, checkVisible)

    + + +
    +
    + + +
    +

    Adds the amount to the given property on all children in this Group. +Group.addAll('x', 10) will add 10 to the child.x value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    property + + +string + + + +

    The property to increment, for example 'body.velocity.x' or 'angle'.

    amount + + +number + + + +

    The amount to increment the property by. If child.x = 10 then addAll('x', 40) would make child.x = 50.

    checkAlive + + +boolean + + + +

    If true the property will only be changed if the child is alive.

    checkVisible + + +boolean + + + +

    If true the property will only be changed if the child is visible.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addAt(child, index) → {*}

    + + +
    +
    + + +
    +

    Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object. +The child is added to the Group at the location specified by the index value, this allows you to control child ordering.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child + + +* + + + +

    An instance of Phaser.Sprite, Phaser.Button or any other display object..

    index + + +number + + + +

    The index within the Group to insert the child to.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The child that was added to the Group.

    +
    + + + +
    +
    + Type +
    +
    + +* + + +
    +
    + + + + + +
    + + + +
    +

    at(object)

    + + +
    +
    + + +
    +

    Change the emitter's midpoint to match the midpoint of a <code>Object</code>.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    object + + +object + + + +

    The <code>Object</code> that you want to sync up with.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    bringToTop(child) → {*}

    + + +
    +
    + + +
    +

    Brings the given child to the top of this Group so it renders above all other children.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child + + +* + + + +

    The child to bring to the top of this Group.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The child that was moved.

    +
    + + + +
    +
    + Type +
    +
    + +* + + +
    +
    + + + + + +
    + + + +
    +

    callAll(callback, parameter)

    + + +
    +
    + + +
    +

    Calls a function on all of the children regardless if they are dead or alive (see callAllExists if you need control over that) +After the callback parameter you can add as many extra parameters as you like, which will all be passed to the child.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    callback + + +function + + + + + + + + + +

    The function that exists on the children that will be called.

    parameter + + +* + + + + + + + + + + <repeatable>
    + +

    Additional parameters that will be passed to the callback.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    callAllExists(callback, existsValue, parameter)

    + + +
    +
    + + +
    +

    Calls a function on all of the children that have exists=true in this Group. +After the existsValue parameter you can add as many parameters as you like, which will all be passed to the child callback.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    callback + + +function + + + + + + + + + +

    The function that exists on the children that will be called.

    existsValue + + +boolean + + + + + + + + + +

    Only children with exists=existsValue will be called.

    parameter + + +* + + + + + + + + + + <repeatable>
    + +

    Additional parameters that will be passed to the callback.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    countDead() → {number}

    + + +
    +
    + + +
    +

    Call this function to find out how many members of the group are dead.

    +
    + + + + + + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The number of children flagged as dead. Returns -1 if Group is empty.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    countLiving() → {number}

    + + +
    +
    + + +
    +

    Call this function to find out how many members of the group are alive.

    +
    + + + + + + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The number of children flagged as alive. Returns -1 if Group is empty.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    create(x, y, key, frame, exists) → {Phaser.Sprite}

    + + +
    +
    + + +
    +

    Automatically creates a new Phaser.Sprite object and adds it to the top of this Group. +Useful if you don't need to create the Sprite instances before-hand.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    x + + +number + + + + + + + + + + + +

    The x coordinate to display the newly created Sprite at. The value is in relation to the Group.x point.

    y + + +number + + + + + + + + + + + +

    The y coordinate to display the newly created Sprite at. The value is in relation to the Group.y point.

    key + + +string + + + + + + + + + + + +

    The Game.cache key of the image that this Sprite will use.

    frame + + +number +| + +string + + + + + + <optional>
    + + + + + +
    + +

    If the Sprite image contains multiple frames you can specify which one to use here.

    exists + + +boolean + + + + + + <optional>
    + + + + + +
    + + true + +

    The default exists state of the Sprite.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The child that was created.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Sprite + + +
    +
    + + + + + +
    + + + +
    +

    createMultiple(quantity, key, frame, exists)

    + + +
    +
    + + +
    +

    Automatically creates multiple Phaser.Sprite objects and adds them to the top of this Group. +Useful if you need to quickly generate a pool of identical sprites, such as bullets. By default the sprites will be set to not exist +and will be positioned at 0, 0 (relative to the Group.x/y)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    quantity + + +number + + + + + + + + + + + +

    The number of Sprites to create.

    key + + +string + + + + + + + + + + + +

    The Game.cache key of the image that this Sprite will use.

    frame + + +number +| + +string + + + + + + <optional>
    + + + + + +
    + +

    If the Sprite image contains multiple frames you can specify which one to use here.

    exists + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    The default exists state of the Sprite.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Destroys this Group. Removes all children, then removes the container from the display list and nulls references.

    +
    + + + + + + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    divideAll(property, amount, checkAlive, checkVisible)

    + + +
    +
    + + +
    +

    Divides the given property by the amount on all children in this Group. +Group.divideAll('x', 2) will half the child.x value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    property + + +string + + + +

    The property to divide, for example 'body.velocity.x' or 'angle'.

    amount + + +number + + + +

    The amount to divide the property by. If child.x = 100 then divideAll('x', 2) would make child.x = 50.

    checkAlive + + +boolean + + + +

    If true the property will only be changed if the child is alive.

    checkVisible + + +boolean + + + +

    If true the property will only be changed if the child is visible.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    dump(full)

    + + +
    +
    + + +
    +

    Dumps out a list of Group children and their index positions to the browser console. Useful for group debugging.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    full + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If full the dump will include the entire display list, start from the Stage. Otherwise it will only include this container.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    emitParticle()

    + + +
    +
    + + +
    +

    This function can be used both internally and externally to emit the next particle.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    forEach(callback, callbackContext, checkExists)

    + + +
    +
    + + +
    +

    Allows you to call your own function on each member of this Group. You must pass the callback and context in which it will run. +After the checkExists parameter you can add as many parameters as you like, which will all be passed to the callback along with the child. +For example: Group.forEach(awardBonusGold, this, true, 100, 500)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callback + + +function + + + +

    The function that will be called. Each child of the Group will be passed to it as its first parameter.

    callbackContext + + +Object + + + +

    The context in which the function should be called (usually 'this').

    checkExists + + +boolean + + + +

    If set only children with exists=true will be passed to the callback, otherwise all children will be passed.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    forEachAlive(callback, callbackContext)

    + + +
    +
    + + +
    +

    Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run. +You can add as many parameters as you like, which will all be passed to the callback along with the child. +For example: Group.forEachAlive(causeDamage, this, 500)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callback + + +function + + + +

    The function that will be called. Each child of the Group will be passed to it as its first parameter.

    callbackContext + + +Object + + + +

    The context in which the function should be called (usually 'this').

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    forEachDead(callback, callbackContext)

    + + +
    +
    + + +
    +

    Allows you to call your own function on each dead member of this Group (where alive=false). You must pass the callback and context in which it will run. +You can add as many parameters as you like, which will all be passed to the callback along with the child. +For example: Group.forEachDead(bringToLife, this)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callback + + +function + + + +

    The function that will be called. Each child of the Group will be passed to it as its first parameter.

    callbackContext + + +Object + + + +

    The context in which the function should be called (usually 'this').

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    getAt(index) → {*}

    + + +
    +
    + + +
    +

    Returns the child found at the given index within this Group.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    index + + +number + + + +

    The index to return the child from.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The child that was found at the given index.

    +
    + + + +
    +
    + Type +
    +
    + +* + + +
    +
    + + + + + +
    + + + +
    +

    getFirstAlive() → {Any}

    + + +
    +
    + + +
    +

    Call this function to retrieve the first object with alive == true in the group. +This is handy for checking if everything has been wiped out, or choosing a squad leader, etc.

    +
    + + + + + + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The first alive child, or null if none found.

    +
    + + + +
    +
    + Type +
    +
    + +Any + + +
    +
    + + + + + +
    + + + +
    +

    getFirstDead() → {Any}

    + + +
    +
    + + +
    +

    Call this function to retrieve the first object with alive == false in the group. +This is handy for checking if everything has been wiped out, or choosing a squad leader, etc.

    +
    + + + + + + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The first dead child, or null if none found.

    +
    + + + +
    +
    + Type +
    +
    + +Any + + +
    +
    + + + + + +
    + + + +
    +

    getFirstExists(state) → {Any}

    + + +
    +
    + + +
    +

    Call this function to retrieve the first object with exists == (the given state) in the Group.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    state + + +boolean + + + +

    True or false.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The first child, or null if none found.

    +
    + + + +
    +
    + Type +
    +
    + +Any + + +
    +
    + + + + + +
    + + + +
    +

    getIndex(child) → {number}

    + + +
    +
    + + +
    +

    Get the index position of the given child in this Group.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child + + +* + + + +

    The child to get the index for.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The index of the child or -1 if it's not a member of this Group.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    getRandom(startIndex, length) → {Any}

    + + +
    +
    + + +
    +

    Returns a member at random from the group.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    startIndex + + +number + + + +

    Optional offset off the front of the array. Default value is 0, or the beginning of the array.

    length + + +number + + + +

    Optional restriction on the number of values you want to randomly select from.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A random child of this Group.

    +
    + + + +
    +
    + Type +
    +
    + +Any + + +
    +
    + + + + + +
    + + + +
    +

    kill()

    + + +
    +
    + + +
    +

    Call this function to turn off all the particles and the emitter.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    makeParticles(keys, frames, quantity, collide, collideWorldBounds)

    + + +
    +
    + + +
    +

    This function generates a new array of particle sprites to attach to the emitter.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    keys + + +Description + + + +

    Description.

    frames + + +number + + + +

    Description.

    quantity + + +number + + + +

    The number of particles to generate when using the "create from image" option.

    collide + + +number + + + +

    Description.

    collideWorldBounds + + +boolean + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Emitter instance (nice for chaining stuff together, if you're into that).

    +
    + + + + + + + +
    + + + +
    +

    multiplyAll(property, amount, checkAlive, checkVisible)

    + + +
    +
    + + +
    +

    Multiplies the given property by the amount on all children in this Group. +Group.multiplyAll('x', 2) will x2 the child.x value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    property + + +string + + + +

    The property to multiply, for example 'body.velocity.x' or 'angle'.

    amount + + +number + + + +

    The amount to multiply the property by. If child.x = 10 then multiplyAll('x', 2) would make child.x = 20.

    checkAlive + + +boolean + + + +

    If true the property will only be changed if the child is alive.

    checkVisible + + +boolean + + + +

    If true the property will only be changed if the child is visible.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    remove(child)

    + + +
    +
    + + +
    +

    Removes the given child from this Group and sets its group property to null.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child + + +Any + + + +

    The child to remove.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeAll()

    + + +
    +
    + + +
    +

    Removes all children from this Group, setting all group properties to null. +The Group container remains on the display list.

    +
    + + + + + + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeBetween(startIndex, endIndex)

    + + +
    +
    + + +
    +

    Removes all children from this Group whos index falls beteen the given startIndex and endIndex values.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    startIndex + + +number + + + +

    The index to start removing children from.

    endIndex + + +number + + + +

    The index to stop removing children from. Must be higher than startIndex and less than the length of the Group.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    replace(oldChild, newChild)

    + + +
    +
    + + +
    +

    Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    oldChild + + +* + + + +

    The child in this Group that will be replaced.

    newChild + + +* + + + +

    The child to be inserted into this group.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    revive()

    + + +
    +
    + + +
    +

    Handy for bringing game objects "back to life". Just sets alive and exists back to true. +In practice, this is most often called by <code>Object.reset()</code>.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setAll(key, value, checkAlive, checkVisible, operation)

    + + +
    +
    + + +
    +

    This function allows you to quickly set the same property across all children of this Group to a new value. +The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    key + + +string + + + + + + + + + + + +

    The property, as a string, to be set. For example: 'body.velocity.x'

    value + + +* + + + + + + + + + + + +

    The value that will be set.

    checkAlive + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If set then only children with alive=true will be updated.

    checkVisible + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If set then only children with visible=true will be updated.

    operation + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setProperty(child, key, value, operation)

    + + +
    +
    + + +
    +

    Sets the given property to the given value on the child. The operation controls the assignment of the value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    child + + +* + + + + + + + + + + + +

    The child to set the property value on.

    key + + +array + + + + + + + + + + + +

    An array of strings that make up the property that will be set.

    value + + +* + + + + + + + + + + + +

    The value that will be set.

    operation + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setRotation(min, max)

    + + +
    +
    + + +
    +

    A more compact way of setting the angular velocity constraints of the emitter.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    min + + +number + + + +

    The minimum value for this range.

    max + + +number + + + +

    The maximum value for this range.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setSize(width, height)

    + + +
    +
    + + +
    +

    A more compact way of setting the width and height of the emitter.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    The desired width of the emitter (particles are spawned randomly within these dimensions).

    height + + +number + + + +

    The desired height of the emitter.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setXSpeed(min, max)

    + + +
    +
    + + +
    +

    A more compact way of setting the X velocity range of the emitter.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    min + + +number + + + +

    The minimum value for this range.

    max + + +number + + + +

    The maximum value for this range.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setYSpeed(min, max)

    + + +
    +
    + + +
    +

    A more compact way of setting the Y velocity range of the emitter.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    min + + +number + + + +

    The minimum value for this range.

    max + + +number + + + +

    The maximum value for this range.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    start(explode, lifespan, frequency, quantity)

    + + +
    +
    + + +
    +

    Call this function to start emitting particles.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    explode + + +boolean + + + +

    Whether the particles should all burst out at once.

    lifespan + + +number + + + +

    How long each particle lives once emitted. 0 = forever.

    frequency + + +number + + + +

    Ignored if Explode is set to true. Frequency is how often to emit a particle in ms.

    quantity + + +number + + + +

    How many particles to launch. 0 = "all of the particles".

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    subAll(property, amount, checkAlive, checkVisible)

    + + +
    +
    + + +
    +

    Subtracts the amount from the given property on all children in this Group. +Group.subAll('x', 10) will minus 10 from the child.x value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    property + + +string + + + +

    The property to decrement, for example 'body.velocity.x' or 'angle'.

    amount + + +number + + + +

    The amount to subtract from the property. If child.x = 50 then subAll('x', 40) would make child.x = 10.

    checkAlive + + +boolean + + + +

    If true the property will only be changed if the child is alive.

    checkVisible + + +boolean + + + +

    If true the property will only be changed if the child is visible.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    swap(child1, child2) → {boolean}

    + + +
    +
    + + +
    +

    Swaps the position of two children in this Group.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    child1 + + +* + + + +

    The first child to swap.

    child2 + + +* + + + +

    The second child to swap.

    + + + + +
    + + + + + + + +
    Inherited From:
    +
    + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    True if the swap was successful, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    update()

    + + +
    +
    + + +
    +

    Called automatically by the game loop, decides when to launch particles and when to "die".

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:29 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Particles.html b/docs/Phaser.Particles.html new file mode 100644 index 00000000..f4abf020 --- /dev/null +++ b/docs/Phaser.Particles.html @@ -0,0 +1,1143 @@ + + + + + + Phaser Class: Particles + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Particles

    +
    + +
    +

    + Phaser. + + Particles +

    + +

    Phaser Particles

    + +
    + +
    +
    + + + + +
    +

    new Particles(game)

    + + +
    +
    + + +
    +

    Phaser.Particles is the Particle Manager for the game. It is called during the game update loop and in turn updates any Emitters attached to it.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    emitters

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    emitters + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    ID

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    ID + + +number + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    add(emitter) → {Phaser.Emitter}

    + + +
    +
    + + +
    +

    Adds a new Particle Emitter to the Particle Manager.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    emitter + + +Phaser.Emitter + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The emitter that was added.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Emitter + + +
    +
    + + + + + +
    + + + +
    +

    remove(emitter)

    + + +
    +
    + + +
    +

    Removes an existing Particle Emitter from the Particle Manager.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    emitter + + +Phaser.Emitter + + + +

    The emitter to remove.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> update()

    + + +
    +
    + + +
    +

    Called by the core game loop. Updates all Emitters who have their exists value set to true.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:29 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.Arcade.Body.html b/docs/Phaser.Physics.Arcade.Body.html new file mode 100644 index 00000000..cd1d8d61 --- /dev/null +++ b/docs/Phaser.Physics.Arcade.Body.html @@ -0,0 +1,6049 @@ + + + + + + Phaser Class: Body + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Body

    +
    + +
    +

    + Phaser.Physics.Arcade. + + Body +

    + +

    Arcade Physics Body Constructor

    + +
    + +
    +
    + + + + +
    +

    new Body(sprite)

    + + +
    +
    + + +
    +

    The Physics Body is linked to a single Sprite. All physics operations should be performed against the body rather than +the Sprite itself. For example you can set the velocity, acceleration, bounce values etc all on the Body.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sprite + + +Phaser.Sprite + + + +

    The Sprite object this physics body belongs to.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    acceleration

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    acceleration + + +Phaser.Point + + + +

    The velocity in pixels per second sq. of the Body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    allowCollision

    + + +
    +
    + +
    +

    Set the allowCollision properties to control which directions collision is processed for this Body. +For example allowCollision.up = false means it won't collide when the collision happened while moving up.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    allowCollision + + +object + + + +

    An object containing allowed collision.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    allowGravity

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    allowGravity + + +boolean + + + +

    Allow this Body to be influenced by the global Gravity?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    allowRotation

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    allowRotation + + +boolean + + + +

    Allow this Body to be rotated? (via angularVelocity, etc)

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    angularAcceleration

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    angularAcceleration + + +number + + + +

    The angular acceleration in pixels per second sq. of the Body.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    angularDrag

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    angularDrag + + +number + + + +

    The angular drag applied to the rotation of the Body.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    angularVelocity

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    angularVelocity + + +number + + + +

    The angular velocity in pixels per second sq. of the Body.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bottom

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bottom + + +number + + + +

    The bottom value of this Body (same as Body.y + Body.height)

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bounce

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bounce + + +Phaser.Point + + + +

    The elasticitiy of the Body when colliding. bounce.x/y = 1 means full rebound, bounce.x/y = 0.5 means 50% rebound velocity.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    collideWorldBounds

    + + +
    +
    + +
    +

    A Body can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    collideWorldBounds + + +boolean + + + +

    Should the Body collide with the World bounds?

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    customSeparateX

    + + +
    +
    + +
    +

    This flag allows you to disable the custom x separation that takes place by Physics.Arcade.separate. +Used in combination with your own collision processHandler you can create whatever type of collision response you need.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    customSeparateX + + +boolean + + + +

    Use a custom separation system or the built-in one?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    customSeparateY

    + + +
    +
    + +
    +

    This flag allows you to disable the custom y separation that takes place by Physics.Arcade.separate. +Used in combination with your own collision processHandler you can create whatever type of collision response you need.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    customSeparateY + + +boolean + + + +

    Use a custom separation system or the built-in one?

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    drag

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    drag + + +Phaser.Point + + + +

    The drag applied to the motion of the Body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    embedded

    + + +
    +
    + +
    +

    If a body is overlapping with another body, but neither of them are moving (maybe they spawned on-top of each other?) this is set to true.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    embedded + + +boolean + + + +

    Body embed value.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    facing

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    facing + + +number + + + +

    A const reference to the direction the Body is traveling or facing.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    gravity

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    gravity + + +Phaser.Point + + + +

    A private Gravity setting for the Body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    halfHeight

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    halfHeight + + +number + + + +

    The calculated height / 2 of the physics body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    halfWidth

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    halfWidth + + +number + + + +

    The calculated width / 2 of the physics body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    height

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    .numInternal + +

    ID cache

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    hullX

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hullX + + +Phaser.Rectangle + + + +

    The dynamically calculated hull used during collision.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    hullY

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hullY + + +Phaser.Rectangle + + + +

    The dynamically calculated hull used during collision.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    immovable

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    immovable + + +boolean + + + +

    An immovable Body will not receive any impacts from other bodies.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mass

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mass + + +number + + + +

    The mass of the Body.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 1
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxAngular

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxAngular + + +number + + + +

    The maximum angular velocity in pixels per second sq. that the Body can reach.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 1000
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxVelocity

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxVelocity + + +Phaser.Point + + + +

    The maximum velocity in pixels per second sq. that the Body can reach.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    moves

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    moves + + +boolean + + + +

    Set to true to allow the Physics system to move this Body, other false to move it manually.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    offset

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    offset + + +Phaser.Point + + + +

    The offset of the Physics Body from the Sprite x/y position.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    overlapX

    + + +
    +
    + +
    +

    When this body collides with another, the amount of overlap is stored here.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    overlapX + + +number + + + +

    The amount of horizontal overlap during the collision.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    overlapY

    + + +
    +
    + +
    +

    When this body collides with another, the amount of overlap is stored here.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    overlapY + + +number + + + +

    The amount of vertical overlap during the collision.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> preRotation

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    preRotation + + +number + + + +

    The previous rotation of the physics body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> preX

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    preX + + +number + + + +

    The previous x position of the physics body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> preY

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    preY + + +number + + + +

    The previous y position of the physics body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <protected> quadTreeIDs

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    quadTreeIDs + + +Array + + + +

    Internal ID cache.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <protected> quadTreeIndex

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    quadTreeIndex + + +number + + + +

    Internal ID cache.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    + + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    right + + +number + + + +

    The right value of this Body (same as Body.x + Body.width)

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    rotation

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    rotation + + +number + + + +

    The amount the Body is rotated.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> screenX

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    screenX + + +number + + + +

    The x position of the physics body translated to screen space.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> screenY

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    screenY + + +number + + + +

    The y position of the physics body translated to screen space.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    skipQuadTree

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    skipQuadTree + + +boolean + + + +

    If the Body is an irregular shape you can set this to true to avoid it being added to the World quad tree.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> sourceHeight

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sourceHeight + + +number + + + +

    The un-scaled original size.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> sourceWidth

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sourceWidth + + +number + + + +

    The un-scaled original size.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    sprite

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sprite + + +Phaser.Sprite + + + +

    Reference to the parent Sprite.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    touching

    + + +
    +
    + +
    +

    This object is populated with boolean values when the Body collides with another. +touching.up = true means the collision happened to the top of this Body for example.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    touching + + +object + + + +

    An object containing touching results.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    velocity

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    velocity + + +Phaser.Point + + + +

    The velocity in pixels per second sq. of the Body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    wasTouching

    + + +
    +
    + +
    +

    This object is populated with previous touching values from the bodies previous collision.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    wasTouching + + +object + + + +

    An object containing previous touching results.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    width

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    The calculated width of the physics body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> x

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The x position of the physics body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> y

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    The y position of the physics body.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    deltaAbsX() → {number}

    + + +
    +
    + + +
    +

    Returns the absolute delta x value.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The absolute delta value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    deltaAbsY() → {number}

    + + +
    +
    + + +
    +

    Returns the absolute delta y value.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The absolute delta value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    deltaX() → {number}

    + + +
    +
    + + +
    +

    Returns the delta x value.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The delta value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    deltaY() → {number}

    + + +
    +
    + + +
    +

    Returns the delta y value.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The delta value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:29 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.Arcade.html b/docs/Phaser.Physics.Arcade.html new file mode 100644 index 00000000..4ef62ed9 --- /dev/null +++ b/docs/Phaser.Physics.Arcade.html @@ -0,0 +1,7646 @@ + + + + + + Phaser Class: Arcade + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Arcade

    +
    + +
    +

    + Phaser.Physics. + + Arcade +

    + +

    Arcade Physics Constructor

    + +
    + +
    +
    + + + + +
    +

    new Arcade(game)

    + + +
    +
    + + +
    +

    Arcade Physics constructor.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    reference to the current game instance.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + +

    Classes

    + +
    +
    Body
    +
    +
    + + + + + +

    Members

    + +
    + +
    +

    bounds

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bounds + + +Phaser.Rectangle + + + +

    The bounds inside of which the physics world exists. Defaults to match the world bounds.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    gravity

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    gravity + + +Phaser.Point + + + +

    The World gravity setting. Defaults to x: 0, y: 0, or no gravity.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxLevels

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxLevels + + +number + + + +

    Used by the QuadTree to set the maximum number of iteration levels.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxObjects

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxObjects + + +number + + + +

    Used by the QuadTree to set the maximum number of objects per quad.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    OVERLAP_BIAS

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    OVERLAP_BIAS + + +number + + + +

    A value added to the delta values during collision checks.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    quadTree

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    quadTree + + +Phaser.QuadTree + + + +

    The world QuadTree.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    quadTreeID

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    quadTreeID + + +number + + + +

    The QuadTree ID.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    accelerateToObject(displayObject, destination, speed, xSpeedMax, ySpeedMax) → {number}

    + + +
    +
    + + +
    +

    Sets the acceleration.x/y property on the display object so it will move towards the target at the given speed (in pixels per second sq.) +You must give a maximum speed value, beyond which the display object won't go any faster. +Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. +Note: The display object doesn't stop moving once it reaches the destination coordinates.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    displayObject + + +any + + + + + + + + + + + +

    The display object to move.

    destination + + +any + + + + + + + + + + + +

    The display object to move towards. Can be any object but must have visible x/y properties.

    speed + + +number + + + + + + <optional>
    + + + + + +
    + + 60 + +

    The speed it will accelerate in pixels per second.

    xSpeedMax + + +number + + + + + + <optional>
    + + + + + +
    + + 500 + +

    The maximum x velocity the display object can reach.

    ySpeedMax + + +number + + + + + + <optional>
    + + + + + +
    + + 500 + +

    The maximum y velocity the display object can reach.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The angle (in radians) that the object should be visually set to in order to match its new trajectory.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    accelerateToPointer(displayObject, pointer, speed, xSpeedMax, ySpeedMax) → {number}

    + + +
    +
    + + +
    +

    Sets the acceleration.x/y property on the display object so it will move towards the target at the given speed (in pixels per second sq.) +You must give a maximum speed value, beyond which the display object won't go any faster. +Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. +Note: The display object doesn't stop moving once it reaches the destination coordinates.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    displayObject + + +any + + + + + + + + + + + +

    The display object to move.

    pointer + + +Phaser.Pointer + + + + + + <optional>
    + + + + + +
    + +

    The pointer to move towards. Defaults to Phaser.Input.activePointer.

    speed + + +number + + + + + + <optional>
    + + + + + +
    + + 60 + +

    The speed it will accelerate in pixels per second.

    xSpeedMax + + +number + + + + + + <optional>
    + + + + + +
    + + 500 + +

    The maximum x velocity the display object can reach.

    ySpeedMax + + +number + + + + + + <optional>
    + + + + + +
    + + 500 + +

    The maximum y velocity the display object can reach.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The angle (in radians) that the object should be visually set to in order to match its new trajectory.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    accelerateToXY(displayObject, x, y, speed, xSpeedMax, ySpeedMax) → {number}

    + + +
    +
    + + +
    +

    Sets the acceleration.x/y property on the display object so it will move towards the x/y coordinates at the given speed (in pixels per second sq.) +You must give a maximum speed value, beyond which the display object won't go any faster. +Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. +Note: The display object doesn't stop moving once it reaches the destination coordinates.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    displayObject + + +any + + + + + + + + + + + +

    The display object to move.

    x + + +number + + + + + + + + + + + +

    The x coordinate to accelerate towards.

    y + + +number + + + + + + + + + + + +

    The y coordinate to accelerate towards.

    speed + + +number + + + + + + <optional>
    + + + + + +
    + + 60 + +

    The speed it will accelerate in pixels per second.

    xSpeedMax + + +number + + + + + + <optional>
    + + + + + +
    + + 500 + +

    The maximum x velocity the display object can reach.

    ySpeedMax + + +number + + + + + + <optional>
    + + + + + +
    + + 500 + +

    The maximum y velocity the display object can reach.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The angle (in radians) that the object should be visually set to in order to match its new trajectory.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    accelerationFromRotation(rotation, speed, point) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Given the rotation (in radians) and speed calculate the acceleration and return it as a Point object, or set it to the given point object. +One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    rotation + + +number + + + + + + + + + + + +

    The angle in radians.

    speed + + +number + + + + + + <optional>
    + + + + + +
    + + 60 + +

    The speed it will move, in pixels per second sq.

    point + + +Phaser.Point +| + +object + + + + + + <optional>
    + + + + + +
    + +

    The Point object in which the x and y properties will be set to the calculated acceleration.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +
      +
    • A Point where point.x contains the acceleration x value and point.y contains the acceleration y value.
    • +
    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    angleBetween(source, target) → {number}

    + + +
    +
    + + +
    +

    Find the angle in radians between two display objects (like Sprites).

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    source + + +any + + + +

    The Display Object to test from.

    target + + +any + + + +

    The Display Object to test to.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The angle in radians between the source and target display objects.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    angleToPointer(displayObject, pointer) → {number}

    + + +
    +
    + + +
    +

    Find the angle in radians between a display object (like a Sprite) and a Pointer, taking their x/y and center into account.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    displayObject + + +any + + + + + + + + + +

    The Display Object to test from.

    pointer + + +Phaser.Pointer + + + + + + <optional>
    + + + + + +

    The Phaser.Pointer to test to. If none is given then Input.activePointer is used.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The angle in radians between displayObject.x/y to Pointer.x/y

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    angleToXY(displayObject, x, y) → {number}

    + + +
    +
    + + +
    +

    Find the angle in radians between a display object (like a Sprite) and the given x/y coordinate.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    displayObject + + +any + + + +

    The Display Object to test from.

    x + + +number + + + +

    The x coordinate to get the angle to.

    y + + +number + + + +

    The y coordinate to get the angle to.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The angle in radians between displayObject.x/y to Pointer.x/y

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <protected> checkWorldBounds()

    + + +
    +
    + + +
    +

    Internal method.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    collide(object1, object2, collideCallback, processCallback, callbackContext) → {number}

    + + +
    +
    + + +
    +

    Checks for collision between two game objects. The objects can be Sprites, Groups, Emitters or Tilemaps. +You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap or Group vs. Tilemap collisions. +The objects are also automatically separated.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    object1 + + +Phaser.Sprite +| + +Phaser.Group +| + +Phaser.Particles.Emitter +| + +Phaser.Tilemap + + + + + + + + + + + +

    The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.Tilemap

    object2 + + +Phaser.Sprite +| + +Phaser.Group +| + +Phaser.Particles.Emitter +| + +Phaser.Tilemap + + + + + + + + + + + +

    The second object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.Tilemap

    collideCallback + + +function + + + + + + <optional>
    + + + + + +
    + + null + +

    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 passed them to Collision.overlap.

    processCallback + + +function + + + + + + <optional>
    + + + + + +
    + + null + +

    A 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 processCallback returns true.

    callbackContext + + +object + + + + + + <optional>
    + + + + + +
    + +

    The context in which to run the callbacks.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The number of collisions that were processed.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    computeVelocity(axis, body, velocity, acceleration, drag, mMax) → {number}

    + + +
    +
    + + +
    +

    A tween-like function that takes a starting velocity and some other factors and returns an altered velocity.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    axis + + +number + + + +

    1 for horizontal, 2 for vertical.

    body + + +Phaser.Physics.Arcade.Body + + + +

    The Body object to be updated.

    velocity + + +number + + + +

    Any component of velocity (e.g. 20).

    acceleration + + +number + + + +

    Rate at which the velocity is changing.

    drag + + +number + + + +

    Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set.

    mMax + + +number + + + +

    An absolute value cap for the velocity.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The altered Velocity value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    distanceBetween(source, target) → {number}

    + + +
    +
    + + +
    +

    Find the distance between two display objects (like Sprites).

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    source + + +any + + + +

    The Display Object to test from.

    target + + +any + + + +

    The Display Object to test to.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The distance between the source and target objects.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    distanceToPointer(displayObject, pointer) → {number}

    + + +
    +
    + + +
    +

    Find the distance between a display object (like a Sprite) and a Pointer. If no Pointer is given the Input.activePointer is used. +The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed. +If you need to calculate from the center of a display object instead use the method distanceBetweenCenters()

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    displayObject + + +any + + + + + + + + + +

    The Display Object to test from.

    pointer + + +Phaser.Pointer + + + + + + <optional>
    + + + + + +

    The Phaser.Pointer to test to. If none is given then Input.activePointer is used.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The distance between the object and the Pointer.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    distanceToXY(displayObject, x, y) → {number}

    + + +
    +
    + + +
    +

    Find the distance between a display object (like a Sprite) and the given x/y coordinates. +The calculation is made from the display objects x/y coordinate. This may be the top-left if its anchor hasn't been changed. +If you need to calculate from the center of a display object instead use the method distanceBetweenCenters()

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    displayObject + + +any + + + +

    The Display Object to test from.

    x + + +number + + + +

    The x coordinate to move towards.

    y + + +number + + + +

    The y coordinate to move towards.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The distance between the object and the x/y coordinates.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    moveToObject(displayObject, destination, speed, maxTime) → {number}

    + + +
    +
    + + +
    +

    Move the given display object towards the destination object at a steady velocity. +If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. +Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. +Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. +Note: The display object doesn't stop moving once it reaches the destination coordinates. +Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    displayObject + + +any + + + + + + + + + + + +

    The display object to move.

    destination + + +any + + + + + + + + + + + +

    The display object to move towards. Can be any object but must have visible x/y properties.

    speed + + +number + + + + + + <optional>
    + + + + + +
    + + 60 + +

    The speed it will move, in pixels per second (default is 60 pixels/sec)

    maxTime + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The angle (in radians) that the object should be visually set to in order to match its new velocity.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    moveToPointer(displayObject, speed, pointer, maxTime) → {number}

    + + +
    +
    + + +
    +

    Move the given display object towards the pointer at a steady velocity. If no pointer is given it will use Phaser.Input.activePointer. +If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. +Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. +Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. +Note: The display object doesn't stop moving once it reaches the destination coordinates.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    displayObject + + +any + + + + + + + + + + + +

    The display object to move.

    speed + + +number + + + + + + <optional>
    + + + + + +
    + + 60 + +

    The speed it will move, in pixels per second (default is 60 pixels/sec)

    pointer + + +Phaser.Pointer + + + + + + <optional>
    + + + + + +
    + +

    The pointer to move towards. Defaults to Phaser.Input.activePointer.

    maxTime + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The angle (in radians) that the object should be visually set to in order to match its new velocity.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    moveToXY(displayObject, x, y, speed, maxTime) → {number}

    + + +
    +
    + + +
    +

    Move the given display object towards the x/y coordinates at a steady velocity. +If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds. +Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms. +Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course. +Note: The display object doesn't stop moving once it reaches the destination coordinates. +Note: Doesn't take into account acceleration, maxVelocity or drag (if you've set drag or acceleration too high this object may not move at all)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    displayObject + + +any + + + + + + + + + + + +

    The display object to move.

    x + + +number + + + + + + + + + + + +

    The x coordinate to move towards.

    y + + +number + + + + + + + + + + + +

    The y coordinate to move towards.

    speed + + +number + + + + + + <optional>
    + + + + + +
    + + 60 + +

    The speed it will move, in pixels per second (default is 60 pixels/sec)

    maxTime + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The angle (in radians) that the object should be visually set to in order to match its new velocity.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    overlap(object1, object2) → {boolean}

    + + +
    +
    + + +
    +

    Checks if two Sprite objects overlap.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    object1 + + +Phaser.Sprite + + + +

    The first object to check. Can be an instance of Phaser.Sprite or anything that extends it.

    object2 + + +Phaser.Sprite + + + +

    The second object to check. Can be an instance of Phaser.Sprite or anything that extends it.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    true if the two objects overlap.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <protected> postUpdate()

    + + +
    +
    + + +
    +

    Called automatically by the core game loop.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> postUpdate()

    + + +
    +
    + + +
    +

    Internal method.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> preUpdate()

    + + +
    +
    + + +
    +

    Called automatically by the core game loop.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> preUpdate()

    + + +
    +
    + + +
    +

    Internal method.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    reset()

    + + +
    +
    + + +
    +

    Resets all Body values (velocity, acceleration, rotation, etc)

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    separate(body1, body2) → {boolean}

    + + +
    +
    + + +
    +

    The core separation function to separate two physics bodies.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    body1 + + +Phaser.Physics.Arcade.Body + + + +

    The Body object to separate.

    body2 + + +Phaser.Physics.Arcade.Body + + + +

    The Body object to separate.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns true if the bodies were separated, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    separateTile(body1, tile) → {boolean}

    + + +
    +
    + + +
    +

    The core separation function to separate a physics body and a tile.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    body1 + + +Phaser.Physics.Arcade.Body + + + +

    The Body object to separate.

    tile + + +Phaser.Tile + + + +

    The tile to collide against.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns true if the bodies were separated, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    separateTileX(body1, tile) → {boolean}

    + + +
    +
    + + +
    +

    The core separation function to separate a physics body and a tile on the x axis.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    body1 + + +Phaser.Physics.Arcade.Body + + + +

    The Body object to separate.

    tile + + +Phaser.Tile + + + +

    The tile to collide against.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns true if the bodies were separated, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    separateTileY(body1, tile) → {boolean}

    + + +
    +
    + + +
    +

    The core separation function to separate a physics body and a tile on the x axis.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    body1 + + +Phaser.Physics.Arcade.Body + + + +

    The Body object to separate.

    tile + + +Phaser.Tile + + + +

    The tile to collide against.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns true if the bodies were separated, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    separateX(body1, body2) → {boolean}

    + + +
    +
    + + +
    +

    The core separation function to separate two physics bodies on the x axis.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    body1 + + +Phaser.Physics.Arcade.Body + + + +

    The Body object to separate.

    body2 + + +Phaser.Physics.Arcade.Body + + + +

    The Body object to separate.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns true if the bodies were separated, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    separateY(body1, body2) → {boolean}

    + + +
    +
    + + +
    +

    The core separation function to separate two physics bodies on the y axis.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    body1 + + +Phaser.Physics.Arcade.Body + + + +

    The Body object to separate.

    body2 + + +Phaser.Physics.Arcade.Body + + + +

    The Body object to separate.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Returns true if the bodies were separated, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    setSize(width, height, offsetX, offsetY)

    + + +
    +
    + + +
    +

    You can modify the size of the physics Body to be any dimension you need. +So it could be smaller or larger than the parent Sprite. You can also control the x and y offset, which +is the position of the Body relative to the top-left of the Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    The width of the Body.

    height + + +number + + + +

    The height of the Body.

    offsetX + + +number + + + +

    The X offset of the Body from the Sprite position.

    offsetY + + +number + + + +

    The Y offset of the Body from the Sprite position.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> updateBounds()

    + + +
    +
    + + +
    +

    Internal method.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> updateHulls()

    + + +
    +
    + + +
    +

    Internal method.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    updateMotion(The)

    + + +
    +
    + + +
    +

    Called automatically by a Physics body, it updates all motion related values on the Body.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    The + + +Phaser.Physics.Arcade.Body + + + +

    Body object to be updated.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    velocityFromAngle(angle, speed, point) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Given the angle (in degrees) and speed calculate the velocity and return it as a Point object, or set it to the given point object. +One way to use this is: velocityFromAngle(angle, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    angle + + +number + + + + + + + + + + + +

    The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)

    speed + + +number + + + + + + <optional>
    + + + + + +
    + + 60 + +

    The speed it will move, in pixels per second sq.

    point + + +Phaser.Point +| + +object + + + + + + <optional>
    + + + + + +
    + +

    The Point object in which the x and y properties will be set to the calculated velocity.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +
      +
    • A Point where point.x contains the velocity x value and point.y contains the velocity y value.
    • +
    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    velocityFromRotation(rotation, speed, point) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Given the rotation (in radians) and speed calculate the velocity and return it as a Point object, or set it to the given point object. +One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    rotation + + +number + + + + + + + + + + + +

    The angle in radians.

    speed + + +number + + + + + + <optional>
    + + + + + +
    + + 60 + +

    The speed it will move, in pixels per second sq.

    point + + +Phaser.Point +| + +object + + + + + + <optional>
    + + + + + +
    + +

    The Point object in which the x and y properties will be set to the calculated velocity.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +
      +
    • A Point where point.x contains the velocity x value and point.y contains the velocity y value.
    • +
    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:29 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Physics.html b/docs/Phaser.Physics.html new file mode 100644 index 00000000..a339c8db --- /dev/null +++ b/docs/Phaser.Physics.html @@ -0,0 +1,552 @@ + + + + + + Phaser Class: Physics + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Physics

    +
    + +
    +

    + Phaser. + + Physics +

    + +
    + +
    +
    + + + + +
    +

    new Physics()

    + + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + +

    Classes

    + +
    +
    Arcade
    +
    +
    + + + + + + + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:29 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Plugin.html b/docs/Phaser.Plugin.html new file mode 100644 index 00000000..835ea5ef --- /dev/null +++ b/docs/Phaser.Plugin.html @@ -0,0 +1,1814 @@ + + + + + + Phaser Class: Plugin + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Plugin

    +
    + +
    +

    + Phaser. + + Plugin +

    + +

    Phaser - Plugin

    + +
    + +
    +
    + + + + +
    +

    new Plugin(game, parent)

    + + +
    +
    + + +
    +

    This is a base Plugin template to use for any Phaser plugin development.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    parent + + +Any + + + +

    The object that owns this plugin, usually Phaser.PluginManager.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    active

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    active + + +boolean + + + +

    A Plugin with active=true has its preUpdate and update methods called by the parent, otherwise they are skipped.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    hasPostRender

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hasPostRender + + +boolean + + + +

    A flag to indicate if this plugin has a postRender method.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    hasPreUpdate

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hasPreUpdate + + +boolean + + + +

    A flag to indicate if this plugin has a preUpdate method.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    hasRender

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hasRender + + +boolean + + + +

    A flag to indicate if this plugin has a render method.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    hasUpdate

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    hasUpdate + + +boolean + + + +

    A flag to indicate if this plugin has an update method.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    parent

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    parent + + +Any + + + +

    The parent of this plugin. If added to the PluginManager the parent will be set to that, otherwise it will be null.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    visible

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    visible + + +boolean + + + +

    A Plugin with visible=true has its render and postRender methods called by the parent, otherwise they are skipped.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Clear down this Plugin and null out references

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    postRender()

    + + +
    +
    + + +
    +

    Post-render is called after the Game Renderer and State.render have run. +It is only called if visible is set to true.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    preUpdate()

    + + +
    +
    + + +
    +

    Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). +It is only called if active is set to true.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    render()

    + + +
    +
    + + +
    +

    Render is called right after the Game Renderer completes, but before the State.render. +It is only called if visible is set to true.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    update()

    + + +
    +
    + + +
    +

    Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. +It is only called if active is set to true.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:29 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.PluginManager.html b/docs/Phaser.PluginManager.html new file mode 100644 index 00000000..4528a022 --- /dev/null +++ b/docs/Phaser.PluginManager.html @@ -0,0 +1,1444 @@ + + + + + + Phaser Class: PluginManager + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: PluginManager

    +
    + +
    +

    + Phaser. + + PluginManager +

    + +

    Phaser - PluginManager

    + +
    + +
    +
    + + + + +
    +

    new PluginManager(game, parent)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    parent + + +Description + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    plugins

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    plugins + + +array + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    add(plugin) → {Phaser.Plugin}

    + + +
    +
    + + +
    +

    Add a new Plugin to the PluginManager. +The plugin's game and parent reference are set to this game and pluginmanager parent.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    plugin + + +Phaser.Plugin + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Description.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Plugin + + +
    +
    + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Clear down this PluginManager and null out references

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    postRender()

    + + +
    +
    + + +
    +

    Post-render is called after the Game Renderer and State.render have run. +It only calls plugins who have visible=true.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    preUpdate()

    + + +
    +
    + + +
    +

    Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). +It only calls plugins who have active=true.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    remove(plugin)

    + + +
    +
    + + +
    +

    Remove a Plugin from the PluginManager.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    plugin + + +Phaser.Plugin + + + +

    The plugin to be removed.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    render()

    + + +
    +
    + + +
    +

    Render is called right after the Game Renderer completes, but before the State.render. +It only calls plugins who have visible=true.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    update()

    + + +
    +
    + + +
    +

    Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. +It only calls plugins who have active=true.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:29 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Point.html b/docs/Phaser.Point.html new file mode 100644 index 00000000..ddee290a --- /dev/null +++ b/docs/Phaser.Point.html @@ -0,0 +1,5004 @@ + + + + + + Phaser Class: Point + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Point

    +
    + +
    +

    + Phaser. + + Point +

    + +

    The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.

    + +
    + +
    +
    + + + + +
    +

    new Point(x, y)

    + + +
    +
    + + +
    +

    Creates a new Point. If you pass no parameters a Point is created set to (0,0).

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The horizontal position of this Point (default 0)

    y + + +number + + + +

    The vertical position of this Point (default 0)

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    x

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The x coordinate of the point.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    The y coordinate of the point.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    <static> add(a, b, out) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Adds the coordinates of two points together to create a new point.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    a + + +Phaser.Point + + + + + + + + + +

    The first Point object.

    b + + +Phaser.Point + + + + + + + + + +

    The second Point object.

    out + + +Phaser.Point + + + + + + <optional>
    + + + + + +

    Optional Point to store the value in, if not supplied a new Point object will be created.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The new Point object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    <static> distance(a, b, round) → {number}

    + + +
    +
    + + +
    +

    Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties).

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    a + + +object + + + + + + + + + +

    The target object. Must have visible x and y properties that represent the center of the object.

    b + + +object + + + + + + + + + +

    The target object. Must have visible x and y properties that represent the center of the object.

    round + + +boolean + + + + + + <optional>
    + + + + + +

    Round the distance to the nearest integer (default false).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The distance between this Point object and the destination Point object.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    <static> divide(a, b, out) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Divides the coordinates of two points to create a new point.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    a + + +Phaser.Point + + + + + + + + + +

    The first Point object.

    b + + +Phaser.Point + + + + + + + + + +

    The second Point object.

    out + + +Phaser.Point + + + + + + <optional>
    + + + + + +

    Optional Point to store the value in, if not supplied a new Point object will be created.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The new Point object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    <static> equals(a, b) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the two given Point objects are equal. They are considered equal if they have the same x and y values.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Point + + + +

    The first Point object.

    b + + +Phaser.Point + + + +

    The second Point object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the Points are equal, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <static> multiply(a, b, out) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Multiplies the coordinates of two points to create a new point.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    a + + +Phaser.Point + + + + + + + + + +

    The first Point object.

    b + + +Phaser.Point + + + + + + + + + +

    The second Point object.

    out + + +Phaser.Point + + + + + + <optional>
    + + + + + +

    Optional Point to store the value in, if not supplied a new Point object will be created.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The new Point object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    <static> rotate(a, x, y, angle, asDegrees, distance) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Rotates a Point around the x/y coordinates given to the desired angle.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Point + + + +

    The Point object to rotate.

    x + + +number + + + +

    The x coordinate of the anchor point

    y + + +number + + + +

    The y coordinate of the anchor point

    angle + + +number + + + +

    The angle in radians (unless asDegrees is true) to rotate the Point to.

    asDegrees + + +boolean + + + +

    Is the given rotation in radians (false) or degrees (true)?

    distance + + +number + + + +

    An optional distance constraint between the Point and the anchor.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The modified point object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    <static> subtract(a, b, out) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Subtracts the coordinates of two points to create a new point.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    a + + +Phaser.Point + + + + + + + + + +

    The first Point object.

    b + + +Phaser.Point + + + + + + + + + +

    The second Point object.

    out + + +Phaser.Point + + + + + + <optional>
    + + + + + +

    Optional Point to store the value in, if not supplied a new Point object will be created.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The new Point object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    add(x, y) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Adds the given x and y values to this Point.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The value to add to Point.x.

    y + + +number + + + +

    The value to add to Point.y.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Point object. Useful for chaining method calls.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    clamp(min, max) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Clamps this Point object values to be between the given min and max.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    min + + +number + + + +

    The minimum value to clamp this Point to.

    max + + +number + + + +

    The maximum value to clamp this Point to.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Point object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    clampX(min, max) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Clamps the x value of this Point to be between the given min and max.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    min + + +number + + + +

    The minimum value to clamp this Point to.

    max + + +number + + + +

    The maximum value to clamp this Point to.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Point object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    clampY(min, max) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Clamps the y value of this Point to be between the given min and max

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    min + + +number + + + +

    The minimum value to clamp this Point to.

    max + + +number + + + +

    The maximum value to clamp this Point to.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Point object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    clone(output) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Creates a copy of the given Point.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    output + + +Phaser.Point + + + + + + <optional>
    + + + + + +

    Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The new Point object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    copyFrom(source) → {Point}

    + + +
    +
    + + +
    +

    Copies the x and y properties from any given object to this Point.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    source + + +any + + + +

    The object to copy from.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Point object.

    +
    + + + +
    +
    + Type +
    +
    + +Point + + +
    +
    + + + + + +
    + + + +
    +

    copyFrom(source) → {Point}

    + + +
    +
    + + +
    +

    Copies the x and y properties from any given object to this Point.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    source + + +any + + + +

    The object to copy from.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Point object.

    +
    + + + +
    +
    + Type +
    +
    + +Point + + +
    +
    + + + + + +
    + + + +
    +

    copyTo(dest) → {Object}

    + + +
    +
    + + +
    +

    Copies the x and y properties from this Point to any given object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    dest + + +any + + + +

    The object to copy to.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The dest object.

    +
    + + + +
    +
    + Type +
    +
    + +Object + + +
    +
    + + + + + +
    + + + +
    +

    distance(dest, round) → {number}

    + + +
    +
    + + +
    +

    Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    dest + + +object + + + + + + + + + +

    The target object. Must have visible x and y properties that represent the center of the object.

    round + + +boolean + + + + + + <optional>
    + + + + + +

    Round the distance to the nearest integer (default false).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The distance between this Point object and the destination Point object.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    divide(x, y) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Divides Point.x and Point.y by the given x and y values.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The value to divide Point.x by.

    y + + +number + + + +

    The value to divide Point.x by.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Point object. Useful for chaining method calls.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    equals(a) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the given objects x/y values are equal to this Point object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Point + + + +

    The first object to compare.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the Points are equal, otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    invert() → {Point}

    + + +
    +
    + + +
    +

    Inverts the x and y values of this Point

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Point object.

    +
    + + + +
    +
    + Type +
    +
    + +Point + + +
    +
    + + + + + +
    + + + +
    +

    multiply(x, y) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Multiplies Point.x and Point.y by the given x and y values.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The value to multiply Point.x by.

    y + + +number + + + +

    The value to multiply Point.x by.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Point object. Useful for chaining method calls.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    rotate(x, y, angle, asDegrees, distance) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Rotates this Point around the x/y coordinates given to the desired angle.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    x + + +number + + + + + + + + + +

    The x coordinate of the anchor point

    y + + +number + + + + + + + + + +

    The y coordinate of the anchor point

    angle + + +number + + + + + + + + + +

    The angle in radians (unless asDegrees is true) to rotate the Point to.

    asDegrees + + +boolean + + + + + + + + + +

    Is the given rotation in radians (false) or degrees (true)?

    distance + + +number + + + + + + <optional>
    + + + + + +

    An optional distance constraint between the Point and the anchor.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The modified point object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    setTo(x, y) → {Point}

    + + +
    +
    + + +
    +

    Sets the x and y values of this Point object to the given coordinates.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The horizontal position of this point.

    y + + +number + + + +

    The vertical position of this point.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Point object. Useful for chaining method calls.

    +
    + + + +
    +
    + Type +
    +
    + +Point + + +
    +
    + + + + + +
    + + + +
    +

    subtract(x, y) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Subtracts the given x and y values from this Point.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The value to subtract from Point.x.

    y + + +number + + + +

    The value to subtract from Point.y.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Point object. Useful for chaining method calls.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    toString() → {string}

    + + +
    +
    + + +
    +

    Returns a string representation of this object.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A string representation of the instance.

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:29 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Pointer.html b/docs/Phaser.Pointer.html new file mode 100644 index 00000000..ee5c62c9 --- /dev/null +++ b/docs/Phaser.Pointer.html @@ -0,0 +1,4847 @@ + + + + + + Phaser Class: Pointer + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Pointer

    +
    + +
    +

    + Phaser. + + Pointer +

    + +

    A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen.

    + +
    + +
    +
    + + + + +
    +

    new Pointer(game, id)

    + + +
    +
    + + +
    +

    Phaser - Pointer constructor.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    id + + +Description + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    active

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isDown + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    circle

    + + +
    +
    + +
    +

    A Circle object centered on the x/y screen coordinates of the Pointer. +Default size of 44px (Apple's recommended "finger tip" size).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    circle + + +Circle + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    circle

    + + +
    +
    + +
    +

    Description

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    circle + + +Phaser.Circle + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    clientX

    + + +
    +
    + +
    +

    The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    clientX + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    clientY

    + + +
    +
    + +
    +

    The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    clientY + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> duration

    + + +
    +
    + +
    +

    How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    duration + + +number + + + +

    How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    id

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    id + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isDown

    + + +
    +
    + +
    +

    If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isDown + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isMouse :boolean

    + + +
    +
    + +
    +

    If the Pointer is a mouse this is true, otherwise false.

    +
    + + + +
    Type:
    +
      +
    • + +boolean + + +
    • +
    + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isMouse + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isUp

    + + +
    +
    + +
    +

    If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isUp + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    msSinceLastClick

    + + +
    +
    + +
    +

    The number of miliseconds since the last click.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    msSinceLastClick + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pageX

    + + +
    +
    + +
    +

    The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pageX + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pageY

    + + +
    +
    + +
    +

    The vertical coordinate of point relative to the viewport in pixels, including any scroll offset.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pageY + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    position

    + + +
    +
    + +
    +

    A Vector object containing the current position of the Pointer on the screen.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    position + + +Vec2 + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    position

    + + +
    +
    + +
    +

    Description

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    position + + +Phaser.Point + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    positionDown

    + + +
    +
    + +
    +

    A Vector object containing the initial position when the Pointer was engaged with the screen.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    positionDown + + +Vec2 + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    positionDown

    + + +
    +
    + +
    +

    Description

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    positionDown + + +Phaser.Point + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    previousTapTime

    + + +
    +
    + +
    +

    A timestamp representing when the Pointer was last tapped or clicked.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    previousTapTime + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    screenX

    + + +
    +
    + +
    +

    The horizontal coordinate of point relative to the screen in pixels.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    screenX + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    screenY

    + + +
    +
    + +
    +

    The vertical coordinate of point relative to the screen in pixels.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    screenY + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    targetObject

    + + +
    +
    + +
    +

    The Game Object this Pointer is currently over / touching / dragging.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    targetObject + + +Any + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    timeDown

    + + +
    +
    + +
    +

    A timestamp representing when the Pointer first touched the touchscreen.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    timeDown + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    timeUp

    + + +
    +
    + +
    +

    A timestamp representing when the Pointer left the touchscreen.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    timeUp + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    totalTouches

    + + +
    +
    + +
    +

    The total number of times this Pointer has been touched to the touchscreen.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    totalTouches + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    withinGame

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    withinGame + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> worldX

    + + +
    +
    + +
    +

    Gets the X value of this Pointer in world coordinates based on the world camera.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    duration + + +number + + + +

    The X value of this Pointer in world coordinates based on the world camera.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> worldY

    + + +
    +
    + +
    +

    Gets the Y value of this Pointer in world coordinates based on the world camera.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    duration + + +number + + + +

    The Y value of this Pointer in world coordinates based on the world camera.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + +
    +

    The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + +
    +

    The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    justPressed(duration) → {boolean}

    + + +
    +
    + + +
    +

    The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    duration + + +number + + + + + + <optional>
    + + + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    justReleased(duration) → {boolean}

    + + +
    +
    + + +
    +

    The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    duration + + +number + + + + + + <optional>
    + + + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    leave(event)

    + + +
    +
    + + +
    +

    Called when the Pointer leaves the target area.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    move(event)

    + + +
    +
    + + +
    +

    Called when the Pointer is moved

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    reset()

    + + +
    +
    + + +
    +

    Resets the Pointer properties. Called by InputManager.reset when you perform a State change.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    start(event)

    + + +
    +
    + + +
    +

    Called when the Pointer is pressed onto the touchscreen.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stop(event)

    + + +
    +
    + + +
    +

    Called when the Pointer leaves the touchscreen.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    toString() → {string}

    + + +
    +
    + + +
    +

    Returns a string representation of this object.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A string representation of the instance.

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + + + +
    +

    update()

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:30 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.QuadTree.html b/docs/Phaser.QuadTree.html new file mode 100644 index 00000000..b00f2216 --- /dev/null +++ b/docs/Phaser.QuadTree.html @@ -0,0 +1,1313 @@ + + + + + + Phaser Class: QuadTree + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: QuadTree

    +
    + +
    +

    + Phaser. + + QuadTree +

    + +

    A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked +it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result. Original version at https://github.com/timohausmann/quadtree-js/

    + +
    + +
    +
    + + + + +
    +

    new QuadTree(physicsManager, x, y, width, height, maxObjects, maxLevels, level)

    + + +
    +
    + + +
    +

    QuadTree Constructor

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    physicsManager + + +Description + + + +

    Description.

    x + + +Description + + + +

    Description.

    y + + +Description + + + +

    Description.

    width + + +number + + + +

    The width of your game in game pixels.

    height + + +number + + + +

    The height of your game in game pixels.

    maxObjects + + +number + + + +

    Description.

    maxLevels + + +number + + + +

    Description.

    level + + +number + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    clear()

    + + +
    +
    + + +
    +

    /* +Clear the quadtree.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    getIndex(rect) → {number}

    + + +
    +
    + + +
    +

    /* +Determine which node the object belongs to.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    rect + + +object + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    index - Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    insert(body)

    + + +
    +
    + + +
    +

    /* +Insert the object into the node. If the node +exceeds the capacity, it will split and add all +objects to their corresponding subnodes.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    body + + +object + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    retrieve(rect) → {array}

    + + +
    +
    + + +
    +

    /* +Return all objects that could collide with the given object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    rect + + +object + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +
      +
    • Array with all detected objects.
    • +
    +
    + + + +
    +
    + Type +
    +
    + +array + + +
    +
    + + + + + +
    + + + +
    +

    split()

    + + +
    +
    + + +
    +

    /* +Split the node into 4 subnodes

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:30 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.RandomDataGenerator.html b/docs/Phaser.RandomDataGenerator.html new file mode 100644 index 00000000..486e2b58 --- /dev/null +++ b/docs/Phaser.RandomDataGenerator.html @@ -0,0 +1,2006 @@ + + + + + + Phaser Class: RandomDataGenerator + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: RandomDataGenerator

    +
    + +
    +

    + Phaser. + + RandomDataGenerator +

    + +

    An extremely useful repeatable random data generator. Access it via Phaser.Game.rnd +Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense. +Random number generator from http://baagoe.org/en/wiki/Better_random_numbers_for_javascript

    + +
    + +
    +
    + + + + +
    +

    new RandomDataGenerator(seeds)

    + + +
    +
    + + +
    +

    Phaser.RandomDataGenerator constructor.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    seeds + + +array + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +

    Methods

    + +
    + +
    +

    angle() → {number}

    + + +
    +
    + + +
    +

    Returns a random angle between -180 and 180.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    frac() → {number}

    + + +
    +
    + + +
    +

    Returns a random real number between 0 and 1.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    integer() → {number}

    + + +
    +
    + + +
    +

    Returns a random integer between 0 and 2^32.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    integerInRange(min, max) → {number}

    + + +
    +
    + + +
    +

    Returns a random integer between min and max.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    min + + +number + + + +
    max + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    normal() → {number}

    + + +
    +
    + + +
    +

    Returns a random real number between -1 and 1.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    pick(ary) → {number}

    + + +
    +
    + + +
    +

    Returns a random member of array.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    ary + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    real() → {number}

    + + +
    +
    + + +
    +

    Returns a random real number between 0 and 2^32.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    realInRange(min, max) → {number}

    + + +
    +
    + + +
    +

    Returns a random real number between min and max.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    min + + +number + + + +
    max + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    sow(seeds)

    + + +
    +
    + + +
    +

    Reset the seed of the random data generator.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    seeds + + +array + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    timestamp(min, max) → {number}

    + + +
    +
    + + +
    +

    Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    min + + +number + + + +
    max + + +number + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    uuid() → {string}

    + + +
    +
    + + +
    +

    Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + + + +
    +

    weightedPick(ary) → {number}

    + + +
    +
    + + +
    +

    Returns a random member of array, favoring the earlier entries.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    ary + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:30 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Rectangle.html b/docs/Phaser.Rectangle.html new file mode 100644 index 00000000..e91b1134 --- /dev/null +++ b/docs/Phaser.Rectangle.html @@ -0,0 +1,7391 @@ + + + + + + Phaser Class: Rectangle + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Rectangle

    +
    + +
    +

    + Phaser. + + Rectangle +

    + +

    Phaser.Rectangle

    + +
    + +
    +
    + + + + +
    +

    new Rectangle(x, y, width, height) → {Rectangle}

    + + +
    +
    + + +
    +

    Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. If you call this function without parameters, a Rectangle with x, y, width, and height properties set to 0 is created.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The x coordinate of the top-left corner of the Rectangle.

    y + + +number + + + +

    The y coordinate of the top-left corner of the Rectangle.

    width + + +number + + + +

    The width of the Rectangle in pixels.

    height + + +number + + + +

    The height of the Rectangle in pixels.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Rectangle object.

    +
    + + + +
    +
    + Type +
    +
    + +Rectangle + + +
    +
    + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    bottom

    + + +
    +
    + +
    +

    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.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bottom + + +number + + + +

    The sum of the y and height properties.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bottom

    + + +
    +
    + +
    +

    The location of the Rectangles bottom right corner as a Point object.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bottomRight + + +Phaser.Point + + + +

    Gets or sets the location of the Rectangles bottom right corner as a Point object.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    centerX

    + + +
    +
    + +
    +

    The x coordinate of the center of the Rectangle.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    centerX + + +number + + + +

    The x coordinate of the center of the Rectangle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    centerY

    + + +
    +
    + +
    +

    The y coordinate of the center of the Rectangle.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    centerY + + +number + + + +

    The y coordinate of the center of the Rectangle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    empty

    + + +
    +
    + +
    +

    Determines whether or not this Rectangle object is empty. A Rectangle object is empty if its width or height is less than or equal to 0. +If set to true then all of the Rectangle properties are set to 0.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    empty + + +boolean + + + +

    Gets or sets the Rectangles empty state.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> halfHeight

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    halfHeight + + +number + + + +

    Half of the height of the Rectangle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> halfWidth

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    halfWidth + + +number + + + +

    Half of the width of the Rectangle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    height

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    height + + +number + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    left

    + + +
    +
    + +
    +

    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.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    left + + +number + + + +

    The x coordinate of the left of the Rectangle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> perimeter

    + + +
    +
    + +
    +

    The perimeter size of the Rectangle. This is the sum of all 4 sides.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    perimeter + + +number + + + +

    The perimeter size of the Rectangle. This is the sum of all 4 sides.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    + + + +
    +
    + +
    +

    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.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    right + + +number + + + +

    The sum of the x and width properties.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    top

    + + +
    +
    + +
    +

    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.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    top + + +number + + + +

    The y coordinate of the top of the Rectangle.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    topLeft

    + + +
    +
    + +
    +

    The location of the Rectangles top left corner as a Point object.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    topLeft + + +Phaser.Point + + + +

    The location of the Rectangles top left corner as a Point object.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> volume

    + + +
    +
    + +
    +

    The volume of the Rectangle derived from width * height.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    volume + + +number + + + +

    The volume of the Rectangle derived from width * height.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    width

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    <static> clone(a, output) → {Phaser.Rectangle}

    + + +
    +
    + + +
    +

    Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    a + + +Phaser.Rectangle + + + + + + + + + +

    The Rectangle object.

    output + + +Phaser.Rectangle + + + + + + <optional>
    + + + + + +

    Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +Phaser.Rectangle + + +
    +
    + + + + + +
    + + + +
    +

    <static> contains(a, x, y) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the specified coordinates are contained within the region defined by this Rectangle object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Rectangle + + + +

    The Rectangle object.

    x + + +number + + + +

    The x coordinate of the point to test.

    y + + +number + + + +

    The y coordinate of the point to test.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the Rectangle object contains the specified point; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <static> containsPoint(a, point) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Rectangle + + + +

    The Rectangle object.

    point + + +Phaser.Point + + + +

    The point object being checked. Can be Point or any object with .x and .y values.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the Rectangle object contains the specified point; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <static> containsRect(a, b) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the first Rectangle object is fully contained within the second Rectangle object. +A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Rectangle + + + +

    The first Rectangle object.

    b + + +Phaser.Rectangle + + + +

    The second Rectangle object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the Rectangle object contains the specified point; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <static> equals(a, b) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the two Rectangles are equal. +This method compares the x, y, width and height properties of each Rectangle.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Rectangle + + + +

    The first Rectangle object.

    b + + +Phaser.Rectangle + + + +

    The second Rectangle object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <static> inflate(a, dx, dy) → {Phaser.Rectangle}

    + + +
    +
    + + +
    +

    Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Rectangle + + + +

    The Rectangle object.

    dx + + +number + + + +

    The amount to be added to the left side of the Rectangle.

    dy + + +number + + + +

    The amount to be added to the bottom side of the Rectangle.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Rectangle object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Rectangle + + +
    +
    + + + + + +
    + + + +
    +

    <static> inflatePoint(a, point) → {Phaser.Rectangle}

    + + +
    +
    + + +
    +

    Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Rectangle + + + +

    The Rectangle object.

    point + + +Phaser.Point + + + +

    The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The Rectangle object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Rectangle + + +
    +
    + + + + + +
    + + + +
    +

    <static> intersection(a, b, out) → {Phaser.Rectangle}

    + + +
    +
    + + +
    +

    If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    a + + +Phaser.Rectangle + + + + + + + + + +

    The first Rectangle object.

    b + + +Phaser.Rectangle + + + + + + + + + +

    The second Rectangle object.

    out + + +Phaser.Rectangle + + + + + + <optional>
    + + + + + +

    Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Rectangle + + +
    +
    + + + + + +
    + + + +
    +

    <static> intersects(a, b) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the two Rectangles intersect with each other. +This method checks the x, y, width, and height properties of the Rectangles.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    a + + +Phaser.Rectangle + + + +

    The first Rectangle object.

    b + + +Phaser.Rectangle + + + +

    The second Rectangle object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the specified object intersects with this Rectangle object; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <static> intersectsRaw(left, right, top, bottom, tolerance) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the object specified intersects (overlaps) with the given values.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    left + + +number + + + +

    Description.

    right + + +number + + + +

    Description.

    top + + +number + + + +

    Description.

    bottom + + +number + + + +

    Description.

    tolerance + + +number + + + +

    A tolerance value to allow for an intersection test with padding, default to 0

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the specified object intersects with the Rectangle; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <static> size(a, output) → {Phaser.Point}

    + + +
    +
    + + +
    +

    The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    a + + +Phaser.Rectangle + + + + + + + + + +

    The Rectangle object.

    output + + +Phaser.Point + + + + + + <optional>
    + + + + + +

    Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The size of the Rectangle object

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    <static> union(a, b, out) → {Phaser.Rectangle}

    + + +
    +
    + + +
    +

    Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    a + + +Phaser.Rectangle + + + + + + + + + +

    The first Rectangle object.

    b + + +Phaser.Rectangle + + + + + + + + + +

    The second Rectangle object.

    out + + +Phaser.Rectangle + + + + + + <optional>
    + + + + + +

    Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A Rectangle object that is the union of the two Rectangles.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Rectangle + + +
    +
    + + + + + +
    + + + +
    +

    clone(output) → {Phaser.Rectangle}

    + + +
    +
    + + +
    +

    Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    output + + +Phaser.Rectangle + + + + + + <optional>
    + + + + + +

    Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +Phaser.Rectangle + + +
    +
    + + + + + +
    + + + +
    +

    contains(x, y) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the specified coordinates are contained within the region defined by this Rectangle object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The x coordinate of the point to test.

    y + + +number + + + +

    The y coordinate of the point to test.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the Rectangle object contains the specified point; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    containsRect(b) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the first Rectangle object is fully contained within the second Rectangle object. +A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    b + + +Phaser.Rectangle + + + +

    The second Rectangle object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the Rectangle object contains the specified point; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    copyFrom(source) → {Rectangle}

    + + +
    +
    + + +
    +

    Copies the x, y, width and height properties from any given object to this Rectangle.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    source + + +any + + + +

    The object to copy from.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Rectangle object.

    +
    + + + +
    +
    + Type +
    +
    + +Rectangle + + +
    +
    + + + + + +
    + + + +
    +

    copyTo(source) → {object}

    + + +
    +
    + + +
    +

    Copies the x, y, width and height properties from this Rectangle to any given object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    source + + +any + + + +

    The object to copy to.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This object.

    +
    + + + +
    +
    + Type +
    +
    + +object + + +
    +
    + + + + + +
    + + + +
    +

    equals(b) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the two Rectangles are equal. +This method compares the x, y, width and height properties of each Rectangle.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    b + + +Phaser.Rectangle + + + +

    The second Rectangle object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    floor()

    + + +
    +
    + + +
    +

    Runs Math.floor() on both the x and y values of this Rectangle.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    floorAll()

    + + +
    +
    + + +
    +

    Runs Math.floor() on the x, y, width and height values of this Rectangle.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    inflate(dx, dy) → {Phaser.Rectangle}

    + + +
    +
    + + +
    +

    Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    dx + + +number + + + +

    The amount to be added to the left side of the Rectangle.

    dy + + +number + + + +

    The amount to be added to the bottom side of the Rectangle.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Rectangle object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Rectangle + + +
    +
    + + + + + +
    + + + +
    +

    intersection(b, out) → {Phaser.Rectangle}

    + + +
    +
    + + +
    +

    If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    b + + +Phaser.Rectangle + + + +

    The second Rectangle object.

    out + + +Phaser.Rectangle + + + +

    Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Rectangle + + +
    +
    + + + + + +
    + + + +
    +

    intersects(b, tolerance) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the two Rectangles intersect with each other. +This method checks the x, y, width, and height properties of the Rectangles.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    b + + +Phaser.Rectangle + + + +

    The second Rectangle object.

    tolerance + + +number + + + +

    A tolerance value to allow for an intersection test with padding, default to 0.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the specified object intersects with this Rectangle object; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    intersectsRaw(left, right, top, bottomt, tolerance) → {boolean}

    + + +
    +
    + + +
    +

    Determines whether the object specified intersects (overlaps) with the given values.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    left + + +number + + + +

    Description.

    right + + +number + + + +

    Description.

    top + + +number + + + +

    Description.

    bottomt + + +number + + + +

    Description.

    tolerance + + +number + + + +

    A tolerance value to allow for an intersection test with padding, default to 0

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A value of true if the specified object intersects with the Rectangle; otherwise false.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    offset(dx, dy) → {Rectangle}

    + + +
    +
    + + +
    +

    Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    dx + + +number + + + +

    Moves the x value of the Rectangle object by this amount.

    dy + + +number + + + +

    Moves the y value of the Rectangle object by this amount.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Rectangle object.

    +
    + + + +
    +
    + Type +
    +
    + +Rectangle + + +
    +
    + + + + + +
    + + + +
    +

    offsetPoint(point) → {Rectangle}

    + + +
    +
    + + +
    +

    Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    point + + +Point + + + +

    A Point object to use to offset this Rectangle object.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Rectangle object.

    +
    + + + +
    +
    + Type +
    +
    + +Rectangle + + +
    +
    + + + + + +
    + + + +
    +

    setTo(x, y, width, height) → {Rectangle}

    + + +
    +
    + + +
    +

    Sets the members of Rectangle to the specified values.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The x coordinate of the top-left corner of the Rectangle.

    y + + +number + + + +

    The y coordinate of the top-left corner of the Rectangle.

    width + + +number + + + +

    The width of the Rectangle in pixels.

    height + + +number + + + +

    The height of the Rectangle in pixels.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    This Rectangle object

    +
    + + + +
    +
    + Type +
    +
    + +Rectangle + + +
    +
    + + + + + +
    + + + +
    +

    size(output) → {Phaser.Point}

    + + +
    +
    + + +
    +

    The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    output + + +Phaser.Point + + + + + + <optional>
    + + + + + +

    Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The size of the Rectangle object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    toString() → {string}

    + + +
    +
    + + +
    +

    Returns a string representation of this object.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A string representation of the instance.

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + + + +
    +

    union(b, out) → {Phaser.Rectangle}

    + + +
    +
    + + +
    +

    Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    b + + +Phaser.Rectangle + + + + + + + + + +

    The second Rectangle object.

    out + + +Phaser.Rectangle + + + + + + <optional>
    + + + + + +

    Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A Rectangle object that is the union of the two Rectangles.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Rectangle + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:30 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.RenderTexture.html b/docs/Phaser.RenderTexture.html new file mode 100644 index 00000000..62ab2199 --- /dev/null +++ b/docs/Phaser.RenderTexture.html @@ -0,0 +1,1392 @@ + + + + + + Phaser Class: RenderTexture + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: RenderTexture

    +
    + +
    +

    + Phaser. + + RenderTexture +

    + +

    Phaser.RenderTexture

    + +
    + +
    +
    + + + + +
    +

    new RenderTexture(game, key, width, height)

    + + +
    +
    + + +
    +

    A dynamic initially blank canvas to which images can be drawn

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Current game instance.

    key + + +string + + + +

    Asset key for the render texture.

    width + + +number + + + +

    the width of the render texture.

    height + + +number + + + +

    the height of the render texture.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    frame

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    frame + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    height

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    height + + +number + + + +

    the height.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    indetityMatrix

    + + +
    +
    + +
    +

    I know this has a typo in it, but it's because the PIXI.RenderTexture does and we need to pair-up with it +once they update pixi to fix the typo, we'll fix it here too :)

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    indetityMatrix + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    name

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    the name of the object.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    width

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    the width.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:30 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.RequestAnimationFrame.html b/docs/Phaser.RequestAnimationFrame.html new file mode 100644 index 00000000..29f60417 --- /dev/null +++ b/docs/Phaser.RequestAnimationFrame.html @@ -0,0 +1,1316 @@ + + + + + + Phaser Class: RequestAnimationFrame + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: RequestAnimationFrame

    +
    + +
    +

    + Phaser. + + RequestAnimationFrame +

    + +

    Phaser.RequestAnimationFrame

    + +
    + +
    +
    + + + + +
    +

    new RequestAnimationFrame(game)

    + + +
    +
    + + +
    +

    Abstracts away the use of RAF or setTimeOut for the core game update loop.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    The currently running game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isRunning

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isRunning + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    isRAF() → {boolean}

    + + +
    +
    + + +
    +

    Is the browser using requestAnimationFrame?

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    isSetTimeOut() → {boolean}

    + + +
    +
    + + +
    +

    Is the browser using setTimeout?

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    start()

    + + +
    +
    + + +
    +

    Starts the requestAnimatioFrame running or setTimeout if unavailable in browser

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stop()

    + + +
    +
    + + +
    +

    Stops the requestAnimationFrame from running.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    updateRAF(time)

    + + +
    +
    + + +
    +

    The update method for the requestAnimationFrame

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    time + + +number + + + +

    A timestamp, either from RAF or setTimeOut

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    updateSetTimeout()

    + + +
    +
    + + +
    +

    The update method for the setTimeout.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:30 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Signal.html b/docs/Phaser.Signal.html new file mode 100644 index 00000000..c2a4313e --- /dev/null +++ b/docs/Phaser.Signal.html @@ -0,0 +1,2301 @@ + + + + + + Phaser Class: Signal + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Signal

    +
    + +
    +

    + Phaser. + + Signal +

    + +

    A Signal is used for object communication via a custom broadcaster instead of Events.

    + +
    + +
    +
    + + + + +
    +

    new Signal()

    + + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + +
    Author:
    +
    +
      +
    • Miller Medeiros http://millermedeiros.github.com/js-signals/
    • +
    +
    + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    active

    + + +
    +
    + +
    +

    If Signal is active and should broadcast events.

    +

    <p><strong>IMPORTANT:</strong> Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use halt() instead.</p>

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    active + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    memorize

    + + +
    +
    + +
    +

    If Signal should keep record of previously dispatched parameters and +automatically execute listener during add()/addOnce() if Signal was +already dispatched before.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    memorize + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    add(listener, listenerContext, priority) → {Phaser.SignalBinding}

    + + +
    +
    + + +
    +

    Add a listener to the signal.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    listener + + +function + + + + + + + + + +

    Signal handler function.

    listenerContext + + +object + + + + + + <optional>
    + + + + + +

    Context on which listener will be executed (object that should represent the this variable inside listener function).

    priority + + +number + + + + + + <optional>
    + + + + + +

    The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    An Object representing the binding between the Signal and listener.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.SignalBinding + + +
    +
    + + + + + +
    + + + +
    +

    addOnce(listener, listenerContext, priority) → {Phaser.SignalBinding}

    + + +
    +
    + + +
    +

    Add listener to the signal that should be removed after first execution (will be executed only once).

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    listener + + +function + + + + + + + + + +

    Signal handler function.

    listenerContext + + +object + + + + + + <optional>
    + + + + + +

    Context on which listener will be executed (object that should represent the this variable inside listener function).

    priority + + +number + + + + + + <optional>
    + + + + + +

    The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    An Object representing the binding between the Signal and listener.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.SignalBinding + + +
    +
    + + + + + +
    + + + +
    +

    dispatch(params)

    + + +
    +
    + + +
    +

    Dispatch/Broadcast Signal to all listeners added to the queue.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    params + + +any + + + + + + <optional>
    + + + + + +

    Parameters that should be passed to each handler.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    dispatch()

    + + +
    +
    + + + + + + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    dispatch + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    dispose()

    + + +
    +
    + + +
    +

    Remove all bindings from signal and destroy any reference to external objects (destroy Signal object).

    +

    <p><strong>IMPORTANT:</strong> calling any method on the signal instance after calling dispose will throw errors.</p>

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    forget()

    + + +
    +
    + + +
    +

    Forget memorized arguments.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + +
    See:
    +
    +
      +
    • Signal.memorize
    • +
    +
    + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    getNumListeners() → {number}

    + + +
    +
    + + +
    +

    Gets the total number of listeneres attached to ths Signal.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Number of listeners attached to the Signal.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    halt()

    + + +
    +
    + + +
    +

    Stop propagation of the event, blocking the dispatch to next listeners on the queue.

    +

    <p><strong>IMPORTANT:</strong> should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.</p>

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + +
    See:
    +
    +
      +
    • Signal.prototype.disable
    • +
    +
    + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    has(listener, context) → {boolean}

    + + +
    +
    + + +
    +

    Check if listener was attached to Signal.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    listener + + +function + + + + + + + + + +

    Signal handler function.

    context + + +Object + + + + + + <optional>
    + + + + + +

    Context on which listener will be executed (object that should represent the this variable inside listener function).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    If Signal has the specified listener.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    remove(listener, context) → {function}

    + + +
    +
    + + +
    +

    Remove a single listener from the dispatch queue.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    listener + + +function + + + + + + + + + +

    Handler function that should be removed.

    context + + +object + + + + + + <optional>
    + + + + + +

    Execution context (since you can add the same handler multiple times if executing in a different context).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Listener handler function.

    +
    + + + +
    +
    + Type +
    +
    + +function + + +
    +
    + + + + + +
    + + + +
    +

    removeAll()

    + + +
    +
    + + +
    +

    Remove all listeners from the Signal.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    toString() → {string}

    + + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    String representation of the object.

    +
    + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:30 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Sound.html b/docs/Phaser.Sound.html new file mode 100644 index 00000000..c22be39b --- /dev/null +++ b/docs/Phaser.Sound.html @@ -0,0 +1,5734 @@ + + + + + + Phaser Class: Sound + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Sound

    +
    + +
    +

    + Phaser. + + Sound +

    + +

    The Sound class

    + +
    + +
    +
    + + + + +
    +

    new Sound(game, key, volume, loop)

    + + +
    +
    + + +
    +

    The Sound class constructor.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    game + + +Phaser.Game + + + + + + + + + + + +

    Reference to the current game instance.

    key + + +string + + + + + + + + + + + +

    Asset key for the sound.

    volume + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    Default value for the volume, between 0 and 1.

    loop + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Whether or not the sound will loop.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    context

    + + +
    +
    + +
    +

    Reference to AudioContext instance.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    context + + +AudioContext + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    currentMarker

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    currentMarker + + +string + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    currentTime

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    currentTime + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    duration

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    duration + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + +
    +

    A reference to the currently running Game.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> isDecoded

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isDecoded + + +boolean + + + +

    Returns true if the sound file has decoded.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> isDecoding

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isDecoding + + +boolean + + + +

    Returns true if the sound file is still decoding.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isPlaying

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isPlaying + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    key

    + + +
    +
    + +
    +

    Asset key for the sound.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    loop

    + + +
    +
    + +
    +

    Whether or not the sound will loop.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    loop + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    markers

    + + +
    +
    + +
    +

    The sound markers, empty by default.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    markers + + +object + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mute

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mute + + +boolean + + + +

    Gets or sets the muted state of this sound.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    name

    + + +
    +
    + +
    +

    Name of the sound.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • key
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onDecoded

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onDecoded + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onLoop

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onLoop + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onMarkerComplete

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onMarkerComplete + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onMute

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onMute + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onPause

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onPause + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onPlay

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onPlay + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onResume

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onResume + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onStop

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onStop + + +Phaser.Signal + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    override

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    override + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    paused

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    paused + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pausedPosition

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pausedPosition + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pausedTime

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pausedTime + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pendingPlayback

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pendingPlayback + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    startTime

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    startTime + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    stopTime

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    stopTime + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    totalDuration

    + + +
    +
    + +
    +

    The total duration of the sound, in milliseconds

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    totalDuration + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    usingAudioTag

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    usingAudioTag + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    usingWebAudio

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    usingWebAudio + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> volume

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    volume + + +number + + + +

    Gets or sets the volume of this sound, a value between 0 and 1.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    addMarker(name, start, stop, volume, loop)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    Description.

    start + + +Description + + + +

    Description.

    stop + + +Description + + + +

    Description.

    volume + + +Description + + + +

    Description.

    loop + + +Description + + + +

    Description. + addMarker: function (name, start, stop, volume, loop) {

    +
        volume = volume || 1;
    +    if (typeof loop == 'undefined') { loop = false; }
    +
    +    this.markers[name] = {
    +        name: name,
    +        start: start,
    +        stop: stop,
    +        volume: volume,
    +        duration: stop - start,
    +        loop: loop
    +    };
    +
    +},
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    addMarker(name, start, duration, volume, loop)

    + + +
    +
    + + +
    +

    Adds a marker into the current Sound. A marker is represented by a unique key and a start time and duration. +This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    name + + +string + + + + + + + + + + + +

    A unique name for this marker, i.e. 'explosion', 'gunshot', etc.

    start + + +number + + + + + + + + + + + +

    The start point of this marker in the audio file, given in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.

    duration + + +number + + + + + + + + + + + +

    The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.

    volume + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    The volume the sound will play back at, between 0 (silent) and 1 (full volume).

    loop + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Sets if the sound will loop or not.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    pause()

    + + +
    +
    + + +
    +

    Pauses the sound

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    play(marker, position, volume, loop, forceRestart) → {Sound}

    + + +
    +
    + + +
    +

    Play this sound, or a marked section of it.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    marker + + +string + + + + + + <optional>
    + + + + + +
    + + '' + +

    If you want to play a marker then give the key here, otherwise leave blank to play the full sound.

    position + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The starting position to play the sound from - this is ignored if you provide a marker.

    volume + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    Volume of the sound you want to play.

    loop + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Loop when it finished playing?

    forceRestart + + +boolean + + + + + + <optional>
    + + + + + +
    + + true + +

    If the sound is already playing you can set forceRestart to restart it from the beginning.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The playing sound object.

    +
    + + + +
    +
    + Type +
    +
    + +Sound + + +
    +
    + + + + + +
    + + + +
    +

    removeMarker(name)

    + + +
    +
    + + +
    +

    Removes a marker from the sound.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    The key of the marker to remove.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    restart(marker, position, volume, loop)

    + + +
    +
    + + +
    +

    Restart the sound, or a marked section of it.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    marker + + +string + + + + + + <optional>
    + + + + + +
    + + '' + +

    If you want to play a marker then give the key here, otherwise leave blank to play the full sound.

    position + + +number + + + + + + <optional>
    + + + + + +
    + + 0 + +

    The starting position to play the sound from - this is ignored if you provide a marker.

    volume + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    Volume of the sound you want to play.

    loop + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Loop when it finished playing?

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    resume()

    + + +
    +
    + + +
    +

    Resumes the sound

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> soundHasUnlocked(key)

    + + +
    +
    + + +
    +

    Called automatically when this sound is unlocked.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stop()

    + + +
    +
    + + +
    +

    Stop playing this sound.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> update()

    + + +
    +
    + + +
    +

    Called automatically by Phaser.SoundManager.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:30 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.SoundManager.html b/docs/Phaser.SoundManager.html new file mode 100644 index 00000000..7c994610 --- /dev/null +++ b/docs/Phaser.SoundManager.html @@ -0,0 +1,2433 @@ + + + + + + Phaser Class: SoundManager + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: SoundManager

    +
    + +
    +

    + Phaser. + + SoundManager +

    + +

    Phaser Sound Manager.

    + +
    + +
    +
    + + + + +
    +

    new SoundManager(game)

    + + +
    +
    + + +
    +

    Sound Manager constructor.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    reference to the current game instance.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    channels

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    channels + + +number + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 32
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    context

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    context + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    mute

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    mute + + +boolean + + + +

    Gets or sets the muted state of the SoundManager. This effects all sounds in the game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    noAudio

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    noAudio + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onSoundDecode

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onSoundDecode + + +Phaser.Signal + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    touchLocked

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    touchLocked + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    usingAudioTag

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    usingAudioTag + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    usingWebAudio

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    usingWebAudio + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    volume

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    volume + + +number + + + +

    Gets or sets the global volume of the SoundManager, a value between 0 and 1.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    add(key, volume, loop)

    + + +
    +
    + + +
    +

    Adds a new Sound into the SoundManager.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    key + + +string + + + + + + + + + + + +

    Asset key for the sound.

    volume + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    Default value for the volume.

    loop + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Whether or not the sound will loop.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> boot()

    + + +
    +
    + + +
    +

    Initialises the sound manager.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    decode(key, sound)

    + + +
    +
    + + +
    +

    Decode a sound by its assets key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    key + + +string + + + + + + + + + +

    Assets key of the sound to be decoded.

    sound + + +Phaser.Sound + + + + + + <optional>
    + + + + + +

    Its buffer will be set to decoded data.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    pauseAll()

    + + +
    +
    + + +
    +

    Pauses all the sounds in the game.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    resumeAll()

    + + +
    +
    + + +
    +

    resumes every sound in the game.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stopAll()

    + + +
    +
    + + +
    +

    Stops all the sounds in the game.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    unlock()

    + + +
    +
    + + +
    +

    Enables the audio, usually after the first touch.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    update()

    + + +
    +
    + + +
    +

    Updates every sound in the game.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:30 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Sprite.html b/docs/Phaser.Sprite.html new file mode 100644 index 00000000..a1212293 --- /dev/null +++ b/docs/Phaser.Sprite.html @@ -0,0 +1,7739 @@ + + + + + + Phaser Class: Sprite + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Sprite

    +
    + +
    +

    + Phaser. + + Sprite +

    + +

    Phaser.Sprite

    + +
    + +
    +
    + + + + +
    +

    new Sprite(game, x, y, key, frame)

    + + +
    +
    + + +
    +

    Create a new Sprite object. Sprites are the lifeblood of your game, used for nearly everything visual. +At its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas. +They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input), +events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    x + + +number + + + +

    The x coordinate (in world space) to position the Sprite at.

    y + + +number + + + +

    The y coordinate (in world space) to position the Sprite at.

    key + + +string +| + +Phaser.RenderTexture +| + +PIXI.Texture + + + +

    This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.

    frame + + +string +| + +number + + + +

    If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    alive

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    alive + + +boolean + + + +

    This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    anchor

    + + +
    +
    + +
    +

    The anchor sets the origin point of the texture. +The default is 0,0 this means the textures origin is the top left +Setting than anchor to 0.5,0.5 means the textures origin is centered +Setting the anchor to 1,1 would mean the textures origin points will be the bottom right

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    anchor + + +Phaser.Point + + + +

    The anchor around with Sprite rotation and scaling takes place.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    angle

    + + +
    +
    + +
    +

    Indicates the rotation of the Sprite, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. +Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90. +If you wish to work in radians instead of degrees use the property Sprite.rotation instead.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    angle + + +number + + + +

    Gets or sets the Sprites angle of rotation in degrees.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    animations

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    animations + + +Phaser.AnimationManager + + + +

    This manages animations of the sprite. You can modify animations through it (see Phaser.AnimationManager)

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    autoCull

    + + +
    +
    + +
    +

    Should this Sprite be automatically culled if out of range of the camera? +A culled sprite has its renderable property set to 'false'.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    autoCull + + +boolean + + + +

    A flag indicating if the Sprite should be automatically camera culled or not.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    body

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    body + + +Phaser.Physics.Arcade.Body + + + +

    By default Sprites have a Phaser.Physics Body attached to them. You can operate physics actions via this property, or null it to skip all physics updates.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bottomLeft

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bottomLeft + + +Phaser.Point + + + +

    A Point containing the bottom left coordinate of the Sprite. Takes rotation and scale into account.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bottomRight

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bottomRight + + +Phaser.Point + + + +

    A Point containing the bottom right coordinate of the Sprite. Takes rotation and scale into account.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    bounds

    + + +
    +
    + +
    +

    This Rectangle object fully encompasses the Sprite and is updated in real-time. +The bounds is the full bounding area after rotation and scale have been taken into account. It should not be modified directly. +It's used for Camera culling and physics body alignment.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bounds + + +Phaser.Rectangle + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    center

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    center + + +Phaser.Point + + + +

    A Point containing the center coordinate of the Sprite. Takes rotation and scale into account.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    crop

    + + +
    +
    + +
    +

    You can crop the Sprites texture by modifying the crop properties. For example crop.width = 50 would set the Sprite to only render 50px wide. +The crop is only applied if you have set Sprite.cropEnabled to true.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    crop + + +Phaser.Rectangle + + + +

    The crop Rectangle applied to the Sprite texture before rendering.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    cropEnabled

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    cropEnabled + + +boolean + + + +

    If true the Sprite.crop property is used to crop the texture before render. Set to false to disable.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    currentFrame

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    currentFrame + + +Phaser.Frame + + + +

    A reference to the currently displayed frame.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    events

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    events + + +Events + + + +

    The Events you can subscribe to that are dispatched when certain things happen on this Sprite or its components.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    exists

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    exists + + +boolean + + + +

    If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    fixedToCamera

    + + +
    +
    + +
    +

    A Sprite that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    fixedToCamera + + +boolean + + + +

    Fixes this Sprite to the Camera.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    frame

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    frame + + +number + + + +

    Gets or sets the current frame index and updates the Texture Cache for display.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    frameName

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    frameName + + +string + + + +

    Gets or sets the current frame name and updates the Texture Cache for display.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    group

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    group + + +Phaser.Group + + + +

    The parent Group of this Sprite. This is usually set after Sprite instantiation by the parent.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    health

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    health + + +number + + + +

    Health value. Used in combination with damage() to allow for quick killing of Sprites.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    height

    + + +
    +
    + +
    +

    The height of the sprite in pixels, setting this will actually modify the scale to acheive the value desired. +If you wish to crop the Sprite instead see the Sprite.crop value.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    height + + +number + + + +

    The height of the Sprite in pixels.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> inCamera

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    inCamera + + +boolean + + + +

    Is this sprite visible to the camera or not?

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    input

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    input + + +InputHandler + + + +

    The Input Handler Component.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    inputEnabled

    + + +
    +
    + +
    +

    By default a Sprite won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is +activated for this Sprite instance and it will then start to process click/touch events and more.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    inputEnabled + + +boolean + + + +

    Set to true to allow this Sprite to receive input events, otherwise false.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    inWorld

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    inWorld + + +boolean + + + +

    This value is set to true if the Sprite is positioned within the World, otherwise false.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    inWorldThreshold

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    inWorldThreshold + + +number + + + +

    A threshold value applied to the inWorld check. If you don't want a Sprite to be considered "out of the world" until at least 100px away for example then set it to 100.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    key

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string +| + +Phaser.RenderTexture +| + +PIXI.Texture + + + +

    This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    lifespan

    + + +
    +
    + +
    +

    If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc. +The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    lifespan + + +number + + + +

    The lifespan of the Sprite (in ms) before it will be killed.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    name

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    The user defined name given to this Sprite.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    offset

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    offset + + +Phaser.Point + + + +

    Corner point defaults. Should not typically be modified.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    outOfBoundsKill

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    outOfBoundsKill + + +boolean + + + +

    If true the Sprite is killed as soon as Sprite.inWorld is false.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    renderOrderID

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    renderOrderID + + +number + + + +

    Used by the Renderer and Input Manager to control picking order.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    scale

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    scale + + +Phaser.Point + + + +

    The scale of the Sprite when rendered. By default it's set to 1 (no scale). You can modify it via scale.x or scale.y or scale.setTo(x, y). A value of 1 means no change to the scale, 0.5 means "half the size", 2 means "twice the size", etc.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    topLeft

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    topLeft + + +Phaser.Point + + + +

    A Point containing the top left coordinate of the Sprite. Takes rotation and scale into account.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    topRight

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    topRight + + +Phaser.Point + + + +

    A Point containing the top right coordinate of the Sprite. Takes rotation and scale into account.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +number + + + +

    The const type of this object.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    width

    + + +
    +
    + +
    +

    The width of the sprite in pixels, setting this will actually modify the scale to acheive the value desired. +If you wish to crop the Sprite instead see the Sprite.crop value.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    The width of the Sprite in pixels.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    x

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The x coordinate (in world space) of this Sprite.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    y

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    y + + +number + + + +

    The y coordinate (in world space) of this Sprite.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    bringToTop()

    + + +
    +
    + + +
    +

    Brings the Sprite to the top of the display list it is a child of. Sprites that are members of a Phaser.Group are only +bought to the top of that Group, not the entire display list.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    (Phaser.Sprite) This instance.

    +
    + + + + + + + +
    + + + +
    +

    centerOn(x, y)

    + + +
    +
    + + +
    +

    Moves the sprite so its center is located on the given x and y coordinates. +Doesn't change the anchor point of the sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The x coordinate (in world space) to position the Sprite at.

    y + + +number + + + +

    The y coordinate (in world space) to position the Sprite at.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    (Phaser.Sprite) This instance.

    +
    + + + + + + + +
    + + + +
    +

    damage(amount)

    + + +
    +
    + + +
    +

    Damages the Sprite, this removes the given amount from the Sprites health property. +If health is then taken below zero Sprite.kill is called.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    amount + + +number + + + +

    The amount to subtract from the Sprite.health value.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    (Phaser.Sprite) This instance.

    +
    + + + + + + + +
    + + + +
    +

    deltaAbsX() → {number}

    + + +
    +
    + + +
    +

    Returns the absolute delta x value.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The absolute delta value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    deltaAbsY() → {number}

    + + +
    +
    + + +
    +

    Returns the absolute delta y value.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The absolute delta value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    deltaX() → {number}

    + + +
    +
    + + +
    +

    Returns the delta x value.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The delta value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    deltaY() → {number}

    + + +
    +
    + + +
    +

    Returns the delta y value.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The delta value.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Destroys the Sprite. This removes it from its parent group, destroys the input, event and animation handlers if present +and nulls its reference to game, freeing it up for garbage collection.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    getLocalPosition(p, x, y, sx, sy) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Gets the local position of a coordinate relative to the Sprite, factoring in rotation and scale. +Mostly only used internally.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    p + + +Phaser.Point + + + +

    The Point object to store the results in.

    x + + +number + + + +

    x coordinate within the Sprite to translate.

    y + + +number + + + +

    x coordinate within the Sprite to translate.

    sx + + +number + + + +

    Scale factor to be applied.

    sy + + +number + + + +

    Scale factor to be applied.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The translated point.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    getLocalUnmodifiedPosition(p, x, y) → {Phaser.Point}

    + + +
    +
    + + +
    +

    Gets the local unmodified position of a coordinate relative to the Sprite, factoring in rotation and scale. +Mostly only used internally by the Input Manager, but also useful for custom hit detection.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    p + + +Phaser.Point + + + +

    The Point object to store the results in.

    x + + +number + + + +

    x coordinate within the Sprite to translate.

    y + + +number + + + +

    x coordinate within the Sprite to translate.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The translated point.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Point + + +
    +
    + + + + + +
    + + + +
    +

    kill()

    + + +
    +
    + + +
    +

    Kills a Sprite. A killed Sprite has its alive, exists and visible properties all set to false. +It will dispatch the onKilled event, you can listen to Sprite.events.onKilled for the signal. +Note that killing a Sprite is a way for you to quickly recycle it in a Sprite pool, it doesn't free it up from memory. +If you don't need this Sprite any more you should call Sprite.destroy instead.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    (Phaser.Sprite) This instance.

    +
    + + + + + + + +
    + + + +
    +

    loadTexture(key, frame)

    + + +
    +
    + + +
    +

    Changes the Texture the Sprite is using entirely. The old texture is removed and the new one is referenced or fetched from the Cache. +This causes a WebGL texture update, so use sparingly or in low-intensity portions of your game.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string +| + +Phaser.RenderTexture +| + +PIXI.Texture + + + +

    This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.

    frame + + +string +| + +number + + + +

    If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    play(name, frameRate, loop, killOnComplete) → {Phaser.Animation}

    + + +
    +
    + + +
    +

    Play an animation based on the given key. The animation should previously have been added via sprite.animations.add() +If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    name + + +string + + + + + + + + + + + +

    The name of the animation to be played, e.g. "fire", "walk", "jump".

    frameRate + + +number + + + + + + <optional>
    + + + + + +
    + + null + +

    The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.

    loop + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.

    killOnComplete + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    A reference to playing Animation instance.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Animation + + +
    +
    + + + + + +
    + + + +
    +

    postUpdate()

    + + +
    +
    + + +
    +

    Internal function called by the World postUpdate cycle.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    preUpdate()

    + + +
    +
    + + +
    +

    Automatically called by World.preUpdate. You can create your own update in Objects that extend Phaser.Sprite.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    preUpdate()

    + + +
    +
    + + +
    +

    Automatically called by World.preUpdate. Handles cache updates, lifespan checks, animation updates and physics updates.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    reset()

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    reset(x, y, health)

    + + +
    +
    + + +
    +

    Resets the Sprite. This places the Sprite at the given x/y world coordinates and then +sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state and health values. +If the Sprite has a physics body that too is reset.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    x + + +number + + + + + + + + + + + +

    The x coordinate (in world space) to position the Sprite at.

    y + + +number + + + + + + + + + + + +

    The y coordinate (in world space) to position the Sprite at.

    health + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    The health to give the Sprite.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    (Phaser.Sprite) This instance.

    +
    + + + + + + + +
    + + + +
    +

    resetCrop()

    + + +
    +
    + + +
    +

    Resets the Sprite.crop value back to the frame dimensions.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    revive(health)

    + + +
    +
    + + +
    +

    Brings a 'dead' Sprite back to life, optionally giving it the health value specified. +A resurrected Sprite has its alive, exists and visible properties all set to true. +It will dispatch the onRevived event, you can listen to Sprite.events.onRevived for the signal.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    health + + +number + + + + + + <optional>
    + + + + + +
    + + 1 + +

    The health to give the Sprite.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    (Phaser.Sprite) This instance.

    +
    + + + + + + + +
    + + + +
    +

    updateAnimation()

    + + +
    +
    + + +
    +

    Internal function called by preUpdate.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    updateBounds()

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    updateBounds()

    + + +
    +
    + + +
    +

    Internal function called by preUpdate.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    updateCache()

    + + +
    +
    + + +
    +

    Internal function called by preUpdate.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    updateCrop()

    + + +
    +
    + + +
    +

    Internal function called by preUpdate.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:30 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Stage.html b/docs/Phaser.Stage.html new file mode 100644 index 00000000..87fb6ae4 --- /dev/null +++ b/docs/Phaser.Stage.html @@ -0,0 +1,1667 @@ + + + + + + Phaser Class: Stage + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Stage

    +
    + +
    +

    + Phaser. + + Stage +

    + +

    Phaser.Stage

    + +
    + +
    +
    + + + + +
    +

    new Stage(game, width, height)

    + + +
    +
    + + +
    +

    The Stage controls the canvas on which everything is displayed. It handles display within the browser, +focus handling, game resizing, scaling and the pause, boot and orientation screens.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Game reference to the currently running game.

    width + + +number + + + +

    Width of the canvas element.

    height + + +number + + + +

    Height of the canvas element.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    aspectRatio

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    aspectRatio + + +number + + + +

    Aspect ratio.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    backgroundColor

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    paused + + +number +| + +string + + + +

    Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000'

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    canvas

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    canvas + + +HTMLCanvasElement + + + +

    Reference to the newly created <canvas> element.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    checkOffsetInterval

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    checkOffsetInterval + + +number +| + +false + + + +

    The time (in ms) between which the stage should check to see if it has moved.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 2500
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    offset

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    offset + + +Phaser.Point + + + +

    Get the offset values (for input and other things).

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    scale

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    scale + + +Phaser.StageScaleMode + + + +

    The scale of the current running game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    scaleMode

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    scaleMode + + +number + + + +

    The current scaleMode.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    update()

    + + +
    +
    + + +
    +

    Runs Stage processes that need periodic updates, such as the offset checks.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    visibilityChange(event)

    + + +
    +
    + + +
    +

    This method is called when the document visibility is changed.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Event + + + +

    Its type will be used to decide whether the game should be paused or not.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:31 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.StageScaleMode.html b/docs/Phaser.StageScaleMode.html new file mode 100644 index 00000000..45c915d4 --- /dev/null +++ b/docs/Phaser.StageScaleMode.html @@ -0,0 +1,3827 @@ + + + + + + Phaser Class: StageScaleMode + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: StageScaleMode

    +
    + +
    +

    + Phaser. + + StageScaleMode +

    + +

    Phaser.StageScaleMode

    + +
    + +
    +
    + + + + +
    +

    new StageScaleMode(game, width, height)

    + + +
    +
    + + +
    +

    An Animation instance contains a single animation and the controls to play it. +It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    width + + +number + + + +

    Description.

    height + + +number + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    <static, constant> EXACT_FIT :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> NO_SCALE :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <static, constant> SHOW_ALL :number

    + + +
    +
    + + + +
    Type:
    +
      +
    • + +number + + +
    • +
    + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    aspectRatio

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    aspectRatio + + +number + + + +

    Aspect ratio.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    enterLandscape

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    enterLandscape + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    enterPortrait

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    enterPortrait + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    forceLandscape

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    forceLandscape + + +boolean + + + +

    If the game should be forced to use Landscape mode, this is set to true by Game.Stage

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    forcePortrait

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    forcePortrait + + +boolean + + + +

    If the game should be forced to use Portrait mode, this is set to true by Game.Stage

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    height

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    height + + +number + + + +

    Height of the stage after calculation.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    incorrectOrientation

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    incorrectOrientation + + +boolean + + + +

    If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> isFullScreen

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isFullScreen + + +boolean + + + +

    Returns true if the browser is in full screen mode, otherwise false.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> isLandscape

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isLandscape + + +boolean + + + +

    Returns true if the browser dimensions match a landscape display.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> isPortrait

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isPortrait + + +boolean + + + +

    Returns true if the browser dimensions match a portrait display.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxHeight

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxHeight + + +number + + + +

    Maximum height the canvas should be scaled to (in pixels). +If null it will scale to whatever height the browser can handle.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxIterations

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxIterations + + +number + + + +

    The maximum number of times it will try to resize the canvas to fill the browser.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 5
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    maxWidth

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    maxWidth + + +number + + + +

    Maximum width the canvas should be scaled to (in pixels). +If null it will scale to whatever width the browser can handle.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    minHeight

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    minHeight + + +number + + + +

    Minimum height the canvas should be scaled to (in pixels).

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    minWidth

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    minWidth + + +number + + + +

    Minimum width the canvas should be scaled to (in pixels).

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pageAlignHorizontally

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pageAlignHorizontally + + +boolean + + + +

    If you wish to align your game in the middle of the page then you can set this value to true. + <ul><li>It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.</li> + <li>It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.</li></ul>

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pageAlignVertically

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pageAlignVertically + + +boolean + + + +

    If you wish to align your game in the middle of the page then you can set this value to true. + <ul><li>It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. + <li>It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.</li></ul>

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    scaleFactor

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    scaleFactor + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    width

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    Width of the stage after calculation.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    checkOrientation(event)

    + + +
    +
    + + +
    +

    Handle window.orientationchange events

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Event + + + +

    The orientationchange event data.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    checkOrientationState()

    + + +
    +
    + + +
    +

    Checks if the browser is in the correct orientation for your game (if forceLandscape or forcePortrait have been set)

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    checkResize(event)

    + + +
    +
    + + +
    +

    Handle window.resize events

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Event + + + +

    The resize event data.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    refresh()

    + + +
    +
    + + +
    +

    Re-calculate scale mode and update screen size.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setExactFit()

    + + +
    +
    + + +
    +

    Sets the width and height values of the canvas, no larger than the maxWidth/Height.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setMaximum()

    + + +
    +
    + + +
    +

    Sets this.width equal to window.innerWidth and this.height equal to window.innerHeight

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setScreenSize(force)

    + + +
    +
    + + +
    +

    Set screen size automatically based on the scaleMode.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    force + + +Description + + + +

    If force is true it will try to resize the game regardless of the document dimensions.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setShowAll()

    + + +
    +
    + + +
    +

    Calculates the multiplier needed to scale the game proportionally.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setSize()

    + + +
    +
    + + +
    +

    Sets the canvas style width and height values based on minWidth/Height and maxWidth/Height.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    startFullScreen()

    + + +
    +
    + + +
    +

    Tries to enter the browser into full screen mode. +Please note that this needs to be supported by the web browser and isn't the same thing as setting your game to fill the browser.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stopFullScreen()

    + + +
    +
    + + +
    +

    Stops full screen mode if the browser is in it.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:31 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.State.html b/docs/Phaser.State.html new file mode 100644 index 00000000..37679159 --- /dev/null +++ b/docs/Phaser.State.html @@ -0,0 +1,2581 @@ + + + + + + Phaser Class: State + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: State

    +
    + +
    +

    + Phaser. + + State +

    + +

    Phaser.State

    + +
    + +
    +
    + + + + +
    +

    new State()

    + + +
    +
    + + +
    +

    This is a base State class which can be extended if you are creating your own game. +It provides quick access to common functions such as the camera, cache, input, match, sound and more.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    add

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    add + + +Phaser.GameObjectFactory + + + +

    Reference to the GameObjectFactory.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    cache

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    cache + + +Phaser.Cache + + + +

    Reference to the assets cache.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    camera

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    camera + + +Phaser.Physics.PhysicsManager + + + +

    A handy reference to world.camera.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    input

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    input + + +Phaser.Input + + + +

    Reference to the input manager

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    load

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    load + + +Phaser.Loader + + + +

    Reference to the assets loader.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    math

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    math + + +Phaser.GameMath + + + +

    Reference to the math helper.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    particles

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    add + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    physics

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    physics + + +Phaser.Physics.PhysicsManager + + + +

    Reference to the physics manager.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    sound

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    sound + + +Phaser.SoundManager + + + +

    Reference to the sound manager.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    stage

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    stage + + +Phaser.Stage + + + +

    Reference to the stage.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    time

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    time + + +Phaser.TimeManager + + + +

    Reference to game clock.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    tweens

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    tweens + + +Phaser.TweenManager + + + +

    Reference to the tween manager.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    world

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    world + + +Phaser.World + + + +

    Reference to the world.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    create()

    + + +
    +
    + + +
    +

    This method is called after the game engine successfully switches states. +Feel free to add any setup code here (do not load anything here, override preload() instead).

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    This method will be called when the state is destroyed.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    loadRender()

    + + +
    +
    + + +
    +

    Put render operations here.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    loadUpdate()

    + + +
    +
    + + +
    +

    Put update logic here.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    paused()

    + + +
    +
    + + +
    +

    This method will be called when game paused.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    preload()

    + + +
    +
    + + +
    +

    Override this method to add some load operations. +If you need to use the loader, you may need to use them here.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    render()

    + + +
    +
    + + +
    +

    Put render operations here.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    update()

    + + +
    +
    + + +
    +

    Put update logic here.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:31 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.StateManager.html b/docs/Phaser.StateManager.html new file mode 100644 index 00000000..42ce6ae7 --- /dev/null +++ b/docs/Phaser.StateManager.html @@ -0,0 +1,3438 @@ + + + + + + Phaser Class: StateManager + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: StateManager

    +
    + +
    +

    + Phaser. + + StateManager +

    + +

    Phaser.StateManager

    + +
    + +
    +
    + + + + +
    +

    new StateManager(game, pendingState)

    + + +
    +
    + + +
    +

    The State Manager is responsible for loading, setting up and switching game states.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    game + + +Phaser.Game + + + + + + + + + + + +

    A reference to the currently running game.

    pendingState + + +Phaser.State +| + +Object + + + + + + <optional>
    + + + + + +
    + + null + +

    A State object to seed the manager with.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    current

    + + +
    +
    + +
    +

    The current active State object (defaults to null).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    current + + +string + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + +
    +

    A reference to the currently running game.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game. + + +Phaser.Game + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + +
    +

    A reference to the currently running game.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game. + + +Phaser.Game + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onCreateCallback

    + + +
    +
    + +
    +

    This will be called when create states (setup states...).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onCreateCallback + + +function + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onInitCallback

    + + +
    +
    + +
    +

    This will be called when the state is started (i.e. set as the current active state).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onInitCallback + + +function + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onLoadRenderCallback

    + + +
    +
    + +
    +

    This will be called when the State is rendered but only during the load process.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onLoadRenderCallback + + +function + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onLoadUpdateCallback

    + + +
    +
    + +
    +

    This will be called when the State is updated but only during the load process.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onLoadUpdateCallback + + +function + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onPausedCallback

    + + +
    +
    + +
    +

    This will be called when states paused.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onPausedCallback + + +function + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onPreloadCallback

    + + +
    +
    + +
    +

    This will be called when init states (loading assets...).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onPreloadCallback + + +function + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onPreRenderCallback

    + + +
    +
    + +
    +

    This will be called before the State is rendered and before the stage is cleared.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onPreRenderCallback + + +function + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onRenderCallback

    + + +
    +
    + +
    +

    This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onRenderCallback + + +function + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onShutDownCallback

    + + +
    +
    + +
    +

    This will be called when the state is shut down (i.e. swapped to another state).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onShutDownCallback + + +function + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onUpdateCallback

    + + +
    +
    + +
    +

    This will be called when State is updated, this doesn't happen during load (@see onLoadUpdateCallback).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onUpdateCallback + + +function + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    states

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    states. + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    states

    + + +
    +
    + +
    +

    The state to be switched to in the next frame.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    states + + +Description + + + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    add(key, state, autoStart)

    + + +
    +
    + + +
    +

    Add a new State.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    A unique key you use to reference this state, i.e. "MainMenu", "Level1".

    state + + +State + + + +

    The state you want to switch to.

    autoStart + + +boolean + + + +

    Start the state immediately after creating it? (default true)

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    checkState(key) → {boolean}

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    The key of the state you want to check.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Description.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Nuke the entire game from orbit

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    + + + +
    +
    + + +
    +

    Links game properties to the State given by the key.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    State key.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> loadComplete()

    + + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> preRender()

    + + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    remove(key)

    + + +
    +
    + + +
    +

    Delete the given state.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    A unique key you use to reference this state, i.e. "MainMenu", "Level1".

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> render()

    + + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> setCurrentState(key)

    + + +
    +
    + + +
    +

    Sets the current State. Should not be called directly (use StateManager.start)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    key + + +string + + + +

    State key.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    start(key, clearWorld, clearCache)

    + + +
    +
    + + +
    +

    Start the given state

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    key + + +string + + + + + + + + + +

    The key of the state you want to start.

    clearWorld + + +boolean + + + + + + <optional>
    + + + + + +

    clear everything in the world? (Default to true)

    clearCache + + +boolean + + + + + + <optional>
    + + + + + +

    clear asset cache? (Default to false and ONLY available when clearWorld=true)

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    <protected> update()

    + + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:31 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Text.html b/docs/Phaser.Text.html new file mode 100644 index 00000000..142961c0 --- /dev/null +++ b/docs/Phaser.Text.html @@ -0,0 +1,1826 @@ + + + + + + Phaser Class: Text + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Text

    +
    + +
    +

    + Phaser. + + Text +

    + +

    Phaser.Text

    + +
    + +
    +
    + + + + +
    +

    new Text(game, x, y, text, style)

    + + +
    +
    + + +
    +

    Create a new <code>Text</code>.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Current game instance.

    x + + +number + + + +

    X position of the new text object.

    y + + +number + + + +

    Y position of the new text object.

    text + + +string + + + +

    The actual text that will be written.

    style + + +object + + + +

    The style object containing style attributes like font, font size ,

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    alive

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    alive + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    anchor

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    anchor + + +Phaser.Point + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    exists

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    exists + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    group

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    group + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    name

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    name + + +string + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    renderable

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    renderable + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    scale

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    scale + + +Phaser.Point + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    destroy()

    + + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    update()

    + + +
    +
    + + +
    +

    Automatically called by World.update.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:31 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.TileSprite.html b/docs/Phaser.TileSprite.html new file mode 100644 index 00000000..e07b7cae --- /dev/null +++ b/docs/Phaser.TileSprite.html @@ -0,0 +1,1159 @@ + + + + + + Phaser Class: TileSprite + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: TileSprite

    +
    + +
    +

    + Phaser. + + TileSprite +

    + +

    Phaser.Tilemap

    + +
    + +
    +
    + + + + +
    +

    new TileSprite(game, x, y, width, height, key, frame)

    + + +
    +
    + + +
    +

    Create a new <code>TileSprite</code>.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Current game instance.

    x + + +number + + + +

    X position of the new tileSprite.

    y + + +number + + + +

    Y position of the new tileSprite.

    width + + +number + + + +

    the width of the tilesprite.

    height + + +number + + + +

    the height of the tilesprite.

    key + + +string +| + +Phaser.RenderTexture +| + +PIXI.Texture + + + +

    This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.

    frame + + +string +| + +number + + + +

    If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    texture

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    texture + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    tilePosition

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    tilePosition + + +Point + + + +

    The offset position of the image that is being tiled.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    tileScale

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    tileScale + + +Point + + + +

    The scaling of the image that is being tiled.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    type

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    type + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:31 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Time.html b/docs/Phaser.Time.html new file mode 100644 index 00000000..38ea3d32 --- /dev/null +++ b/docs/Phaser.Time.html @@ -0,0 +1,2902 @@ + + + + + + Phaser Class: Time + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Time

    +
    + +
    +

    + Phaser. + + Time +

    + +

    This is the core internal game clock. It manages the elapsed time and calculation of elapsed values, used for game object motion and tweens.

    + +
    + +
    +
    + + + + +
    +

    new Time(game)

    + + +
    +
    + + +
    +

    Time constructor.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    _justResumed

    + + +
    +
    + +
    +

    Description.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    _justResumed + + +boolean + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    elapsed

    + + +
    +
    + +
    +

    Elapsed time since the last frame.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    elapsed + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    fps

    + + +
    +
    + +
    +

    Frames per second.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    fps + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    fpsMax

    + + +
    +
    + +
    +

    The highest rate the fps has reached (usually no higher than 60fps).

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    fpsMax + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    fpsMin

    + + +
    +
    + +
    +

    The lowest rate the fps has dropped to.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    fpsMin + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 1000
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    frames

    + + +
    +
    + +
    +

    The number of frames record in the last second.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    frames + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    lastTime

    + + +
    +
    + +
    +

    Internal value used by timeToCall as part of the setTimeout loop

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    lastTime + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    msMax

    + + +
    +
    + +
    +

    The maximum amount of time the game has taken between two frames.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    msMax + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    msMin

    + + +
    +
    + +
    +

    The minimum amount of time the game has taken between two frames.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    msMin + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 1000
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    now

    + + +
    +
    + +
    +

    The time right now.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    now + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pausedTime

    + + +
    +
    + +
    +

    Records how long the game has been paused for. Is reset each time the game pauses.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pausedTime + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pauseDuration

    + + +
    +
    + +
    +

    Records how long the game was paused for in miliseconds.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pauseDuration + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    physicsElapsed

    + + +
    +
    + +
    +

    The elapsed time calculated for the physics motion updates.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    physicsElapsed + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    time

    + + +
    +
    + +
    +

    Game time counter.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    time + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    timeToCall

    + + +
    +
    + +
    +

    The value that setTimeout needs to work out when to next update

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    timeToCall + + +number + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    elapsedSecondsSince(since) → {number}

    + + +
    +
    + + +
    +

    How long has passed since the given time (in seconds).

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    since + + +number + + + +

    The time you want to measure (in seconds).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Duration between given time and now (in seconds).

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    elapsedSince(since) → {number}

    + + +
    +
    + + +
    +

    How long has passed since the given time.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    since + + +number + + + +

    The time you want to measure against.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The difference between the given time and now.

    +
    + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    reset()

    + + +
    +
    + + +
    +

    Resets the private _started value to now.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    totalElapsedSeconds() → {number}

    + + +
    +
    + + +
    +

    The number of seconds that have elapsed since the game was started.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +number + + +
    +
    + + + + + +
    + + + +
    +

    update(time)

    + + +
    +
    + + +
    +

    Updates the game clock and calculate the fps. This is called automatically by Phaser.Game.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    time + + +number + + + +

    The current timestamp, either performance.now or Date.now depending on the browser.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:31 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Touch.html b/docs/Phaser.Touch.html new file mode 100644 index 00000000..2967411e --- /dev/null +++ b/docs/Phaser.Touch.html @@ -0,0 +1,2553 @@ + + + + + + Phaser Class: Touch + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Touch

    +
    + +
    +

    + Phaser. + + Touch +

    + +

    The Touch class handles touch interactions with the game and the resulting Pointer objects.

    + +
    + +
    +
    + + + + +
    +

    new Touch(game)

    + + +
    +
    + + +
    +

    Phaser.Touch handles touch events with your game. Note: Android 2.x only supports 1 touch event at once, no multi-touch.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    callbackContext

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callbackContext + + +Phaser.Game + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    preventDefault

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    preventDefault + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • true
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    touchCancelCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    touchCancelCallback + + +Description + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    touchEndCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    touchEndCallback + + +Phaser.Game + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    touchEnterCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    touchEnterCallback + + +Phaser.Game + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    touchLeaveCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    touchLeaveCallback + + +Phaser.Game + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    touchMoveCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    touchMoveCallback + + +Phaser.Game + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    touchStartCallback

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    touchStartCallback + + +Phaser.Game + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • null
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    consumeTouchMove()

    + + +
    +
    + + +
    +

    Consumes all touchmove events on the document (only enable this if you know you need it!).

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    disabled() → {boolean}

    + + +
    +
    + + +
    +

    You can disable all Input by setting disabled = true. While set all new input related events will be ignored.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    onTouchCancel(event)

    + + +
    +
    + + +
    +

    Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome). +Occurs for example on iOS when you put down 4 fingers and the app selector UI appears.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onTouchEnd(event)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onTouchEnter(event)

    + + +
    +
    + + +
    +

    For touch enter and leave its a list of the touch points that have entered or left the target. +Doesn't appear to be supported by most browsers on a canvas element yet.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onTouchLeave(event)

    + + +
    +
    + + +
    +

    For touch enter and leave its a list of the touch points that have entered or left the target. +Doesn't appear to be supported by most browsers on a canvas element yet.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onTouchMove(event)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    onTouchStart(event)

    + + +
    +
    + + +
    +

    Description.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    event + + +Any + + + +
    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    start()

    + + +
    +
    + + +
    +

    Starts the event listeners running.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stop()

    + + +
    +
    + + +
    +

    Stop the event listeners.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:31 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Tween.html b/docs/Phaser.Tween.html new file mode 100644 index 00000000..0712f3ac --- /dev/null +++ b/docs/Phaser.Tween.html @@ -0,0 +1,3259 @@ + + + + + + Phaser Class: Tween + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Tween

    +
    + +
    +

    + Phaser. + + Tween +

    + +

    Phaser.Tween

    + +
    + +
    +
    + + + + +
    +

    new Tween(object, game)

    + + +
    +
    + + +
    +

    Tween constructor +Create a new <code>Tween</code>.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    object + + +object + + + +

    Target object will be affected by this tween.

    game + + +Phaser.Game + + + +

    Current game instance.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    isRunning

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    isRunning + + +boolean + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onComplete

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onComplete + + +Phaser.Signal + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    onStart

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    onStart + + +Phaser.Signal + + + +

    Description.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    pendingDelete

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    pendingDelete + + +boolean + + + +

    If this tween is ready to be deleted by the TweenManager.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • false
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    chain() → {Phaser.Tween}

    + + +
    +
    + + +
    +

    You can chain tweens together by passing a reference to the chain function. This enables one tween to call another on completion. +You can pass as many tweens as you like to this function, they will each be chained in sequence.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    delay(amount) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Sets a delay time before this tween will start.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    amount + + +number + + + +

    The amount of the delay in ms.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    easing(easing) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Set easing function this tween will use, i.e. Phaser.Easing.Linear.None.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    easing + + +function + + + +

    The easing function this tween will use, i.e. Phaser.Easing.Linear.None.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    interpolation(interpolation) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Set interpolation function the tween will use, by default it uses Phaser.Math.linearInterpolation.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    interpolation + + +function + + + +

    The interpolation function to use (Phaser.Math.linearInterpolation by default)

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    loop() → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Loop a chain of tweens

    +

    Usage: +game.add.tween(p).to({ x: 700 }, 1000, Phaser.Easing.Linear.None, true) +.to({ y: 300 }, 1000, Phaser.Easing.Linear.None) +.to({ x: 0 }, 1000, Phaser.Easing.Linear.None) +.to({ y: 0 }, 1000, Phaser.Easing.Linear.None) +.loop();

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    onCompleteCallback(callback) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Sets a callback to be fired when the tween completes. Note: callback will be called in the context of the global scope.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callback + + +function + + + +

    The callback to invoke on completion.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    onStartCallback(callback) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Sets a callback to be fired when the tween starts. Note: callback will be called in the context of the global scope.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callback + + +function + + + +

    The callback to invoke on start.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    onUpdateCallback(callback) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Sets a callback to be fired each time this tween updates. Note: callback will be called in the context of the global scope.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    callback + + +function + + + +

    The callback to invoke each time this tween is updated.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    pause()

    + + +
    +
    + + +
    +

    Pauses the tween.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    repeat(times) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Sets the number of times this tween will repeat.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    times + + +number + + + +

    How many times to repeat.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    resume()

    + + +
    +
    + + +
    +

    Resumes a paused tween.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    start(time) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Starts the tween running. Can also be called by the autoStart parameter of Tween.to.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    time + + +number + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    stop() → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Stops the tween if running and removes it from the TweenManager. If there are any onComplete callbacks or events they are not dispatched.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    to(properties, duration, ease, autoStart, delay, repeat, yoyo) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Configure the Tween

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    properties + + +object + + + +

    Properties you want to tween.

    duration + + +number + + + +

    Duration of this tween.

    ease + + +function + + + +

    Easing function.

    autoStart + + +boolean + + + +

    Whether this tween will start automatically or not.

    delay + + +number + + + +

    Delay before this tween will start, defaults to 0 (no delay).

    repeat + + +boolean + + + +

    Should the tween automatically restart once complete? (ignores any chained tweens).

    yoyo + + +Phaser.Tween + + + +

    Description.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    update(time) → {boolean}

    + + +
    +
    + + +
    +

    Core tween update function called by the TweenManager. Does not need to be invoked directly.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    time + + +number + + + +

    A timestamp passed in by the TweenManager.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    false if the tween has completed and should be deleted from the manager, otherwise true (still active).

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    yoyo(yoyo) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    A tween that has yoyo set to true will run through from start to finish, then reverse from finish to start. +Used in combination with repeat you can create endless loops.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    yoyo + + +boolean + + + +

    Set to true to yoyo this tween.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Itself.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:31 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.TweenManager.html b/docs/Phaser.TweenManager.html new file mode 100644 index 00000000..b8ae3f5b --- /dev/null +++ b/docs/Phaser.TweenManager.html @@ -0,0 +1,1615 @@ + + + + + + Phaser Class: TweenManager + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: TweenManager

    +
    + +
    +

    + Phaser. + + TweenManager +

    + +

    Phaser.Game has a single instance of the TweenManager through which all Tween objects are created and updated. +Tweens are hooked into the game clock and pause system, adjusting based on the game state.

    +

    TweenManager is based heavily on tween.js by http://soledadpenades.com. +The difference being that tweens belong to a games instance of TweenManager, rather than to a global TWEEN object. +It also has callbacks swapped for Signals and a few issues patched with regard to properties and completion errors. +Please see https://github.com/sole/tween.js for a full list of contributors.

    + +
    + +
    +
    + + + + +
    +

    new TweenManager(game)

    + + +
    +
    + + +
    +

    Phaser - TweenManager

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Local reference to game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    REVISION

    + + +
    +
    + +
    +

    Version number of this library.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    REVISION + + +string + + + +
    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • "11dev"
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    add(tween) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Add a new tween into the TweenManager.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    tween + + +Phaser.Tween + + + +

    The tween object you want to add.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The tween object you added to the manager.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    create(object) → {Phaser.Tween}

    + + +
    +
    + + +
    +

    Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    object + + +Object + + + +

    Object the tween will be run on.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The newly created tween object.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween + + +
    +
    + + + + + +
    + + + +
    +

    getAll() → {Phaser.Tween[]}

    + + +
    +
    + + +
    +

    Get all the tween objects in an array.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Array with all tween objects.

    +
    + + + +
    +
    + Type +
    +
    + +Phaser.Tween[] + + +
    +
    + + + + + +
    + + + +
    +

    remove(tween)

    + + +
    +
    + + +
    +

    Remove a tween from this manager.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    tween + + +Phaser.Tween + + + +

    The tween object you want to remove.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    removeAll()

    + + +
    +
    + + +
    +

    Remove all tween objects.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    resumeAll()

    + + +
    +
    + + +
    +

    Pauses all currently paused tweens.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    update() → {boolean}

    + + +
    +
    + + +
    +

    Update all the tween objects you added to this manager.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    Return false if there's no tween to update, otherwise return true.

    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    update()

    + + +
    +
    + + +
    +

    Pauses all currently running tweens.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:31 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Utils.Debug.html b/docs/Phaser.Utils.Debug.html new file mode 100644 index 00000000..f5156051 --- /dev/null +++ b/docs/Phaser.Utils.Debug.html @@ -0,0 +1,5968 @@ + + + + + + Phaser Class: Debug + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Debug

    +
    + +
    +

    + Phaser.Utils. + + Debug +

    + +

    Phaser.Utils.Debug

    + +
    + +
    +
    + + + + +
    +

    new Debug(game)

    + + +
    +
    + + +
    +

    A collection of methods for displaying debug information about game objects. Phaser.Debug requires a CANVAS game type in order to render, so if you've got +your game set to use Phaser.AUTO then swap it for Phaser.CANVAS to ensure WebGL doesn't kick in, then the Debug functions will all display.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running game.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    context

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    context + + +Context + + + +

    The canvas context on which to render the debug information.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    currentAlpha

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    currentAlpha + + +number + + + +

    The current alpha the debug information will be rendered at.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 1
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    currentX

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    currentX + + +Context + + + +

    The current X position the debug information will be rendered at.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    currentY

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    currentY + + +number + + + +

    The current Y position the debug information will be rendered at.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • 0
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    font

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    font + + +string + + + +

    The font that the debug information is rendered in.

    +
    + + + + + + + + + + + + + + + + + + +
    Default Value:
    +
    • '14px Courier'
    + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    game

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    A reference to the currently running Game.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    lineHeight

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    lineHeight + + +number + + + +

    The line height between the debug text.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    renderShadow

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    renderShadow + + +boolean + + + +

    Should the text be rendered with a slight shadow? Makes it easier to read on different types of background.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    line(text, x, y)

    + + +
    +
    + + +
    +

    Internal method that outputs a single line of text.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    text + + +string + + + +

    The line of text to draw.

    x + + +number + + + +

    The X value the debug info will start from.

    y + + +number + + + +

    The Y value the debug info will start from.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderCameraInfo(camera, x, y, color)

    + + +
    +
    + + +
    +

    Render camera information including dimensions and location.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    camera + + +Phaser.Camera + + + + + + + + + + + +

    Description.

    x + + +number + + + + + + + + + + + +

    X position of the debug info to be rendered.

    y + + +number + + + + + + + + + + + +

    Y position of the debug info to be rendered.

    color + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgb(255,255,255)' + +

    color of the debug info to be rendered. (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderCircle(circle, color)

    + + +
    +
    + + +
    +

    Renders a Circle.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    circle + + +Phaser.Circle + + + + + + + + + +

    The Circle to render.

    color + + +string + + + + + + <optional>
    + + + + + +

    Color of the debug info to be rendered (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderDebug(pointer, hideIfUp, downColor, upColor, color)

    + + +
    +
    + + +
    +

    Renders the Pointer.circle object onto the stage in green if down or red if up along with debug text.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    pointer + + +Phaser.Pointer + + + + + + + + + + + +

    Description.

    hideIfUp + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    Doesn't render the circle if the pointer is up.

    downColor + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgba(0,255,0,0.5)' + +

    The color the circle is rendered in if down.

    upColor + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgba(255,0,0,0.5)' + +

    The color the circle is rendered in if up (and hideIfUp is false).

    color + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgb(255,255,255)' + +

    color of the debug info to be rendered. (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderInputInfo(x, y, color)

    + + +
    +
    + + +
    +

    Render debug information about the Input object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    x + + +number + + + + + + + + + + + +

    X position of the debug info to be rendered.

    y + + +number + + + + + + + + + + + +

    Y position of the debug info to be rendered.

    color + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgb(255,255,255)' + +

    color of the debug info to be rendered. (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderLocalTransformInfo(sprite, x, y, color)

    + + +
    +
    + + +
    +

    Render the Local Transform information of the given Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    sprite + + +Phaser.Sprite + + + + + + + + + + + +

    Description.

    x + + +number + + + + + + + + + + + +

    X position of the debug info to be rendered.

    y + + +number + + + + + + + + + + + +

    Y position of the debug info to be rendered.

    color + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgb(255,255,255)' + +

    color of the debug info to be rendered. (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderPixel(x, y, color)

    + + +
    +
    + + +
    +

    Renders a single pixel.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    x + + +number + + + + + + + + + +

    X position of the debug info to be rendered.

    y + + +number + + + + + + + + + +

    Y position of the debug info to be rendered.

    color + + +string + + + + + + <optional>
    + + + + + +

    Color of the debug info to be rendered (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderPoint(point, color)

    + + +
    +
    + + +
    +

    Renders a Point object.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    point + + +Phaser.Point + + + + + + + + + +

    The Point to render.

    color + + +string + + + + + + <optional>
    + + + + + +

    Color of the debug info to be rendered (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderPointInfo(sprite, x, y, color)

    + + +
    +
    + + +
    +

    Renders Point coordinates in the given color.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    sprite + + +Phaser.Point + + + + + + + + + + + +

    Description.

    x + + +number + + + + + + + + + + + +

    X position of the debug info to be rendered.

    y + + +number + + + + + + + + + + + +

    Y position of the debug info to be rendered.

    color + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgb(255,255,255)' + +

    color of the debug info to be rendered. (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderQuadTree(quadtree, color)

    + + +
    +
    + + +
    +

    Visually renders a QuadTree to the display.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    quadtree + + +Phaser.QuadTree + + + +

    The quadtree to render.

    color + + +string + + + +

    The color of the lines in the quadtree.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderRectangle(rect, color)

    + + +
    +
    + + +
    +

    Renders a Rectangle.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    rect + + +Phaser.Rectangle + + + + + + + + + +

    The Rectangle to render.

    color + + +string + + + + + + <optional>
    + + + + + +

    Color of the debug info to be rendered (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderSoundInfo(sound, x, y, color)

    + + +
    +
    + + +
    +

    Render Sound information, including decoded state, duration, volume and more.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    sound + + +Phaser.Sound + + + + + + + + + + + +

    The sound object to debug.

    x + + +number + + + + + + + + + + + +

    X position of the debug info to be rendered.

    y + + +number + + + + + + + + + + + +

    Y position of the debug info to be rendered.

    color + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgb(255,255,255)' + +

    color of the debug info to be rendered. (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderSpriteBody(sprite, color)

    + + +
    +
    + + +
    +

    Renders just the Sprite.body bounds.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    sprite + + +Phaser.Sprite + + + + + + + + + +

    Description.

    color + + +string + + + + + + <optional>
    + + + + + +

    Color of the debug info to be rendered (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderSpriteBounds(sprite, color, fill)

    + + +
    +
    + + +
    +

    Renders just the full Sprite bounds.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    sprite + + +Phaser.Sprite + + + + + + + + + + + +

    Description.

    color + + +string + + + + + + <optional>
    + + + + + +
    + +

    Color of the debug info to be rendered (format is css color string).

    fill + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If false the bounds outline is rendered, if true the whole rectangle is rendered.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderSpriteCollision(sprite, x, y, color)

    + + +
    +
    + + +
    +

    Render Sprite collision.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    sprite + + +Phaser.Sprite + + + + + + + + + + + +

    The sprite to be rendered.

    x + + +number + + + + + + + + + + + +

    X position of the debug info to be rendered.

    y + + +number + + + + + + + + + + + +

    Y position of the debug info to be rendered.

    color + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgb(255,255,255)' + +

    color of the debug info to be rendered. (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderSpriteCorners(sprite, showText, showBounds, color)

    + + +
    +
    + + +
    +

    Renders the corners and point information of the given Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    sprite + + +Phaser.Sprite + + + + + + + + + + + +

    The sprite to be rendered.

    showText + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If true the x/y coordinates of each point will be rendered.

    showBounds + + +boolean + + + + + + <optional>
    + + + + + +
    + + false + +

    If true the bounds will be rendered over the top of the sprite.

    color + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgb(255,0,255)' + +

    The color the text is rendered in.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderSpriteInfo(sprite, x, y, color)

    + + +
    +
    + + +
    +

    Render debug infos (including name, bounds info, position and some other properties) about the Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    sprite + + +Phaser.Sprite + + + + + + + + + + + +

    Description.

    x + + +number + + + + + + + + + + + +

    X position of the debug info to be rendered.

    y + + +number + + + + + + + + + + + +

    Y position of the debug info to be rendered.

    color + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgb(255,255,255)' + +

    color of the debug info to be rendered. (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderSpriteInputInfo(sprite, x, y, color)

    + + +
    +
    + + +
    +

    Render Sprite Input Debug information.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    sprite + + +Phaser.Sprite + + + + + + + + + + + +

    The sprite to be rendered.

    x + + +number + + + + + + + + + + + +

    X position of the debug info to be rendered.

    y + + +number + + + + + + + + + + + +

    Y position of the debug info to be rendered.

    color + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgb(255,255,255)' + +

    color of the debug info to be rendered. (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderText(text, x, y, color, font)

    + + +
    +
    + + +
    +

    Render text.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    text + + +string + + + + + + + + + +

    The line of text to draw.

    x + + +number + + + + + + + + + +

    X position of the debug info to be rendered.

    y + + +number + + + + + + + + + +

    Y position of the debug info to be rendered.

    color + + +string + + + + + + <optional>
    + + + + + +

    Color of the debug info to be rendered (format is css color string).

    font + + +string + + + + + + + + + +

    The font of text to draw.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    renderWorldTransformInfo(sprite, x, y, color)

    + + +
    +
    + + +
    +

    Render the World Transform information of the given Sprite.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    sprite + + +Phaser.Sprite + + + + + + + + + + + +

    Description.

    x + + +number + + + + + + + + + + + +

    X position of the debug info to be rendered.

    y + + +number + + + + + + + + + + + +

    Y position of the debug info to be rendered.

    color + + +string + + + + + + <optional>
    + + + + + +
    + + 'rgb(255,255,255)' + +

    color of the debug info to be rendered. (format is css color string).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    start(x, y, color)

    + + +
    +
    + + +
    +

    Internal method that resets and starts the debug output values.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    The X value the debug info will start from.

    y + + +number + + + +

    The Y value the debug info will start from.

    color + + +string + + + +

    The color the debug info will drawn in.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    stop()

    + + +
    +
    + + +
    +

    Internal method that stops the debug output.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:32 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.Utils.html b/docs/Phaser.Utils.html new file mode 100644 index 00000000..fde44034 --- /dev/null +++ b/docs/Phaser.Utils.html @@ -0,0 +1,1127 @@ + + + + + + Phaser Class: Utils + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: Utils

    +
    + +
    +

    + Phaser. + + Utils +

    + +
    + +
    +
    + + + + +
    +

    new Utils()

    + + +
    +
    + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + +

    Classes

    + +
    +
    Debug
    +
    +
    + + + + + + + +

    Methods

    + +
    + +
    +

    <static> extend(deep, target) → {object}

    + + +
    +
    + + +
    +

    This is a slightly modified version of http://api.jquery.com/jQuery.extend/

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    deep + + +boolean + + + +

    Perform a deep copy?

    target + + +object + + + +

    The target object to copy to.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +

    The extended object.

    +
    + + + +
    +
    + Type +
    +
    + +object + + +
    +
    + + + + + +
    + + + +
    +

    <static> isPlainObject(obj) → {boolean}

    + + +
    +
    + + +
    +

    This is a slightly modified version of jQuery.isPlainObject. A plain object is an object whose internal class property is [object Object].

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    obj + + +object + + + +

    The object to inspect.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + +
    +
      +
    • true if the object is plain, otherwise false.
    • +
    +
    + + + +
    +
    + Type +
    +
    + +boolean + + +
    +
    + + + + + +
    + + + +
    +

    <static> pad(str, len, pad, dir) → {string}

    + + +
    +
    + + +
    +

    Javascript string pad http://www.webtoolkit.info/. +pad = the string to pad it out with (defaults to a space)<br> +dir = 1 (left), 2 (right), 3 (both)

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDefaultDescription
    str + + +string + + + + + + + + + + + +

    The target string.

    len + + +number + + + + + + + + + + + +

    Description.

    pad + + +number + + + + + + + + + + + +

    the string to pad it out with (defaults to a space).

    dir + + +number + + + + + + <optional>
    + + + + + +
    + + 3 + +

    the direction dir = 1 (left), 2 (right), 3 (both).

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + +
    Returns:
    + + + + +
    +
    + Type +
    +
    + +string + + +
    +
    + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:31 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.World.html b/docs/Phaser.World.html new file mode 100644 index 00000000..685bc77d --- /dev/null +++ b/docs/Phaser.World.html @@ -0,0 +1,2102 @@ + + + + + + Phaser Class: World + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: World

    +
    + +
    +

    + Phaser. + + World +

    + +

    Phaser.World

    + +
    + +
    +
    + + + + +
    +

    new World(game)

    + + +
    +
    + + +
    +

    "This world is but a canvas to our imagination." - Henry David Thoreau

    +

    A game has only one world. The world is an abstract place in which all game objects live. It is not bound +by stage limits and can be any size. You look into the world via cameras. All game objects live within +the world at world-based coordinates. By default a world is created the same size as your Stage.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    game + + +Phaser.Game + + + +

    Reference to the current game instance.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + +

    Members

    + +
    + +
    +

    bounds

    + + +
    +
    + +
    +

    The World has no fixed size, but it does have a bounds outside of which objects are no longer considered as being "in world" and you should use this to clean-up the display list and purge dead objects. +By default we set the Bounds to be from 0,0 to Game.width,Game.height. I.e. it will match the size given to the game constructor with 0,0 representing the top-left of the display. +However 0,0 is actually the center of the world, and if you rotate or scale the world all of that will happen from 0,0. +So if you want to make a game in which the world itself will rotate you should adjust the bounds so that 0,0 is the center point, i.e. set them to -1000,-1000,2000,2000 for a 2000x2000 sized world centered around 0,0.

    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    bounds + + +Phaser.Rectangle + + + +

    Bound of this world that objects can not escape from.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    camera

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    camera + + +Phaser.Camera + + + +

    Camera instance.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> centerX

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    centerX + + +number + + + +

    Gets the X position corresponding to the center point of the world.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> centerY

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    centerY + + +number + + + +

    Gets the Y position corresponding to the center point of the world.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    currentRenderOrderID

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    currentRenderOrderID + + +number + + + +

    Reset each frame, keeps a count of the total number of objects updated.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    height

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    height + + +number + + + +

    Gets or sets the current height of the game world.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> randomX

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    randomX + + +number + + + +

    Gets a random integer which is lesser than or equal to the current width of the game world.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    <readonly> randomY

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    randomY + + +number + + + +

    Gets a random integer which is lesser than or equal to the current height of the game world.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    scale

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    scale + + +Phaser.Point + + + +

    Replaces the PIXI.Point with a slightly more flexible one.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + + + +
    +

    width

    + + +
    +
    + + + + + +
    + + +
    Properties:
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    width + + +number + + + +

    Gets or sets the current width of the game world.

    +
    + + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + +
    + +
    + + + +

    Methods

    + +
    + +
    +

    <protected> boot()

    + + +
    +
    + + +
    +

    Initialises the game world.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    destroy()

    + + +
    +
    + + +
    +

    Destroyer of worlds.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    postUpdate()

    + + +
    +
    + + +
    +

    This is called automatically every frame, and is where main logic happens.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    setBounds(x, y, width, height)

    + + +
    +
    + + +
    +

    Updates the size of this world. Note that this doesn't modify the world x/y coordinates, just the width and height. +If you need to adjust the bounds of the world

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    x + + +number + + + +

    Top left most corner of the world.

    y + + +number + + + +

    Top left most corner of the world.

    width + + +number + + + +

    New width of the world.

    height + + +number + + + +

    New height of the world.

    + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + + +
    +

    update()

    + + +
    +
    + + +
    +

    This is called automatically every frame, and is where main logic happens.

    +
    + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + +
    + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:32 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.html b/docs/Phaser.html new file mode 100644 index 00000000..5b5da4f6 --- /dev/null +++ b/docs/Phaser.html @@ -0,0 +1,695 @@ + + + + + + Phaser Namespace: Phaser + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Namespace: Phaser

    +
    + +
    +

    + Phaser +

    + +
    + +
    +
    + + + + + + +
    + + + + + + + + + + + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + +
    + + + + + + + + +

    Classes

    + +
    +
    Animation
    +
    + +
    AnimationManager
    +
    + +
    AnimationParser
    +
    + +
    BitmapText
    +
    + +
    Bullet
    +
    + +
    Button
    +
    + +
    Cache
    +
    + +
    Camera
    +
    + +
    Canvas
    +
    + +
    Circle
    +
    + +
    Color
    +
    + +
    Device
    +
    + +
    Easing
    +
    + +
    Events
    +
    + +
    Frame
    +
    + +
    FrameData
    +
    + +
    Game
    +
    + +
    GameObjectFactory
    +
    + +
    Graphics
    +
    + +
    Group
    +
    + +
    Input
    +
    + +
    InputHandler
    +
    + +
    Key
    +
    + +
    Keyboard
    +
    + +
    LinkedList
    +
    + +
    Loader
    +
    + +
    LoaderParser
    +
    + +
    Math
    +
    + +
    Mouse
    +
    + +
    MSPointer
    +
    + +
    Net
    +
    + +
    Particles
    +
    + +
    Physics
    +
    + +
    Plugin
    +
    + +
    PluginManager
    +
    + +
    Point
    +
    + +
    Pointer
    +
    + +
    QuadTree
    +
    + +
    RandomDataGenerator
    +
    + +
    Rectangle
    +
    + +
    RenderTexture
    +
    + +
    RequestAnimationFrame
    +
    + +
    Signal
    +
    + +
    Sound
    +
    + +
    SoundManager
    +
    + +
    Sprite
    +
    + +
    Stage
    +
    + +
    StageScaleMode
    +
    + +
    State
    +
    + +
    StateManager
    +
    + +
    Text
    +
    + +
    TileSprite
    +
    + +
    Time
    +
    + +
    Touch
    +
    + +
    Tween
    +
    + +
    TweenManager
    +
    + +
    Utils
    +
    + +
    World
    +
    +
    + + + + + + + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/Phaser.js.html b/docs/Phaser.js.html new file mode 100644 index 00000000..9fc7b1fb --- /dev/null +++ b/docs/Phaser.js.html @@ -0,0 +1,487 @@ + + + + + + Phaser Source: Phaser.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: Phaser.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* @namespace Phaser
    +*/
    +var Phaser = Phaser || {
    +
    +	VERSION: '<%= version %>',
    +	GAMES: [],
    +	AUTO: 0,
    +	CANVAS: 1,
    +	WEBGL: 2,
    +
    +	SPRITE: 0,
    +	BUTTON: 1,
    +	BULLET: 2,
    +	GRAPHICS: 3,
    +	TEXT: 4,
    +	TILESPRITE: 5,
    +	BITMAPTEXT: 6,
    +	GROUP: 7,
    +	RENDERTEXTURE: 8,
    +	TILEMAP: 9,
    +	TILEMAPLAYER: 10,
    +	EMITTER: 11,
    +
    +	NONE: 0,
    +	LEFT: 1,
    +	RIGHT: 2,
    +	UP: 3,
    +	DOWN: 4
    +
    + };
    +
    +PIXI.InteractionManager = function (dummy) {
    +	//	We don't need this in Pixi, so we've removed it to save space
    +	//	however the Stage object expects a reference to it, so here is a dummy entry.
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Plugin.js.html b/docs/Plugin.js.html new file mode 100644 index 00000000..b823ed7f --- /dev/null +++ b/docs/Plugin.js.html @@ -0,0 +1,560 @@ + + + + + + Phaser Source: core/Plugin.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/Plugin.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/** 
    +* This is a base Plugin template to use for any Phaser plugin development.
    +* 
    +* @class Phaser.Plugin
    +* @classdesc Phaser - Plugin
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +* @param {Any} parent - The object that owns this plugin, usually Phaser.PluginManager.
    +*/
    +Phaser.Plugin = function (game, parent) {
    +
    +    if (typeof parent === 'undefined') { parent = null; }
    +
    +	/**
    +	* @property {Phaser.Game} game - A reference to the currently running game.
    +	*/
    +    this.game = game;
    +    
    +    /**
    +	* @property {Any} parent - The parent of this plugin. If added to the PluginManager the parent will be set to that, otherwise it will be null.
    +	*/
    +    this.parent = parent;
    +    
    +    /**
    +	* @property {boolean} active - A Plugin with active=true has its preUpdate and update methods called by the parent, otherwise they are skipped.
    +	* @default
    +	*/
    +    this.active = false;
    +    
    +    /**
    +	* @property {boolean} visible - A Plugin with visible=true has its render and postRender methods called by the parent, otherwise they are skipped.
    +	* @default
    +	*/
    +    this.visible = false;
    +    
    +    /**
    +	* @property {boolean} hasPreUpdate - A flag to indicate if this plugin has a preUpdate method.
    +	* @default
    +	*/
    +    this.hasPreUpdate = false;
    +    
    +    /**
    +	* @property {boolean} hasUpdate - A flag to indicate if this plugin has an update method.
    +	* @default
    +	*/
    +    this.hasUpdate = false;
    +    
    +    /**
    +	* @property {boolean} hasRender - A flag to indicate if this plugin has a render method.
    +	* @default
    +	*/
    +    this.hasRender = false;
    +    
    +    /**
    +	* @property {boolean} hasPostRender - A flag to indicate if this plugin has a postRender method.
    +	* @default
    +	*/
    +    this.hasPostRender = false;
    +
    +};
    +
    +Phaser.Plugin.prototype = {
    +
    +    /**
    +    * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics).
    +    * It is only called if active is set to true.
    +    * @method Phaser.Plugin#preUpdate
    +    */
    +    preUpdate: function () {
    +    },
    +
    +    /**
    +    * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render.
    +    * It is only called if active is set to true.
    +    * @method Phaser.Plugin#update
    +    */
    +    update: function () {
    +    },
    +
    +    /**
    +    * Render is called right after the Game Renderer completes, but before the State.render.
    +    * It is only called if visible is set to true.
    +    * @method Phaser.Plugin#render
    +    */
    +    render: function () {
    +    },
    +
    +    /**
    +    * Post-render is called after the Game Renderer and State.render have run.
    +    * It is only called if visible is set to true.
    +    * @method Phaser.Plugin#postRender
    +    */
    +    postRender: function () {
    +    },
    +
    +    /**
    +    * Clear down this Plugin and null out references
    +    * @method Phaser.Plugin#destroy
    +    */
    +    destroy: function () {
    +
    +        this.game = null;
    +        this.parent = null;
    +        this.active = false;
    +        this.visible = false;
    +        
    +    }
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/PluginManager.js.html b/docs/PluginManager.js.html new file mode 100644 index 00000000..e0a609ea --- /dev/null +++ b/docs/PluginManager.js.html @@ -0,0 +1,677 @@ + + + + + + Phaser Source: core/PluginManager.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/PluginManager.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/** 
    +* Description.
    +* 
    +* @class Phaser.PluginManager
    +* @classdesc Phaser - PluginManager
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +* @param {Description} parent - Description.
    +*/
    +Phaser.PluginManager = function(game, parent) {
    +
    +	/**
    +	* @property {Phaser.Game} game - A reference to the currently running game.
    +	*/
    +    this.game = game;
    +    
    +    /**
    +	* @property {Description} _parent - Description.
    +	* @private
    +	*/
    +    this._parent = parent;
    +    
    +    /**
    +	* @property {array} plugins - Description.
    +	*/
    +    this.plugins = [];
    +    
    +    /**
    +	* @property {array} _pluginsLength - Description.
    +	* @private
    +	* @default
    +	*/
    +    this._pluginsLength = 0;
    +
    +};
    +
    +Phaser.PluginManager.prototype = {
    +
    +    /**
    +    * Add a new Plugin to the PluginManager.
    +    * The plugin's game and parent reference are set to this game and pluginmanager parent.
    +    * @method Phaser.PluginManager#add
    +    * @param {Phaser.Plugin} plugin - Description.
    +    * @return {Phaser.Plugin} Description.
    +    */
    +    add: function (plugin) {
    +
    +        var result = false;
    +
    +        //  Prototype?
    +        if (typeof plugin === 'function')
    +        {
    +            plugin = new plugin(this.game, this._parent);
    +        }
    +        else
    +        {
    +            plugin.game = this.game;
    +            plugin.parent = this._parent;
    +        }
    +
    +        //  Check for methods now to avoid having to do this every loop
    +        if (typeof plugin['preUpdate'] === 'function')
    +        {
    +            plugin.hasPreUpdate = true;
    +            result = true;
    +        }
    +
    +        if (typeof plugin['update'] === 'function')
    +        {
    +            plugin.hasUpdate = true;
    +            result = true;
    +        }
    +
    +        if (typeof plugin['render'] === 'function')
    +        {
    +            plugin.hasRender = true;
    +            result = true;
    +        }
    +
    +        if (typeof plugin['postRender'] === 'function')
    +        {
    +            plugin.hasPostRender = true;
    +            result = true;
    +        }
    +
    +        //  The plugin must have at least one of the above functions to be added to the PluginManager.
    +        if (result)
    +        {
    +            if (plugin.hasPreUpdate || plugin.hasUpdate)
    +            {
    +                plugin.active = true;
    +            }
    +
    +            if (plugin.hasRender || plugin.hasPostRender)
    +            {
    +                plugin.visible = true;
    +            }
    +
    +            this._pluginsLength = this.plugins.push(plugin);
    +            return plugin;
    +        }
    +        else
    +        {
    +            return null;
    +        }
    +    },
    +
    +    /**
    +     * Remove a Plugin from the PluginManager.
    +     * @method Phaser.PluginManager#remove
    +     * @param {Phaser.Plugin} plugin - The plugin to be removed.
    +     */
    +    remove: function (plugin) {
    +
    +        //  TODO
    +        this._pluginsLength--;
    +
    +    },
    +
    +    /**
    +    * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics).
    +    * It only calls plugins who have active=true.
    +    * 
    +    * @method Phaser.PluginManager#preUpdate
    +    */
    +    preUpdate: function () {
    +
    +        if (this._pluginsLength == 0)
    +        {
    +            return;
    +        }
    +
    +        for (this._p = 0; this._p < this._pluginsLength; this._p++)
    +        {
    +            if (this.plugins[this._p].active && this.plugins[this._p].hasPreUpdate)
    +            {
    +                this.plugins[this._p].preUpdate();
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render.
    +    * It only calls plugins who have active=true.
    +    * 
    +    * @method Phaser.PluginManager#update
    +    */
    +    update: function () {
    +        
    +        if (this._pluginsLength == 0)
    +        {
    +            return;
    +        }
    +
    +        for (this._p = 0; this._p < this._pluginsLength; this._p++)
    +        {
    +            if (this.plugins[this._p].active && this.plugins[this._p].hasUpdate)
    +            {
    +                this.plugins[this._p].update();
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * Render is called right after the Game Renderer completes, but before the State.render.
    +    * It only calls plugins who have visible=true.
    +    * 
    +    * @method Phaser.PluginManager#render
    +    */
    +    render: function () {
    +
    +        if (this._pluginsLength == 0)
    +        {
    +            return;
    +        }
    +
    +        for (this._p = 0; this._p < this._pluginsLength; this._p++)
    +        {
    +            if (this.plugins[this._p].visible && this.plugins[this._p].hasRender)
    +            {
    +                this.plugins[this._p].render();
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * Post-render is called after the Game Renderer and State.render have run.
    +    * It only calls plugins who have visible=true.
    +    * 
    +    * @method Phaser.PluginManager#postRender
    +    */
    +    postRender: function () {
    +
    +        if (this._pluginsLength == 0)
    +        {
    +            return;
    +        }
    +
    +        for (this._p = 0; this._p < this._pluginsLength; this._p++)
    +        {
    +            if (this.plugins[this._p].visible && this.plugins[this._p].hasPostRender)
    +            {
    +                this.plugins[this._p].postRender();
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * Clear down this PluginManager and null out references
    +    * 
    +    * @method Phaser.PluginManager#destroy
    +    */
    +    destroy: function () {
    +
    +        this.plugins.length = 0;
    +        this._pluginsLength = 0;
    +        this.game = null;
    +        this._parent = null;
    +
    +    }
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Point.js.html b/docs/Point.js.html new file mode 100644 index 00000000..f1a9a1a0 --- /dev/null +++ b/docs/Point.js.html @@ -0,0 +1,842 @@ + + + + + + Phaser Source: geom/Point.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: geom/Point.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Creates a new Point. If you pass no parameters a Point is created set to (0,0).
    +* @class Phaser.Point
    +* @classdesc The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.
    +* @constructor
    +* @param {number} x The horizontal position of this Point (default 0)
    +* @param {number} y The vertical position of this Point (default 0)
    +**/
    +Phaser.Point = function (x, y) {
    +
    +    x = x || 0;
    +    y = y || 0;
    +
    +    /**
    +     * @property {number} x - The x coordinate of the point.
    +     **/
    +    this.x = x;
    +    
    +    /**
    +     * @property {number} y - The y coordinate of the point.
    +     **/
    +    this.y = y;
    +
    +};
    +
    +Phaser.Point.prototype = {
    +
    +    /**
    +    * Copies the x and y properties from any given object to this Point.
    +    * @method Phaser.Point#copyFrom
    +    * @param {any} source - The object to copy from.
    +    * @return {Point} This Point object.
    +    **/
    +    copyFrom: function (source) {
    +        return this.setTo(source.x, source.y);
    +    },
    +
    +    /**
    +    * Inverts the x and y values of this Point
    +    * @method Phaser.Point#invert
    +    * @return {Point} This Point object.
    +    **/
    +    invert: function () {
    +        return this.setTo(this.y, this.x);
    +    },
    +
    +    /**
    +    * Sets the x and y values of this Point object to the given coordinates.
    +    * @method Phaser.Point#setTo
    +    * @param {number} x - The horizontal position of this point.
    +    * @param {number} y - The vertical position of this point.
    +    * @return {Point} This Point object. Useful for chaining method calls.
    +    **/        
    +    setTo: function (x, y) {
    +
    +        this.x = x;
    +        this.y = y;
    +        return this;
    +        
    +    },
    +
    +    /**
    +    * Adds the given x and y values to this Point.
    +    * @method Phaser.Point#add
    +    * @param {number} x - The value to add to Point.x.
    +    * @param {number} y - The value to add to Point.y.
    +    * @return {Phaser.Point} This Point object. Useful for chaining method calls.
    +    **/        
    +    add: function (x, y) {
    +
    +        this.x += x;
    +        this.y += y;
    +        return this;
    +
    +    },
    +
    +    /**
    +    * Subtracts the given x and y values from this Point.
    +    * @method Phaser.Point#subtract
    +    * @param {number} x - The value to subtract from Point.x.
    +    * @param {number} y - The value to subtract from Point.y.
    +    * @return {Phaser.Point} This Point object. Useful for chaining method calls.
    +    **/        
    +    subtract: function (x, y) {
    +
    +        this.x -= x;
    +        this.y -= y;
    +        return this;
    +
    +    },
    +
    +    /**
    +    * Multiplies Point.x and Point.y by the given x and y values.
    +    * @method Phaser.Point#multiply
    +    * @param {number} x - The value to multiply Point.x by.
    +    * @param {number} y - The value to multiply Point.x by.
    +    * @return {Phaser.Point} This Point object. Useful for chaining method calls.
    +    **/        
    +    multiply: function (x, y) {
    +
    +        this.x *= x;
    +        this.y *= y;
    +        return this;
    +
    +    },
    +
    +    /**
    +    * Divides Point.x and Point.y by the given x and y values.
    +    * @method Phaser.Point#divide
    +    * @param {number} x - The value to divide Point.x by.
    +    * @param {number} y - The value to divide Point.x by.
    +    * @return {Phaser.Point} This Point object. Useful for chaining method calls.
    +    **/        
    +    divide: function (x, y) {
    +
    +        this.x /= x;
    +        this.y /= y;
    +        return this;
    +
    +    },
    +
    +    /**
    +    * Clamps the x value of this Point to be between the given min and max.
    +    * @method Phaser.Point#clampX
    +    * @param {number} min - The minimum value to clamp this Point to.
    +    * @param {number} max - The maximum value to clamp this Point to.
    +    * @return {Phaser.Point} This Point object.
    +    */
    +    clampX: function (min, max) {
    +
    +        this.x = Phaser.Math.clamp(this.x, min, max);
    +        return this;
    +        
    +    },
    +
    +    /**
    +    * Clamps the y value of this Point to be between the given min and max
    +    * @method Phaser.Point#clampY
    +    * @param {number} min - The minimum value to clamp this Point to.
    +    * @param {number} max - The maximum value to clamp this Point to.
    +    * @return {Phaser.Point} This Point object.
    +    */
    +    clampY: function (min, max) {
    +
    +        this.y = Phaser.Math.clamp(this.y, min, max);
    +        return this;
    +        
    +    },
    +
    +    /**
    +    * Clamps this Point object values to be between the given min and max.
    +    * @method Phaser.Point#clamp
    +    * @param {number} min - The minimum value to clamp this Point to.
    +    * @param {number} max - The maximum value to clamp this Point to.
    +    * @return {Phaser.Point} This Point object.
    +    */
    +    clamp: function (min, max) {
    +
    +        this.x = Phaser.Math.clamp(this.x, min, max);
    +        this.y = Phaser.Math.clamp(this.y, min, max);
    +        return this;
    +
    +    },
    +
    +    /**
    +    * Creates a copy of the given Point.
    +    * @method Phaser.Point#clone
    +    * @param {Phaser.Point} [output] Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.
    +    * @return {Phaser.Point} The new Point object.
    +    */
    +    clone: function (output) {
    +
    +        if (typeof output === "undefined") { output = new Phaser.Point; }
    +
    +        return output.setTo(this.x, this.y);
    +
    +    },
    +
    +    /**
    +    * Copies the x and y properties from any given object to this Point.
    +    * @method Phaser.Point#copyFrom
    +    * @param {any} source - The object to copy from.
    +    * @return {Point} This Point object.
    +    **/
    +    copyFrom: function (source) {
    +        return this.setTo(source.x, source.y);
    +    },
    +
    +    /**
    +    * Copies the x and y properties from this Point to any given object.
    +    * @method Phaser.Point#copyTo
    +    * @param {any} dest - The object to copy to.
    +    * @return {Object} The dest object.
    +    **/
    +    copyTo: function(dest) {
    +
    +        dest[x] = this.x;
    +        dest[y] = this.y;
    +
    +        return dest;
    +
    +    },
    +
    +    /**
    +    * Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties)
    +    * @method Phaser.Point#distance
    +    * @param {object} dest - The target object. Must have visible x and y properties that represent the center of the object.
    +    * @param {boolean} [round] - Round the distance to the nearest integer (default false).
    +    * @return {number} The distance between this Point object and the destination Point object.
    +    */
    +    distance: function (dest, round) {
    +
    +        return Phaser.Point.distance(this, dest, round);
    +        
    +    },
    +
    +    /**
    +    * Determines whether the given objects x/y values are equal to this Point object.
    +    * @method Phaser.Point#equals
    +    * @param {Phaser.Point} a - The first object to compare.
    +    * @return {boolean} A value of true if the Points are equal, otherwise false.
    +    */
    +    equals: function (a) {
    +        return (a.x == this.x && a.y == this.y);
    +    },
    +
    +    /**
    +    * Rotates this Point around the x/y coordinates given to the desired angle.
    +    * @method Phaser.Point#rotate
    +    * @param {number} x - The x coordinate of the anchor point
    +    * @param {number} y - The y coordinate of the anchor point
    +    * @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the Point to.
    +    * @param {boolean} asDegrees - Is the given rotation in radians (false) or degrees (true)?
    +    * @param {number} [distance] - An optional distance constraint between the Point and the anchor.
    +    * @return {Phaser.Point} The modified point object.
    +    */
    +    rotate: function (x, y, angle, asDegrees, distance) {
    +        return Phaser.Point.rotate(this, x, y, angle, asDegrees, distance);
    +    },
    +
    +    /**
    +    * Returns a string representation of this object.
    +    * @method Phaser.Point#toString
    +    * @return {string} A string representation of the instance.
    +    **/
    +    toString: function () {
    +        return '[{Point (x=' + this.x + ' y=' + this.y + ')}]';
    +    }
    +
    +};
    +
    +/**
    +* Adds the coordinates of two points together to create a new point.
    +* @method Phaser.Point.add
    +* @param {Phaser.Point} a - The first Point object.
    +* @param {Phaser.Point} b - The second Point object.
    +* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created.
    +* @return {Phaser.Point} The new Point object.
    +*/
    +Phaser.Point.add = function (a, b, out) {
    +
    +    if (typeof out === "undefined") { out = new Phaser.Point(); }
    +
    +    out.x = a.x + b.x;
    +    out.y = a.y + b.y;
    +
    +    return out;
    +
    +};
    +
    +/**
    +* Subtracts the coordinates of two points to create a new point.
    +* @method Phaser.Point.subtract
    +* @param {Phaser.Point} a - The first Point object.
    +* @param {Phaser.Point} b - The second Point object.
    +* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created.
    +* @return {Phaser.Point} The new Point object.
    +*/
    +Phaser.Point.subtract = function (a, b, out) {
    +
    +    if (typeof out === "undefined") { out = new Phaser.Point(); }
    +
    +    out.x = a.x - b.x;
    +    out.y = a.y - b.y;
    +
    +    return out;
    +
    +};
    +
    +/**
    +* Multiplies the coordinates of two points to create a new point.
    +* @method Phaser.Point.multiply
    +* @param {Phaser.Point} a - The first Point object.
    +* @param {Phaser.Point} b - The second Point object.
    +* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created.
    +* @return {Phaser.Point} The new Point object.
    +*/
    +Phaser.Point.multiply = function (a, b, out) {
    +
    +    if (typeof out === "undefined") { out = new Phaser.Point(); }
    +
    +    out.x = a.x * b.x;
    +    out.y = a.y * b.y;
    +
    +    return out;
    +
    +};
    +
    +/**
    +* Divides the coordinates of two points to create a new point.
    +* @method Phaser.Point.divide
    +* @param {Phaser.Point} a - The first Point object.
    +* @param {Phaser.Point} b - The second Point object.
    +* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created.
    +* @return {Phaser.Point} The new Point object.
    +*/
    +Phaser.Point.divide = function (a, b, out) {
    +
    +    if (typeof out === "undefined") { out = new Phaser.Point(); }
    +
    +    out.x = a.x / b.x;
    +    out.y = a.y / b.y;
    +
    +    return out;
    +
    +};
    +
    +/**
    +* Determines whether the two given Point objects are equal. They are considered equal if they have the same x and y values.
    +* @method Phaser.Point.equals
    +* @param {Phaser.Point} a - The first Point object.
    +* @param {Phaser.Point} b - The second Point object.
    +* @return {boolean} A value of true if the Points are equal, otherwise false.
    +*/
    +Phaser.Point.equals = function (a, b) {
    +    return (a.x == b.x && a.y == b.y);
    +};
    +
    +/**
    +* Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties).
    +* @method Phaser.Point.distance
    +* @param {object} a - The target object. Must have visible x and y properties that represent the center of the object.
    +* @param {object} b - The target object. Must have visible x and y properties that represent the center of the object.
    +* @param {boolean} [round] - Round the distance to the nearest integer (default false).
    +* @return {number} The distance between this Point object and the destination Point object.
    +*/
    +Phaser.Point.distance = function (a, b, round) {
    +
    +    if (typeof round === "undefined") { round = false }
    +
    +    if (round)
    +    {
    +        return Phaser.Math.distanceRound(a.x, a.y, b.x, b.y);
    +    }
    +    else
    +    {
    +        return Phaser.Math.distance(a.x, a.y, b.x, b.y);
    +    }
    +
    +},
    +
    +/**
    +* Rotates a Point around the x/y coordinates given to the desired angle.
    +* @method Phaser.Point.rotate
    +* @param {Phaser.Point} a - The Point object to rotate.
    +* @param {number} x - The x coordinate of the anchor point
    +* @param {number} y - The y coordinate of the anchor point
    +* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the Point to.
    +* @param {boolean} asDegrees - Is the given rotation in radians (false) or degrees (true)?
    +* @param {number} distance - An optional distance constraint between the Point and the anchor.
    +* @return {Phaser.Point} The modified point object.
    +*/
    +Phaser.Point.rotate = function (a, x, y, angle, asDegrees, distance) {
    +
    +    asDegrees = asDegrees || false;
    +    distance = distance || null;
    +
    +    if (asDegrees)
    +    {
    +        angle = Phaser.Math.radToDeg(angle);
    +    }
    +
    +    //  Get distance from origin (cx/cy) to this point
    +    if (distance === null)
    +    {
    +        distance = Math.sqrt(((x - a.x) * (x - a.x)) + ((y - a.y) * (y - a.y)));
    +    }
    +
    +    return a.setTo(x + distance * Math.cos(angle), y + distance * Math.sin(angle));
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Pointer.js.html b/docs/Pointer.js.html new file mode 100644 index 00000000..8a8a8b90 --- /dev/null +++ b/docs/Pointer.js.html @@ -0,0 +1,1134 @@ + + + + + + Phaser Source: input/Pointer.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: input/Pointer.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser - Pointer constructor.
    +*
    +* @class Phaser.Pointer
    +* @classdesc A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen.
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +* @param {Description} id - Description.
    +*/
    +Phaser.Pointer = function (game, id) {
    +
    +    /**
    +    * @property {Phaser.Game} game - Local reference to game.
    +    */
    +    this.game = game;
    +
    +    /**
    +    * @property {Description} id - Description.
    +    */
    +    this.id = id;
    +
    +    /**
    +    * Local private variable to store the status of dispatching a hold event.
    +    * @property {boolean} _holdSent
    +    * @private
    +    * @default
    +    */
    +    this._holdSent = false;
    +
    +    /**
    +    * Local private variable storing the short-term history of pointer movements.
    +    * @property {array} _history
    +    * @private
    +    */
    +    this._history = [];
    +
    +    /**
    +    * Local private variable storing the time at which the next history drop should occur
    +    * @property {number} _lastDrop
    +    * @private
    +    * @default
    +    */
    +    this._nextDrop = 0;
    +
    +    /**
    +     * Monitor events outside of a state reset loop.
    +     * @property {boolean} _stateReset
    +     * @private
    +     * @default
    +     */
    +    this._stateReset = false;
    +
    +    /**
    +    * A Vector object containing the initial position when the Pointer was engaged with the screen.
    +    * @property {Vec2} positionDown
    +    * @default 
    +    **/
    +    this.positionDown = null;
    +
    +    /**
    +    * A Vector object containing the current position of the Pointer on the screen.
    +    * @property {Vec2} position
    +    * @default
    +    **/
    +    this.position = null;
    +
    +    /**
    +    * A Circle object centered on the x/y screen coordinates of the Pointer.
    +    * Default size of 44px (Apple's recommended "finger tip" size).
    +    * @property {Circle} circle
    +    * @default
    +    **/
    +    this.circle = null;
    +
    +    /**
    +    * Description.
    +    * @property {boolean} withinGame
    +    */
    +    this.withinGame = false;
    +
    +    /**
    +    * The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset.
    +    * @property {number} clientX
    +    * @default
    +    */
    +    this.clientX = -1;
    +
    +    /**
    +    * The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset.
    +    * @property {number} clientY
    +    * @default
    +    */
    +    this.clientY = -1;
    +
    +    /**
    +    * The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset.
    +    * @property {number} pageX
    +    * @default
    +    */
    +    this.pageX = -1;
    +
    +    /**
    +    * The vertical coordinate of point relative to the viewport in pixels, including any scroll offset.
    +    * @property {number} pageY
    +    * @default
    +    */
    +    this.pageY = -1;
    +
    +    /**
    +    * The horizontal coordinate of point relative to the screen in pixels.
    +    * @property {number} screenX
    +    * @default
    +    */
    +    this.screenX = -1;
    +
    +    /**
    +    * The vertical coordinate of point relative to the screen in pixels.
    +    * @property {number} screenY
    +    * @default
    +    */
    +    this.screenY = -1;
    +
    +    /**
    +    * The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size.
    +    * @property {number} x
    +    * @default
    +    */
    +    this.x = -1;
    +
    +    /**
    +    * The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size.
    +    * @property {number} y
    +    * @default
    +    */
    +    this.y = -1;
    +
    +    /**
    +    * If the Pointer is a mouse this is true, otherwise false.
    +    * @property {boolean} isMouse
    +    * @type {boolean}
    +    */
    +    this.isMouse = false;
    +
    +    /**
    +    * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true.
    +    * @property {boolean} isDown
    +    * @default
    +    */
    +    this.isDown = false;
    +
    +    /**
    +    * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true.
    +    * @property {boolean} isUp
    +    * @default
    +    */
    +    this.isUp = true;
    +
    +    /**
    +    * A timestamp representing when the Pointer first touched the touchscreen.
    +    * @property {number} timeDown
    +    * @default
    +    */
    +    this.timeDown = 0;
    +
    +    /**
    +    * A timestamp representing when the Pointer left the touchscreen.
    +    * @property {number} timeUp
    +    * @default
    +    */
    +    this.timeUp = 0;
    +
    +    /**
    +    * A timestamp representing when the Pointer was last tapped or clicked.
    +    * @property {number} previousTapTime
    +    * @default
    +    */
    +    this.previousTapTime = 0;
    +
    +    /**
    +    * The total number of times this Pointer has been touched to the touchscreen.
    +    * @property {number} totalTouches
    +    * @default
    +    */
    +    this.totalTouches = 0;
    +
    +    /**
    +    * The number of miliseconds since the last click.
    +    * @property {number} msSinceLastClick
    +    * @default
    +    */
    +    this.msSinceLastClick = Number.MAX_VALUE;
    +
    +    /**
    +    * The Game Object this Pointer is currently over / touching / dragging.
    +    * @property {Any} targetObject
    +    * @default
    +    */
    +    this.targetObject = null;
    +
    +    /**
    +    * Description.
    +    * @property {boolean} isDown - Description.
    +    * @default
    +    */
    +    this.active = false;
    +
    +    /**
    +    * Description
    +    * @property {Phaser.Point} position
    +    */
    +    this.position = new Phaser.Point();
    +    
    +    /**
    +    * Description
    +    * @property {Phaser.Point} positionDown
    +    */
    +    this.positionDown = new Phaser.Point();
    +
    +    /**
    +    * Description
    +    * @property {Phaser.Circle} circle
    +    */
    +    this.circle = new Phaser.Circle(0, 0, 44);
    +
    +    if (id == 0)
    +    {
    +        this.isMouse = true;
    +    }
    +
    +};
    +
    +Phaser.Pointer.prototype = {
    +
    +	/**
    +    * Called when the Pointer is pressed onto the touchscreen.
    +    * @method Phaser.Pointer#start
    +    * @param {Any} event
    +    */
    +    start: function (event) {
    +
    +        this.identifier = event.identifier;
    +        this.target = event.target;
    +
    +        if (typeof event.button !== 'undefined')
    +        {
    +            this.button = event.button;
    +        }
    +
    +        //  Fix to stop rogue browser plugins from blocking the visibility state event
    +        if (this.game.paused == true && this.game.stage.scale.incorrectOrientation == false)
    +        {
    +            this.game.paused = false;
    +            return this;
    +        }
    +
    +        this._history.length = 0;
    +        this.active = true;
    +        this.withinGame = true;
    +        this.isDown = true;
    +        this.isUp = false;
    +
    +        //  Work out how long it has been since the last click
    +        this.msSinceLastClick = this.game.time.now - this.timeDown;
    +        this.timeDown = this.game.time.now;
    +        this._holdSent = false;
    +
    +        //  This sets the x/y and other local values
    +        this.move(event);
    +
    +        // x and y are the old values here?
    +        this.positionDown.setTo(this.x, this.y);
    +
    +        if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
    +        {
    +            this.game.input.x = this.x * this.game.input.scale.x;
    +            this.game.input.y = this.y * this.game.input.scale.y;
    +            this.game.input.position.setTo(this.x, this.y);
    +            this.game.input.onDown.dispatch(this, event);
    +            this.game.input.resetSpeed(this.x, this.y);
    +        }
    +
    +        this._stateReset = false;
    +        this.totalTouches++;
    +
    +        if (this.isMouse == false)
    +        {
    +            this.game.input.currentPointers++;
    +        }
    +
    +        if (this.targetObject !== null)
    +        {
    +            this.targetObject._touchedHandler(this);
    +        }
    +
    +        return this;
    +
    +    },
    +
    +	/**
    +    * Description.
    +    * @method Phaser.Pointer#update
    +    */
    +    update: function () {
    +
    +        if (this.active)
    +        {
    +            if (this._holdSent == false && this.duration >= this.game.input.holdRate)
    +            {
    +                if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
    +                {
    +                    this.game.input.onHold.dispatch(this);
    +                }
    +
    +                this._holdSent = true;
    +            }
    +
    +            //  Update the droppings history
    +            if (this.game.input.recordPointerHistory && this.game.time.now >= this._nextDrop)
    +            {
    +                this._nextDrop = this.game.time.now + this.game.input.recordRate;
    +
    +                this._history.push({
    +                    x: this.position.x,
    +                    y: this.position.y
    +                });
    +            
    +                if (this._history.length > this.game.input.recordLimit)
    +                {
    +                    this._history.shift();
    +                }
    +            }
    +        }
    +
    +    },
    +
    +	/**
    +    * Called when the Pointer is moved
    +    * @method Phaser.Pointer#move
    +    * @param {Any} event
    +    */
    +    move: function (event) {
    +
    +        if (this.game.input.pollLocked)
    +        {
    +            return;
    +        }
    +
    +        if (typeof event.button !== 'undefined')
    +        {
    +            this.button = event.button;
    +        }
    +
    +        this.clientX = event.clientX;
    +        this.clientY = event.clientY;
    +
    +        this.pageX = event.pageX;
    +        this.pageY = event.pageY;
    +
    +        this.screenX = event.screenX;
    +        this.screenY = event.screenY;
    +
    +        this.x = (this.pageX - this.game.stage.offset.x) * this.game.input.scale.x;
    +        this.y = (this.pageY - this.game.stage.offset.y) * this.game.input.scale.y;
    +
    +        this.position.setTo(this.x, this.y);
    +        this.circle.x = this.x;
    +        this.circle.y = this.y;
    +
    +        if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
    +        {
    +            this.game.input.activePointer = this;
    +            this.game.input.x = this.x;
    +            this.game.input.y = this.y;
    +            this.game.input.position.setTo(this.game.input.x, this.game.input.y);
    +            this.game.input.circle.x = this.game.input.x;
    +            this.game.input.circle.y = this.game.input.y;
    +        }
    +
    +        //  If the game is paused we don't process any target objects
    +        if (this.game.paused)
    +        {
    +            return this;
    +        }
    +
    +        //  Easy out if we're dragging something and it still exists
    +        if (this.targetObject !== null && this.targetObject.isDragged == true)
    +        {
    +            if (this.targetObject.update(this) == false)
    +            {
    +                this.targetObject = null;
    +            }
    +
    +            return this;
    +
    +        }
    +
    +        //  Work out which object is on the top
    +        this._highestRenderOrderID = -1;
    +        this._highestRenderObject = null;
    +        this._highestInputPriorityID = -1;
    +
    +        //  Just run through the linked list
    +        if (this.game.input.interactiveItems.total > 0)
    +        {
    +            var currentNode = this.game.input.interactiveItems.next;
    +
    +            do  
    +            {
    +                //  If the object is using pixelPerfect checks, or has a higher InputManager.PriorityID OR if the priority ID is the same as the current highest AND it has a higher renderOrderID, then set it to the top
    +                if (currentNode.pixelPerfect || currentNode.priorityID > this._highestInputPriorityID || (currentNode.priorityID == this._highestInputPriorityID && currentNode.sprite.renderOrderID > this._highestRenderOrderID))
    +                {
    +                    if (currentNode.checkPointerOver(this))
    +                    {
    +                        // console.log('HRO set', currentNode.sprite.name);
    +                        this._highestRenderOrderID = currentNode.sprite.renderOrderID;
    +                        this._highestInputPriorityID = currentNode.priorityID;
    +                        this._highestRenderObject = currentNode;
    +                    }
    +                }
    +                currentNode = currentNode.next;
    +            }
    +            while (currentNode != null)
    +        }
    +
    +        if (this._highestRenderObject == null)
    +        {
    +            //  The pointer isn't currently over anything, check if we've got a lingering previous target
    +            if (this.targetObject)
    +            {
    +                // console.log("The pointer isn't currently over anything, check if we've got a lingering previous target");
    +                this.targetObject._pointerOutHandler(this);
    +                this.targetObject = null;
    +            }
    +        }
    +        else
    +        {
    +            if (this.targetObject == null)
    +            {
    +                //  And now set the new one
    +                // console.log('And now set the new one');
    +                this.targetObject = this._highestRenderObject;
    +                this._highestRenderObject._pointerOverHandler(this);
    +            }
    +            else
    +            {
    +                //  We've got a target from the last update
    +                // console.log("We've got a target from the last update");
    +                if (this.targetObject == this._highestRenderObject)
    +                {
    +                    //  Same target as before, so update it
    +                    // console.log("Same target as before, so update it");
    +                    if (this._highestRenderObject.update(this) == false)
    +                    {
    +                        this.targetObject = null;
    +                    }
    +                }
    +                else
    +                {
    +                    //  The target has changed, so tell the old one we've left it
    +                    // console.log("The target has changed, so tell the old one we've left it");
    +                    this.targetObject._pointerOutHandler(this);
    +
    +                    //  And now set the new one
    +                    this.targetObject = this._highestRenderObject;
    +                    this.targetObject._pointerOverHandler(this);
    +                }
    +            }
    +        }
    +
    +        return this;
    +
    +    },
    +
    +	/**
    +    * Called when the Pointer leaves the target area.
    +    * @method Phaser.Pointer#leave
    +    * @param {Any} event
    +    */
    +    leave: function (event) {
    +
    +        this.withinGame = false;
    +        this.move(event);
    +
    +    },
    +
    +	/**
    +    * Called when the Pointer leaves the touchscreen.
    +    * @method Phaser.Pointer#stop
    +    * @param {Any} event
    +    */
    +    stop: function (event) {
    +
    +        if (this._stateReset)
    +        {
    +            event.preventDefault();
    +            return;
    +        }
    +
    +        this.timeUp = this.game.time.now;
    +
    +        if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
    +        {
    +            this.game.input.onUp.dispatch(this, event);
    +
    +            //  Was it a tap?
    +            if (this.duration >= 0 && this.duration <= this.game.input.tapRate)
    +            {
    +                //  Was it a double-tap?
    +                if (this.timeUp - this.previousTapTime < this.game.input.doubleTapRate)
    +                {
    +                    //  Yes, let's dispatch the signal then with the 2nd parameter set to true
    +                    this.game.input.onTap.dispatch(this, true);
    +                }
    +                else
    +                {
    +                    //  Wasn't a double-tap, so dispatch a single tap signal
    +                    this.game.input.onTap.dispatch(this, false);
    +                }
    +
    +                this.previousTapTime = this.timeUp;
    +            }
    +        }
    +
    +        //  Mouse is always active
    +        if (this.id > 0)
    +        {
    +            this.active = false;
    +        }
    +
    +        this.withinGame = false;
    +        this.isDown = false;
    +        this.isUp = true;
    +
    +        if (this.isMouse == false)
    +        {
    +            this.game.input.currentPointers--;
    +        }
    +
    +        if (this.game.input.interactiveItems.total > 0)
    +        {
    +            var currentNode = this.game.input.interactiveItems.next;
    +            
    +            do  
    +            {
    +                if (currentNode)
    +                {
    +                    currentNode._releasedHandler(this);
    +                }
    +                
    +                currentNode = currentNode.next;
    +            }
    +            while (currentNode != null)
    +        }
    +
    +        if (this.targetObject)
    +        {
    +            this.targetObject._releasedHandler(this);
    +        }
    +
    +        this.targetObject = null;
    +        return this;
    +
    +    },
    +
    +	/**
    +    * The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate.
    +    * @method Phaser.Pointer#justPressed
    +    * @param {number} [duration]
    +    * @return {boolean}
    +    */
    +    justPressed: function (duration) {
    +
    +        duration = duration || this.game.input.justPressedRate;
    +
    +        return (this.isDown === true && (this.timeDown + duration) > this.game.time.now);
    +
    +    },
    +
    +	/**
    +    * The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate.
    +    * @method Phaser.Pointer#justReleased
    +    * @param {number} [duration]
    +    * @return {boolean}
    +    */
    +    justReleased: function (duration) {
    +
    +        duration = duration || this.game.input.justReleasedRate;
    +
    +        return (this.isUp === true && (this.timeUp + duration) > this.game.time.now);
    +
    +    },
    +
    +	/**
    +    * Resets the Pointer properties. Called by InputManager.reset when you perform a State change.
    +    * @method Phaser.Pointer#reset
    +    */
    +    reset: function () {
    +
    +        if (this.isMouse == false)
    +        {
    +            this.active = false;
    +        }
    +
    +        this.identifier = null;
    +        this.isDown = false;
    +        this.isUp = true;
    +        this.totalTouches = 0;
    +        this._holdSent = false;
    +        this._history.length = 0;
    +        this._stateReset = true;
    +
    +        if (this.targetObject)
    +        {
    +            this.targetObject._releasedHandler(this);
    +        }
    +
    +        this.targetObject = null;
    +
    +    },
    +
    +	/**
    +    * Returns a string representation of this object.
    +    * @method Phaser.Pointer#toString
    +    * @return {string} A string representation of the instance.
    +    **/
    +    toString: function () {
    +        return "[{Pointer (id=" + this.id + " identifer=" + this.identifier + " active=" + this.active + " duration=" + this.duration + " withinGame=" + this.withinGame + " x=" + this.x + " y=" + this.y + " clientX=" + this.clientX + " clientY=" + this.clientY + " screenX=" + this.screenX + " screenY=" + this.screenY + " pageX=" + this.pageX + " pageY=" + this.pageY + ")}]";
    +    }
    +
    +};
    +
    +/**
    +* How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
    +* @name Phaser.Pointer#duration
    +* @property {number} duration - How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Pointer.prototype, "duration", {
    +
    +    get: function () {
    +
    +        if (this.isUp)
    +        {
    +            return -1;
    +        }
    +
    +        return this.game.time.now - this.timeDown;
    +
    +    }
    +
    +});
    +
    +/**
    +* Gets the X value of this Pointer in world coordinates based on the world camera.
    +* @name Phaser.Pointer#worldX
    +* @property {number} duration - The X value of this Pointer in world coordinates based on the world camera.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Pointer.prototype, "worldX", {
    +
    +    get: function () {
    +
    +		return this.game.world.camera.x + this.x;
    +
    +    }
    +
    +});
    +
    +/**
    +* Gets the Y value of this Pointer in world coordinates based on the world camera.
    +* @name Phaser.Pointer#worldY
    +* @property {number} duration - The Y value of this Pointer in world coordinates based on the world camera.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Pointer.prototype, "worldY", {
    +
    +    get: function () {
    +
    +		return this.game.world.camera.y + this.y;
    +
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/QuadTree.js.html b/docs/QuadTree.js.html new file mode 100644 index 00000000..b58109cf --- /dev/null +++ b/docs/QuadTree.js.html @@ -0,0 +1,709 @@ + + + + + + Phaser Source: math/QuadTree.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: math/QuadTree.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    + * Javascript QuadTree 
    + * @version 1.0
    + * @author Timo Hausmann
    + *
    + * @version 1.2, September 4th 2013
    + * @author Richard Davey
    + * The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked
    + * it massively to add node indexing, removed lots of temp. var creation and significantly
    + * increased performance as a result.
    + *
    + * Original version at https://github.com/timohausmann/quadtree-js/
    + */
    + 
    +/**
    +* @copyright © 2012 Timo Hausmann
    +*
    +* Permission is hereby granted, free of charge, to any person obtaining
    +* a copy of this software and associated documentation files (the
    +* "Software"), to deal in the Software without restriction, including
    +* without limitation the rights to use, copy, modify, merge, publish,
    +* distribute, sublicense, and/or sell copies of the Software, and to
    +* permit persons to whom the Software is furnished to do so, subject to
    +* the following conditions:
    +*
    +* The above copyright notice and this permission notice shall be
    +* included in all copies or substantial portions of the Software.
    +*
    +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    +* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    +* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    +* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    +*/
    +
    +/**
    + * QuadTree Constructor
    + * 
    + * @class Phaser.QuadTree
    + * @classdesc A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked
    + * it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result. Original version at https://github.com/timohausmann/quadtree-js/
    + * @constructor
    + * @param {Description} physicsManager - Description.
    + * @param {Description} x - Description.
    + * @param {Description} y - Description.
    + * @param {number} width - The width of your game in game pixels.
    + * @param {number} height - The height of your game in game pixels.
    + * @param {number} maxObjects - Description.
    + * @param {number} maxLevels - Description.
    + * @param {number} level - Description.
    + */
    +Phaser.QuadTree = function (physicsManager, x, y, width, height, maxObjects, maxLevels, level) {
    +		
    +	this.physicsManager = physicsManager;
    +	this.ID = physicsManager.quadTreeID;
    +	physicsManager.quadTreeID++;
    +
    +	this.maxObjects = maxObjects || 10;
    +	this.maxLevels = maxLevels || 4;
    +	this.level = level || 0;
    +
    +	this.bounds = { 
    +		x: Math.round(x), 
    +		y: Math.round(y), 
    +		width: width, 
    +		height: height, 
    +		subWidth: Math.floor(width / 2),
    +		subHeight: Math.floor(height / 2),
    +		right: Math.round(x) + Math.floor(width / 2),
    +		bottom: Math.round(y) + Math.floor(height / 2)
    +	};
    +	
    +	this.objects = [];
    +	this.nodes = [];
    +
    +};
    +
    +Phaser.QuadTree.prototype = {
    +
    +	/*
    +	* Split the node into 4 subnodes
    +	* 
    +	* @method Phaser.QuadTree#split
    +	*/
    +	split: function() {
    +
    +		this.level++;
    +		
    +	 	//	top right node
    +		this.nodes[0] = new Phaser.QuadTree(this.physicsManager, this.bounds.right, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
    +		
    +		//	top left node
    +		this.nodes[1] = new Phaser.QuadTree(this.physicsManager, this.bounds.x, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
    +		
    +		//	bottom left node
    +		this.nodes[2] = new Phaser.QuadTree(this.physicsManager, this.bounds.x, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
    +		
    +		//	bottom right node
    +		this.nodes[3] = new Phaser.QuadTree(this.physicsManager, this.bounds.right, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
    +
    +	},
    +
    +	/*
    +	 * Insert the object into the node. If the node
    +	 * exceeds the capacity, it will split and add all
    +	 * objects to their corresponding subnodes.
    +	 * 
    +	 * @method Phaser.QuadTree#insert
    +	 * @param {object} body - Description.
    +	 */
    +	insert: function (body) {
    +		
    +		var i = 0;
    +		var index;
    +	 	
    +	 	//	if we have subnodes ...
    +		if (this.nodes[0] != null)
    +		{
    +			index = this.getIndex(body);
    +	 
    +		  	if (index !== -1)
    +		  	{
    +				this.nodes[index].insert(body);
    +			 	return;
    +			}
    +		}
    +	 
    +	 	this.objects.push(body);
    +		
    +		if (this.objects.length > this.maxObjects && this.level < this.maxLevels)
    +		{
    +			//	Split if we don't already have subnodes
    +			if (this.nodes[0] == null)
    +			{
    +				this.split();
    +			}
    +			
    +			//	Add objects to subnodes
    +			while (i < this.objects.length)
    +			{
    +				index = this.getIndex(this.objects[i]);
    +				
    +				if (index !== -1)
    +				{
    +					//	this is expensive - see what we can do about it
    +					this.nodes[index].insert(this.objects.splice(i, 1)[0]);
    +				}
    +				else
    +				{
    +					i++;
    +			 	}
    +		 	}
    +		}
    +	 },
    +	 
    +	/*
    +	 * Determine which node the object belongs to.
    +	 * 
    +	 * @method Phaser.QuadTree#getIndex
    +	 * @param {object} rect	- Description.
    +	 * @return {number} index -	Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node.
    +	 */
    +	getIndex: function (rect) {
    +		
    +		//	default is that rect doesn't fit, i.e. it straddles the internal quadrants
    +		var index = -1;
    +
    +		if (rect.x < this.bounds.right && rect.right < this.bounds.right)
    +		{
    +			if ((rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom))
    +			{
    +				//	rect fits within the top-left quadrant of this quadtree
    +				index = 1;
    +			}
    +			else if ((rect.y > this.bounds.bottom))
    +			{
    +				//	rect fits within the bottom-left quadrant of this quadtree
    +				index = 2;
    +			}
    +		}
    +		else if (rect.x > this.bounds.right)
    +		{
    +			//	rect can completely fit within the right quadrants
    +			if ((rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom))
    +			{
    +				//	rect fits within the top-right quadrant of this quadtree
    +				index = 0;
    +			}
    +			else if ((rect.y > this.bounds.bottom))
    +			{
    +				//	rect fits within the bottom-right quadrant of this quadtree
    +				index = 3;
    +			}
    +		}
    +	 
    +		return index;
    +
    +	},
    +
    +	 /*
    +	 * Return all objects that could collide with the given object.
    +	 * 
    +	 * @method Phaser.QuadTree#retrieve
    +	 * @param {object} rect	- Description.
    +	 * @Return {array} - Array with all detected objects.
    +	 */
    +	retrieve: function (sprite) {
    +	 	
    +		var returnObjects = this.objects;
    +
    +		sprite.body.quadTreeIndex = this.getIndex(sprite.body);
    +
    +		//	Temp store for the node IDs this sprite is in, we can use this for fast elimination later
    +		sprite.body.quadTreeIDs.push(this.ID);
    +
    +		if (this.nodes[0])
    +		{
    +			//	if rect fits into a subnode ..
    +			if (sprite.body.quadTreeIndex !== -1)
    +			{
    +				returnObjects = returnObjects.concat(this.nodes[sprite.body.quadTreeIndex].retrieve(sprite));
    +			}
    +			else
    +			{
    +				//	if rect does not fit into a subnode, check it against all subnodes (unrolled for speed)
    +				returnObjects = returnObjects.concat(this.nodes[0].retrieve(sprite));
    +				returnObjects = returnObjects.concat(this.nodes[1].retrieve(sprite));
    +				returnObjects = returnObjects.concat(this.nodes[2].retrieve(sprite));
    +				returnObjects = returnObjects.concat(this.nodes[3].retrieve(sprite));
    +			}
    +		}
    +	 
    +		return returnObjects;
    +
    +	},
    +
    +	/*
    +	 * Clear the quadtree.
    +	 * @method Phaser.QuadTree#clear
    +	 */
    +	clear: function () {
    +		
    +		this.objects = [];
    +	 
    +		for (var i = 0, len = this.nodes.length; i < len; i++)
    +		{
    +			// if (typeof this.nodes[i] !== 'undefined')
    +			if (this.nodes[i])
    +			{
    +				this.nodes[i].clear();
    +				delete this.nodes[i];
    +		  	}
    +		}
    +	}
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/RandomDataGenerator.js.html b/docs/RandomDataGenerator.js.html new file mode 100644 index 00000000..aae4f2ff --- /dev/null +++ b/docs/RandomDataGenerator.js.html @@ -0,0 +1,691 @@ + + + + + + Phaser Source: math/RandomDataGenerator.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: math/RandomDataGenerator.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser.RandomDataGenerator constructor.
    +* 
    +* @class Phaser.RandomDataGenerator
    +* @classdesc An extremely useful repeatable random data generator. Access it via Phaser.Game.rnd
    +* Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense.
    +* Random number generator from http://baagoe.org/en/wiki/Better_random_numbers_for_javascript
    +* 
    +* @constructor
    +* @param {array} seeds
    +*/
    +Phaser.RandomDataGenerator = function (seeds) {
    +	
    +	if (typeof seeds === "undefined") { seeds = []; }
    +
    +	this.sow(seeds);
    +
    +};
    +
    +Phaser.RandomDataGenerator.prototype = {
    +
    +	/**
    +	* @property {number} c
    +	* @private
    +	*/
    +	c: 1,
    +
    +	/**
    +	* @property {number} s0
    +	* @private
    +	*/
    +	s0: 0,
    +
    +	/**
    +	* @property {number} s1
    +	* @private
    +	*/
    +	s1: 0,
    +
    +	/**
    +	* @property {number} s2
    +	* @private
    +	*/
    +	s2: 0,
    +
    +	/**
    +	* Private random helper.
    +	* @method Phaser.RandomDataGenerator#rnd
    +	* @private
    +	* @return {number} Description.
    +	*/
    +	rnd: function () {
    +
    +		var t = 2091639 * this.s0 + this.c * 2.3283064365386963e-10; // 2^-32
    +
    +		this.c = t | 0;
    +		this.s0 = this.s1;
    +		this.s1 = this.s2;
    +		this.s2 = t - this.c;
    +
    +		return this.s2;
    +	},
    +
    +	/**
    +	* Reset the seed of the random data generator.
    +	* 
    +	* @method Phaser.RandomDataGenerator#sow
    +	* @param {array} seeds
    +	*/
    +	sow: function (seeds) {
    +
    +		if (typeof seeds === "undefined") { seeds = []; }
    +
    +		this.s0 = this.hash(' ');
    +		this.s1 = this.hash(this.s0);
    +		this.s2 = this.hash(this.s1);
    +		this.c = 1;
    +
    +		var seed;
    +
    +		for (var i = 0; seed = seeds[i++]; )
    +		{
    +			this.s0 -= this.hash(seed);
    +			this.s0 += ~~(this.s0 < 0);
    +			this.s1 -= this.hash(seed);
    +			this.s1 += ~~(this.s1 < 0);
    +			this.s2 -= this.hash(seed);
    +			this.s2 += ~~(this.s2 < 0);
    +		}
    +		
    +	},
    +
    +	/**
    +	* Description.
    +	* @method Phaser.RandomDataGenerator#hash
    +	* @param {Any} data
    +	* @private
    +	* @return {number} Description.
    +	*/
    +	hash: function (data) {
    +
    +		var h, i, n;
    +		n = 0xefc8249d;
    +		data = data.toString();
    +
    +		for (i = 0; i < data.length; i++) {
    +			n += data.charCodeAt(i);
    +			h = 0.02519603282416938 * n;
    +			n = h >>> 0;
    +			h -= n;
    +			h *= n;
    +			n = h >>> 0;
    +			h -= n;
    +			n += h * 0x100000000;// 2^32
    +		}
    +
    +		return (n >>> 0) * 2.3283064365386963e-10;// 2^-32
    +
    +	},
    +
    +	/**
    +	* Returns a random integer between 0 and 2^32.
    +	* @method Phaser.RandomDataGenerator#integer
    +	* @return {number}
    +	*/
    +	integer: function() {
    +		return this.rnd.apply(this) * 0x100000000;// 2^32
    +	},
    +
    +	/**
    +	* Returns a random real number between 0 and 1.
    +	* @method Phaser.RandomDataGenerator#frac
    +	* @return {number}
    +	*/	
    +	frac: function() {
    +		return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16;// 2^-53
    +	},
    +
    +	/**
    +	* Returns a random real number between 0 and 2^32.
    +	* @method Phaser.RandomDataGenerator#real
    +	* @return {number}
    +	*/
    +	real: function() {
    +		return this.integer() + this.frac();
    +	},
    +
    +	/**
    +	* Returns a random integer between min and max.
    +	* @method Phaser.RandomDataGenerator#integerInRange
    +	* @param {number} min
    +	* @param {number} max
    +	* @return {number}
    +	*/
    +	integerInRange: function (min, max) {
    +		return Math.floor(this.realInRange(min, max));
    +	},
    +
    +	/**
    +	* Returns a random real number between min and max.
    +	* @method Phaser.RandomDataGenerator#realInRange
    +	* @param {number} min
    +	* @param {number} max
    +	* @return {number}
    +	*/
    +	realInRange: function (min, max) {
    +
    +		return this.frac() * (max - min) + min;
    +
    +	},
    +
    +	/**
    +	* Returns a random real number between -1 and 1.
    +	* @method Phaser.RandomDataGenerator#normal
    +	* @return {number}
    +	*/
    +	normal: function () {
    +		return 1 - 2 * this.frac();
    +	},
    +
    +	/**
    +	* Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368
    +	* @method Phaser.RandomDataGenerator#uuid
    +	* @return {string}
    +	*/
    +	uuid: function () {
    +
    +		var a, b;
    +
    +		for (
    +			b=a='';
    +			a++<36;
    +			b+=~a%5|a*3&4?(a^15?8^this.frac()*(a^20?16:4):4).toString(16):'-'
    +		);
    +
    +		return b;
    +
    +	},
    +
    +	/**
    +	* Returns a random member of `array`.
    +	* @method Phaser.RandomDataGenerator#pick
    +	* @param {Any} ary
    +	* @return {number}
    +	*/
    +	pick: function (ary) {
    +		return ary[this.integerInRange(0, ary.length)];
    +	},
    +
    +	/**
    +	* Returns a random member of `array`, favoring the earlier entries.
    +	* @method Phaser.RandomDataGenerator#weightedPick
    +	* @param {Any} ary
    +	* @return {number}
    +	*/
    +	weightedPick: function (ary) {
    +		return ary[~~(Math.pow(this.frac(), 2) * ary.length)];
    +	},
    +
    +	/**
    +	* Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified.
    +	* @method Phaser.RandomDataGenerator#timestamp
    +	* @param {number} min
    +	* @param {number} max
    +	* @return {number}
    +	*/
    +	timestamp: function (a, b) {
    +		return this.realInRange(a || 946684800000, b || 1577862000000);
    +	},
    +
    +	/**
    +	* Returns a random angle between -180 and 180.
    +	* @method Phaser.RandomDataGenerator#angle
    +	* @return {number}
    +	*/
    +	angle: function() {
    +		return this.integerInRange(-180, 180);
    +	}
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Rectangle.js.html b/docs/Rectangle.js.html new file mode 100644 index 00000000..3a2f95a2 --- /dev/null +++ b/docs/Rectangle.js.html @@ -0,0 +1,1128 @@ + + + + + + Phaser Source: geom/Rectangle.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: geom/Rectangle.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. If you call this function without parameters, a Rectangle with x, y, width, and height properties set to 0 is created.
    +*
    +* @class Phaser.Rectangle
    +* @constructor
    +* @param {number} x - The x coordinate of the top-left corner of the Rectangle.
    +* @param {number} y - The y coordinate of the top-left corner of the Rectangle.
    +* @param {number} width - The width of the Rectangle in pixels.
    +* @param {number} height - The height of the Rectangle in pixels.
    +* @return {Rectangle} This Rectangle object.
    +**/
    +Phaser.Rectangle = function (x, y, width, height) {
    +
    +    x = x || 0;
    +    y = y || 0;
    +    width = width || 0;
    +    height = height || 0;
    +
    +    /**
    +    * @property {number} x - Description.
    +    */
    +    this.x = x;
    +    
    +    /**
    +    * @property {number} y - Description.
    +    */
    +    this.y = y;
    +    
    +    /**
    +    * @property {number} width - Description.
    +    */
    +    this.width = width;
    +    
    +    /**
    +    * @property {number} height - Description.
    +    */
    +    this.height = height;
    +
    +};
    +
    +Phaser.Rectangle.prototype = {
    +
    +    /**
    +    * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.
    +    * @method Phaser.Rectangle#offset
    +    * @param {number} dx - Moves the x value of the Rectangle object by this amount.
    +    * @param {number} dy - Moves the y value of the Rectangle object by this amount.
    +    * @return {Rectangle} This Rectangle object.
    +    **/
    +    offset: function (dx, dy) {
    +
    +        this.x += dx;
    +        this.y += dy;
    +
    +        return this;
    +
    +    },
    + 
    +    /**
    +    * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter.
    +    * @method Phaser.Rectangle#offsetPoint
    +    * @param {Point} point - A Point object to use to offset this Rectangle object.
    +    * @return {Rectangle} This Rectangle object.
    +    **/
    +    offsetPoint: function (point) {
    +        return this.offset(point.x, point.y);
    +    },
    + 
    +    /**
    +    * Sets the members of Rectangle to the specified values.
    +    * @method Phaser.Rectangle#setTo
    +    * @param {number} x - The x coordinate of the top-left corner of the Rectangle.
    +    * @param {number} y - The y coordinate of the top-left corner of the Rectangle.
    +    * @param {number} width - The width of the Rectangle in pixels.
    +    * @param {number} height - The height of the Rectangle in pixels.
    +    * @return {Rectangle} This Rectangle object
    +    **/
    +    setTo: function (x, y, width, height) {
    +
    +        this.x = x;
    +        this.y = y;
    +        this.width = width;
    +        this.height = height;
    +
    +        return this;
    +
    +    },
    + 
    +    /**
    +    * Runs Math.floor() on both the x and y values of this Rectangle.
    +    * @method Phaser.Rectangle#floor
    +    **/
    +    floor: function () {
    +
    +        this.x = Math.floor(this.x);
    +        this.y = Math.floor(this.y);
    +
    +    },
    + 
    +    /**
    +    * Runs Math.floor() on the x, y, width and height values of this Rectangle.
    +    * @method Phaser.Rectangle#floorAll
    +    **/
    +    floorAll: function () {
    +
    +        this.x = Math.floor(this.x);
    +        this.y = Math.floor(this.y);
    +        this.width = Math.floor(this.width);
    +        this.height = Math.floor(this.height);
    +
    +    },
    +
    +    /**
    +    * Copies the x, y, width and height properties from any given object to this Rectangle.
    +    * @method Phaser.Rectangle#copyFrom
    +    * @param {any} source - The object to copy from.
    +    * @return {Rectangle} This Rectangle object.
    +    **/
    +    copyFrom: function (source) {
    +        return this.setTo(source.x, source.y, source.width, source.height);
    +    },
    +
    +    /**
    +    * Copies the x, y, width and height properties from this Rectangle to any given object.
    +    * @method Phaser.Rectangle#copyTo
    +    * @param {any} source - The object to copy to.
    +    * @return {object} This object.
    +    **/
    +    copyTo: function (dest) {
    +
    +        dest.x = this.x;
    +        dest.y = this.y;
    +        dest.width = this.width;
    +        dest.height = this.height;
    +
    +        return dest;
    +
    +    },
    +
    +    /**
    +    * Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.
    +    * @method Phaser.Rectangle#inflate
    +    * @param {number} dx - The amount to be added to the left side of the Rectangle.
    +    * @param {number} dy - The amount to be added to the bottom side of the Rectangle.
    +    * @return {Phaser.Rectangle} This Rectangle object.
    +    */
    +    inflate: function (dx, dy) {
    +        return Phaser.Rectangle.inflate(this, dx, dy);
    +    },
    +
    +    /**
    +    * The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.
    +    * @method Phaser.Rectangle#size
    +    * @param {Phaser.Point} [output] - Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned.
    +    * @return {Phaser.Point} The size of the Rectangle object.
    +    */
    +    size: function (output) {
    +        return Phaser.Rectangle.size(this, output);
    +    },
    +
    +    /**
    +    * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
    +    * @method Phaser.Rectangle#clone
    +    * @param {Phaser.Rectangle} [output] - Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned.
    +    * @return {Phaser.Rectangle} 
    +    */
    +    clone: function (output) {
    +        return Phaser.Rectangle.clone(this, output);
    +    },
    +
    +    /**
    +    * Determines whether the specified coordinates are contained within the region defined by this Rectangle object.
    +    * @method Phaser.Rectangle#contains
    +    * @param {number} x - The x coordinate of the point to test.
    +    * @param {number} y - The y coordinate of the point to test.
    +    * @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
    +    */
    +    contains: function (x, y) {
    +        return Phaser.Rectangle.contains(this, x, y);
    +    },
    +
    +    /**
    +    * Determines whether the first Rectangle object is fully contained within the second Rectangle object.
    +    * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.
    +    * @method Phaser.Rectangle#containsRect
    +    * @param {Phaser.Rectangle} b - The second Rectangle object.
    +    * @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
    +    */
    +    containsRect: function (b) {
    +        return Phaser.Rectangle.containsRect(this, b);
    +    },
    +
    +    /**
    +    * Determines whether the two Rectangles are equal.
    +    * This method compares the x, y, width and height properties of each Rectangle.
    +    * @method Phaser.Rectangle#equals
    +    * @param {Phaser.Rectangle} b - The second Rectangle object.
    +    * @return {boolean} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false.
    +    */
    +    equals: function (b) {
    +        return Phaser.Rectangle.equals(this, b);
    +    },
    +
    +    /**
    +    * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.
    +    * @method Phaser.Rectangle#intersection
    +    * @param {Phaser.Rectangle} b - The second Rectangle object.
    +    * @param {Phaser.Rectangle} out - Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
    +    * @return {Phaser.Rectangle} A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0.
    +    */
    +    intersection: function (b, out) {
    +        return Phaser.Rectangle.intersection(this, b, output);
    +    },
    +
    +    /**
    +    * Determines whether the two Rectangles intersect with each other.
    +    * This method checks the x, y, width, and height properties of the Rectangles.
    +    * @method Phaser.Rectangle#intersects
    +    * @param {Phaser.Rectangle} b - The second Rectangle object.
    +    * @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0.
    +    * @return {boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false.
    +    */
    +    intersects: function (b, tolerance) {
    +        return Phaser.Rectangle.intersects(this, b, tolerance);
    +    },
    +
    +    /**
    +    * Determines whether the object specified intersects (overlaps) with the given values.
    +    * @method Phaser.Rectangle#intersectsRaw
    +    * @param {number} left - Description.
    +    * @param {number} right - Description.
    +    * @param {number} top - Description.
    +    * @param {number} bottomt - Description.
    +    * @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0
    +    * @return {boolean} A value of true if the specified object intersects with the Rectangle; otherwise false.
    +    */
    +    intersectsRaw: function (left, right, top, bottom, tolerance) {
    +        return Phaser.Rectangle.intersectsRaw(this, left, right, top, bottom, tolerance);
    +    },
    +
    +    /**
    +    * Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles.
    +    * @method Phaser.Rectangle#union
    +    * @param {Phaser.Rectangle} b - The second Rectangle object.
    +    * @param {Phaser.Rectangle} [out] - Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
    +    * @return {Phaser.Rectangle} A Rectangle object that is the union of the two Rectangles.
    +    */
    +    union: function (b, out) {
    +        return Phaser.Rectangle.union(this, b, out);
    +    },
    +
    +    /**
    +    * Returns a string representation of this object.
    +    * @method Phaser.Rectangle#toString
    +    * @return {string} A string representation of the instance.
    +    **/
    +    toString: function () {
    +        return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.empty + ")}]";
    +    }
    +
    +};
    +
    +/**
    +* @name Phaser.Rectangle#halfWidth
    +* @property {number} halfWidth - Half of the width of the Rectangle.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "halfWidth", {
    +
    +    get: function () {
    +        return Math.round(this.width / 2);
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Rectangle#halfHeight
    +* @property {number} halfHeight - Half of the height of the Rectangle.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", {
    +
    +    get: function () {
    +        return Math.round(this.height / 2);
    +    }
    +
    +});
    +
    +/**
    +* 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.
    +* @name Phaser.Rectangle#bottom
    +* @property {number} bottom - The sum of the y and height properties.
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "bottom", {
    +    
    +    get: function () {
    +        return this.y + this.height;
    +    },
    +  
    +    set: function (value) {
    +        if (value <= this.y) {
    +            this.height = 0;
    +        } else {
    +            this.height = (this.y - value);
    +        }
    +    }
    +
    +});
    +
    +/**
    +* The location of the Rectangles bottom right corner as a Point object.
    +* @name Phaser.Rectangle#bottom
    +* @property {Phaser.Point} bottomRight - Gets or sets the location of the Rectangles bottom right corner as a Point object.
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", {
    +    
    +    get: function () {
    +        return new Phaser.Point(this.right, this.bottom);
    +    },
    +
    +    set: function (value) {
    +        this.right = value.x;
    +        this.bottom = value.y;
    +    }
    +
    +});
    +
    +/**
    +* 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.
    +* @name Phaser.Rectangle#left
    +* @property {number} left - The x coordinate of the left of the Rectangle.
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "left", {
    +   
    +    get: function () {
    +        return this.x;
    +    },
    +
    +    set: function (value) {
    +        if (value >= this.right) {
    +            this.width = 0;
    +        } else {
    +            this.width = this.right - value;
    +        }
    +        this.x = value;
    +    }
    +
    +});
    +
    +/**
    +* 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.
    +* @name Phaser.Rectangle#right
    +* @property {number} right - The sum of the x and width properties.
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "right", {
    +       
    +    get: function () {
    +        return this.x + this.width;
    +    },
    +
    +    set: function (value) {
    +        if (value <= this.x) {
    +            this.width = 0;
    +        } else {
    +            this.width = this.x + value;
    +        }
    +    }
    +
    +});
    +
    +/**
    +* The volume of the Rectangle derived from width * height.
    +* @name Phaser.Rectangle#volume
    +* @property {number} volume - The volume of the Rectangle derived from width * height.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "volume", {
    +    
    +    get: function () {
    +        return this.width * this.height;
    +    }
    +
    +});
    +
    +/**
    +* The perimeter size of the Rectangle. This is the sum of all 4 sides.
    +* @name Phaser.Rectangle#perimeter
    +* @property {number} perimeter - The perimeter size of the Rectangle. This is the sum of all 4 sides.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", {
    +    
    +    get: function () {
    +        return (this.width * 2) + (this.height * 2);
    +    }
    +
    +});
    +
    +/**
    +* The x coordinate of the center of the Rectangle.
    +* @name Phaser.Rectangle#centerX
    +* @property {number} centerX - The x coordinate of the center of the Rectangle.
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "centerX", {
    +    
    +    get: function () {
    +        return this.x + this.halfWidth;
    +    },
    +
    +    set: function (value) {
    +        this.x = value - this.halfWidth;
    +    }
    +
    +});
    +
    +/**
    +* The y coordinate of the center of the Rectangle.
    +* @name Phaser.Rectangle#centerY
    +* @property {number} centerY - The y coordinate of the center of the Rectangle.
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "centerY", {
    +    
    +    get: function () {
    +        return this.y + this.halfHeight;
    +    },
    +
    +    set: function (value) {
    +        this.y = value - this.halfHeight;
    +    }
    +
    +});
    +
    +/**
    +* 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.
    +* @name Phaser.Rectangle#top
    +* @property {number} top - The y coordinate of the top of the Rectangle.
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "top", {
    +    
    +    get: function () {
    +        return this.y;
    +    },
    +
    +    set: function (value) {
    +        if (value >= this.bottom) {
    +            this.height = 0;
    +            this.y = value;
    +        } else {
    +            this.height = (this.bottom - value);
    +        }
    +    }
    +
    +});
    +
    +/**
    +* The location of the Rectangles top left corner as a Point object.
    +* @name Phaser.Rectangle#topLeft
    +* @property {Phaser.Point} topLeft - The location of the Rectangles top left corner as a Point object.
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", {
    +
    +    get: function () {
    +        return new Phaser.Point(this.x, this.y);
    +    },
    +    
    +    set: function (value) {
    +        this.x = value.x;
    +        this.y = value.y;
    +    }
    +
    +});
    +
    +/**
    +* Determines whether or not this Rectangle object is empty. A Rectangle object is empty if its width or height is less than or equal to 0.
    +* If set to true then all of the Rectangle properties are set to 0. 
    +* @name Phaser.Rectangle#empty
    +* @property {boolean} empty - Gets or sets the Rectangles empty state.
    +*/
    +Object.defineProperty(Phaser.Rectangle.prototype, "empty", {
    +    
    +    get: function () {
    +        return (!this.width || !this.height);
    +    },
    +
    +    set: function (value) {
    +        this.setTo(0, 0, 0, 0);
    +    }
    +
    +});
    +
    +/**
    +* Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.
    +* @method Phaser.Rectangle.inflate
    +* @param {Phaser.Rectangle} a - The Rectangle object.
    +* @param {number} dx - The amount to be added to the left side of the Rectangle.
    +* @param {number} dy - The amount to be added to the bottom side of the Rectangle.
    +* @return {Phaser.Rectangle} This Rectangle object.
    +*/
    +Phaser.Rectangle.inflate = function (a, dx, dy) {
    +    a.x -= dx;
    +    a.width += 2 * dx;
    +    a.y -= dy;
    +    a.height += 2 * dy;
    +    return a;
    +};
    +
    +/**
    +* Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter.
    +* @method Phaser.Rectangle.inflatePoint
    +* @param {Phaser.Rectangle} a - The Rectangle object.
    +* @param {Phaser.Point} point - The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object.
    +* @return {Phaser.Rectangle} The Rectangle object.
    +*/
    +Phaser.Rectangle.inflatePoint = function (a, point) {
    +    return Phaser.Rectangle.inflate(a, point.x, point.y);
    +};
    +
    +/**
    +* The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.
    +* @method Phaser.Rectangle.size
    +* @param {Phaser.Rectangle} a - The Rectangle object.
    +* @param {Phaser.Point} [output] - Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned.
    +* @return {Phaser.Point} The size of the Rectangle object
    +*/
    +Phaser.Rectangle.size = function (a, output) {
    +    if (typeof output === "undefined") { output = new Phaser.Point(); }
    +    return output.setTo(a.width, a.height);
    +};
    +
    +/**
    +* Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
    +* @method Phaser.Rectangle.clone
    +* @param {Phaser.Rectangle} a - The Rectangle object.
    +* @param {Phaser.Rectangle} [output] - Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned.
    +* @return {Phaser.Rectangle}
    +*/
    +Phaser.Rectangle.clone = function (a, output) {
    +    if (typeof output === "undefined") { output = new Phaser.Rectangle(); }
    +    return output.setTo(a.x, a.y, a.width, a.height);
    +};
    +
    +/**
    +* Determines whether the specified coordinates are contained within the region defined by this Rectangle object.
    +* @method Phaser.Rectangle.contains
    +* @param {Phaser.Rectangle} a - The Rectangle object.
    +* @param {number} x - The x coordinate of the point to test.
    +* @param {number} y - The y coordinate of the point to test.
    +* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
    +*/
    +Phaser.Rectangle.contains = function (a, x, y) {
    +    return (x >= a.x && x <= a.right && y >= a.y && y <= a.bottom);
    +};
    +
    +Phaser.Rectangle.containsRaw = function (rx, ry, rw, rh, x, y) {
    +    return (x >= rx && x <= (rx + rw) && y >= ry && y <= (ry + rh));
    +};
    +
    +/**
    +* Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter.
    +* @method Phaser.Rectangle.containsPoint
    +* @param {Phaser.Rectangle} a - The Rectangle object.
    +* @param {Phaser.Point} point - The point object being checked. Can be Point or any object with .x and .y values.
    +* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
    +*/
    +Phaser.Rectangle.containsPoint = function (a, point) {
    +    return Phaser.Rectangle.contains(a, point.x, point.y);
    +};
    +
    +/**
    +* Determines whether the first Rectangle object is fully contained within the second Rectangle object.
    +* A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.
    +* @method Phaser.Rectangle.containsRect
    +* @param {Phaser.Rectangle} a - The first Rectangle object.
    +* @param {Phaser.Rectangle} b - The second Rectangle object.
    +* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
    +*/
    +Phaser.Rectangle.containsRect = function (a, b) {
    +
    +    //  If the given rect has a larger volume than this one then it can never contain it
    +    if (a.volume > b.volume)
    +    {
    +        return false;
    +    }
    +
    +    return (a.x >= b.x && a.y >= b.y && a.right <= b.right && a.bottom <= b.bottom);
    +
    +};
    +
    +/**
    +* Determines whether the two Rectangles are equal.
    +* This method compares the x, y, width and height properties of each Rectangle.
    +* @method Phaser.Rectangle.equals
    +* @param {Phaser.Rectangle} a - The first Rectangle object.
    +* @param {Phaser.Rectangle} b - The second Rectangle object.
    +* @return {boolean} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false.
    +*/
    +Phaser.Rectangle.equals = function (a, b) {
    +    return (a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height);
    +};
    +
    +/**
    +* If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.
    +* @method Phaser.Rectangle.intersection
    +* @param {Phaser.Rectangle} a - The first Rectangle object.
    +* @param {Phaser.Rectangle} b - The second Rectangle object.
    +* @param {Phaser.Rectangle} [out] - Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
    +* @return {Phaser.Rectangle} A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0.
    +*/
    +Phaser.Rectangle.intersection = function (a, b, out) {
    +
    +    out  = out || new Phaser.Rectangle;
    +
    +    if (Phaser.Rectangle.intersects(a, b))
    +    {
    +        out.x = Math.max(a.x, b.x);
    +        out.y = Math.max(a.y, b.y);
    +        out.width = Math.min(a.right, b.right) - out.x;
    +        out.height = Math.min(a.bottom, b.bottom) - out.y;
    +    }
    +
    +    return out;
    +
    +};
    +
    +/**
    +* Determines whether the two Rectangles intersect with each other.
    +* This method checks the x, y, width, and height properties of the Rectangles.
    +* @method Phaser.Rectangle.intersects
    +* @param {Phaser.Rectangle} a - The first Rectangle object.
    +* @param {Phaser.Rectangle} b - The second Rectangle object.
    +* @return {boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false.
    +*/
    +Phaser.Rectangle.intersects = function (a, b) {
    +
    +    return (a.x < b.right && b.x < a.right && a.y < b.bottom && b.y < a.bottom);
    +
    +    // return (a.x <= b.right && b.x <= a.right && a.y <= b.bottom && b.y <= a.bottom);
    +
    +    // return (a.left <= b.right && b.left <= a.right && a.top <= b.bottom && b.top <= a.bottom);
    +    // return !(a.x > b.right + tolerance || a.right < b.x - tolerance || a.y > b.bottom + tolerance || a.bottom < b.y - tolerance);
    +
    +};
    +
    +/**
    +* Determines whether the object specified intersects (overlaps) with the given values.
    +* @method Phaser.Rectangle.intersectsRaw
    +* @param {number} left - Description.
    +* @param {number} right - Description.
    +* @param {number} top - Description.
    +* @param {number} bottom - Description.
    +* @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0
    +* @return {boolean} A value of true if the specified object intersects with the Rectangle; otherwise false.
    +*/
    +Phaser.Rectangle.intersectsRaw = function (a, left, right, top, bottom, tolerance) {
    +
    +    if (typeof tolerance === "undefined") { tolerance = 0; }
    +
    +    return !(left > a.right + tolerance || right < a.left - tolerance || top > a.bottom + tolerance || bottom < a.top - tolerance);
    +
    +};
    +
    +/**
    +* Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles.
    +* @method Phaser.Rectangle.union
    +* @param {Phaser.Rectangle} a - The first Rectangle object.
    +* @param {Phaser.Rectangle} b - The second Rectangle object.
    +* @param {Phaser.Rectangle} [out] - Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
    +* @return {Phaser.Rectangle} A Rectangle object that is the union of the two Rectangles.
    +*/
    +Phaser.Rectangle.union = function (a, b, out) {
    +
    +    if (typeof out === "undefined") { out = new Phaser.Rectangle(); }
    +
    +    return out.setTo(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.right, b.right) - Math.min(a.left, b.left), Math.max(a.bottom, b.bottom) - Math.min(a.top, b.top));
    +    
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/RenderTexture.js.html b/docs/RenderTexture.js.html new file mode 100644 index 00000000..ea651e4f --- /dev/null +++ b/docs/RenderTexture.js.html @@ -0,0 +1,514 @@ + + + + + + Phaser Source: gameobjects/RenderTexture.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: gameobjects/RenderTexture.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* A dynamic initially blank canvas to which images can be drawn
    +* @class Phaser.RenderTexture
    +* @constructor
    +* @param {Phaser.Game} game - Current game instance.
    +* @param {string} key - Asset key for the render texture.
    +* @param {number} width - the width of the render texture.
    +* @param {number} height - the height of the render texture.
    +*/
    +Phaser.RenderTexture = function (game, key, width, height) {
    +
    +	/**
    +	* @property {Phaser.Game} game - A reference to the currently running game. 
    +	*/
    +	this.game = game;
    +
    +	/**
    +    * @property {string} name - the name of the object. 
    +	*/
    +    this.name = key;
    +
    +	PIXI.EventTarget.call( this );
    +
    +	/**
    +	* @property {number} width - the width. 
    +    */
    +	this.width = width || 100;
    +	
    +	/**
    +	* @property {number} height - the height. 
    +    */
    +	this.height = height || 100;
    +
    +	/**
    +	* I know this has a typo in it, but it's because the PIXI.RenderTexture does and we need to pair-up with it
    +	* once they update pixi to fix the typo, we'll fix it here too :)
    +    * @property {Description} indetityMatrix - Description. 
    + 	*/
    +	this.indetityMatrix = PIXI.mat3.create();
    +
    +	/**
    +	* @property {Description} frame - Description. 
    +    */
    +	this.frame = new PIXI.Rectangle(0, 0, this.width, this.height);	
    +
    +	/**
    +	* @property {Description} type - Description. 
    +    */
    +	this.type = Phaser.RENDERTEXTURE;
    +
    +	if (PIXI.gl)
    +	{
    +		this.initWebGL();
    +	}
    +	else
    +	{
    +		this.initCanvas();
    +	}
    +	
    +};
    +
    +Phaser.RenderTexture.prototype = Phaser.Utils.extend(true, PIXI.RenderTexture.prototype);
    +Phaser.RenderTexture.prototype.constructor = Phaser.RenderTexture;
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/RequestAnimationFrame.js.html b/docs/RequestAnimationFrame.js.html new file mode 100644 index 00000000..5672c631 --- /dev/null +++ b/docs/RequestAnimationFrame.js.html @@ -0,0 +1,597 @@ + + + + + + Phaser Source: system/RequestAnimationFrame.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: system/RequestAnimationFrame.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Abstracts away the use of RAF or setTimeOut for the core game update loop.
    +*
    +* @class Phaser.RequestAnimationFrame 
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +*/
    +Phaser.RequestAnimationFrame = function(game) {
    +	
    +     /**
    +     * @property {Phaser.Game} game - The currently running game.
    +     */
    +	this.game = game;
    +
    +     /**
    +     * @property {boolean} _isSetTimeOut  - Description.
    +     * @private
    +     */
    +	this._isSetTimeOut = false;
    +     
    +     /**
    +     * @property {boolean} isRunning - Description.
    +     * @default
    +     */
    +	this.isRunning = false;
    +
    +	var vendors = [
    +		'ms', 
    +		'moz', 
    +		'webkit', 
    +		'o'
    +	];
    +
    +	for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++)
    +	{
    +		window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
    +		window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'];
    +	}
    +
    +	/**
    +	* The function called by the update
    +	* @property _onLoop
    +	* @private
    +	*/
    +	this._onLoop = null;
    +
    +};
    +
    +Phaser.RequestAnimationFrame.prototype = {
    +
    +
    +	/**
    +	* Starts the requestAnimatioFrame running or setTimeout if unavailable in browser
    +	* @method Phaser.RequestAnimationFrame#start
    +	*/
    +	start: function () {
    +
    +		this.isRunning = true;
    +
    +		var _this = this;
    +
    +		if (!window.requestAnimationFrame)
    +		{
    +			this._isSetTimeOut = true;
    +
    +            this._onLoop = function () {
    +                return _this.updateSetTimeout();
    +            };
    +
    +			this._timeOutID = window.setTimeout(this._onLoop, 0);
    +		}
    +		else
    +		{
    +			this._isSetTimeOut = false;
    +
    +            this._onLoop = function (time) {
    +                return _this.updateRAF(time);
    +            };
    +
    +			window.requestAnimationFrame(this._onLoop);
    +		}
    +
    +	},
    +
    +	/**
    +	* The update method for the requestAnimationFrame
    +	* @method Phaser.RequestAnimationFrame#updateRAF	
    +	* @param {number} time - A timestamp, either from RAF or setTimeOut
    +	*/
    +	updateRAF: function (time) {
    +
    +		this.game.update(time);
    +
    +		window.requestAnimationFrame(this._onLoop);
    +
    +	},
    +
    +	/**
    +	* The update method for the setTimeout.
    +	* @method Phaser.RequestAnimationFrame#updateSetTimeout
    +	*/
    +	updateSetTimeout: function () {
    +
    +		this.game.update(Date.now());
    +
    +		this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall);
    +
    +	},
    +
    +	/**
    +	* Stops the requestAnimationFrame from running.
    +	* @method Phaser.RequestAnimationFrame#stop
    +	*/
    +	stop: function () {
    +
    +		if (this._isSetTimeOut)
    +		{
    +			clearTimeout(this._timeOutID);
    +		}
    +		else
    +		{
    +			window.cancelAnimationFrame;
    +		}
    +
    +		this.isRunning = false;
    +
    +	},
    +
    +	/**
    +	* Is the browser using setTimeout?
    +	* @method Phaser.RequestAnimationFrame#isSetTimeOut
    +	* @return {boolean}
    +	*/
    +	isSetTimeOut: function () {
    +		return this._isSetTimeOut;
    +	},
    +
    +	/**
    +	* Is the browser using requestAnimationFrame?
    +	* @method Phaser.RequestAnimationFrame#isRAF
    +	* @return {boolean}
    +	*/
    +	isRAF: function () {
    +		return (this._isSetTimeOut === false);
    +	}
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Signal.js.html b/docs/Signal.js.html new file mode 100644 index 00000000..12d883ad --- /dev/null +++ b/docs/Signal.js.html @@ -0,0 +1,742 @@ + + + + + + Phaser Source: core/Signal.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/Signal.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* @class Phaser.Signal
    +* @classdesc A Signal is used for object communication via a custom broadcaster instead of Events.
    +* @author Miller Medeiros http://millermedeiros.github.com/js-signals/
    +* @constructor
    +*/
    +Phaser.Signal = function () {
    +
    +	/**
    +	* @property {Array.<Phaser.SignalBinding>} _bindings - Description.
    +	* @private
    +	*/
    +	this._bindings = [];
    +	
    +	/**
    +	* @property {Description} _prevParams - Description.
    +	* @private
    +	*/
    +	this._prevParams = null;
    +
    +	// enforce dispatch to aways work on same context (#47)
    +	var self = this;
    +
    +	/**
    +	* @property {Description} dispatch - Description.
    +	*/
    +	this.dispatch = function(){
    +		Phaser.Signal.prototype.dispatch.apply(self, arguments);
    +	};
    +
    +};
    +
    +Phaser.Signal.prototype = {
    +
    +	/**
    +    * If Signal should keep record of previously dispatched parameters and
    +	* automatically execute listener during `add()`/`addOnce()` if Signal was
    +	* already dispatched before.
    +	* @property {boolean} memorize
    +	*/
    +	memorize: false,
    +
    +	/**
    +	* @property {boolean} _shouldPropagate 
    +	* @private
    +	*/
    +	_shouldPropagate: true,
    +
    +	/**
    +	* If Signal is active and should broadcast events.
    +	* <p><strong>IMPORTANT:</strong> Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.</p>
    +	* @property {boolean} active
    +    * @default
    +    */
    +	active: true,
    +
    +	/**
    +	* @method Phaser.Signal#validateListener
    +	* @param {function} listener - Signal handler function.
    +	* @param {Description} fnName - Description.
    +	* @private
    +    */
    +	validateListener: function (listener, fnName) {
    +		if (typeof listener !== 'function') {
    +			throw new Error( 'listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName) );
    +		}
    +	},
    +
    +	/**
    +	 * @method Phaser.Signal#_registerListener
    +	 * @param {function} listener - Signal handler function.
    +	 * @param {boolean} isOnce - Description.
    +	 * @param {object} [listenerContext] - Description.
    +	 * @param {number} [priority] - The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0).
    +	 * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener.
    +	 * @private
    +	 */
    +	_registerListener: function (listener, isOnce, listenerContext, priority) {
    +
    +		var prevIndex = this._indexOfListener(listener, listenerContext),
    +			binding;
    +
    +		if (prevIndex !== -1) {
    +			binding = this._bindings[prevIndex];
    +			if (binding.isOnce() !== isOnce) {
    +				throw new Error('You cannot add'+ (isOnce? '' : 'Once') +'() then add'+ (!isOnce? '' : 'Once') +'() the same listener without removing the relationship first.');
    +			}
    +		} else {
    +			binding = new Phaser.SignalBinding(this, listener, isOnce, listenerContext, priority);
    +			this._addBinding(binding);
    +		}
    +
    +		if (this.memorize && this._prevParams){
    +			binding.execute(this._prevParams);
    +		}
    +
    +		return binding;
    +	},
    +
    +	/**
    +	 * @method Phaser.Signal#_addBinding 
    +	 * @param {Phaser.SignalBinding} binding - An Object representing the binding between the Signal and listener.
    +	 * @private
    +	 */
    +	_addBinding: function (binding) {
    +		//simplified insertion sort
    +		var n = this._bindings.length;
    +		do { --n; } while (this._bindings[n] && binding._priority <= this._bindings[n]._priority);
    +		this._bindings.splice(n + 1, 0, binding);
    +	},
    +
    +	/**
    +	 * @method Phaser.Signal#_indexOfListener
    +	 * @param {function} listener - Signal handler function.
    +	 * @return {number} Description.
    +	 * @private
    +	 */
    +	_indexOfListener: function (listener, context) {
    +		var n = this._bindings.length,
    +			cur;
    +		while (n--) {
    +			cur = this._bindings[n];
    +			if (cur._listener === listener && cur.context === context) {
    +				return n;
    +			}
    +		}
    +		return -1;
    +	},
    +
    +	/**
    +	 * Check if listener was attached to Signal.
    +	 * 
    +	 * @method Phaser.Signal#has
    +	 * @param {Function} listener - Signal handler function.
    +	 * @param {Object} [context] - Context on which listener will be executed (object that should represent the `this` variable inside listener function).
    +	 * @return {boolean} If Signal has the specified listener.
    +	 */
    +	has: function (listener, context) {
    +		return this._indexOfListener(listener, context) !== -1;
    +	},
    +
    +	/**
    +	 * Add a listener to the signal.
    +	 * 
    +	 * @method Phaser.Signal#add
    +	 * @param {function} listener - Signal handler function.
    +	 * @param {object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
    +	 * @param {number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0).
    +	 * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener.
    +	 */
    +	add: function (listener, listenerContext, priority) {
    +		this.validateListener(listener, 'add');
    +		return this._registerListener(listener, false, listenerContext, priority);
    +	},
    +
    +	/**
    +	* Add listener to the signal that should be removed after first execution (will be executed only once).
    +	*
    +	* @method Phaser.Signal#addOnce
    +	* @param {function} listener Signal handler function.
    +	* @param {object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
    +	* @param {number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
    +	* @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener.
    +	*/
    +	addOnce: function (listener, listenerContext, priority) {
    +		this.validateListener(listener, 'addOnce');
    +		return this._registerListener(listener, true, listenerContext, priority);
    +	},
    +
    +	/**
    +	* Remove a single listener from the dispatch queue.
    +	*
    +	* @method Phaser.Signal#remove
    +	* @param {function} listener Handler function that should be removed.
    +	* @param {object} [context] Execution context (since you can add the same handler multiple times if executing in a different context).
    +	* @return {function} Listener handler function.
    +	*/
    +	remove: function (listener, context) {
    +
    +		this.validateListener(listener, 'remove');
    +
    +		var i = this._indexOfListener(listener, context);
    +
    +		if (i !== -1)
    +		{
    +			this._bindings[i]._destroy(); //no reason to a Phaser.SignalBinding exist if it isn't attached to a signal
    +			this._bindings.splice(i, 1);
    +		}
    +
    +		return listener;
    +
    +	},
    +
    +	/**
    +	* Remove all listeners from the Signal.
    +	*
    +	* @method Phaser.Signal#removeAll
    +	*/
    +	removeAll: function () {
    +		var n = this._bindings.length;
    +		while (n--) {
    +			this._bindings[n]._destroy();
    +		}
    +		this._bindings.length = 0;
    +	},
    +
    +	/**
    +	* Gets the total number of listeneres attached to ths Signal.
    +	*
    +	* @method Phaser.Signal#getNumListeners
    +	* @return {number} Number of listeners attached to the Signal.
    +	*/
    +	getNumListeners: function () {
    +		return this._bindings.length;
    +	},
    +
    +	/**
    +	* Stop propagation of the event, blocking the dispatch to next listeners on the queue.
    +	* <p><strong>IMPORTANT:</strong> should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.</p>
    +	* @see Signal.prototype.disable
    +	*
    +	* @method Phaser.Signal#halt
    +	*/
    +	halt: function () {
    +		this._shouldPropagate = false;
    +	},
    +
    +	/**
    +	* Dispatch/Broadcast Signal to all listeners added to the queue.
    +	*
    +	* @method Phaser.Signal#dispatch
    +	* @param {any} [params] - Parameters that should be passed to each handler.
    +	*/
    +	dispatch: function (params) {
    +		if (! this.active) {
    +			return;
    +		}
    +
    +		var paramsArr = Array.prototype.slice.call(arguments),
    +			n = this._bindings.length,
    +			bindings;
    +
    +		if (this.memorize) {
    +			this._prevParams = paramsArr;
    +		}
    +
    +		if (! n) {
    +			//should come after memorize
    +			return;
    +		}
    +
    +		bindings = this._bindings.slice(); //clone array in case add/remove items during dispatch
    +		this._shouldPropagate = true; //in case `halt` was called before dispatch or during the previous dispatch.
    +
    +		//execute all callbacks until end of the list or until a callback returns `false` or stops propagation
    +		//reverse loop since listeners with higher priority will be added at the end of the list
    +		do { n--; } while (bindings[n] && this._shouldPropagate && bindings[n].execute(paramsArr) !== false);
    +	},
    +
    +	/**
    +	* Forget memorized arguments.
    +	* @see Signal.memorize
    +	*
    +	* @method Phaser.Signal#forget
    + 	*/
    +	forget: function(){
    +		this._prevParams = null;
    +	},
    +
    +	/**
    +	* Remove all bindings from signal and destroy any reference to external objects (destroy Signal object).
    +	* <p><strong>IMPORTANT:</strong> calling any method on the signal instance after calling dispose will throw errors.</p>
    +	*
    +	* @method Phaser.Signal#dispose
    +	*/
    +	dispose: function () {
    +		this.removeAll();
    +		delete this._bindings;
    +		delete this._prevParams;
    +	},
    +
    +	/**
    +	*
    +	* @method Phaser.Signal#toString
    +	* @return {string} String representation of the object.
    +	*/
    +	toString: function () {
    +		return '[Phaser.Signal active:'+ this.active +' numListeners:'+ this.getNumListeners() +']';
    +	}
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/SignalBinding.html b/docs/SignalBinding.html new file mode 100644 index 00000000..64277efe --- /dev/null +++ b/docs/SignalBinding.html @@ -0,0 +1,746 @@ + + + + + + Phaser Class: SignalBinding + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Class: SignalBinding

    +
    + +
    +

    + SignalBinding +

    + +

    Phaser.SignalBinding

    + +
    + +
    +
    + + + + +
    +

    new SignalBinding(signal, listener, isOnce, listenerContext, priority)

    + + +
    +
    + + +
    +

    Phaser.SignalBinding

    +

    Object that represents a binding between a Signal and a listener function. +<br />- <strong>This is an internal constructor and shouldn't be called by regular users.</strong> +<br />- inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.

    +
    + + + + + + + +
    Parameters:
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeArgumentDescription
    signal + + +Signal + + + + + + + + + +

    Reference to Signal object that listener is currently bound to.

    listener + + +function + + + + + + + + + +

    Handler function bound to the signal.

    isOnce + + +boolean + + + + + + + + + +

    If binding should be executed just once.

    listenerContext + + +object + + + + + + <optional>
    + + + + + +

    Context on which listener will be executed (object that should represent the this variable inside listener function).

    priority + + +number + + + + + + <optional>
    + + + + + +

    The priority level of the event listener. (default = 0).

    + + + + +
    + + + + + + + + + + + +
    Author:
    +
    +
      +
    • Miller Medeiros http://millermedeiros.github.com/js-signals/
    • +
    +
    + + + + + + + + + +
    Source:
    +
    + + + + + + + +
    + + + + + + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + + + + + +
    + +
    + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:32 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/SignalBinding.js.html b/docs/SignalBinding.js.html new file mode 100644 index 00000000..76457202 --- /dev/null +++ b/docs/SignalBinding.js.html @@ -0,0 +1,607 @@ + + + + + + Phaser Source: core/SignalBinding.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/SignalBinding.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser.SignalBinding
    +*
    +* Object that represents a binding between a Signal and a listener function.
    +* <br />- <strong>This is an internal constructor and shouldn't be called by regular users.</strong>
    +* <br />- inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.
    +*
    +* @class Phaser.SignalBinding
    +* @name SignalBinding
    +* @author Miller Medeiros http://millermedeiros.github.com/js-signals/
    +* @constructor
    +* @inner
    +* @param {Signal} signal - Reference to Signal object that listener is currently bound to.
    +* @param {function} listener - Handler function bound to the signal.
    +* @param {boolean} isOnce - If binding should be executed just once.
    +* @param {object} [listenerContext] - Context on which listener will be executed (object that should represent the `this` variable inside listener function).
    +* @param {number} [priority] - The priority level of the event listener. (default = 0).
    +*/
    +Phaser.SignalBinding = function (signal, listener, isOnce, listenerContext, priority) {
    +
    +    /**
    +	* @property {Phaser.Game} _listener - Handler function bound to the signal.
    +	* @private
    +	*/
    +    this._listener = listener;
    +
    +    /**
    +	* @property {boolean} _isOnce - If binding should be executed just once.
    +	* @private
    +	*/
    +    this._isOnce = isOnce;
    +
    +    /**
    +	* @property {object|undefined|null} context - Context on which listener will be executed (object that should represent the `this` variable inside listener function).
    +	* @memberof SignalBinding.prototype
    +	*/
    +    this.context = listenerContext;
    +
    +    /**
    +	* @property {Signal} _signal - Reference to Signal object that listener is currently bound to.
    +	* @private
    +	*/
    +    this._signal = signal;
    +
    +    /**
    +	* @property {number} _priority - Listener priority.
    +	* @private
    +	*/
    +    this._priority = priority || 0;
    +
    +};
    +
    +Phaser.SignalBinding.prototype = {
    +
    +    /**
    +    * If binding is active and should be executed.
    +    * @property {boolean} active
    +    * @default
    +    */ 
    +    active: true,
    +
    +    /**
    +    * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute` (curried parameters).
    +    * @property {array|null} params 
    +    * @default 
    +    */
    +    params: null,
    +
    +    /**
    +    * Call listener passing arbitrary parameters.
    +    * <p>If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.</p>
    +    * @method Phaser.SignalBinding#execute
    +    * @param {array} [paramsArr] - Array of parameters that should be passed to the listener.
    +    * @return {Description} Value returned by the listener.
    +    */
    +    execute: function (paramsArr) {
    +
    +        var handlerReturn, params;
    +
    +        if (this.active && !!this._listener)
    +        {
    +            params = this.params? this.params.concat(paramsArr) : paramsArr;
    +            handlerReturn = this._listener.apply(this.context, params);
    +
    +            if (this._isOnce)
    +            {
    +                this.detach();
    +            }
    +        }
    +
    +        return handlerReturn;
    +
    +    },
    +
    +    /**
    +    * Detach binding from signal.
    +    * <p>alias to: @see mySignal.remove(myBinding.getListener());
    +    * @method Phaser.SignalBinding#detach
    +    * @return {function|null} Handler function bound to the signal or `null` if binding was previously detached.
    +    */
    +    detach: function () {
    +        return this.isBound() ? this._signal.remove(this._listener, this.context) : null;
    +    },
    +
    +    /**
    +    * @method Phaser.SignalBinding#isBound
    +    * @return {boolean} True if binding is still bound to the signal and has a listener.
    +    */
    +    isBound: function () {
    +        return (!!this._signal && !!this._listener);
    +    },
    +
    +    /**
    +    * @method Phaser.SignalBinding#isOnce
    +    * @return {boolean} If SignalBinding will only be executed once.
    +    */
    +    isOnce: function () {
    +        return this._isOnce;
    +    },
    +
    +    /**
    +    * @method Phaser.SignalBinding#getListener
    +    * @return {Function} Handler function bound to the signal.
    +    */
    +    getListener: function () {
    +        return this._listener;
    +    },
    +
    +    /**
    +    * @method Phaser.SignalBinding#getSignal
    +    * @return {Signal} Signal that listener is currently bound to.
    +    */
    +    getSignal: function () {
    +        return this._signal;
    +    },
    +
    +    /**
    +    * @method Phaser.SignalBinding#_destroy
    +    * Delete instance properties
    +    * @private
    +    */
    +    _destroy: function () {
    +        delete this._signal;
    +        delete this._listener;
    +        delete this.context;
    +    },
    +
    +    /**
    +    * @method Phaser.SignalBinding#toString
    +    * @return {string} String representation of the object.
    +    */
    +    toString: function () {
    +        return '[Phaser.SignalBinding isOnce:' + this._isOnce +', isBound:'+ this.isBound() +', active:' + this.active + ']';
    +    }
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Sound.js.html b/docs/Sound.js.html new file mode 100644 index 00000000..e149bb2c --- /dev/null +++ b/docs/Sound.js.html @@ -0,0 +1,1272 @@ + + + + + + Phaser Source: sound/Sound.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: sound/Sound.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* The Sound class constructor.
    +*
    +* @class Phaser.Sound
    +* @classdesc The Sound class
    +* @constructor
    +* @param {Phaser.Game} game - Reference to the current game instance.
    +* @param {string} key - Asset key for the sound.
    +* @param {number} [volume=1] - Default value for the volume, between 0 and 1.
    +* @param {boolean} [loop=false] - Whether or not the sound will loop.
    +*/
    +Phaser.Sound = function (game, key, volume, loop) {
    +	
    +	volume = volume || 1;
    +	if (typeof loop == 'undefined') { loop = false; }
    +
    +    /**
    +    * A reference to the currently running Game.
    +    * @property {Phaser.Game} game
    +    */
    +    this.game = game;
    +
    +    /**
    +    * Name of the sound.
    +    * @property {string} name
    +    * @default
    +    */
    +    this.name = key;
    +
    +    /**
    +    * Asset key for the sound.
    +    * @property {string} key
    +    */
    +    this.key = key;
    +
    +    /**
    +    * Whether or not the sound will loop.
    +    * @property {boolean} loop
    +    */
    +    this.loop = loop;
    +
    +    /**
    +    * The global audio volume. A value between 0 (silence) and 1 (full volume).
    +    * @property {number} _volume
    +    * @private
    +    */
    +    this._volume = volume;
    +
    +    /**
    +    * The sound markers, empty by default.
    +    * @property {object} markers
    +    */
    +    this.markers = {};
    +
    +    
    +    /**
    +    * Reference to AudioContext instance.
    +    * @property {AudioContext} context
    +    * @default
    +    */
    +    this.context = null;
    +
    +    /**
    +    * Decoded data buffer / Audio tag.
    +    * @property {Description} _buffer
    +    * @private
    +    */
    +    this._buffer = null;
    +
    +    /**
    +    * Boolean indicating whether the game is on "mute". 
    +    * @property {boolean} _muted
    +    * @private
    +    * @default
    +    */
    +    this._muted = false;
    +
    +    /**
    +    * Boolean indicating whether the sound should start automatically.
    +    * @property {boolean} autoplay
    +    * @private
    +    */
    +    this.autoplay = false;
    +
    +    /**
    +    * The total duration of the sound, in milliseconds
    +    * @property {number} totalDuration
    +    * @default
    +    */
    +    this.totalDuration = 0;
    +   
    +    /**
    +    * Description.
    +    * @property {number} startTime
    +    * @default
    +    */
    +    this.startTime = 0;
    +    
    +    /**
    +    * Description.
    +    * @property {number} currentTime
    +    * @default
    +    */
    +    this.currentTime = 0;
    +    
    +    /**
    +    * Description.
    +    * @property {number} duration
    +    * @default
    +    */
    +    this.duration = 0;
    +    
    +    /**
    +    * Description.
    +    * @property {number} stopTime
    +    */
    +    this.stopTime = 0;
    +    
    +    /**
    +    * Description.
    +    * @property {boolean} paused
    +    * @default
    +    */
    +    this.paused = false;
    +    
    +    /**
    +    * Description.
    +    * @property {number} pausedPosition
    +    */
    +    this.pausedPosition = 0;
    +
    +    /**
    +    * Description.
    +    * @property {number} pausedTime
    +    */
    +    this.pausedTime = 0;
    +
    +    /**
    +    * Description.
    +    * @property {boolean} isPlaying
    +    * @default
    +    */
    +    this.isPlaying = false;
    +    
    +    /**
    +    * Description.
    +    * @property {string} currentMarker
    +    * @default
    +    */
    +    this.currentMarker = '';
    +    
    +    /**
    +    * Description.
    +    * @property {boolean} pendingPlayback
    +    * @default
    +    */
    +    this.pendingPlayback = false;
    +    
    +    /**
    +    * Description.
    +    * @property {boolean} override
    +    * @default
    +    */
    +    this.override = false;
    +    
    +    /**
    +    * Description.
    +    * @property {boolean} usingWebAudio
    +    */
    +    this.usingWebAudio = this.game.sound.usingWebAudio;
    +    
    +    /**
    +    * Description.
    +    * @property {Description} usingAudioTag
    +    */
    +    this.usingAudioTag = this.game.sound.usingAudioTag;
    +
    +    if (this.usingWebAudio)
    +    {
    +        this.context = this.game.sound.context;
    +        this.masterGainNode = this.game.sound.masterGain;
    +
    +        if (typeof this.context.createGain === 'undefined')
    +        {
    +            this.gainNode = this.context.createGainNode();
    +        }
    +        else
    +        {
    +            this.gainNode = this.context.createGain();
    +        }
    +
    +        this.gainNode.gain.value = volume * this.game.sound.volume;
    +        this.gainNode.connect(this.masterGainNode);
    +    }
    +    else
    +    {
    +        if (this.game.cache.getSound(key) && this.game.cache.isSoundReady(key))
    +        {
    +            this._sound = this.game.cache.getSoundData(key);
    +            this.totalDuration = 0;
    +
    +            if (this._sound.duration)
    +            {
    +                this.totalDuration = this._sound.duration;
    +            }
    +        }
    +        else
    +        {
    +            this.game.cache.onSoundUnlock.add(this.soundHasUnlocked, this);
    +        }
    +    }
    +
    +    /**
    +    * Description.
    +    * @property {Phaser.Signal} onDecoded
    +    */
    +    this.onDecoded = new Phaser.Signal;
    +    
    +    /**
    +    * Description.
    +    * @property {Phaser.Signal} onPlay
    +    */
    +    this.onPlay = new Phaser.Signal;
    +    
    +    /**
    +    * Description.
    +    * @property {Phaser.Signal} onPause
    +    */
    +    this.onPause = new Phaser.Signal;
    +    
    +    /**
    +    * Description.
    +    * @property {Phaser.Signal} onResume
    +    */
    +    this.onResume = new Phaser.Signal;
    +    
    +    /**
    +    * Description.
    +    * @property {Phaser.Signal} onLoop
    +    */
    +    this.onLoop = new Phaser.Signal;
    +    
    +    /**
    +    * Description.
    +    * @property {Phaser.Signal} onStop
    +    */
    +    this.onStop = new Phaser.Signal;
    +    
    +    /**
    +    * Description.
    +    * @property {Phaser.Signal} onMute
    +    */
    +    this.onMute = new Phaser.Signal;
    +    
    +    /**
    +    * Description.
    +    * @property {Phaser.Signal} onMarkerComplete
    +    */
    +    this.onMarkerComplete = new Phaser.Signal;
    +
    +};
    +
    +Phaser.Sound.prototype = {
    +
    +	/**
    +    * Called automatically when this sound is unlocked.
    +	* @method Phaser.Sound#soundHasUnlocked
    +	* @param {string} key - Description.
    +    * @protected
    +	*/
    +    soundHasUnlocked: function (key) {
    +
    +        if (key == this.key)
    +        {
    +            this._sound = this.game.cache.getSoundData(this.key);
    +            this.totalDuration = this._sound.duration;
    +            // console.log('sound has unlocked' + this._sound);
    +	    }
    +
    +	},
    +
    +	/**
    +	 * Description.
    +	 * @method Phaser.Sound#addMarker
    +	 * @param {string} name - Description.
    +	 * @param {Description} start - Description.
    +	 * @param {Description} stop - Description.
    +	 * @param {Description} volume - Description.
    +	 * @param {Description} loop - Description.
    +    addMarker: function (name, start, stop, volume, loop) {
    +
    +    	volume = volume || 1;
    +    	if (typeof loop == 'undefined') { loop = false; }
    +
    +        this.markers[name] = {
    +            name: name,
    +            start: start,
    +            stop: stop,
    +            volume: volume,
    +            duration: stop - start,
    +            loop: loop
    +        };
    +
    +    },
    +    */
    +
    +    /**
    +    * Adds a marker into the current Sound. A marker is represented by a unique key and a start time and duration.
    +    * This allows you to bundle multiple sounds together into a single audio file and use markers to jump between them for playback.
    +    *
    +    * @method Phaser.Sound#addMarker
    +    * @param {string} name - A unique name for this marker, i.e. 'explosion', 'gunshot', etc.
    +    * @param {number} start - The start point of this marker in the audio file, given in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
    +    * @param {number} duration - The duration of the marker in seconds. 2.5 = 2500ms, 0.5 = 500ms, etc.
    +    * @param {number} [volume=1] - The volume the sound will play back at, between 0 (silent) and 1 (full volume).
    +    * @param {boolean} [loop=false] - Sets if the sound will loop or not.
    +    */
    +    addMarker: function (name, start, duration, volume, loop) {
    +
    +        volume = volume || 1;
    +        if (typeof loop == 'undefined') { loop = false; }
    +
    +        this.markers[name] = {
    +            name: name,
    +            start: start,
    +            stop: start + duration,
    +            volume: volume,
    +            duration: duration,
    +            durationMS: duration * 1000,
    +            loop: loop
    +        };
    +
    +    },
    +
    +	/**
    +	* Removes a marker from the sound.
    +	* @method Phaser.Sound#removeMarker
    +	* @param {string} name - The key of the marker to remove.
    +	*/
    +    removeMarker: function (name) {
    +
    +        delete this.markers[name];
    +
    +    },
    +
    +	/**
    +	* Called automatically by Phaser.SoundManager.
    +	* @method Phaser.Sound#update
    +    * @protected
    +	*/
    +    update: function () {
    +
    +        if (this.pendingPlayback && this.game.cache.isSoundReady(this.key))
    +        {
    +            this.pendingPlayback = false;
    +            this.play(this._tempMarker, this._tempPosition, this._tempVolume, this._tempLoop);
    +        }
    +
    +        if (this.isPlaying)
    +        {
    +            this.currentTime = this.game.time.now - this.startTime;
    +
    +            if (this.currentTime >= this.durationMS)
    +            {
    +                //console.log(this.currentMarker, 'has hit duration');
    +                if (this.usingWebAudio)
    +                {
    +                    if (this.loop)
    +                    {
    +                        //console.log('loop1');
    +                        //  won't work with markers, needs to reset the position
    +                        this.onLoop.dispatch(this);
    +
    +                        if (this.currentMarker == '')
    +                        {
    +                            //console.log('loop2');
    +                            this.currentTime = 0;
    +                            this.startTime = this.game.time.now;
    +                        }
    +                        else
    +                        {
    +                            //console.log('loop3');
    +                            this.play(this.currentMarker, 0, this.volume, true, true);
    +                        }
    +                    }
    +                    else
    +                    {
    +                        //console.log('stopping, no loop for marker');
    +                        this.stop();
    +                    }
    +                }
    +                else
    +                {
    +                    if (this.loop)
    +                    {
    +                        this.onLoop.dispatch(this);
    +                        this.play(this.currentMarker, 0, this.volume, true, true);
    +                    }
    +                    else
    +                    {
    +                        this.stop();
    +                    }
    +                }
    +            }
    +        }
    +    },
    +
    +	/**
    +    * Play this sound, or a marked section of it.
    +    * @method Phaser.Sound#play
    +    * @param {string} [marker=''] - If you want to play a marker then give the key here, otherwise leave blank to play the full sound.
    +    * @param {number} [position=0] - The starting position to play the sound from - this is ignored if you provide a marker.
    +    * @param {number} [volume=1] - Volume of the sound you want to play.
    +    * @param {boolean} [loop=false] - Loop when it finished playing?
    +    * @param {boolean} [forceRestart=true] - If the sound is already playing you can set forceRestart to restart it from the beginning.
    +    * @return {Sound} The playing sound object.
    +    */
    +    play: function (marker, position, volume, loop, forceRestart) {
    +
    +    	marker = marker || '';
    +    	position = position || 0;
    +    	volume = volume || 1;
    +    	if (typeof loop == 'undefined') { loop = false; }
    +    	if (typeof forceRestart == 'undefined') { forceRestart = true; }
    +
    +        // console.log(this.name + ' play ' + marker + ' position ' + position + ' volume ' + volume + ' loop ' + loop, 'force', forceRestart);
    +
    +        if (this.isPlaying == true && forceRestart == false && this.override == false)
    +        {
    +            //  Use Restart instead
    +            return;
    +        }
    +
    +        if (this.isPlaying && this.override)
    +        {
    +            // console.log('asked to play ' + marker + ' but already playing ' + this.currentMarker);
    +        
    +            if (this.usingWebAudio)
    +            {
    +                if (typeof this._sound.stop === 'undefined')
    +                {
    +                    this._sound.noteOff(0);
    +                }
    +                else
    +                {
    +                    this._sound.stop(0);
    +                }
    +            }
    +            else if (this.usingAudioTag)
    +            {
    +                this._sound.pause();
    +                this._sound.currentTime = 0;
    +            }
    +        }
    +
    +        this.currentMarker = marker;
    +
    +        if (marker !== '')
    +        {
    +            if (this.markers[marker])
    +            {
    +                this.position = this.markers[marker].start;
    +                this.volume = this.markers[marker].volume;
    +                this.loop = this.markers[marker].loop;
    +                this.duration = this.markers[marker].duration;
    +                this.durationMS = this.markers[marker].durationMS;
    +
    +                // console.log('Marker Loaded: ', marker, 'start:', this.position, 'end: ', this.duration, 'loop', this.loop);
    +
    +                this._tempMarker = marker;
    +                this._tempPosition = this.position;
    +                this._tempVolume = this.volume;
    +                this._tempLoop = this.loop;
    +            }
    +            else
    +            {
    +                console.warn("Phaser.Sound.play: audio marker " + marker + " doesn't exist");
    +                return;
    +            }
    +        }
    +        else
    +        {
    +            // console.log('no marker info loaded', marker);
    +
    +            this.position = position;
    +            this.volume = volume;
    +            this.loop = loop;
    +            this.duration = 0;
    +            this.durationMS = 0;
    +
    +            this._tempMarker = marker;
    +            this._tempPosition = position;
    +            this._tempVolume = volume;
    +            this._tempLoop = loop;
    +        }
    +
    +        if (this.usingWebAudio)
    +        {
    +            //  Does the sound need decoding?
    +            if (this.game.cache.isSoundDecoded(this.key))
    +            {
    +                //  Do we need to do this every time we play? How about just if the buffer is empty?
    +                if (this._buffer == null)
    +                {
    +                    this._buffer = this.game.cache.getSoundData(this.key);
    +                }
    +
    +                this._sound = this.context.createBufferSource();
    +                this._sound.buffer = this._buffer;
    +                this._sound.connect(this.gainNode);
    +                this.totalDuration = this._sound.buffer.duration;
    +
    +                if (this.duration == 0)
    +                {
    +                    // console.log('duration reset');
    +                    this.duration = this.totalDuration;
    +                    this.durationMS = this.totalDuration * 1000;
    +                }
    +
    +                if (this.loop && marker == '')
    +                {
    +                    this._sound.loop = true;
    +                }
    +
    +                //  Useful to cache this somewhere perhaps?
    +                if (typeof this._sound.start === 'undefined')
    +                {
    +                    this._sound.noteGrainOn(0, this.position, this.duration);
    +                    // this._sound.noteGrainOn(0, this.position, this.duration / 1000);
    +                    //this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it
    +				}
    +				else
    +				{
    +                    // this._sound.start(0, this.position, this.duration / 1000);
    +                    this._sound.start(0, this.position, this.duration);
    +                }
    +
    +                this.isPlaying = true;
    +                this.startTime = this.game.time.now;
    +                this.currentTime = 0;
    +                this.stopTime = this.startTime + this.durationMS;
    +                this.onPlay.dispatch(this);
    +			}
    +			else
    +			{
    +                this.pendingPlayback = true;
    +
    +                if (this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).isDecoding == false)
    +                {
    +                    this.game.sound.decode(this.key, this);
    +                }
    +            }
    +        }
    +        else
    +        {
    +            // console.log('Sound play Audio');
    +            if (this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).locked)
    +            {
    +                // console.log('tried playing locked sound, pending set, reload started');
    +                this.game.cache.reloadSound(this.key);
    +                this.pendingPlayback = true;
    +            }
    +            else
    +            {
    +                // console.log('sound not locked, state?', this._sound.readyState);
    +                if (this._sound && this._sound.readyState == 4)
    +                {
    +                    this._sound.play();
    +                    //  This doesn't become available until you call play(), wonderful ...
    +                    this.totalDuration = this._sound.duration;
    +
    +                    if (this.duration == 0)
    +                    {
    +                        this.duration = this.totalDuration;
    +                        this.durationMS = this.totalDuration * 1000;
    +                    }
    +
    +                    // console.log('playing', this._sound);
    +                    this._sound.currentTime = this.position;
    +                    this._sound.muted = this._muted;
    +                    
    +                    if (this._muted)
    +                    {
    +                        this._sound.volume = 0;
    +                    }
    +                    else
    +                    {
    +                        this._sound.volume = this._volume;
    +                    }
    +
    +                    this.isPlaying = true;
    +                    this.startTime = this.game.time.now;
    +                    this.currentTime = 0;
    +                    this.stopTime = this.startTime + this.durationMS;
    +                    this.onPlay.dispatch(this);
    +                }
    +                else
    +                {
    +                    this.pendingPlayback = true;
    +                }
    +            }
    +        }
    +    },
    +
    +    /**
    +    * Restart the sound, or a marked section of it.
    +    * @method Phaser.Sound#restart
    +    * @param {string} [marker=''] - If you want to play a marker then give the key here, otherwise leave blank to play the full sound.
    +    * @param {number} [position=0] - The starting position to play the sound from - this is ignored if you provide a marker.
    +    * @param {number} [volume=1] - Volume of the sound you want to play.
    +    * @param {boolean} [loop=false] - Loop when it finished playing?
    +    */
    +    restart: function (marker, position, volume, loop) {
    +
    +    	marker = marker || '';
    +    	position = position || 0;
    +    	volume = volume || 1;
    +    	if (typeof loop == 'undefined') { loop = false; }
    +
    +        this.play(marker, position, volume, loop, true);
    +
    +    },
    +
    +    /**
    +    * Pauses the sound
    +    * @method Phaser.Sound#pause
    +    */
    +    pause: function () {
    +
    +        if (this.isPlaying && this._sound)
    +        {
    +            this.stop();
    +            this.isPlaying = false;
    +            this.paused = true;
    +            this.pausedPosition = this.currentTime;
    +            this.pausedTime = this.game.time.now;
    +            this.onPause.dispatch(this);
    +        }
    +
    +    },
    +
    +    /**
    +    * Resumes the sound
    +    * @method Phaser.Sound#resume
    +    */
    +    resume: function () {
    +
    +        if (this.paused && this._sound)
    +        {
    +            if (this.usingWebAudio)
    +            {
    +                var p = this.position + (this.pausedPosition / 1000);
    +
    +                this._sound = this.context.createBufferSource();
    +                this._sound.buffer = this._buffer;
    +                this._sound.connect(this.gainNode);
    +
    +                if (typeof this._sound.start === 'undefined')
    +                {
    +                    this._sound.noteGrainOn(0, p, this.duration);
    +                    //this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it
    +				}
    +				else
    +				{
    +                    this._sound.start(0, p, this.duration);
    +                }
    +            }
    +            else
    +            {
    +                this._sound.play();
    +            }
    +
    +            this.isPlaying = true;
    +            this.paused = false;
    +            this.startTime += (this.game.time.now - this.pausedTime);
    +            this.onResume.dispatch(this);
    +        }
    +
    +    },
    +
    +	/**
    +    * Stop playing this sound.
    +    * @method Phaser.Sound#stop
    +    */
    +    stop: function () {
    +
    +        if (this.isPlaying && this._sound)
    +        {
    +            if (this.usingWebAudio)
    +            {
    +                if (typeof this._sound.stop === 'undefined')
    +                {
    +                    this._sound.noteOff(0);
    +                }
    +                else
    +                {
    +                    this._sound.stop(0);
    +                }
    +            }
    +            else if (this.usingAudioTag)
    +            {
    +                this._sound.pause();
    +                this._sound.currentTime = 0;
    +            }
    +        }
    +
    +        this.isPlaying = false;
    +        var prevMarker = this.currentMarker;
    +        
    +        this.currentMarker = '';
    +        this.onStop.dispatch(this, prevMarker);
    +
    +    }
    +
    +};
    +
    +/**
    +* @name Phaser.Sound#isDecoding
    +* @property {boolean} isDecoding - Returns true if the sound file is still decoding.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Sound.prototype, "isDecoding", {
    +
    +    get: function () {
    +        return this.game.cache.getSound(this.key).isDecoding;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Sound#isDecoded
    +* @property {boolean} isDecoded - Returns true if the sound file has decoded.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Sound.prototype, "isDecoded", {
    +
    +    get: function () {
    +        return this.game.cache.isSoundDecoded(this.key);
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Sound#mute
    +* @property {boolean} mute - Gets or sets the muted state of this sound.
    +*/
    +Object.defineProperty(Phaser.Sound.prototype, "mute", {
    +	
    +    get: function () {
    +        return this._muted;
    +    },
    + 
    +    set: function (value) {
    +
    +    	value = value || null;
    +
    +        if (value)
    +        {
    +            this._muted = true;
    +
    +            if (this.usingWebAudio)
    +            {
    +                this._muteVolume = this.gainNode.gain.value;
    +                this.gainNode.gain.value = 0;
    +            }
    +            else if (this.usingAudioTag && this._sound)
    +            {
    +                this._muteVolume = this._sound.volume;
    +                this._sound.volume = 0;
    +            }
    +        }
    +        else
    +        {
    +            this._muted = false;
    +
    +            if (this.usingWebAudio)
    +            {
    +                this.gainNode.gain.value = this._muteVolume;
    +            }
    +            else if (this.usingAudioTag && this._sound)
    +            {
    +                this._sound.volume = this._muteVolume;
    +            }
    +        }
    +
    +        this.onMute.dispatch(this);
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Sound#volume
    +* @property {number} volume - Gets or sets the volume of this sound, a value between 0 and 1.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Sound.prototype, "volume", {
    +
    +    get: function () {
    +        return this._volume;
    +    },
    +
    +    set: function (value) {
    +
    +        if (this.usingWebAudio)
    +        {
    +            this._volume = value;
    +            this.gainNode.gain.value = value;
    +        }
    +        else if (this.usingAudioTag && this._sound)
    +        {
    +            //  Causes an Index size error in Firefox if you don't clamp the value
    +            if (value >= 0 && value <= 1)
    +            {
    +                this._volume = value;
    +                this._sound.volume = value;
    +            }
    +        }
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/SoundManager.js.html b/docs/SoundManager.js.html new file mode 100644 index 00000000..83d398a3 --- /dev/null +++ b/docs/SoundManager.js.html @@ -0,0 +1,894 @@ + + + + + + Phaser Source: sound/SoundManager.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: sound/SoundManager.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Sound Manager constructor.
    +*
    +* @class Phaser.SoundManager
    +* @classdesc Phaser Sound Manager.
    +* @constructor
    +* @param {Phaser.Game} game reference to the current game instance.
    +*/
    +Phaser.SoundManager = function (game) {
    +
    +	/**
    +	* @property {Phaser.Game} game - Local reference to game.
    +	*/
    +	this.game = game;
    +	
    +	/**
    +	* @property {Phaser.Signal} onSoundDecode - Description.
    +	*/
    +	this.onSoundDecode = new Phaser.Signal;
    +	
    +	/**
    +	* @property {boolean} _muted - Description.
    +	* @private
    +	* @default
    +	*/
    +    this._muted = false;
    +   
    +	/**
    +	* @property {Description} _unlockSource - Description.
    +	* @private
    +	* @default
    +	*/
    +    this._unlockSource = null;
    +
    +    /**
    +    * @property {number} _volume - The global audio volume. A value between 0 (silence) and 1 (full volume).
    +    * @private
    +    * @default 
    +    */
    +    this._volume = 1;
    +
    +    /**
    +    * @property {array} _sounds - An array containing all the sounds 
    +    * @private
    +    * @default The empty array.
    +    */
    +    this._sounds = [];
    +
    +    /**
    +    * @property {Description} context - Description. 
    +    * @default
    +    */
    +    this.context = null;
    +    
    +	/**
    +	* @property {boolean} usingWebAudio - Description.
    +	* @default
    +	*/
    +    this.usingWebAudio = true;
    +    
    +	/**
    +	* @property {boolean} usingAudioTag - Description.
    +	* @default
    +	*/
    +    this.usingAudioTag = false;
    +    
    +	/**
    +	* @property {boolean} noAudio - Description.
    +	* @default
    +	*/
    +    this.noAudio = false;
    +
    +	/**
    +	* @property {boolean} touchLocked - Description.
    +	* @default
    +	*/
    +    this.touchLocked = false;
    +
    +	/**
    +	* @property {number} channels - Description.
    +	* @default
    +	*/
    +    this.channels = 32;
    +	
    +};
    +
    +Phaser.SoundManager.prototype = {
    +
    +    /**
    +    * Initialises the sound manager.
    +    * @method Phaser.SoundManager#boot
    +    * @protected
    +    */
    +    boot: function () {
    +
    +        if (this.game.device.iOS && this.game.device.webAudio == false)
    +        {
    +            this.channels = 1;
    +        }
    +
    +        if (this.game.device.iOS || (window['PhaserGlobal'] && window['PhaserGlobal'].fakeiOSTouchLock))
    +        {
    +            this.game.input.touch.callbackContext = this;
    +            this.game.input.touch.touchStartCallback = this.unlock;
    +            this.game.input.mouse.callbackContext = this;
    +            this.game.input.mouse.mouseDownCallback = this.unlock;
    +            this.touchLocked = true;
    +        }
    +        else
    +        {
    +            //  What about iOS5?
    +            this.touchLocked = false;
    +        }
    +
    +        if (window['PhaserGlobal'])
    +        {
    +            //  Check to see if all audio playback is disabled (i.e. handled by a 3rd party class)
    +            if (window['PhaserGlobal'].disableAudio == true)
    +            {
    +                this.usingWebAudio = false;
    +                this.noAudio = true;
    +                return;
    +            }
    +
    +            //  Check if the Web Audio API is disabled (for testing Audio Tag playback during development)
    +            if (window['PhaserGlobal'].disableWebAudio == true)
    +            {
    +                this.usingWebAudio = false;
    +                this.usingAudioTag = true;
    +                this.noAudio = false;
    +                return;
    +            }
    +        }
    +
    +        if (!!window['AudioContext'])
    +        {
    +            this.context = new window['AudioContext']();
    +        }
    +        else if (!!window['webkitAudioContext'])
    +        {
    +            this.context = new window['webkitAudioContext']();
    +        }
    +        else if (!!window['Audio'])
    +        {
    +            this.usingWebAudio = false;
    +            this.usingAudioTag = true;
    +        }
    +        else
    +        {
    +            this.usingWebAudio = false;
    +            this.noAudio = true;
    +        }
    +
    +        if (this.context !== null)
    +        {
    +            if (typeof this.context.createGain === 'undefined')
    +            {
    +                this.masterGain = this.context.createGainNode();
    +            }
    +            else
    +            {
    +                this.masterGain = this.context.createGain();
    +            }
    +
    +            this.masterGain.gain.value = 1;
    +            this.masterGain.connect(this.context.destination);
    +        }
    +
    +
    +    },
    +
    +    /**
    +    * Enables the audio, usually after the first touch.
    +    * @method Phaser.SoundManager#unlock
    +    */
    +    unlock: function () {
    +
    +        if (this.touchLocked == false)
    +        {
    +            return;
    +        }
    +
    +        //  Global override (mostly for Audio Tag testing)
    +        if (this.game.device.webAudio == false || (window['PhaserGlobal'] && window['PhaserGlobal'].disableWebAudio == true))
    +        {
    +            //  Create an Audio tag?
    +            this.touchLocked = false;
    +            this._unlockSource = null;
    +            this.game.input.touch.callbackContext = null;
    +            this.game.input.touch.touchStartCallback = null;
    +            this.game.input.mouse.callbackContext = null;
    +            this.game.input.mouse.mouseDownCallback = null;
    +        }
    +        else
    +        {
    +            // Create empty buffer and play it
    +            var buffer = this.context.createBuffer(1, 1, 22050);
    +            this._unlockSource = this.context.createBufferSource();
    +            this._unlockSource.buffer = buffer;
    +            this._unlockSource.connect(this.context.destination);
    +            this._unlockSource.noteOn(0);
    +        }
    +
    +    },
    +
    +    /**
    +    * Stops all the sounds in the game.
    +    * @method Phaser.SoundManager#stopAll
    +    */
    +    stopAll: function () {
    +
    +        for (var i = 0; i < this._sounds.length; i++)
    +        {
    +            if (this._sounds[i])
    +            {
    +                this._sounds[i].stop();
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * Pauses all the sounds in the game.
    +    * @method Phaser.SoundManager#pauseAll
    +    */
    +    pauseAll: function () {
    +
    +        for (var i = 0; i < this._sounds.length; i++)
    +        {
    +            if (this._sounds[i])
    +            {
    +                this._sounds[i].pause();
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * resumes every sound in the game.
    +    * @method Phaser.SoundManager#resumeAll
    +    */
    +    resumeAll: function () {
    +
    +        for (var i = 0; i < this._sounds.length; i++)
    +        {
    +            if (this._sounds[i])
    +            {
    +                this._sounds[i].resume();
    +            }
    +        }
    +   
    +	},
    +
    +	/**
    +    * Decode a sound by its assets key.
    +    * @method Phaser.SoundManager#decode
    +    * @param {string} key - Assets key of the sound to be decoded.
    +    * @param {Phaser.Sound} [sound] - Its buffer will be set to decoded data.
    +    */
    +    decode: function (key, sound) {
    +
    +        sound = sound || null;
    +
    +        var soundData = this.game.cache.getSoundData(key);
    +
    +        if (soundData)
    +        {
    +            if (this.game.cache.isSoundDecoded(key) === false)
    +            {
    +                this.game.cache.updateSound(key, 'isDecoding', true);
    +
    +                var that = this;
    +
    +                this.context.decodeAudioData(soundData, function (buffer) {
    +                    that.game.cache.decodedSound(key, buffer);
    +                    if (sound)
    +                    {
    +                        that.onSoundDecode.dispatch(sound);
    +                    }
    +                });
    +            }
    +        }
    +
    +    },
    +
    +    /**
    +    * Updates every sound in the game.
    +    * @method Phaser.SoundManager#update
    +    */
    +    update: function () {
    +
    +        if (this.touchLocked)
    +        {
    +            if (this.game.device.webAudio && this._unlockSource !== null)
    +            {
    +                if ((this._unlockSource.playbackState === this._unlockSource.PLAYING_STATE || this._unlockSource.playbackState === this._unlockSource.FINISHED_STATE))
    +                {
    +                    this.touchLocked = false;
    +                    this._unlockSource = null;
    +                    this.game.input.touch.callbackContext = null;
    +                    this.game.input.touch.touchStartCallback = null;
    +                }
    +            }
    +        }
    +
    +        for (var i = 0; i < this._sounds.length; i++)
    +        {
    +            this._sounds[i].update();
    +        }
    +
    +    },
    +
    +    /**
    +    * Adds a new Sound into the SoundManager.
    +    * @method Phaser.SoundManager#add
    +    * @param {string} key - Asset key for the sound.
    +    * @param {number} [volume=1] - Default value for the volume.
    +    * @param {boolean} [loop=false] - Whether or not the sound will loop.
    +    */
    +    add: function (key, volume, loop) {
    +
    +    	volume = volume || 1;
    +    	if (typeof loop == 'undefined') { loop = false; }
    +
    +        var sound = new Phaser.Sound(this.game, key, volume, loop);
    +
    +        this._sounds.push(sound);
    +
    +        return sound;
    +
    +    }
    +
    +};
    +
    +/**
    +* @name Phaser.SoundManager#mute
    +* @property {boolean} mute - Gets or sets the muted state of the SoundManager. This effects all sounds in the game.
    +*/
    +Object.defineProperty(Phaser.SoundManager.prototype, "mute", {
    +
    +    get: function () {
    +
    +        return this._muted;
    +
    +    },
    +
    +    set: function (value) {
    +
    +        value = value || null;
    +
    +        if (value)
    +        {
    +            if (this._muted)
    +            {
    +                return;
    +            }
    +
    +            this._muted = true;
    +            
    +            if (this.usingWebAudio)
    +            {
    +                this._muteVolume = this.masterGain.gain.value;
    +                this.masterGain.gain.value = 0;
    +            }
    +
    +            //  Loop through sounds
    +            for (var i = 0; i < this._sounds.length; i++)
    +            {
    +                if (this._sounds[i].usingAudioTag)
    +                {
    +                    this._sounds[i].mute = true;
    +                }
    +            }
    +        }
    +        else
    +        {
    +            if (this._muted == false)
    +            {
    +                return;
    +            }
    +
    +            this._muted = false;
    +
    +            if (this.usingWebAudio)
    +            {
    +                this.masterGain.gain.value = this._muteVolume;
    +            }
    +
    +            //  Loop through sounds
    +            for (var i = 0; i < this._sounds.length; i++)
    +            {
    +                if (this._sounds[i].usingAudioTag)
    +                {
    +                    this._sounds[i].mute = false;
    +                }
    +            }
    +        }
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.SoundManager#volume
    +* @property {number} volume - Gets or sets the global volume of the SoundManager, a value between 0 and 1.
    +*/
    +Object.defineProperty(Phaser.SoundManager.prototype, "volume", {
    +    
    +    get: function () {
    +
    +        if (this.usingWebAudio)
    +        {
    +            return this.masterGain.gain.value;
    +        }
    +        else
    +        {
    +            return this._volume;
    +        }
    +
    +    },
    +
    +    set: function (value) {
    +
    +        value = this.game.math.clamp(value, 1, 0);
    +
    +        this._volume = value;
    +
    +        if (this.usingWebAudio)
    +        {
    +            this.masterGain.gain.value = value;
    +        }
    +
    +        //  Loop through the sound cache and change the volume of all html audio tags
    +        for (var i = 0; i < this._sounds.length; i++)
    +        {
    +            if (this._sounds[i].usingAudioTag)
    +            {
    +                this._sounds[i].volume = this._sounds[i].volume * value;
    +            }
    +        }
    +        
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Sprite.js.html b/docs/Sprite.js.html new file mode 100644 index 00000000..3b07c29b --- /dev/null +++ b/docs/Sprite.js.html @@ -0,0 +1,1570 @@ + + + + + + Phaser Source: gameobjects/Sprite.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: gameobjects/Sprite.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Create a new `Sprite` object. Sprites are the lifeblood of your game, used for nearly everything visual.
    +* At its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas.
    +* They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input),
    +* events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases.
    +*
    +* @class Phaser.Sprite
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +* @param {number} x - The x coordinate (in world space) to position the Sprite at.
    +* @param {number} y - The y coordinate (in world space) to position the Sprite at.
    +* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
    +* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
    +*/
    +Phaser.Sprite = function (game, x, y, key, frame) {
    +
    +    x = x || 0;
    +    y = y || 0;
    +    key = key || null;
    +    frame = frame || null;
    +    
    +    /**
    +	* @property {Phaser.Game} game - A reference to the currently running Game.
    +	*/
    +	this.game = game;
    + 
    +	/**
    +	* @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
    +	* @default
    +	*/
    +    this.exists = true;
    +
    +	/**
    +    * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.
    +   	* @default
    +   	*/
    +    this.alive = true;
    +
    +	/**
    +    * @property {Phaser.Group} group - The parent Group of this Sprite. This is usually set after Sprite instantiation by the parent.
    +   	*/
    +    this.group = null;
    +
    +    /**
    +     * @property {string} name - The user defined name given to this Sprite.
    +     * @default
    +     */
    +    this.name = '';
    +
    +    /**
    +	* @property {number} type - The const type of this object.
    +    * @default
    +	*/
    +    this.type = Phaser.SPRITE;
    +
    +    /**
    +	* @property {number} renderOrderID - Used by the Renderer and Input Manager to control picking order.
    +	* @default
    +	*/
    +    this.renderOrderID = -1;
    +
    +    /**
    +    * If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc.
    +	* The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called.
    +	* @property {number} lifespan - The lifespan of the Sprite (in ms) before it will be killed.
    +	* @default
    +	*/    
    +    this.lifespan = 0;
    +
    +    /**
    +    * @property {Events} events - The Events you can subscribe to that are dispatched when certain things happen on this Sprite or its components.
    +    */
    +    this.events = new Phaser.Events(this);
    +
    +    /**
    +    * @property {Phaser.AnimationManager} animations - This manages animations of the sprite. You can modify animations through it (see Phaser.AnimationManager)
    +    */
    +    this.animations = new Phaser.AnimationManager(this);
    +
    +    /**
    +    * @property {InputHandler} input - The Input Handler Component.
    +    */
    +    this.input = new Phaser.InputHandler(this);
    +
    +    /**
    +    *  @property {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
    +    */
    +    this.key = key;
    +
    +    /**
    +    *  @property {Phaser.Frame} currentFrame - A reference to the currently displayed frame.
    +    */
    +    this.currentFrame = null;
    +
    +    if (key instanceof Phaser.RenderTexture)
    +    {
    +        PIXI.Sprite.call(this, key);
    +
    +        this.currentFrame = this.game.cache.getTextureFrame(key.name);
    +    }
    +    else if (key instanceof PIXI.Texture)
    +    {
    +        PIXI.Sprite.call(this, key);
    +
    +        this.currentFrame = frame;
    +    }
    +    else
    +    {
    +        if (key == null || this.game.cache.checkImageKey(key) == false)
    +        {
    +            key = '__default';
    +            this.key = key;
    +        }
    +
    +        PIXI.Sprite.call(this, PIXI.TextureCache[key]);
    +
    +        if (this.game.cache.isSpriteSheet(key))
    +        {
    +            this.animations.loadFrameData(this.game.cache.getFrameData(key));
    +
    +            if (frame !== null)
    +            {
    +                if (typeof frame === 'string')
    +                {
    +                    this.frameName = frame;
    +                }
    +                else
    +                {
    +                    this.frame = frame;
    +                }
    +            }
    +        }
    +        else
    +        {
    +            this.currentFrame = this.game.cache.getFrame(key);
    +        }
    +    }
    +
    +    /**
    +    * The anchor sets the origin point of the texture.
    +    * The default is 0,0 this means the textures origin is the top left 
    +    * Setting than anchor to 0.5,0.5 means the textures origin is centered
    +    * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right
    +    *
    +    * @property {Phaser.Point} anchor - The anchor around with Sprite rotation and scaling takes place.
    +    */
    +    this.anchor = new Phaser.Point();
    +
    +    /**
    +    * @property {number} x - The x coordinate (in world space) of this Sprite.
    +    */
    +    this.x = x;
    +    
    +    /**
    +    * @property {number} y - The y coordinate (in world space) of this Sprite.
    +    */
    +    this.y = y;
    +
    +	this.position.x = x;
    +	this.position.y = y;
    +
    +    /**
    +    * Should this Sprite be automatically culled if out of range of the camera?
    +    * A culled sprite has its renderable property set to 'false'.
    +    *
    +    * @property {boolean} autoCull - A flag indicating if the Sprite should be automatically camera culled or not.
    +    * @default
    +    */
    +    this.autoCull = false;
    +
    +    /**
    +    * @property {Phaser.Point} scale - The scale of the Sprite when rendered. By default it's set to 1 (no scale). You can modify it via scale.x or scale.y or scale.setTo(x, y). A value of 1 means no change to the scale, 0.5 means "half the size", 2 means "twice the size", etc.
    +    */ 
    +    this.scale = new Phaser.Point(1, 1);
    +
    +    /**
    +    * @property {Phaser.Point} _cache - A mini cache for storing all of the calculated values.
    +    * @private
    +    */
    +    this._cache = { 
    +
    +        dirty: false,
    +
    +        //  Transform cache
    +        a00: -1, a01: -1, a02: -1, a10: -1, a11: -1, a12: -1, id: -1, 
    +
    +        //  Input specific transform cache
    +        i01: -1, i10: -1, idi: -1,
    +
    +        //  Bounds check
    +        left: null, right: null, top: null, bottom: null, 
    +
    +        //  The previous calculated position
    +        x: -1, y: -1,
    +
    +        //  The actual scale values based on the worldTransform
    +        scaleX: 1, scaleY: 1,
    +
    +        //  cache scale check
    +        realScaleX: 1, realScaleY: 1,
    +
    +        //  The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size
    +        width: this.currentFrame.sourceSizeW, height: this.currentFrame.sourceSizeH,
    +
    +        //  The actual width/height of the image if from a trimmed atlas, multiplied by the final calculated scale size
    +        halfWidth: Math.floor(this.currentFrame.sourceSizeW / 2), halfHeight: Math.floor(this.currentFrame.sourceSizeH / 2),
    +
    +        //  The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size
    +        calcWidth: -1, calcHeight: -1,
    +
    +        //  The current frame details
    +        // frameID: this.currentFrame.uuid, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height,
    +        frameID: -1, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height,
    +
    +        boundsX: 0, boundsY: 0,
    +
    +        //  If this sprite visible to the camera (regardless of being set to visible or not)
    +        cameraVisible: true,
    +
    +        //  Crop cache
    +        cropX: 0, cropY: 0, cropWidth: this.currentFrame.sourceSizeW, cropHeight: this.currentFrame.sourceSizeH
    +
    +    };
    +  
    +    /**
    +    * @property {Phaser.Point} offset - Corner point defaults. Should not typically be modified.
    +    */    
    +    this.offset = new Phaser.Point;
    +    
    +    /**
    +    * @property {Phaser.Point} center - A Point containing the center coordinate of the Sprite. Takes rotation and scale into account.
    +    */
    +    this.center = new Phaser.Point(x + Math.floor(this._cache.width / 2), y + Math.floor(this._cache.height / 2));
    +   
    +    /**
    +    * @property {Phaser.Point} topLeft - A Point containing the top left coordinate of the Sprite. Takes rotation and scale into account.
    +    */
    +    this.topLeft = new Phaser.Point(x, y);
    +    
    +    /**
    +    * @property {Phaser.Point} topRight - A Point containing the top right coordinate of the Sprite. Takes rotation and scale into account.
    +    */
    +    this.topRight = new Phaser.Point(x + this._cache.width, y);
    +    
    +    /**
    +    * @property {Phaser.Point} bottomRight - A Point containing the bottom right coordinate of the Sprite. Takes rotation and scale into account.
    +    */
    +    this.bottomRight = new Phaser.Point(x + this._cache.width, y + this._cache.height);
    +    
    +    /**
    +    * @property {Phaser.Point} bottomLeft - A Point containing the bottom left coordinate of the Sprite. Takes rotation and scale into account.
    +    */
    +    this.bottomLeft = new Phaser.Point(x, y + this._cache.height);
    +    
    +    /**
    +    * This Rectangle object fully encompasses the Sprite and is updated in real-time.
    +    * The bounds is the full bounding area after rotation and scale have been taken into account. It should not be modified directly.
    +    * It's used for Camera culling and physics body alignment.
    +    * @property {Phaser.Rectangle} bounds
    +    */
    +    this.bounds = new Phaser.Rectangle(x, y, this._cache.width, this._cache.height);
    +    
    +    /**
    +    * @property {Phaser.Physics.Arcade.Body} body - By default Sprites have a Phaser.Physics Body attached to them. You can operate physics actions via this property, or null it to skip all physics updates.
    +    */
    +    this.body = new Phaser.Physics.Arcade.Body(this);
    +
    +    /**
    +    * @property {number} health - Health value. Used in combination with damage() to allow for quick killing of Sprites.
    +    */    
    +    this.health = 1;
    +
    +    /**
    +    * @property {boolean} inWorld - This value is set to true if the Sprite is positioned within the World, otherwise false.
    +    */
    +    this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds);
    +    
    +    /**
    +    * @property {number} inWorldThreshold - A threshold value applied to the inWorld check. If you don't want a Sprite to be considered "out of the world" until at least 100px away for example then set it to 100.
    +    * @default
    +    */
    +    this.inWorldThreshold = 0;
    +
    +    /**
    +    * @property {boolean} outOfBoundsKill - If true the Sprite is killed as soon as Sprite.inWorld is false.
    +    * @default
    +    */
    +    this.outOfBoundsKill = false;
    +    
    +    /**
    +    * @property {boolean} _outOfBoundsFired - Internal flag.
    +    * @private
    +    * @default
    +    */
    +    this._outOfBoundsFired = false;
    +
    +    /**
    +    * A Sprite that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera.
    +    * @property {boolean} fixedToCamera - Fixes this Sprite to the Camera.
    +    * @default
    +    */
    +    this.fixedToCamera = false;
    +
    +    /**
    +    * You can crop the Sprites texture by modifying the crop properties. For example crop.width = 50 would set the Sprite to only render 50px wide.
    +    * The crop is only applied if you have set Sprite.cropEnabled to true.
    +    * @property {Phaser.Rectangle} crop - The crop Rectangle applied to the Sprite texture before rendering.
    +    * @default
    +    */
    +    this.crop = new Phaser.Rectangle(0, 0, this._cache.width, this._cache.height);
    +
    +    /**
    +    * @property {boolean} cropEnabled - If true the Sprite.crop property is used to crop the texture before render. Set to false to disable.
    +    * @default
    +    */
    +    this.cropEnabled = false;
    +
    +};
    +
    +//  Needed to keep the PIXI.Sprite constructor in the prototype chain (as the core pixi renderer uses an instanceof check sadly)
    +Phaser.Sprite.prototype = Object.create(PIXI.Sprite.prototype);
    +Phaser.Sprite.prototype.constructor = Phaser.Sprite;
    +
    +/**
    +* Automatically called by World.preUpdate. Handles cache updates, lifespan checks, animation updates and physics updates.
    +*
    +* @method Phaser.Sprite#preUpdate
    +* @memberof Phaser.Sprite
    +*/
    +Phaser.Sprite.prototype.preUpdate = function() {
    +
    +    if (!this.exists)
    +    {
    +        this.renderOrderID = -1;
    +        return;
    +    }
    +
    +    if (this.lifespan > 0)
    +    {
    +        this.lifespan -= this.game.time.elapsed;
    +
    +        if (this.lifespan <= 0)
    +        {
    +            this.kill();
    +            return;
    +        }
    +    }
    +
    +    this._cache.dirty = false;
    +
    +    if (this.animations.update())
    +    {
    +        this._cache.dirty = true;
    +    }
    +
    +    if (this.visible)
    +    {
    +        this.renderOrderID = this.game.world.currentRenderOrderID++;
    +    }
    +
    +    this.prevX = this.x;
    +    this.prevY = this.y;
    +
    +    this.updateCache();
    +    this.updateAnimation();
    +
    +    if (this.cropEnabled)
    +    {
    +        this.updateCrop();
    +    }
    +
    +    //  Re-run the camera visibility check
    +    if (this._cache.dirty)
    +    {
    +        this.updateBounds();
    +
    +        this._cache.cameraVisible = Phaser.Rectangle.intersects(this.game.world.camera.screenView, this.bounds, 0);
    +
    +        if (this.autoCull == true)
    +        {
    +            //  Won't get rendered but will still get its transform updated
    +            this.renderable = this._cache.cameraVisible;
    +        }
    +
    +        //  Update our physics bounds
    +        if (this.body)
    +        {
    +            this.body.updateBounds(this.center.x, this.center.y, this._cache.scaleX, this._cache.scaleY);
    +        }
    +    }
    +
    +    if (this.body)
    +    {
    +        this.body.preUpdate();
    +    }
    +
    +}
    +
    +/**
    +* Internal function called by preUpdate.
    +*
    +* @method Phaser.Sprite#updateCache
    +* @memberof Phaser.Sprite
    +*/
    +Phaser.Sprite.prototype.updateCache = function() {
    +
    +    //  |a c tx|
    +    //  |b d ty|
    +    //  |0 0  1|
    +
    +    if (this.worldTransform[1] != this._cache.i01 || this.worldTransform[3] != this._cache.i10)
    +    {
    +        this._cache.a00 = this.worldTransform[0];  //  scaleX         a
    +        this._cache.a01 = this.worldTransform[1];  //  skewY          c
    +        this._cache.a10 = this.worldTransform[3];  //  skewX          b
    +        this._cache.a11 = this.worldTransform[4];  //  scaleY         d
    +
    +        this._cache.i01 = this.worldTransform[1];  //  skewY          c (remains non-modified for input checks)
    +        this._cache.i10 = this.worldTransform[3];  //  skewX          b (remains non-modified for input checks)
    +
    +        this._cache.scaleX = Math.sqrt((this._cache.a00 * this._cache.a00) + (this._cache.a01 * this._cache.a01)); // round this off a bit?
    +        this._cache.scaleY = Math.sqrt((this._cache.a10 * this._cache.a10) + (this._cache.a11 * this._cache.a11)); // round this off a bit?
    +
    +        this._cache.a01 *= -1;
    +        this._cache.a10 *= -1;
    +
    +        this._cache.dirty = true;
    +    }
    +
    +    if (this.worldTransform[2] != this._cache.a02 || this.worldTransform[5] != this._cache.a12)
    +    {
    +        this._cache.a02 = this.worldTransform[2];  //  translateX     tx
    +        this._cache.a12 = this.worldTransform[5];  //  translateY     ty
    +        this._cache.dirty = true;
    +    }
    +
    +}
    +
    +/**
    +* Internal function called by preUpdate.
    +*
    +* @method Phaser.Sprite#updateAnimation
    +* @memberof Phaser.Sprite
    +*/
    +Phaser.Sprite.prototype.updateAnimation = function() {
    +
    +    if (this.currentFrame && this.currentFrame.uuid != this._cache.frameID)
    +    {
    +        this._cache.frameWidth = this.texture.frame.width;
    +        this._cache.frameHeight = this.texture.frame.height;
    +        this._cache.frameID = this.currentFrame.uuid;
    +        this._cache.dirty = true;
    +    }
    +
    +    if (this._cache.dirty && this.currentFrame)
    +    {
    +        this._cache.width = this.currentFrame.width;
    +        this._cache.height = this.currentFrame.height;
    +        this._cache.halfWidth = Math.floor(this._cache.width / 2);
    +        this._cache.halfHeight = Math.floor(this._cache.height / 2);
    +
    +        this._cache.id = 1 / (this._cache.a00 * this._cache.a11 + this._cache.a01 * -this._cache.a10);
    +        this._cache.idi = 1 / (this._cache.a00 * this._cache.a11 + this._cache.i01 * -this._cache.i10);
    +    }
    +
    +}
    +
    +/**
    +* Internal function called by preUpdate.
    +*
    +* @method Phaser.Sprite#updateBounds
    +* @memberof Phaser.Sprite
    +*/
    +Phaser.Sprite.prototype.updateBounds = function() {
    +
    +    var sx = 1;
    +    var sy = 1;
    +
    +    if (this.worldTransform[3] !== 0 || this.worldTransform[1] !== 0)
    +    {
    +        sx = this.scale.x;
    +        sy = this.scale.y;
    +    }
    +
    +    this.offset.setTo(this._cache.a02 - (this.anchor.x * this.width), this._cache.a12 - (this.anchor.y * this.height));
    +
    +    this.getLocalPosition(this.center, this.offset.x + (this.width / 2), this.offset.y + (this.height / 2), sx, sy);
    +    this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y, sx, sy);
    +    this.getLocalPosition(this.topRight, this.offset.x + this.width, this.offset.y, sx, sy);
    +    this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this.height, sx, sy);
    +    this.getLocalPosition(this.bottomRight, this.offset.x + this.width, this.offset.y + this.height, sx, sy);
    +
    +    this._cache.left = Phaser.Math.min(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x);
    +    this._cache.right = Phaser.Math.max(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x);
    +    this._cache.top = Phaser.Math.min(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y);
    +    this._cache.bottom = Phaser.Math.max(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y);
    +
    +    this.bounds.setTo(this._cache.left, this._cache.top, this._cache.right - this._cache.left, this._cache.bottom - this._cache.top);
    +
    +    //  This is the coordinate the Sprite was at when the last bounds was created
    +    this._cache.boundsX = this._cache.x;
    +    this._cache.boundsY = this._cache.y;
    +        
    +    this.updateFrame = true;
    +
    +    if (this.inWorld == false)
    +    {
    +        //  Sprite WAS out of the screen, is it still?
    +        this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
    +
    +        if (this.inWorld)
    +        {
    +            //  It's back again, reset the OOB check
    +            this._outOfBoundsFired = false;
    +        }
    +    }
    +    else
    +    {
    +        //   Sprite WAS in the screen, has it now left?
    +        this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
    +
    +        if (this.inWorld == false)
    +        {
    +            this.events.onOutOfBounds.dispatch(this);
    +            this._outOfBoundsFired = true;
    +
    +            if (this.outOfBoundsKill)
    +            {
    +                this.kill();
    +            }
    +        }
    +    }
    +
    +}
    +
    +/**
    +* Gets the local position of a coordinate relative to the Sprite, factoring in rotation and scale.
    +* Mostly only used internally.
    +* 
    +* @method Phaser.Sprite#getLocalPosition
    +* @memberof Phaser.Sprite
    +* @param {Phaser.Point} p - The Point object to store the results in.
    +* @param {number} x - x coordinate within the Sprite to translate.
    +* @param {number} y - x coordinate within the Sprite to translate.
    +* @param {number} sx - Scale factor to be applied.
    +* @param {number} sy - Scale factor to be applied.
    +* @return {Phaser.Point} The translated point.
    +*/
    +Phaser.Sprite.prototype.getLocalPosition = function(p, x, y, sx, sy) {
    +
    +    p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * sx) + this._cache.a02;
    +    p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * sy) + this._cache.a12;
    +
    +    return p;
    +
    +}
    +
    +/**
    +* Gets the local unmodified position of a coordinate relative to the Sprite, factoring in rotation and scale.
    +* Mostly only used internally by the Input Manager, but also useful for custom hit detection.
    +* 
    +* @method Phaser.Sprite#getLocalUnmodifiedPosition
    +* @memberof Phaser.Sprite
    +* @param {Phaser.Point} p - The Point object to store the results in.
    +* @param {number} x - x coordinate within the Sprite to translate.
    +* @param {number} y - x coordinate within the Sprite to translate.
    +* @return {Phaser.Point} The translated point.
    +*/
    +Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, gx, gy) {
    +
    +    var a00 = this.worldTransform[0], a01 = this.worldTransform[1], a02 = this.worldTransform[2],
    +        a10 = this.worldTransform[3], a11 = this.worldTransform[4], a12 = this.worldTransform[5],
    +        id = 1 / (a00 * a11 + a01 * -a10),
    +        x = a11 * id * gx + -a01 * id * gy + (a12 * a01 - a02 * a11) * id,
    +        y = a00 * id * gy + -a10 * id * gx + (-a12 * a00 + a02 * a10) * id;
    +
    +    p.x = x + (this.anchor.x * this._cache.width);
    +    p.y = y + (this.anchor.y * this._cache.height);
    +
    +    return p;
    +
    +}
    +
    +/**
    +* Internal function called by preUpdate.
    +*
    +* @method Phaser.Sprite#updateCrop
    +* @memberof Phaser.Sprite
    +*/
    +Phaser.Sprite.prototype.updateCrop = function() {
    +
    +    //  This only runs if crop is enabled
    +    if (this.crop.width != this._cache.cropWidth || this.crop.height != this._cache.cropHeight || this.crop.x != this._cache.cropX || this.crop.y != this._cache.cropY)
    +    {
    +        this.crop.floorAll();
    +
    +        this._cache.cropX = this.crop.x;
    +        this._cache.cropY = this.crop.y;
    +        this._cache.cropWidth = this.crop.width;
    +        this._cache.cropHeight = this.crop.height;
    +
    +        this.texture.frame = this.crop;
    +        this.texture.width = this.crop.width;
    +        this.texture.height = this.crop.height;
    +
    +        this.texture.updateFrame = true;
    +
    +        PIXI.Texture.frameUpdates.push(this.texture);
    +    }
    +
    +}
    +
    +/**
    +* Resets the Sprite.crop value back to the frame dimensions.
    +*
    +* @method Phaser.Sprite#resetCrop
    +* @memberof Phaser.Sprite
    +*/
    +Phaser.Sprite.prototype.resetCrop = function() {
    +
    +    this.crop = new Phaser.Rectangle(0, 0, this._cache.width, this._cache.height);
    +    this.texture.setFrame(this.crop);
    +    this.cropEnabled = false;
    +
    +}
    +
    +/**
    +* Internal function called by the World postUpdate cycle.
    +*
    +* @method Phaser.Sprite#postUpdate
    +* @memberof Phaser.Sprite
    +*/
    +Phaser.Sprite.prototype.postUpdate = function() {
    +
    +    if (this.exists)
    +    {
    +        //  The sprite is positioned in this call, after taking into consideration motion updates and collision
    +        if (this.body)
    +        {
    +            this.body.postUpdate();
    +        }
    +
    +        if (this.fixedToCamera)
    +        {
    +            this._cache.x = this.game.camera.view.x + this.x;
    +            this._cache.y = this.game.camera.view.y + this.y;
    +        }
    +        else
    +        {
    +            this._cache.x = this.x;
    +            this._cache.y = this.y;
    +        }
    +
    +        if (this.position.x != this._cache.x || this.position.y != this._cache.y)
    +        {
    +            this.position.x = this._cache.x;
    +            this.position.y = this._cache.y;
    +        }
    +    }
    +
    +}
    +
    +/**
    +* Changes the Texture the Sprite is using entirely. The old texture is removed and the new one is referenced or fetched from the Cache.
    +* This causes a WebGL texture update, so use sparingly or in low-intensity portions of your game.
    +*
    +* @method Phaser.Sprite#loadTexture
    +* @memberof Phaser.Sprite
    +* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
    +* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
    +*/
    +Phaser.Sprite.prototype.loadTexture = function (key, frame) {
    +
    +    this.key = key;
    +
    +    if (key instanceof Phaser.RenderTexture)
    +    {
    +        this.currentFrame = this.game.cache.getTextureFrame(key.name);
    +    }
    +    else if (key instanceof PIXI.Texture)
    +    {
    +        this.currentFrame = frame;
    +    }
    +    else
    +    {
    +        if (typeof key === 'undefined' || this.game.cache.checkImageKey(key) === false)
    +        {
    +            key = '__default';
    +            this.key = key;
    +        }
    +
    +        if (this.game.cache.isSpriteSheet(key))
    +        {
    +            this.animations.loadFrameData(this.game.cache.getFrameData(key));
    +
    +            if (typeof frame !== 'undefined')
    +            {
    +                if (typeof frame === 'string')
    +                {
    +                    this.frameName = frame;
    +                }
    +                else
    +                {
    +                    this.frame = frame;
    +                }
    +            }
    +        }
    +        else
    +        {
    +            this.currentFrame = this.game.cache.getFrame(key);
    +            this.setTexture(PIXI.TextureCache[key]);
    +        }
    +    }
    +
    +}
    +
    +/**
    +* Returns the absolute delta x value.
    +*
    +* @method Phaser.Sprite#deltaAbsX
    +* @memberof Phaser.Sprite
    +* @return {number} The absolute delta value.
    +*/
    +Phaser.Sprite.prototype.deltaAbsX = function () {
    +    return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX());
    +}
    +
    +/**
    +* Returns the absolute delta y value.
    +*
    +* @method Phaser.Sprite#deltaAbsY
    +* @memberof Phaser.Sprite
    +* @return {number} The absolute delta value.
    +*/
    +Phaser.Sprite.prototype.deltaAbsY = function () {
    +    return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY());
    +}
    +
    +/**
    +* Returns the delta x value.
    +*
    +* @method Phaser.Sprite#deltaX
    +* @memberof Phaser.Sprite
    +* @return {number} The delta value.
    +*/
    +Phaser.Sprite.prototype.deltaX = function () {
    +    return this.x - this.prevX;
    +}
    +
    +/**
    +* Returns the delta y value.
    +*
    +* @method Phaser.Sprite#deltaY
    +* @memberof Phaser.Sprite
    +* @return {number} The delta value.
    +*/
    +Phaser.Sprite.prototype.deltaY = function () {
    +    return this.y - this.prevY;
    +}
    +
    +/**
    +* Moves the sprite so its center is located on the given x and y coordinates.
    +* Doesn't change the anchor point of the sprite.
    +* 
    +* @method Phaser.Sprite#centerOn
    +* @memberof Phaser.Sprite
    +* @param {number} x - The x coordinate (in world space) to position the Sprite at.
    +* @param {number} y - The y coordinate (in world space) to position the Sprite at.
    +* @return (Phaser.Sprite) This instance.
    +*/
    +Phaser.Sprite.prototype.centerOn = function(x, y) {
    +
    +    this.x = x + (this.x - this.center.x);
    +    this.y = y + (this.y - this.center.y);
    +    return this;
    +
    +}
    +
    +/**
    +* Brings a 'dead' Sprite back to life, optionally giving it the health value specified.
    +* A resurrected Sprite has its alive, exists and visible properties all set to true.
    +* It will dispatch the onRevived event, you can listen to Sprite.events.onRevived for the signal.
    +* 
    +* @method Phaser.Sprite#revive
    +* @memberof Phaser.Sprite
    +* @param {number} [health=1] - The health to give the Sprite.
    +* @return (Phaser.Sprite) This instance.
    +*/
    +Phaser.Sprite.prototype.revive = function(health) {
    +
    +    if (typeof health === 'undefined') { health = 1; }
    +
    +    this.alive = true;
    +    this.exists = true;
    +    this.visible = true;
    +    this.health = health;
    +
    +    if (this.events)
    +    {
    +        this.events.onRevived.dispatch(this);
    +    }
    +
    +    return this;
    +
    +}
    +
    +/**
    +* Kills a Sprite. A killed Sprite has its alive, exists and visible properties all set to false.
    +* It will dispatch the onKilled event, you can listen to Sprite.events.onKilled for the signal.
    +* Note that killing a Sprite is a way for you to quickly recycle it in a Sprite pool, it doesn't free it up from memory.
    +* If you don't need this Sprite any more you should call Sprite.destroy instead.
    +* 
    +* @method Phaser.Sprite#kill
    +* @memberof Phaser.Sprite
    +* @return (Phaser.Sprite) This instance.
    +*/
    +Phaser.Sprite.prototype.kill = function() {
    +
    +    this.alive = false;
    +    this.exists = false;
    +    this.visible = false;
    +
    +    if (this.events)
    +    {
    +        this.events.onKilled.dispatch(this);
    +    }
    +
    +    return this;
    +
    +}
    +
    +/**
    +* Destroys the Sprite. This removes it from its parent group, destroys the input, event and animation handlers if present
    +* and nulls its reference to game, freeing it up for garbage collection.
    +* 
    +* @method Phaser.Sprite#destroy
    +* @memberof Phaser.Sprite
    +*/
    +Phaser.Sprite.prototype.destroy = function() {
    +
    +    if (this.group)
    +    {
    +        this.group.remove(this);
    +    }
    +
    +    if (this.input)
    +    {
    +        this.input.destroy();
    +    }
    +
    +    if (this.events)
    +    {
    +        this.events.destroy();
    +    }
    +
    +    if (this.animations)
    +    {
    +        this.animations.destroy();
    +    }
    +
    +    this.alive = false;
    +    this.exists = false;
    +    this.visible = false;
    +
    +    this.game = null;
    +
    +}
    +
    +/**
    +* Damages the Sprite, this removes the given amount from the Sprites health property.
    +* If health is then taken below zero Sprite.kill is called.
    +* 
    +* @method Phaser.Sprite#damage
    +* @memberof Phaser.Sprite
    +* @param {number} amount - The amount to subtract from the Sprite.health value.
    +* @return (Phaser.Sprite) This instance.
    +*/
    +Phaser.Sprite.prototype.damage = function(amount) {
    +
    +    if (this.alive)
    +    {
    +        this.health -= amount;
    +
    +        if (this.health < 0)
    +        {
    +            this.kill();
    +        }
    +    }
    +
    +    return this;
    +
    +}
    +
    +/**
    +* Resets the Sprite. This places the Sprite at the given x/y world coordinates and then
    +* sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state and health values.
    +* If the Sprite has a physics body that too is reset.
    +* 
    +* @method Phaser.Sprite#reset
    +* @memberof Phaser.Sprite
    +* @param {number} x - The x coordinate (in world space) to position the Sprite at.
    +* @param {number} y - The y coordinate (in world space) to position the Sprite at.
    +* @param {number} [health=1] - The health to give the Sprite.
    +* @return (Phaser.Sprite) This instance.
    +*/
    +Phaser.Sprite.prototype.reset = function(x, y, health) {
    +
    +    if (typeof health === 'undefined') { health = 1; }
    +
    +    this.x = x;
    +    this.y = y;
    +    this.position.x = this.x;
    +    this.position.y = this.y;
    +    this.alive = true;
    +    this.exists = true;
    +    this.visible = true;
    +    this.renderable = true;
    +    this._outOfBoundsFired = false;
    +
    +    this.health = health;
    +
    +    if (this.body)
    +    {
    +        this.body.reset();
    +    }
    +
    +    return this;
    +    
    +}
    +
    +/**
    +* Brings the Sprite to the top of the display list it is a child of. Sprites that are members of a Phaser.Group are only
    +* bought to the top of that Group, not the entire display list.
    +* 
    +* @method Phaser.Sprite#bringToTop
    +* @memberof Phaser.Sprite
    +* @return (Phaser.Sprite) This instance.
    +*/
    +Phaser.Sprite.prototype.bringToTop = function() {
    +
    +    if (this.group)
    +    {
    +        this.group.bringToTop(this);
    +    }
    +    else
    +    {
    +        this.game.world.bringToTop(this);
    +    }
    +
    +    return this;
    +
    +}
    +
    +/**
    +* Play an animation based on the given key. The animation should previously have been added via sprite.animations.add()
    +* If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself.
    +* 
    +* @method Phaser.Sprite#play
    +* @memberof Phaser.Sprite
    +* @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump".
    +* @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
    +* @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
    +* @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed.
    +* @return {Phaser.Animation} A reference to playing Animation instance.
    +*/
    +Phaser.Sprite.prototype.play = function (name, frameRate, loop, killOnComplete) {
    +
    +    if (this.animations)
    +    {
    +        return this.animations.play(name, frameRate, loop, killOnComplete);
    +    }
    +
    +}
    +
    +/**
    +* Indicates the rotation of the Sprite, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
    +* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90.
    +* If you wish to work in radians instead of degrees use the property Sprite.rotation instead.
    +* @name Phaser.Sprite#angle
    +* @property {number} angle - Gets or sets the Sprites angle of rotation in degrees.
    +*/
    +Object.defineProperty(Phaser.Sprite.prototype, 'angle', {
    +
    +    get: function() {
    +        return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation));
    +    },
    +
    +    set: function(value) {
    +        this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value));
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Sprite#frame
    +* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display.
    +*/
    +Object.defineProperty(Phaser.Sprite.prototype, "frame", {
    +    
    +    get: function () {
    +        return this.animations.frame;
    +    },
    +
    +    set: function (value) {
    +        this.animations.frame = value;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Sprite#frameName
    +* @property {string} frameName - Gets or sets the current frame name and updates the Texture Cache for display.
    +*/
    +Object.defineProperty(Phaser.Sprite.prototype, "frameName", {
    +    
    +    get: function () {
    +        return this.animations.frameName;
    +    },
    +
    +    set: function (value) {
    +        this.animations.frameName = value;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.Sprite#inCamera
    +* @property {boolean} inCamera - Is this sprite visible to the camera or not?
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.Sprite.prototype, "inCamera", {
    +    
    +    get: function () {
    +        return this._cache.cameraVisible;
    +    }
    +
    +});
    +
    +/**
    +* The width of the sprite in pixels, setting this will actually modify the scale to acheive the value desired.
    +* If you wish to crop the Sprite instead see the Sprite.crop value.
    +*
    +* @name Phaser.Sprite#width
    +* @property {number} width - The width of the Sprite in pixels.
    +*/
    +Object.defineProperty(Phaser.Sprite.prototype, 'width', {
    +
    +    get: function() {
    +        return this.scale.x * this.currentFrame.width;
    +    },
    +
    +    set: function(value) {
    +
    +        this.scale.x = value / this.currentFrame.width;
    +        this._cache.scaleX = value / this.currentFrame.width;
    +        this._width = value;
    +
    +    }
    +
    +});
    +
    +/**
    +* The height of the sprite in pixels, setting this will actually modify the scale to acheive the value desired.
    +* If you wish to crop the Sprite instead see the Sprite.crop value.
    +*
    +* @name Phaser.Sprite#height
    +* @property {number} height - The height of the Sprite in pixels.
    +*/
    +Object.defineProperty(Phaser.Sprite.prototype, 'height', {
    +
    +    get: function() {
    +        return this.scale.y * this.currentFrame.height;
    +    },
    +
    +    set: function(value) {
    +
    +        this.scale.y = value / this.currentFrame.height;
    +        this._cache.scaleY = value / this.currentFrame.height;
    +        this._height = value;
    +
    +    }
    +
    +});
    +
    +/**
    +* By default a Sprite won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is
    +* activated for this Sprite instance and it will then start to process click/touch events and more.
    +*
    +* @name Phaser.Sprite#inputEnabled
    +* @property {boolean} inputEnabled - Set to true to allow this Sprite to receive input events, otherwise false.
    +*/
    +Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", {
    +    
    +    get: function () {
    +
    +        return (this.input.enabled);
    +
    +    },
    +
    +    set: function (value) {
    +
    +        if (value)
    +        {
    +            if (this.input.enabled == false)
    +            {
    +                this.input.start();
    +            }
    +        }
    +        else
    +        {
    +            if (this.input.enabled)
    +            {
    +                this.input.stop();
    +            }
    +        }
    +
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Stage.js.html b/docs/Stage.js.html new file mode 100644 index 00000000..f10ebda5 --- /dev/null +++ b/docs/Stage.js.html @@ -0,0 +1,621 @@ + + + + + + Phaser Source: core/Stage.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/Stage.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* The Stage controls the canvas on which everything is displayed. It handles display within the browser,
    +* focus handling, game resizing, scaling and the pause, boot and orientation screens.
    +*
    +* @class Phaser.Stage
    +* @constructor
    +* @param {Phaser.Game} game - Game reference to the currently running game.
    +* @param {number} width - Width of the canvas element.
    +* @param {number} height - Height of the canvas element.
    + */
    +Phaser.Stage = function (game, width, height) {
    +
    +    /**
    +	* @property {Phaser.Game} game - A reference to the currently running Game.
    +	*/
    +	this.game = game;
    +
    +    /**
    +	* @property {string} game - Background color of the stage (defaults to black). Set via the public backgroundColor property.
    +	* @private
    +	* @default 'rgb(0,0,0)'
    +	*/
    +    this._backgroundColor = 'rgb(0,0,0)';
    +
    +    /**
    +	* @property {Phaser.Point} offset - Get the offset values (for input and other things).
    +	*/
    +	this.offset = new Phaser.Point;
    +    
    +    /**
    +    * @property {HTMLCanvasElement} canvas - Reference to the newly created <canvas> element.
    +    */
    +    this.canvas = Phaser.Canvas.create(width, height); 
    +    this.canvas.style['-webkit-full-screen'] = 'width: 100%; height: 100%';
    +    
    +    /**
    +    * @property {PIXI.Stage} _stage - The Pixi Stage which is hooked to the renderer.
    +    * @private
    +    */
    +    this._stage = new PIXI.Stage(0x000000, false);
    +    this._stage.name = '_stage_root';
    +
    +    /**
    +    * @property {number} scaleMode - The current scaleMode.
    +    */    
    +    this.scaleMode = Phaser.StageScaleMode.NO_SCALE;
    +
    +    /**
    +    * @property {Phaser.StageScaleMode} scale - The scale of the current running game.
    +    */
    +    this.scale = new Phaser.StageScaleMode(this.game, width, height);
    +
    +    /**
    +     * @property {number} aspectRatio - Aspect ratio.
    +     */
    +    this.aspectRatio = width / height;
    +
    +    /**
    +    * @property {number} _nextOffsetCheck - The time to run the next offset check.
    +    * @private
    +    */
    +    this._nextOffsetCheck = 0;
    +
    +    /**
    +    * @property {number|false} checkOffsetInterval - The time (in ms) between which the stage should check to see if it has moved.
    +    * @default
    +    */
    +    this.checkOffsetInterval = 2500;
    +
    +};
    +
    +Phaser.Stage.prototype = {
    +
    +    /**
    +    * Initialises the stage and adds the event listeners.
    +    * @method Phaser.Stage#boot
    +    * @private
    +    */
    +    boot: function () {
    +
    +        Phaser.Canvas.getOffset(this.canvas, this.offset);
    +
    +        this.bounds = new Phaser.Rectangle(this.offset.x, this.offset.y, this.game.width, this.game.height);
    +
    +        var _this = this;
    +
    +        this._onChange = function (event) {
    +            return _this.visibilityChange(event);
    +        }
    +
    +        Phaser.Canvas.setUserSelect(this.canvas, 'none');
    +        Phaser.Canvas.setTouchAction(this.canvas, 'none');
    +
    +        document.addEventListener('visibilitychange', this._onChange, false);
    +        document.addEventListener('webkitvisibilitychange', this._onChange, false);
    +        document.addEventListener('pagehide', this._onChange, false);
    +        document.addEventListener('pageshow', this._onChange, false);
    +
    +        window.onblur = this._onChange;
    +        window.onfocus = this._onChange;
    +
    +    },
    +
    +    /**
    +    * Runs Stage processes that need periodic updates, such as the offset checks.
    +    * @method Phaser.Stage#update
    +    */
    +    update: function () {
    +
    +        if (this.checkOffsetInterval !== false)
    +        {
    +            if (this.game.time.now > this._nextOffsetCheck)
    +            {
    +                Phaser.Canvas.getOffset(this.canvas, this.offset);
    +                this._nextOffsetCheck = this.game.time.now + this.checkOffsetInterval;
    +            }
    +
    +        }
    +
    +    },
    +
    +	/**
    +    * This method is called when the document visibility is changed.
    +    * @method Phaser.Stage#visibilityChange
    +    * @param {Event} event - Its type will be used to decide whether the game should be paused or not.
    +    */
    +    visibilityChange: function (event) {
    +
    +        if (this.disableVisibilityChange)
    +        {
    +            return;
    +        }
    +
    +        if (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] == true || document['webkitHidden'] == true)
    +        {
    +	        this.game.paused = true;
    +        }
    +        else
    +        {
    +	        this.game.paused = false;
    +        }
    +
    +    },
    +
    +};
    +
    +/**
    +* @name Phaser.Stage#backgroundColor
    +* @property {number|string} paused - Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000'
    +*/
    +Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", {
    +
    +    get: function () {
    +        return this._backgroundColor;
    +    },
    +
    +    set: function (color) {
    +
    +        this._backgroundColor = color;
    +
    +        if (typeof color === 'string')
    +        {
    +            color = Phaser.Color.hexToRGB(color);
    +        }
    +
    +        this._stage.setBackgroundColor(color);
    +
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/StageScaleMode.js.html b/docs/StageScaleMode.js.html new file mode 100644 index 00000000..31be6dd7 --- /dev/null +++ b/docs/StageScaleMode.js.html @@ -0,0 +1,1016 @@ + + + + + + Phaser Source: system/StageScaleMode.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: system/StageScaleMode.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* An Animation instance contains a single animation and the controls to play it.
    +* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
    +*
    +* @class Phaser.StageScaleMode 
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +* @param {number} width - Description.
    +* @param {number} height - Description.
    +*/
    +Phaser.StageScaleMode = function (game, width, height) {
    +
    +    /**
    +    * @property {number} _startHeight - Stage height when starting the game.
    +    * @default
    +    * @private
    +    */
    +    this._startHeight = 0;
    +
    +    /**
    +    * @property {boolean} forceLandscape - If the game should be forced to use Landscape mode, this is set to true by Game.Stage
    +    * @default
    +    */
    +    this.forceLandscape = false;
    +
    +    /**
    +    * @property {boolean} forcePortrait - If the game should be forced to use Portrait mode, this is set to true by Game.Stage
    +    * @default
    +    */
    +     this.forcePortrait = false;
    +
    +    /**
    +    * @property {boolean} incorrectOrientation - If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true.
    +    * @default
    +    */
    +    this.incorrectOrientation = false;
    +
    +    /**
    +    * @property {boolean} pageAlignHorizontally - If you wish to align your game in the middle of the page then you can set this value to true.
    +    <ul><li>It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.</li>
    +    <li>It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.</li></ul>
    +    * @default
    +    */
    +    this.pageAlignHorizontally = false;
    +
    +    /**
    +    * @property {boolean} pageAlignVertically - If you wish to align your game in the middle of the page then you can set this value to true.
    +    <ul><li>It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing.
    +    <li>It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.</li></ul>
    +    * @default
    +    */
    +    this.pageAlignVertically = false;
    +
    +    /**
    +    * @property {number} minWidth - Minimum width the canvas should be scaled to (in pixels).
    +    * @default
    +    */
    +    this.minWidth = null;
    +
    +    /**
    +    * @property {number} maxWidth - Maximum width the canvas should be scaled to (in pixels).
    +    * If null it will scale to whatever width the browser can handle.
    +    * @default
    +    */
    +    this.maxWidth = null;
    +
    +    /**
    +    * @property {number} minHeight - Minimum height the canvas should be scaled to (in pixels).
    +    * @default
    +    */
    +    this.minHeight = null;
    +
    +    /**
    +    * @property {number} maxHeight - Maximum height the canvas should be scaled to (in pixels).
    +    * If null it will scale to whatever height the browser can handle.
    +    * @default
    +    */
    +    this.maxHeight = null;
    +
    +    /**
    +    * @property {number} width - Width of the stage after calculation.
    +    * @default
    +    */
    +    this.width = 0;
    +
    +    /**
    +    * @property {number} height - Height of the stage after calculation.
    +    * @default
    +    */
    +    this.height = 0;
    +
    +    /**
    +    * @property {number} maxIterations - The maximum number of times it will try to resize the canvas to fill the browser.
    +    * @default
    +    */
    +    this.maxIterations = 5;
    +    
    +    /**
    +    * @property {Phaser.Game} game - A reference to the currently running game.
    +    */
    +    this.game = game;
    +
    +    /**
    +    * @property {Description} enterLandscape - Description.
    +    */
    +    this.enterLandscape = new Phaser.Signal();
    +
    +    /**
    +    * @property {Description} enterPortrait - Description.
    +    */
    +    this.enterPortrait = new Phaser.Signal();
    +
    +    if (window['orientation'])
    +    {
    +        this.orientation = window['orientation'];
    +    }
    +    else
    +    {
    +        if (window.outerWidth > window.outerHeight)
    +        {
    +            this.orientation = 90;
    +        }
    +        else
    +        {
    +            this.orientation = 0;
    +        }
    +    }
    +
    +    /**
    +    * @property {Description} scaleFactor - Description.
    +    */
    +    this.scaleFactor = new Phaser.Point(1, 1);
    +
    +    /**
    +    * @property {number} aspectRatio - Aspect ratio.
    +    * @default
    +    */
    +    this.aspectRatio = 0;
    +
    +    var _this = this;
    +
    +    window.addEventListener('orientationchange', function (event) {
    +        return _this.checkOrientation(event);
    +    }, false);
    +
    +    window.addEventListener('resize', function (event) {
    +        return _this.checkResize(event);
    +    }, false);
    +	
    +};
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.StageScaleMode.EXACT_FIT = 0;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.StageScaleMode.NO_SCALE = 1;
    +
    +/**
    +* @constant
    +* @type {number}
    +*/
    +Phaser.StageScaleMode.SHOW_ALL = 2;
    +
    +Phaser.StageScaleMode.prototype = {
    +
    +    /**
    +    * Tries to enter the browser into full screen mode.
    +    * Please note that this needs to be supported by the web browser and isn't the same thing as setting your game to fill the browser.
    +    * @method Phaser.StageScaleMode#startFullScreen
    +    */
    +    startFullScreen: function () {
    +
    +        if (this.isFullScreen)
    +        {
    +            return;
    +        }
    +
    +        var element = this.game.canvas;
    +        
    +        if (element['requestFullScreen'])
    +        {
    +            element['requestFullScreen']();
    +        }
    +        else if (element['mozRequestFullScreen'])
    +        {
    +            element['mozRequestFullScreen']();
    +        }
    +        else if (element['webkitRequestFullScreen'])
    +        {
    +            element['webkitRequestFullScreen'](Element.ALLOW_KEYBOARD_INPUT);
    +        }
    +
    +        this.game.stage.canvas.style['width'] = '100%';
    +        this.game.stage.canvas.style['height'] = '100%';
    +
    +    },
    +
    +    /**
    +    * Stops full screen mode if the browser is in it.
    +    * @method Phaser.StageScaleMode#stopFullScreen
    +    */
    +    stopFullScreen: function () {
    +
    +        if (document['cancelFullScreen'])
    +        {
    +            document['cancelFullScreen']();
    +        }
    +        else if (document['mozCancelFullScreen'])
    +        {
    +            document['mozCancelFullScreen']();
    +        }
    +        else if (document['webkitCancelFullScreen'])
    +        {
    +            document['webkitCancelFullScreen']();
    +        }
    +
    +    },
    +
    +    /**
    +    * Checks if the browser is in the correct orientation for your game (if forceLandscape or forcePortrait have been set)
    +    * @method Phaser.StageScaleMode#checkOrientationState
    +    */
    +    checkOrientationState: function () {
    +
    +        //  They are in the wrong orientation
    +        if (this.incorrectOrientation)
    +        {
    +            if ((this.forceLandscape && window.innerWidth > window.innerHeight) || (this.forcePortrait && window.innerHeight > window.innerWidth))
    +            {
    +                //  Back to normal
    +                this.game.paused = false;
    +                this.incorrectOrientation = false;
    +                this.refresh();
    +            }
    +        }
    +        else
    +        {
    +            if ((this.forceLandscape && window.innerWidth < window.innerHeight) || (this.forcePortrait && window.innerHeight < window.innerWidth))
    +            {
    +                //  Show orientation screen
    +                this.game.paused = true;
    +                this.incorrectOrientation = true;
    +                this.refresh();
    +            }
    +        }
    +    },
    +
    +    /**
    +    * Handle window.orientationchange events
    +    * @method Phaser.StageScaleMode#checkOrientation
    +    * @param {Event} event - The orientationchange event data.
    +    */
    +    checkOrientation: function (event) {
    +
    +        this.orientation = window['orientation'];
    +
    +        if (this.isLandscape)
    +        {
    +            this.enterLandscape.dispatch(this.orientation, true, false);
    +        }
    +        else
    +        {
    +            this.enterPortrait.dispatch(this.orientation, false, true);
    +        }
    +
    +        if (this.game.stage.scaleMode !== Phaser.StageScaleMode.NO_SCALE)
    +        {
    +            this.refresh();
    +        }
    +
    +    },
    +
    +    /**
    +    * Handle window.resize events
    +    * @method Phaser.StageScaleMode#checkResize
    +    * @param {Event} event - The resize event data.
    +    */
    +    checkResize: function (event) {
    +
    +        if (window.outerWidth > window.outerHeight)
    +        {
    +            this.orientation = 90;
    +        }
    +        else
    +        {
    +            this.orientation = 0;
    +        }
    +
    +        if (this.isLandscape)
    +        {
    +            this.enterLandscape.dispatch(this.orientation, true, false);
    +        }
    +        else
    +        {
    +            this.enterPortrait.dispatch(this.orientation, false, true);
    +        }
    +
    +        if (this.game.stage.scaleMode !== Phaser.StageScaleMode.NO_SCALE)
    +        {
    +            this.refresh();
    +        }
    +    },
    +
    +    /**
    +    * Re-calculate scale mode and update screen size.
    +    * @method Phaser.StageScaleMode#refresh
    +    */
    +    refresh: function () {
    +
    +        var _this = this;
    +        
    +        //  We can't do anything about the status bars in iPads, web apps or desktops
    +        if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false)
    +        {
    +            // document.documentElement['style'].minHeight = '2000px';
    +            // this._startHeight = window.innerHeight;
    +
    +            if (this.game.device.android && this.game.device.chrome == false)
    +            {
    +                window.scrollTo(0, 1);
    +            }
    +            else
    +            {
    +                window.scrollTo(0, 0);
    +            }
    +        }
    +
    +        if (this._check == null && this.maxIterations > 0)
    +        {
    +            this._iterations = this.maxIterations;
    +            this._check = window.setInterval(function () {
    +                return _this.setScreenSize();
    +            }, 10);
    +            this.setScreenSize();
    +        }
    +
    +    },
    +
    +    /**
    +    * Set screen size automatically based on the scaleMode.
    +    * @param {Description} force - If force is true it will try to resize the game regardless of the document dimensions.
    +    */
    +    setScreenSize: function (force) {
    +
    +        if (typeof force == 'undefined')
    +        {
    +            force = false;
    +        }
    +        
    +        if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false) 
    +        {
    +            if (this.game.device.android && this.game.device.chrome == false)
    +            {
    +                window.scrollTo(0, 1);
    +            }
    +            else
    +            {
    +                window.scrollTo(0, 0);
    +            }
    +        }
    +
    +        this._iterations--;
    +
    +        if (force || window.innerHeight > this._startHeight || this._iterations < 0)
    +        {
    +            // Set minimum height of content to new window height
    +            document.documentElement['style'].minHeight = window.innerHeight + 'px';
    +        
    +            if (this.incorrectOrientation == true)
    +            {
    +                this.setMaximum();
    +            }
    +            else if (this.game.stage.scaleMode == Phaser.StageScaleMode.EXACT_FIT)
    +            {
    +                this.setExactFit();
    +            }
    +            else if (this.game.stage.scaleMode == Phaser.StageScaleMode.SHOW_ALL)
    +            {
    +                this.setShowAll();
    +            }
    +
    +            this.setSize();
    +            clearInterval(this._check);
    +            this._check = null;
    +        }
    +
    +    },
    +
    +    /**
    +    * Sets the canvas style width and height values based on minWidth/Height and maxWidth/Height.
    +    * @method Phaser.StageScaleMode#setSize
    +    */
    +    setSize: function () {
    +
    +        if (this.incorrectOrientation == false)
    +        {
    +            if (this.maxWidth && this.width > this.maxWidth)
    +            {
    +                this.width = this.maxWidth;
    +            }
    +
    +            if (this.maxHeight && this.height > this.maxHeight)
    +            {
    +                this.height = this.maxHeight;
    +            }
    +
    +            if (this.minWidth && this.width < this.minWidth)
    +            {
    +                this.width = this.minWidth;
    +            }
    +
    +            if (this.minHeight && this.height < this.minHeight)
    +            {
    +                this.height = this.minHeight;
    +            }
    +        }
    +
    +        this.game.canvas.style.width = this.width + 'px';
    +        this.game.canvas.style.height = this.height + 'px';
    +        
    +        this.game.input.scale.setTo(this.game.width / this.width, this.game.height / this.height);
    +
    +        if (this.pageAlignHorizontally)
    +        {
    +            if (this.width < window.innerWidth && this.incorrectOrientation == false)
    +            {
    +                this.game.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px';
    +            }
    +            else
    +            {
    +                this.game.canvas.style.marginLeft = '0px';
    +            }
    +        }
    +
    +        if (this.pageAlignVertically)
    +        {
    +            if (this.height < window.innerHeight && this.incorrectOrientation == false)
    +            {
    +                this.game.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px';
    +            }
    +            else
    +            {
    +                this.game.canvas.style.marginTop = '0px';
    +            }
    +        }
    +
    +        Phaser.Canvas.getOffset(this.game.canvas, this.game.stage.offset);
    +        
    +        this.aspectRatio = this.width / this.height;
    +        
    +        this.scaleFactor.x = this.game.width / this.width;
    +        this.scaleFactor.y = this.game.height / this.height;
    +
    +    },
    +
    +    /**
    +    * Sets this.width equal to window.innerWidth and this.height equal to window.innerHeight
    +    * @method Phaser.StageScaleMode#setMaximum
    +    */
    +    setMaximum: function () {
    +
    +        this.width = window.innerWidth;
    +        this.height = window.innerHeight;
    +
    +    },
    +
    +    /**
    +    * Calculates the multiplier needed to scale the game proportionally.
    +    * @method Phaser.StageScaleMode#setShowAll
    +    */
    +    setShowAll: function () {
    +
    +        var multiplier = Math.min((window.innerHeight / this.game.height), (window.innerWidth / this.game.width));
    +
    +        this.width = Math.round(this.game.width * multiplier);
    +        this.height = Math.round(this.game.height * multiplier);
    +
    +    },
    +
    +    /**
    +    * Sets the width and height values of the canvas, no larger than the maxWidth/Height.
    +    * @method Phaser.StageScaleMode#setExactFit
    +    */
    +    setExactFit: function () {
    +
    +        var availableWidth = window.innerWidth - 0;
    +        var availableHeight = window.innerHeight - 5;
    +
    +        // console.log('available', availableWidth, availableHeight);
    +
    +        if (this.maxWidth && availableWidth > this.maxWidth)
    +        {
    +            this.width = this.maxWidth;
    +        }
    +        else
    +        {
    +            this.width = availableWidth;
    +        }
    +
    +        if (this.maxHeight && availableHeight > this.maxHeight)
    +        {
    +            this.height = this.maxHeight;
    +        }
    +        else
    +        {
    +            this.height = availableHeight;
    +        }
    +
    +        console.log('setExactFit', this.width, this.height, this.game.stage.offset);
    +
    +    }
    +
    +};
    +
    +/**
    +* @name Phaser.StageScaleMode#isFullScreen
    +* @property {boolean} isFullScreen - Returns true if the browser is in full screen mode, otherwise false.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.StageScaleMode.prototype, "isFullScreen", {
    +
    +    get: function () {
    +
    +        if (document['fullscreenElement'] === null || document['mozFullScreenElement'] === null || document['webkitFullscreenElement'] === null)
    +        {
    +            return false;
    +        }
    +
    +        return true;
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.StageScaleMode#isPortrait
    +* @property {boolean} isPortrait - Returns true if the browser dimensions match a portrait display.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.StageScaleMode.prototype, "isPortrait", {
    +
    +    get: function () {
    +        return this.orientation == 0 || this.orientation == 180;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.StageScaleMode#isLandscape
    +* @property {boolean} isLandscape - Returns true if the browser dimensions match a landscape display.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.StageScaleMode.prototype, "isLandscape", {
    +
    +    get: function () {
    +        return this.orientation === 90 || this.orientation === -90;
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/State.js.html b/docs/State.js.html new file mode 100644 index 00000000..2d04c7dc --- /dev/null +++ b/docs/State.js.html @@ -0,0 +1,614 @@ + + + + + + Phaser Source: core/State.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/State.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* This is a base State class which can be extended if you are creating your own game.
    +* It provides quick access to common functions such as the camera, cache, input, match, sound and more.
    +*
    +* @class Phaser.State
    +* @constructor
    +*/
    +
    +Phaser.State = function () {
    +
    +    /**
    +	* @property {Phaser.Game} game - A reference to the currently running Game.
    +	*/
    +    this.game = null;
    +    
    +	/**
    +	* @property {Phaser.GameObjectFactory} add - Reference to the GameObjectFactory.
    +	* @default
    +	*/
    +    this.add = null;
    +    
    +    /**
    +	* @property {Phaser.Physics.PhysicsManager} camera - A handy reference to world.camera.
    +	* @default
    +	*/
    +    this.camera = null;
    +    
    +    /**
    +	* @property {Phaser.Cache} cache - Reference to the assets cache.
    +	* @default
    +	*/
    +    this.cache = null;
    +    
    +    /**
    +	* @property {Phaser.Input} input - Reference to the input manager
    +	* @default
    +	*/
    +    this.input = null;
    +    
    +    /**
    +	* @property {Phaser.Loader} load - Reference to the assets loader.
    +	* @default
    +	*/
    +    this.load = null;
    +    
    +    /**
    +	* @property {Phaser.GameMath} math - Reference to the math helper.
    +	* @default
    +	*/
    +    this.math = null;
    +    
    +    /**
    +	* @property {Phaser.SoundManager} sound - Reference to the sound manager.
    +	* @default
    +	*/
    +    this.sound = null;
    +    
    +    /**
    +	* @property {Phaser.Stage} stage - Reference to the stage.
    +	* @default
    +	*/
    +    this.stage = null;
    +    
    +    /**
    +	* @property {Phaser.TimeManager} time - Reference to game clock.
    +	* @default
    +	*/
    +    this.time = null;
    +    
    +    /**
    +	* @property {Phaser.TweenManager} tweens - Reference to the tween manager.
    +	* @default
    +	*/
    +    this.tweens = null;
    +    
    +    /**
    +	* @property {Phaser.World} world - Reference to the world.
    +	* @default
    +	*/
    +    this.world = null;
    +    
    +	/**
    +	* @property {Description} add - Description.
    +	* @default
    +	*/
    +    this.particles = null;
    +    
    +    /**
    +	* @property {Phaser.Physics.PhysicsManager} physics - Reference to the physics manager.
    +	* @default
    +	*/
    +    this.physics = null;
    +
    +};
    +
    +Phaser.State.prototype = {
    +
    +    /**
    +    * Override this method to add some load operations.
    +    * If you need to use the loader, you may need to use them here.
    +    * 
    +    * @method Phaser.State#preload
    +    */
    +    preload: function () {
    +    },
    +
    +    /**
    +    * Put update logic here.
    +    * 
    +    * @method Phaser.State#loadUpdate
    +    */
    +    loadUpdate: function () {
    +    },
    +
    +    /**
    +    * Put render operations here.
    +    * 
    +    * @method Phaser.State#loadRender
    +    */
    +    loadRender: function () {
    +    },
    +
    +    /**
    +    * This method is called after the game engine successfully switches states.
    +    * Feel free to add any setup code here (do not load anything here, override preload() instead).
    +    * 
    +    * @method Phaser.State#create
    +    */
    +    create: function () {
    +    },
    +
    +    /**
    +    * Put update logic here.
    +    * 
    +    * @method Phaser.State#update
    +    */
    +    update: function () {
    +    },
    +
    +    /**
    +    * Put render operations here.
    +    * 
    +    * @method Phaser.State#render
    +    */
    +    render: function () {
    +    },
    +
    +    /**
    +    * This method will be called when game paused.
    +    * 
    +    * @method Phaser.State#paused
    +    */
    +    paused: function () {
    +    },
    +
    +    /**
    +    * This method will be called when the state is destroyed.
    +    * @method Phaser.State#destroy
    +    */
    +    destroy: function () {
    +    }
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/StateManager.js.html b/docs/StateManager.js.html new file mode 100644 index 00000000..2604fa8f --- /dev/null +++ b/docs/StateManager.js.html @@ -0,0 +1,970 @@ + + + + + + Phaser Source: core/StateManager.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/StateManager.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* The State Manager is responsible for loading, setting up and switching game states.
    +* 
    +* @class Phaser.StateManager
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +* @param {Phaser.State|Object} [pendingState=null] - A State object to seed the manager with.
    +*/
    +Phaser.StateManager = function (game, pendingState) {
    +
    +	/**
    +	* A reference to the currently running game.
    +	* @property {Phaser.Game} game.
    +	*/
    +	this.game = game;
    +
    +	/**
    +	* Description.
    +	* @property {Description} states.
    +	*/
    +	this.states = {};
    +
    +	if (pendingState !== null)
    +	{
    +		this._pendingState = pendingState;
    +	}
    +
    +};
    +
    +Phaser.StateManager.prototype = {
    +	
    +	/**
    +	* A reference to the currently running game.
    +	* @property {Phaser.Game} game.
    +	*/
    +	game: null,
    +
    +	/**
    +	* The state to be switched to in the next frame.
    +	* @property {State} _pendingState 
    +	* @private
    +	*/
    +	_pendingState: null,
    +
    +	/**
    +	* Flag that sets if the State has been created or not.
    +	* @property {boolean}_created
    +	* @private
    +	*/
    +	_created: false,
    +
    +	/**
    +	* The state to be switched to in the next frame.
    +	* @property {Description} states
    +	*/
    +	states: {},
    +
    +	/**
    +	* The current active State object (defaults to null).
    +	* @property {string} current
    +	*/
    +	current: '',
    +	
    +	/**
    +	* This will be called when the state is started (i.e. set as the current active state).
    +	* @property {function} onInitCallback
    +	*/
    +	onInitCallback: null,
    +
    +	/**
    +	* This will be called when init states (loading assets...).
    +	* @property {function} onPreloadCallback
    +	*/
    +	onPreloadCallback: null,
    +	
    +	/**
    +	* This will be called when create states (setup states...).
    +	* @property {function} onCreateCallback
    +	*/
    +	onCreateCallback: null,
    +
    +	/**
    +	* This will be called when State is updated, this doesn't happen during load (@see onLoadUpdateCallback).
    +	* @property {function} onUpdateCallback
    +	*/
    +	onUpdateCallback: null,
    +
    +	/**
    +	* This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback).
    +	* @property {function} onRenderCallback
    +	*/
    +	onRenderCallback: null,
    +
    +	/**
    +	* This will be called before the State is rendered and before the stage is cleared.
    +	* @property {function} onPreRenderCallback
    +	*/
    +	onPreRenderCallback: null,
    +
    +	/**
    +	* This will be called when the State is updated but only during the load process.
    +	* @property {function} onLoadUpdateCallback
    +	*/
    +	onLoadUpdateCallback: null,
    +
    +	/**
    +	* This will be called when the State is rendered but only during the load process.
    +	* @property {function} onLoadRenderCallback
    +	*/
    +	onLoadRenderCallback: null,
    +
    +	/**
    +	* This will be called when states paused.
    +	* @property {function} onPausedCallback
    +	*/
    +	onPausedCallback: null,
    +
    +	/**
    +	* This will be called when the state is shut down (i.e. swapped to another state).
    +	* @property {function} onShutDownCallback
    +	*/
    +	onShutDownCallback: null,
    +
    +	/**
    +	* Description.
    +	* @method Phaser.StateManager#boot
    +	* @private
    +	*/
    +	boot: function () {
    +
    +		// console.log('Phaser.StateManager.boot');
    +
    +		if (this._pendingState !== null)
    +		{
    +			// console.log('_pendingState found');
    +			// console.log(typeof this._pendingState);
    +
    +			if (typeof this._pendingState === 'string')
    +			{
    +				//	State was already added, so just start it
    +				this.start(this._pendingState, false, false);
    +			}
    +			else
    +			{
    +				this.add('default', this._pendingState, true);
    +			}
    +
    +		}
    +
    +	},
    +
    +	/**
    +    * Add a new State.
    +    * @method Phaser.StateManager#add
    +    * @param key {string} - A unique key you use to reference this state, i.e. "MainMenu", "Level1".
    +    * @param state {State} - The state you want to switch to.
    +    * @param autoStart {boolean} - Start the state immediately after creating it? (default true)
    +    */
    +    add: function (key, state, autoStart) {
    +
    +        if (typeof autoStart === "undefined") { autoStart = false; }
    +
    +		// console.log('Phaser.StateManager.addState', key);
    +		// console.log(typeof state);
    +		// console.log('autoStart?', autoStart);
    +
    +		var newState;
    +
    +		if (state instanceof Phaser.State)
    +		{
    +			// console.log('Phaser.StateManager.addState: Phaser.State given');
    +			newState = state;
    +		}
    +		else if (typeof state === 'object')
    +		{
    +			// console.log('Phaser.StateManager.addState: Object given');
    +			newState = state;
    +			newState.game = this.game;
    +		}
    +		else if (typeof state === 'function')
    +		{
    +			// console.log('Phaser.StateManager.addState: Function given');
    +			newState = new state(this.game);
    +		}
    +
    +		this.states[key] = newState;
    +
    +		if (autoStart)
    +		{
    +			if (this.game.isBooted)
    +			{
    +				// console.log('Game is booted, so we can start the state now');
    +				this.start(key);
    +			}
    +			else
    +			{
    +				// console.log('Game is NOT booted, so set the current state as pending');
    +				this._pendingState = key;
    +			}
    +		}
    +
    +		return newState;
    +
    +    },
    +
    +	/**
    +     * Delete the given state.
    +     * @method Phaser.StateManager#remove
    +     * @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1".
    +     */
    +    remove: function (key) {
    +
    +    	if (this.current == key)
    +    	{
    +	        this.callbackContext = null;
    +
    +	        this.onInitCallback = null;
    +	        this.onShutDownCallback = null;
    +
    +	        this.onPreloadCallback = null;
    +	        this.onLoadRenderCallback = null;
    +	        this.onLoadUpdateCallback = null;
    +	        this.onCreateCallback = null;
    +	        this.onUpdateCallback = null;
    +	        this.onRenderCallback = null;
    +	        this.onPausedCallback = null;
    +	        this.onDestroyCallback = null;
    +    	}
    +
    +    	delete this.states[key];
    +
    +    },
    +
    +	/**
    +    * Start the given state
    +    * @method Phaser.StateManager#start
    +    * @param {string} key - The key of the state you want to start.
    +    * @param {boolean} [clearWorld] - clear everything in the world? (Default to true)
    +    * @param {boolean} [clearCache] - clear asset cache? (Default to false and ONLY available when clearWorld=true)
    +    */
    +    start: function (key, clearWorld, clearCache) {
    +
    +    	// console.log('Phaser.StateManager.start', key);
    +    	// console.log(this);
    +    	// console.log(this.callbackContext);
    +
    +        if (typeof clearWorld === "undefined") { clearWorld = true; }
    +        if (typeof clearCache === "undefined") { clearCache = false; }
    +
    +        if (this.game.isBooted == false)
    +        {
    +			// console.log('Game is NOT booted, so set the requested state as pending');
    +			this._pendingState = key;
    +			return;
    +        }
    +
    +		if (this.checkState(key) == false)
    +		{
    +			return;
    +		}
    +		else
    +		{
    +			//	Already got a state running?
    +			if (this.current)
    +			{
    +				this.onShutDownCallback.call(this.callbackContext);
    +			}
    +
    +	        if (clearWorld)
    +	        {
    +				this.game.tweens.removeAll();
    +
    +	            this.game.world.destroy();
    +
    +	            if (clearCache == true)
    +	            {
    +	                this.game.cache.destroy();
    +	            }
    +	        }
    +
    +			this.setCurrentState(key);
    +		}
    +
    +        if (this.onPreloadCallback)
    +        {
    +	    	// console.log('Preload Callback found');
    +            this.game.load.reset();
    +            this.onPreloadCallback.call(this.callbackContext);
    +
    +            //  Is the loader empty?
    +            if (this.game.load.queueSize == 0)
    +            {
    +		    	// console.log('Loader queue empty');
    +                this.game.loadComplete();
    +            }
    +            else
    +            {
    +		    	// console.log('Loader started');
    +                //  Start the loader going as we have something in the queue
    +                this.game.load.start();
    +            }
    +        }
    +        else
    +        {
    +			// console.log('Preload callback not found');
    +            //  No init? Then there was nothing to load either
    +            this.game.loadComplete();
    +        }
    +
    +    },
    +	
    +	/**
    +	* Used by onInit and onShutdown when those functions don't exist on the state
    +    * @method Phaser.StateManager#dummy
    +    * @private
    +    */
    +    dummy: function () {
    +    },
    +
    +	/**
    +    * Description.
    +    * @method Phaser.StateManager#checkState
    +    * @param {string} key - The key of the state you want to check.
    +    * @return {boolean} Description.
    +    */
    +    checkState: function (key) {
    +
    +		if (this.states[key])
    +		{
    +			var valid = false;
    +
    +			if (this.states[key]['preload']) { valid = true; }
    +
    +			if (valid == false && this.states[key]['loadRender']) { valid = true; }
    +			if (valid == false && this.states[key]['loadUpdate']) { valid = true; }
    +			if (valid == false && this.states[key]['create']) { valid = true; }
    +			if (valid == false && this.states[key]['update']) { valid = true; }
    +			if (valid == false && this.states[key]['preRender']) { valid = true; }
    +			if (valid == false && this.states[key]['render']) { valid = true; }
    +			if (valid == false && this.states[key]['paused']) { valid = true; }
    +
    +        	if (valid == false)
    +        	{
    +	            console.warn("Invalid Phaser State object given. Must contain at least a one of the required functions.");
    +	            return false;
    +	        }
    +
    +			return true;
    +		}
    +		else
    +		{
    +			console.warn("Phaser.StateManager - No state found with the key: " + key);
    +			return false;
    +		}
    +
    +    },
    +
    +	/**
    +    * Links game properties to the State given by the key.
    +    * @method Phaser.StateManager#link
    +    * @param {string} key - State key.
    +    * @protected
    +    */
    +    link: function (key) {
    +
    +		// console.log('linked');
    +        this.states[key].game = this.game;
    +        this.states[key].add = this.game.add;
    +        this.states[key].camera = this.game.camera;
    +        this.states[key].cache = this.game.cache;
    +        this.states[key].input = this.game.input;
    +        this.states[key].load = this.game.load;
    +        this.states[key].math = this.game.math;
    +        this.states[key].sound = this.game.sound;
    +        this.states[key].stage = this.game.stage;
    +        this.states[key].time = this.game.time;
    +        this.states[key].tweens = this.game.tweens;
    +        this.states[key].world = this.game.world;
    +        this.states[key].particles = this.game.particles;
    +        this.states[key].physics = this.game.physics;
    +        this.states[key].rnd = this.game.rnd;
    +
    +    },
    +
    +	/**
    +    * Sets the current State. Should not be called directly (use StateManager.start)
    +    * @method Phaser.StateManager#setCurrentState
    +    * @param {string} key - State key.
    +    * @protected
    +    */
    +	setCurrentState: function (key) {
    +
    +        this.callbackContext = this.states[key];
    +
    +        this.link(key);
    +
    +        //	Used when the state is set as being the current active state
    +        this.onInitCallback = this.states[key]['init'] || this.dummy;
    +
    +        this.onPreloadCallback = this.states[key]['preload'] || null;
    +        this.onLoadRenderCallback = this.states[key]['loadRender'] || null;
    +        this.onLoadUpdateCallback = this.states[key]['loadUpdate'] || null;
    +        this.onCreateCallback = this.states[key]['create'] || null;
    +        this.onUpdateCallback = this.states[key]['update'] || null;
    +        this.onPreRenderCallback = this.states[key]['preRender'] || null;
    +        this.onRenderCallback = this.states[key]['render'] || null;
    +        this.onPausedCallback = this.states[key]['paused'] || null;
    +
    +        //	Used when the state is no longer the current active state
    +        this.onShutDownCallback = this.states[key]['shutdown'] || this.dummy;
    +
    +		this.current = key;
    +		this._created = false;
    +
    +		this.onInitCallback.call(this.callbackContext);
    +
    +	},
    +
    +	/**
    +	* @method Phaser.StateManager#loadComplete
    +    * @protected
    +	*/
    +    loadComplete: function () {
    +
    +		// console.log('Phaser.StateManager.loadComplete');
    +
    +        if (this._created == false && this.onCreateCallback)
    +        {
    +			// console.log('Create callback found');
    +	        this._created = true;
    +            this.onCreateCallback.call(this.callbackContext);
    +        }
    +        else
    +        {
    +	        this._created = true;
    +        }
    +
    +    },
    +
    +	/**
    +	* @method Phaser.StateManager#update
    +    * @protected
    +	*/
    +    update: function () {
    +
    +    	if (this._created && this.onUpdateCallback)
    +    	{
    +			this.onUpdateCallback.call(this.callbackContext);
    +    	}
    +    	else
    +    	{
    +		    if (this.onLoadUpdateCallback)
    +		    {
    +		    	this.onLoadUpdateCallback.call(this.callbackContext);
    +			}
    +		}
    +
    +    },
    +
    +	/**
    +	* @method Phaser.StateManager#preRender
    +    * @protected
    +	*/
    +    preRender: function () {
    +
    +	    if (this.onPreRenderCallback)
    +	    {
    +	    	this.onPreRenderCallback.call(this.callbackContext);
    +		}
    +
    +    },
    +
    +	/**
    +	* @method Phaser.StateManager#render
    +    * @protected
    +	*/
    +    render: function () {
    +
    +    	if (this._created && this.onRenderCallback)
    +    	{
    +			this.onRenderCallback.call(this.callbackContext);
    +    	}
    +    	else
    +    	{
    +		    if (this.onLoadRenderCallback)
    +		    {
    +		    	this.onLoadRenderCallback.call(this.callbackContext);
    +			}
    +		}
    +
    +    },
    +
    +	/**
    +    * Nuke the entire game from orbit
    +    * @method Phaser.StateManager#destroy
    +    */
    +    destroy: function () {
    +
    +        this.callbackContext = null;
    +
    +        this.onInitCallback = null;
    +        this.onShutDownCallback = null;
    +
    +        this.onPreloadCallback = null;
    +        this.onLoadRenderCallback = null;
    +        this.onLoadUpdateCallback = null;
    +        this.onCreateCallback = null;
    +        this.onUpdateCallback = null;
    +        this.onRenderCallback = null;
    +        this.onPausedCallback = null;
    +        this.onDestroyCallback = null;
    +
    +        this.game = null;
    +        this.states = {};
    +        this._pendingState = null;
    +
    +    }
    +
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Text.js.html b/docs/Text.js.html new file mode 100644 index 00000000..5a0d9205 --- /dev/null +++ b/docs/Text.js.html @@ -0,0 +1,666 @@ + + + + + + Phaser Source: gameobjects/Text.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: gameobjects/Text.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Create a new <code>Text</code>.
    +* @class Phaser.Text
    +* @constructor
    +* @param {Phaser.Game} game - Current game instance.
    +* @param {number} x - X position of the new text object.
    +* @param {number} y - Y position of the new text object.
    +* @param {string} text - The actual text that will be written.
    +* @param {object} style - The style object containing style attributes like font, font size ,
    +*/
    +Phaser.Text = function (game, x, y, text, style) {
    +
    +    x = x || 0;
    +    y = y || 0;
    +    text = text || '';
    +    style = style || '';
    +
    +    //  If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all
    +	/**
    +	* @property {boolean} exists - Description.
    +	* @default
    +	*/
    +    this.exists = true;
    +
    +    //  This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering
    +	/**
    +	* @property {boolean} alive - Description.
    +	* @default
    +	*/
    +    this.alive = true;
    +
    +	/**
    +	* @property {Description} group - Description.
    +	* @default
    +	*/
    +    this.group = null;
    +
    +	/**
    +	* @property {string} name - Description.
    +	* @default
    +	*/
    +    this.name = '';
    +
    +    /**
    +    * @property {Phaser.Game} game - A reference to the currently running game. 
    +    */
    +    this.game = game;
    +
    +    this._text = text;
    +    this._style = style;
    +
    +    PIXI.Text.call(this, text, style);
    +
    +    /**
    +     * @property {Description} type - Description. 
    +     */
    +    this.type = Phaser.TEXT;
    +
    +    /**
    +     * @property {Description} position - Description. 
    +     */
    +    this.position.x = this.x = x;
    +    this.position.y = this.y = y;
    +
    +    //  Replaces the PIXI.Point with a slightly more flexible one
    +    /**
    +     * @property {Phaser.Point} anchor - Description. 
    +     */
    +    this.anchor = new Phaser.Point();
    +    
    +    /**
    +     * @property {Phaser.Point} scale - Description. 
    +     */
    +    this.scale = new Phaser.Point(1, 1);
    +
    +    //  A mini cache for storing all of the calculated values
    +    /**
    +    * @property {Description} _cache - Description. 
    +    * @private
    +    */
    +    this._cache = { 
    +
    +        dirty: false,
    +
    +        //  Transform cache
    +        a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, 
    +
    +        //  The previous calculated position
    +        x: -1, y: -1,
    +
    +        //  The actual scale values based on the worldTransform
    +        scaleX: 1, scaleY: 1
    +
    +    };
    +
    +    this._cache.x = this.x;
    +    this._cache.y = this.y;
    +
    +    /**
    +    * @property {boolean} renderable - Description. 
    +    */
    +    this.renderable = true;
    +
    +};
    +
    +Phaser.Text.prototype = Object.create(PIXI.Text.prototype);
    +Phaser.Text.prototype.constructor = Phaser.Text;
    +
    +/**
    +* Automatically called by World.update.
    +* @method Phaser.Text.prototype.update
    +*/
    +Phaser.Text.prototype.update = function() {
    +
    +    if (!this.exists)
    +    {
    +        return;
    +    }
    +
    +    this._cache.dirty = false;
    +
    +    this._cache.x = this.x;
    +    this._cache.y = this.y;
    +
    +    if (this.position.x != this._cache.x || this.position.y != this._cache.y)
    +    {
    +        this.position.x = this._cache.x;
    +        this.position.y = this._cache.y;
    +        this._cache.dirty = true;
    +    }
    +
    +}
    +
    +/**
    +* @method Phaser.Text.prototype.destroy
    +*/
    +Phaser.Text.prototype.destroy = function() {
    +
    +    if (this.group)
    +    {
    +        this.group.remove(this);
    +    }
    +
    +    if (this.canvas.parentNode)
    +    {
    +        this.canvas.parentNode.removeChild(this.canvas);
    +    }
    +    else
    +    {
    +        this.canvas = null;
    +        this.context = null;
    +    }
    +
    +    this.exists = false;
    +
    +    this.group = null;
    +
    +}
    +
    +/**
    +* Get
    +* @returns {Description}
    +*//**
    +* Set
    +* @param {Description} value - Description
    +*/
    +Object.defineProperty(Phaser.Text.prototype, 'angle', {
    +
    +    get: function() {
    +        return Phaser.Math.radToDeg(this.rotation);
    +    },
    +
    +    set: function(value) {
    +        this.rotation = Phaser.Math.degToRad(value);
    +    }
    +
    +});
    +
    +Object.defineProperty(Phaser.Text.prototype, 'content', {
    +
    +    get: function() {
    +        return this._text;
    +    },
    +
    +    set: function(value) {
    +
    +        //  Let's not update unless needed, this way we can safely update the text in a core loop without constant re-draws
    +        if (value !== this._text)
    +        {
    +            this._text = value;
    +            this.setText(value);
    +        }
    +
    +    }
    +
    +});
    +
    +Object.defineProperty(Phaser.Text.prototype, 'font', {
    +
    +    get: function() {
    +        return this._style;
    +    },
    +
    +    set: function(value) {
    +
    +        //  Let's not update unless needed, this way we can safely update the text in a core loop without constant re-draws
    +        if (value !== this._style)
    +        {
    +            this._style = value;
    +            this.setStyle(value);
    +        }
    +
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/TileSprite.js.html b/docs/TileSprite.js.html new file mode 100644 index 00000000..9d88842c --- /dev/null +++ b/docs/TileSprite.js.html @@ -0,0 +1,502 @@ + + + + + + Phaser Source: gameobjects/TileSprite.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: gameobjects/TileSprite.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Create a new <code>TileSprite</code>.
    +* @class Phaser.Tilemap
    +* @constructor
    +* @param {Phaser.Game} game - Current game instance.
    +* @param {number} x - X position of the new tileSprite.
    +* @param {number} y - Y position of the new tileSprite.
    +* @param {number} width - the width of the tilesprite.
    +* @param {number} height - the height of the tilesprite.
    +* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture.
    +* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index.
    +*/
    +Phaser.TileSprite = function (game, x, y, width, height, key, frame) {
    +
    +    x = x || 0;
    +    y = y || 0;
    +    width = width || 256;
    +    height = height || 256;
    +    key = key || null;
    +    frame = frame || null;
    +
    +	Phaser.Sprite.call(this, game, x, y, key, frame);
    +
    +	/**
    +	* @property {Description} texture - Description. 
    +    */
    +    this.texture = PIXI.TextureCache[key];
    +
    +	PIXI.TilingSprite.call(this, this.texture, width, height);
    +
    +	/**
    +	* @property {Description} type - Description. 
    +    */
    +	this.type = Phaser.TILESPRITE;
    +
    +	/**
    +	* @property {Point} tileScale - The scaling of the image that is being tiled.
    +	*/	
    +	this.tileScale = new Phaser.Point(1, 1);
    +
    +	/**
    +	* @property {Point} tilePosition - The offset position of the image that is being tiled.
    +	*/	
    +	this.tilePosition = new Phaser.Point(0, 0);
    +
    +};
    +
    +Phaser.TileSprite.prototype = Phaser.Utils.extend(true, PIXI.TilingSprite.prototype, Phaser.Sprite.prototype);
    +Phaser.TileSprite.prototype.constructor = Phaser.TileSprite;
    +
    +//  Add our own custom methods
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Time.js.html b/docs/Time.js.html new file mode 100644 index 00000000..e43d0193 --- /dev/null +++ b/docs/Time.js.html @@ -0,0 +1,716 @@ + + + + + + Phaser Source: time/Time.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: time/Time.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Time constructor.
    +*
    +* @class Phaser.Time
    +* @classdesc This is the core internal game clock. It manages the elapsed time and calculation of elapsed values, used for game object motion and tweens.
    +* @constructor
    +* @param {Phaser.Game} game A reference to the currently running game.
    +*/
    +Phaser.Time = function (game) {
    +
    +	/**
    +	* @property {Phaser.Game} game - Local reference to game.
    +	*/
    +	this.game = game;
    +
    +	/**
    +	* The time at which the Game instance started.
    +	* @property {number} _started
    +	* @private
    +	* @default
    +	*/
    +	this._started = 0;
    +
    +	/**
    +	* The time (in ms) that the last second counter ticked over.
    +	* @property {number} _timeLastSecond
    +	* @private
    +	* @default
    +	*/
    +	this._timeLastSecond = 0;
    +
    +	/**
    +	* The time the game started being paused.
    +	* @property {number} _pauseStarted
    +	* @private
    +	* @default
    +	*/
    +	this._pauseStarted = 0;
    +
    +	/**
    +	* The elapsed time calculated for the physics motion updates.
    +	* @property {number} physicsElapsed
    +	* @default
    +	*/
    +	this.physicsElapsed = 0;
    +
    +	/**
    +	* Game time counter.
    +	* @property {number} time
    +	* @default
    +	*/
    +	this.time = 0;
    +
    +	/**
    +	* Records how long the game has been paused for. Is reset each time the game pauses.
    +	* @property {number} pausedTime
    +	* @default
    +	*/
    +	this.pausedTime = 0;
    +
    +	/**
    +	* The time right now.
    +	* @property {number} now
    +    * @default
    +	*/
    +	this.now = 0;
    +
    +	/**
    +	* Elapsed time since the last frame.
    +	* @property {number} elapsed
    +	* @default
    +	*/
    +	this.elapsed = 0;
    +
    +	/**
    +	* Frames per second.
    +	* @property {number} fps
    +	* @default
    +	*/
    +	this.fps = 0;
    +
    +	/**
    +	* The lowest rate the fps has dropped to.
    +	* @property {number} fpsMin
    +	* @default
    +	*/
    +	this.fpsMin = 1000;
    +
    +	/**
    +	* The highest rate the fps has reached (usually no higher than 60fps).
    +	* @property {number} fpsMax
    +	* @default
    +	*/
    +	this.fpsMax = 0;
    +
    +	/**
    +	* The minimum amount of time the game has taken between two frames.
    +	* @property {number} msMin
    +	* @default
    +	*/
    +	this.msMin = 1000;
    +
    +	/**
    +	* The maximum amount of time the game has taken between two frames.
    +	* @property {number} msMax
    +	* @default
    +	*/
    +	this.msMax = 0;
    +
    +	/**
    +	* The number of frames record in the last second.
    +	* @property {number} frames
    +	* @default
    +	*/
    +	this.frames = 0;
    +
    +	/**
    +	* Records how long the game was paused for in miliseconds.
    +	* @property {number} pauseDuration
    +	* @default
    +	*/
    +	this.pauseDuration = 0;
    +
    +	/**
    +	* The value that setTimeout needs to work out when to next update
    +	* @property {number} timeToCall
    +	* @default
    +	*/
    +	this.timeToCall = 0;
    +
    +	/**
    +	* Internal value used by timeToCall as part of the setTimeout loop
    +	* @property {number} lastTime
    +	* @default
    +	*/
    +	this.lastTime = 0;
    +
    +	//	Listen for game pause/resume events
    +	this.game.onPause.add(this.gamePaused, this);
    +	this.game.onResume.add(this.gameResumed, this);
    +
    +	/**
    +	* Description.
    +	* @property {boolean} _justResumed
    +    * @default
    +	*/
    +	this._justResumed = false;
    +
    +};
    +
    +Phaser.Time.prototype = {
    +
    +	/**
    +	* The number of seconds that have elapsed since the game was started.
    +	* @method Phaser.Time#totalElapsedSeconds
    +	* @return {number}
    +	*/
    +	totalElapsedSeconds: function() {
    +		return (this.now - this._started) * 0.001;
    +	},
    +
    +	/**
    +	* Updates the game clock and calculate the fps. This is called automatically by Phaser.Game.
    +	* @method Phaser.Time#update
    +	* @param {number} time - The current timestamp, either performance.now or Date.now depending on the browser.
    +	*/
    +	update: function (time) {
    +
    +		this.now = time;
    +
    +		if (this._justResumed)
    +		{
    +			this.time = this.now;
    +			this._justResumed = false;
    +		}
    +
    +		this.timeToCall = this.game.math.max(0, 16 - (time - this.lastTime));
    +
    +		this.elapsed = this.now - this.time;
    +
    +		this.msMin = this.game.math.min(this.msMin, this.elapsed);
    +		this.msMax = this.game.math.max(this.msMax, this.elapsed);
    +
    +		this.frames++;
    +
    +		if (this.now > this._timeLastSecond + 1000)
    +		{
    +			this.fps = Math.round((this.frames * 1000) / (this.now - this._timeLastSecond));
    +			this.fpsMin = this.game.math.min(this.fpsMin, this.fps);
    +			this.fpsMax = this.game.math.max(this.fpsMax, this.fps);
    +			this._timeLastSecond = this.now;
    +			this.frames = 0;
    +		}
    +
    +		this.time = this.now;
    +        this.lastTime = time + this.timeToCall;
    +		this.physicsElapsed = 1.0 * (this.elapsed / 1000);
    +
    +		//	Clamp the delta
    +		if (this.physicsElapsed > 1)
    +		{
    +			this.physicsElapsed = 1;
    +		}
    +
    +		//  Paused?
    +		if (this.game.paused)
    +		{
    +			this.pausedTime = this.now - this._pauseStarted;
    +		}
    +
    +	},
    +
    +	/**
    +	* Called when the game enters a paused state.
    +	* @method Phaser.Time#gamePaused
    +	* @private
    +	*/
    +	gamePaused: function () {
    +		
    +		this._pauseStarted = this.now;
    +
    +	},
    +
    +	/**
    +	* Called when the game resumes from a paused state.
    +	* @method Phaser.Time#gameResumed
    +	* @private
    +	*/
    +	gameResumed: function () {
    +
    +		//  Level out the elapsed timer to avoid spikes
    +		this.time = Date.now();
    +		this.pauseDuration = this.pausedTime;
    +		this._justResumed = true;
    +
    +	},
    +
    +	/**
    +	* How long has passed since the given time.
    +	* @method Phaser.Time#elapsedSince
    +	* @param {number} since - The time you want to measure against.
    +	* @return {number} The difference between the given time and now.
    +	*/
    +	elapsedSince: function (since) {
    +		return this.now - since;
    +	},
    +
    +	/**
    +	* How long has passed since the given time (in seconds).
    +	* @method Phaser.Time#elapsedSecondsSince
    +	* @param {number} since - The time you want to measure (in seconds).
    +	* @return {number} Duration between given time and now (in seconds).
    +	*/
    +	elapsedSecondsSince: function (since) {
    +		return (this.now - since) * 0.001;
    +	},
    +
    +	/**
    +	* Resets the private _started value to now.
    +	* @method Phaser.Time#reset
    +	*/
    +	reset: function () {
    +		this._started = this.now;
    +	}
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Touch.js.html b/docs/Touch.js.html new file mode 100644 index 00000000..ff9954b2 --- /dev/null +++ b/docs/Touch.js.html @@ -0,0 +1,778 @@ + + + + + + Phaser Source: input/Touch.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: input/Touch.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser.Touch handles touch events with your game. Note: Android 2.x only supports 1 touch event at once, no multi-touch.
    +*
    +* @class Phaser.Touch
    +* @classdesc The Touch class handles touch interactions with the game and the resulting Pointer objects.
    +* @constructor
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +*/
    +Phaser.Touch = function (game) {
    +
    +    /**
    +    * @property {Phaser.Game} game - Local reference to game.
    +    */
    +    this.game = game;
    +    
    +    /**
    +    * You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
    +    * @method Phaser.Touch#disabled
    +    * @return {boolean}
    +    */
    +    this.disabled = false;
    +
    +    /**
    +    * @property {Phaser.Game} callbackContext - Description.
    +    */
    +    this.callbackContext = this.game;
    +
    +    /**
    +    * @property {Phaser.Game} touchStartCallback - Description.
    +    * @default
    +    */
    +    this.touchStartCallback = null;
    +    
    +    /**
    +    * @property {Phaser.Game} touchMoveCallback - Description.
    +    * @default
    +    */
    +    this.touchMoveCallback = null;
    +    
    +    /**
    +    * @property {Phaser.Game} touchEndCallback - Description.
    +    * @default
    +    */
    +    this.touchEndCallback = null;
    +    
    +    /**
    +    * @property {Phaser.Game} touchEnterCallback - Description.
    +    * @default
    +    */
    +    this.touchEnterCallback = null;
    +    
    +    /**
    +    * @property {Phaser.Game} touchLeaveCallback - Description.
    +    * @default
    +    */
    +    this.touchLeaveCallback = null;
    +    
    +    /**
    +    * @property {Description} touchCancelCallback - Description.
    +    * @default
    +    */
    +    this.touchCancelCallback = null;
    +    
    +    /**
    +    * @property {boolean} preventDefault - Description.
    +    * @default
    +    */
    +    this.preventDefault = true;
    +
    +    this._onTouchStart = null;
    +    this._onTouchMove = null;
    +    this._onTouchEnd = null;
    +    this._onTouchEnter = null;
    +    this._onTouchLeave = null;
    +    this._onTouchCancel = null;
    +    this._onTouchMove = null;
    +
    +};
    +
    +Phaser.Touch.prototype = {
    +
    +    /**
    +    * Starts the event listeners running.
    +    * @method Phaser.Touch#start
    +    */
    +    start: function () {
    +
    +        var _this = this;
    +
    +        if (this.game.device.touch)
    +        {
    +            this._onTouchStart = function (event) {
    +                return _this.onTouchStart(event);
    +            };
    +
    +            this._onTouchMove = function (event) {
    +                return _this.onTouchMove(event);
    +            };
    +
    +            this._onTouchEnd = function (event) {
    +                return _this.onTouchEnd(event);
    +            };
    +
    +            this._onTouchEnter = function (event) {
    +                return _this.onTouchEnter(event);
    +            };
    +
    +            this._onTouchLeave = function (event) {
    +                return _this.onTouchLeave(event);
    +            };
    +
    +            this._onTouchCancel = function (event) {
    +                return _this.onTouchCancel(event);
    +            };
    +
    +            this.game.renderer.view.addEventListener('touchstart', this._onTouchStart, false);
    +            this.game.renderer.view.addEventListener('touchmove', this._onTouchMove, false);
    +            this.game.renderer.view.addEventListener('touchend', this._onTouchEnd, false);
    +            this.game.renderer.view.addEventListener('touchenter', this._onTouchEnter, false);
    +            this.game.renderer.view.addEventListener('touchleave', this._onTouchLeave, false);
    +            this.game.renderer.view.addEventListener('touchcancel', this._onTouchCancel, false);
    +        }
    +
    +    },
    +
    +    /**
    +    * Consumes all touchmove events on the document (only enable this if you know you need it!).
    +    * @method Phaser.Touch#consumeTouchMove
    +    */
    +    consumeDocumentTouches: function () {
    +
    +        this._documentTouchMove = function (event) {
    +            event.preventDefault();
    +        };
    +
    +        document.addEventListener('touchmove', this._documentTouchMove, false);
    +
    +    },
    +
    +    /**
    +    * Description.
    +    * @method Phaser.Touch#onTouchStart
    +    * @param {Any} event
    +    */
    +    onTouchStart: function (event) {
    +
    +        if (this.touchStartCallback)
    +        {
    +            this.touchStartCallback.call(this.callbackContext, event);
    +        }
    +
    +        if (this.game.input.disabled || this.disabled)
    +        {
    +            return;
    +        }
    +
    +        if (this.preventDefault)
    +        {
    +            event.preventDefault();
    +        }
    +
    +        //  event.targetTouches = list of all touches on the TARGET ELEMENT (i.e. game dom element)
    +        //  event.touches = list of all touches on the ENTIRE DOCUMENT, not just the target element
    +        //  event.changedTouches = the touches that CHANGED in this event, not the total number of them
    +        for (var i = 0; i < event.changedTouches.length; i++)
    +        {
    +            this.game.input.startPointer(event.changedTouches[i]);
    +        }
    +
    +    },
    +
    +    /**
    +    * Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome).
    +    * Occurs for example on iOS when you put down 4 fingers and the app selector UI appears.
    +    * @method Phaser.Touch#onTouchCancel
    +    * @param {Any} event
    +    */
    +    onTouchCancel: function (event) {
    +
    +        if (this.touchCancelCallback)
    +        {
    +            this.touchCancelCallback.call(this.callbackContext, event);
    +        }
    +
    +        if (this.game.input.disabled || this.disabled)
    +        {
    +            return;
    +        }
    +
    +        if (this.preventDefault)
    +        {
    +            event.preventDefault();
    +        }
    +
    +        //  Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome)
    +        //  http://www.w3.org/TR/touch-events/#dfn-touchcancel
    +        for (var i = 0; i < event.changedTouches.length; i++)
    +        {
    +            this.game.input.stopPointer(event.changedTouches[i]);
    +        }
    +
    +    },
    +
    +    /**
    +    * For touch enter and leave its a list of the touch points that have entered or left the target.
    +    * Doesn't appear to be supported by most browsers on a canvas element yet.
    +    * @method Phaser.Touch#onTouchEnter
    +    * @param {Any} event
    +    */
    +    onTouchEnter: function (event) {
    +
    +        if (this.touchEnterCallback)
    +        {
    +            this.touchEnterCallback.call(this.callbackContext, event);
    +        }
    +
    +        if (this.game.input.disabled || this.disabled)
    +        {
    +            return;
    +        }
    +
    +        if (this.preventDefault)
    +        {
    +            event.preventDefault();
    +        }
    +
    +        for (var i = 0; i < event.changedTouches.length; i++)
    +        {
    +            //console.log('touch enter');
    +        }
    +
    +    },
    +
    +    /**
    +    * For touch enter and leave its a list of the touch points that have entered or left the target.
    +    * Doesn't appear to be supported by most browsers on a canvas element yet.
    +    * @method Phaser.Touch#onTouchLeave
    +    * @param {Any} event
    +    */    
    +    onTouchLeave: function (event) {
    +
    +        if (this.touchLeaveCallback)
    +        {
    +            this.touchLeaveCallback.call(this.callbackContext, event);
    +        }
    +
    +        if (this.preventDefault)
    +        {
    +            event.preventDefault();
    +        }
    +
    +        for (var i = 0; i < event.changedTouches.length; i++)
    +        {
    +            //console.log('touch leave');
    +        }
    +
    +    },
    +
    +    /**
    +    * Description.
    +    * @method Phaser.Touch#onTouchMove
    +    * @param {Any} event
    +    */
    +    onTouchMove: function (event) {
    +
    +        if (this.touchMoveCallback)
    +        {
    +            this.touchMoveCallback.call(this.callbackContext, event);
    +        }
    +
    +        if (this.preventDefault)
    +        {
    +            event.preventDefault();
    +        }
    +
    +        for (var i = 0; i < event.changedTouches.length; i++)
    +        {
    +            this.game.input.updatePointer(event.changedTouches[i]);
    +        }
    +
    +    },
    +
    +    /**
    +    * Description.
    +    * @method Phaser.Touch#onTouchEnd
    +    * @param {Any} event
    +    */
    +    onTouchEnd: function (event) {
    +
    +        if (this.touchEndCallback)
    +        {
    +            this.touchEndCallback.call(this.callbackContext, event);
    +        }
    +
    +        if (this.preventDefault)
    +        {
    +            event.preventDefault();
    +        }
    +
    +        //  For touch end its a list of the touch points that have been removed from the surface
    +        //  https://developer.mozilla.org/en-US/docs/DOM/TouchList
    +        //  event.changedTouches = the touches that CHANGED in this event, not the total number of them
    +        for (var i = 0; i < event.changedTouches.length; i++)
    +        {
    +            this.game.input.stopPointer(event.changedTouches[i]);
    +        }
    +
    +    },
    +
    +    /**
    +    * Stop the event listeners.
    +    * @method Phaser.Touch#stop
    +    */
    +    stop: function () {
    +
    +        if (this.game.device.touch)
    +        {
    +            this.game.stage.canvas.removeEventListener('touchstart', this._onTouchStart);
    +            this.game.stage.canvas.removeEventListener('touchmove', this._onTouchMove);
    +            this.game.stage.canvas.removeEventListener('touchend', this._onTouchEnd);
    +            this.game.stage.canvas.removeEventListener('touchenter', this._onTouchEnter);
    +            this.game.stage.canvas.removeEventListener('touchleave', this._onTouchLeave);
    +            this.game.stage.canvas.removeEventListener('touchcancel', this._onTouchCancel);
    +        }
    +
    +    }
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Tween.js.html b/docs/Tween.js.html new file mode 100644 index 00000000..a03cbbfd --- /dev/null +++ b/docs/Tween.js.html @@ -0,0 +1,1054 @@ + + + + + + Phaser Source: tween/Tween.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: tween/Tween.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Tween constructor
    +* Create a new <code>Tween</code>.
    +*
    +* @class Phaser.Tween
    +* @constructor
    +* @param {object} object - Target object will be affected by this tween.
    +* @param {Phaser.Game} game - Current game instance.
    +*/
    +Phaser.Tween = function (object, game) {
    +
    +    /**
    +    * Reference to the target object.
    +    * @property {object} _object
    +    * @private
    +    */
    +	this._object = object;
    +
    +    /**
    +    * @property {Phaser.Game} game - A reference to the currently running Game.
    +    */
    +    this.game = game;
    +
    +    /**
    +    * @property {object} _manager - Description.
    +    * @private
    +    */
    +    this._manager = this.game.tweens;
    +
    +    /**
    +    * @property {object} _valuesStart - Description.
    +    * @private
    +    */
    +    this._valuesStart = {};
    +
    +    /**
    +    * @property {object} _valuesEnd - Description.
    +    * @private
    +    */
    +    this._valuesEnd = {};
    +
    +    /**
    +    * @property {object} _valuesStartRepeat - Description.
    +    * @private
    +    */
    +    this._valuesStartRepeat = {};
    +
    +    /**
    +    * @property {number} _duration - Description.
    +    * @private
    +    * @default
    +    */
    +    this._duration = 1000;
    +
    +    /**
    +    * @property {number} _repeat - Description.
    +    * @private
    +    * @default
    +    */
    +    this._repeat = 0;
    +
    +    /**
    +    * @property {boolean} _yoyo - Description.
    +    * @private
    +    * @default
    +    */
    +    this._yoyo = false;
    +
    +    /**
    +    * @property {boolean} _reversed - Description.
    +    * @private
    +    * @default
    +    */
    +    this._reversed = false;
    +
    +    /**
    +    * @property {number} _delayTime - Description.
    +    * @private
    +    * @default
    +    */
    +    this._delayTime = 0;
    +
    +    /**
    +    * @property {Description} _startTime - Description.
    +    * @private
    +    * @default null
    +    */
    +    this._startTime = null;
    +
    +    /**
    +    * @property {Description} _easingFunction - Description.
    +    * @private
    +    */
    +    this._easingFunction = Phaser.Easing.Linear.None;
    +
    +    /**
    +    * @property {Description} _interpolationFunction - Description.
    +    * @private
    +    */
    +    this._interpolationFunction = Phaser.Math.linearInterpolation;
    +
    +    /**
    +    * @property {Description} _chainedTweens - Description.
    +    * @private
    +    */
    +    this._chainedTweens = [];
    +
    +    /**
    +    * @property {Description} _onStartCallback - Description.
    +    * @private
    +    * @default
    +    */
    +    this._onStartCallback = null;
    +
    +    /**
    +    * @property {boolean} _onStartCallbackFired - Description.
    +    * @private
    +    * @default
    +    */
    +    this._onStartCallbackFired = false;
    +
    +    /**
    +    * @property {Description} _onUpdateCallback - Description.
    +    * @private
    +    * @default null
    +    */
    +    this._onUpdateCallback = null;
    +
    +    /**
    +    * @property {Description} _onCompleteCallback - Description.
    +    * @private
    +    * @default null
    +    */
    +    this._onCompleteCallback = null;
    +    
    +    /**
    +    * @property {number} _pausedTime - Description.
    +    * @private
    +    * @default
    +    */
    +    this._pausedTime = 0;
    +
    +    /**
    +    * @property {boolean} pendingDelete - If this tween is ready to be deleted by the TweenManager.
    +    * @default
    +    */
    +    this.pendingDelete = false;
    +
    +    // Set all starting values present on the target object
    +    for ( var field in object ) {
    +    	this._valuesStart[ field ] = parseFloat(object[field], 10);
    +    }
    +    
    +    /**
    +    * @property {Phaser.Signal} onStart - Description.
    +    */
    +    this.onStart = new Phaser.Signal();
    +
    +    /**
    +    * @property {Phaser.Signal} onComplete - Description.
    +    */
    +    this.onComplete = new Phaser.Signal();
    +
    +    /**
    +    * @property {boolean} isRunning - Description.
    +    * @default
    +    */
    +    this.isRunning = false;
    +
    +};
    +
    +Phaser.Tween.prototype = {
    +
    +	/**
    +	* Configure the Tween
    +	*
    +	* @method Phaser.Tween#to
    +	* @param {object} properties - Properties you want to tween.
    +	* @param {number} duration - Duration of this tween.
    +	* @param {function} ease - Easing function.
    +	* @param {boolean} autoStart - Whether this tween will start automatically or not.
    +	* @param {number} delay - Delay before this tween will start, defaults to 0 (no delay).
    +	* @param {boolean} repeat - Should the tween automatically restart once complete? (ignores any chained tweens).
    +	* @param {Phaser.Tween} yoyo - Description.
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	to: function ( properties, duration, ease, autoStart, delay, repeat, yoyo ) {
    +
    +		duration = duration || 1000;
    +		ease = ease || null;
    +		autoStart = autoStart || false;
    +		delay = delay || 0;
    +		repeat = repeat || 0;
    +		yoyo = yoyo || false;
    +
    +		var self;
    +		if (this._parent)
    +		{
    +			self = this._manager.create(this._object);
    +			this._lastChild.chain(self);
    +			this._lastChild = self;
    +		}
    +		else
    +		{
    +			self = this;
    +			this._parent = this;
    +			this._lastChild = this;
    +		}
    +
    +		self._repeat = repeat;
    +        self._duration = duration;
    +		self._valuesEnd = properties;
    +
    +        if (ease !== null)
    +        {
    +            self._easingFunction = ease;
    +        }
    +
    +        if (delay > 0)
    +        {
    +            self._delayTime = delay;
    +        }
    +
    +        self._yoyo = yoyo;
    +
    +        if (autoStart) {
    +            return this.start();
    +        } else {
    +            return this;
    +        }
    +
    +	},
    +
    +	/**
    +	* Starts the tween running. Can also be called by the autoStart parameter of Tween.to.
    +	*
    +	* @method Phaser.Tween#start
    +	* @param {number} time - Description.
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	start: function ( time ) {
    +
    +        if (this.game === null || this._object === null) {
    +            return;
    +        }
    +
    +		this._manager.add(this);
    +
    +		this.onStart.dispatch(this._object);
    +
    +        this.isRunning = true;
    +
    +		this._onStartCallbackFired = false;
    +
    +        this._startTime = this.game.time.now + this._delayTime;
    +
    +		for ( var property in this._valuesEnd ) {
    +
    +			// check if an Array was provided as property value
    +			if ( this._valuesEnd[ property ] instanceof Array ) {
    +
    +				if ( this._valuesEnd[ property ].length === 0 ) {
    +
    +					continue;
    +
    +				}
    +
    +				// create a local copy of the Array with the start value at the front
    +				this._valuesEnd[ property ] = [ this._object[ property ] ].concat( this._valuesEnd[ property ] );
    +
    +			}
    +
    +			this._valuesStart[ property ] = this._object[ property ];
    +
    +			if ( ( this._valuesStart[ property ] instanceof Array ) === false ) {
    +				this._valuesStart[ property ] *= 1.0; // Ensures we're using numbers, not strings
    +			}
    +
    +			this._valuesStartRepeat[ property ] = this._valuesStart[ property ] || 0;
    +
    +		}
    +
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Stops the tween if running and removes it from the TweenManager. If there are any onComplete callbacks or events they are not dispatched.
    +	*
    +	* @method Phaser.Tween#stop
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	stop: function () {
    +
    +		this._manager.remove(this);
    +        this.isRunning = false;
    +
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Sets a delay time before this tween will start.
    +	*
    +	* @method Phaser.Tween#delay
    +	* @param {number} amount - The amount of the delay in ms.
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	delay: function ( amount ) {
    +
    +		this._delayTime = amount;
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Sets the number of times this tween will repeat.
    +	*
    +	* @method Phaser.Tween#repeat
    +	* @param {number} times - How many times to repeat.
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	repeat: function ( times ) {
    +
    +		this._repeat = times;
    +		return this;
    +
    +	},
    +
    +	/**
    +	* A tween that has yoyo set to true will run through from start to finish, then reverse from finish to start.
    +	* Used in combination with repeat you can create endless loops.
    +	*
    +	* @method Phaser.Tween#yoyo
    +	* @param {boolean} yoyo - Set to true to yoyo this tween.
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	yoyo: function( yoyo ) {
    +
    +		this._yoyo = yoyo;
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Set easing function this tween will use, i.e. Phaser.Easing.Linear.None. 
    +	*
    +	* @method Phaser.Tween#easing
    +	* @param {function} easing - The easing function this tween will use, i.e. Phaser.Easing.Linear.None.
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	easing: function ( easing ) {
    +
    +		this._easingFunction = easing;
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Set interpolation function the tween will use, by default it uses Phaser.Math.linearInterpolation.
    +	*
    +	* @method Phaser.Tween#interpolation
    +	* @param {function} interpolation - The interpolation function to use (Phaser.Math.linearInterpolation by default)
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	interpolation: function ( interpolation ) {
    +
    +		this._interpolationFunction = interpolation;
    +		return this;
    +
    +	},
    +
    +	/**
    +	* You can chain tweens together by passing a reference to the chain function. This enables one tween to call another on completion.
    +	* You can pass as many tweens as you like to this function, they will each be chained in sequence.
    +	*
    +	* @method Phaser.Tween#chain
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	chain: function () {
    +
    +		this._chainedTweens = arguments;
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Loop a chain of tweens
    +	* 
    +	* Usage:
    +	* game.add.tween(p).to({ x: 700 }, 1000, Phaser.Easing.Linear.None, true)
    +	* .to({ y: 300 }, 1000, Phaser.Easing.Linear.None)
    +	* .to({ x: 0 }, 1000, Phaser.Easing.Linear.None)
    +	* .to({ y: 0 }, 1000, Phaser.Easing.Linear.None)
    +	* .loop();
    +	* @method Phaser.Tween#loop
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	loop: function() {
    +
    +		this._lastChild.chain(this);
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Sets a callback to be fired when the tween starts. Note: callback will be called in the context of the global scope.
    +	*
    +	* @method Phaser.Tween#onStartCallback
    +	* @param {function} callback - The callback to invoke on start.
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	onStartCallback: function ( callback ) {
    +
    +		this._onStartCallback = callback;
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Sets a callback to be fired each time this tween updates. Note: callback will be called in the context of the global scope.
    +	*
    +	* @method Phaser.Tween#onUpdateCallback
    +	* @param {function} callback - The callback to invoke each time this tween is updated.
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	onUpdateCallback: function ( callback ) {
    +
    +		this._onUpdateCallback = callback;
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Sets a callback to be fired when the tween completes. Note: callback will be called in the context of the global scope.
    +	*
    +	* @method Phaser.Tween#onCompleteCallback
    +	* @param {function} callback - The callback to invoke on completion.
    +	* @return {Phaser.Tween} Itself.
    +	*/
    +	onCompleteCallback: function ( callback ) {
    +
    +		this._onCompleteCallback = callback;
    +		return this;
    +
    +	},
    +
    +	/**
    +	* Pauses the tween. 
    +	*
    +	* @method Phaser.Tween#pause
    +	*/
    +    pause: function () {
    +        this._paused = true;
    +        this._pausedTime = this.game.time.now;
    +    },
    +
    +	/**
    +	* Resumes a paused tween.
    +	*
    +	* @method Phaser.Tween#resume
    +	*/
    +    resume: function () {
    +        this._paused = false;
    +        this._startTime += (this.game.time.now - this._pausedTime);
    +    },
    +
    +	/**
    +	* Core tween update function called by the TweenManager. Does not need to be invoked directly.
    +	*
    +	* @method Phaser.Tween#update
    +	* @param {number} time - A timestamp passed in by the TweenManager.
    +	* @return {boolean} false if the tween has completed and should be deleted from the manager, otherwise true (still active).
    +	*/
    +	update: function ( time ) {
    +
    +		if (this.pendingDelete)
    +		{
    +			return false;
    +		}
    +
    +        if (this._paused || time < this._startTime) {
    +
    +            return true;
    +
    +        }
    +
    +		var property;
    +
    +		if ( time < this._startTime ) {
    +
    +			return true;
    +
    +		}
    +
    +		if ( this._onStartCallbackFired === false ) {
    +
    +			if ( this._onStartCallback !== null ) {
    +
    +				this._onStartCallback.call( this._object );
    +
    +			}
    +
    +			this._onStartCallbackFired = true;
    +
    +		}
    +
    +		var elapsed = ( time - this._startTime ) / this._duration;
    +		elapsed = elapsed > 1 ? 1 : elapsed;
    +
    +		var value = this._easingFunction( elapsed );
    +
    +		for ( property in this._valuesEnd ) {
    +
    +			var start = this._valuesStart[ property ] || 0;
    +			var end = this._valuesEnd[ property ];
    +
    +			if ( end instanceof Array ) {
    +
    +				this._object[ property ] = this._interpolationFunction( end, value );
    +
    +			} else {
    +
    +                // Parses relative end values with start as base (e.g.: +10, -3)
    +				if ( typeof(end) === "string" ) {
    +					end = start + parseFloat(end, 10);
    +				}
    +
    +				// protect against non numeric properties.
    +                if ( typeof(end) === "number" ) {
    +					this._object[ property ] = start + ( end - start ) * value;
    +				}
    +
    +			}
    +
    +		}
    +
    +		if ( this._onUpdateCallback !== null ) {
    +
    +			this._onUpdateCallback.call( this._object, value );
    +
    +		}
    +
    +		if ( elapsed == 1 ) {
    +
    +			if ( this._repeat > 0 ) {
    +
    +				if ( isFinite( this._repeat ) ) {
    +					this._repeat--;
    +				}
    +
    +				// reassign starting values, restart by making startTime = now
    +				for ( property in this._valuesStartRepeat ) {
    +
    +					if ( typeof( this._valuesEnd[ property ] ) === "string" ) {
    +						this._valuesStartRepeat[ property ] = this._valuesStartRepeat[ property ] + parseFloat(this._valuesEnd[ property ], 10);
    +					}
    +
    +					if (this._yoyo) {
    +						var tmp = this._valuesStartRepeat[ property ];
    +						this._valuesStartRepeat[ property ] = this._valuesEnd[ property ];
    +						this._valuesEnd[ property ] = tmp;
    +						this._reversed = !this._reversed;
    +					}
    +					this._valuesStart[ property ] = this._valuesStartRepeat[ property ];
    +
    +				}
    +
    +				this._startTime = time + this._delayTime;
    +
    +				this.onComplete.dispatch(this._object);
    +
    +				if ( this._onCompleteCallback !== null ) {
    +					this._onCompleteCallback.call( this._object );
    +				}
    +
    +				return true;
    +
    +			} else {
    +
    +				this.onComplete.dispatch(this._object);
    +
    +				if ( this._onCompleteCallback !== null ) {
    +					this._onCompleteCallback.call( this._object );
    +				}
    +
    +				for ( var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i ++ ) {
    +
    +					this._chainedTweens[ i ].start( time );
    +
    +				}
    +
    +				return false;
    +
    +			}
    +
    +		}
    +
    +		return true;
    +
    +	}
    +	
    +};
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/TweenManager.js.html b/docs/TweenManager.js.html new file mode 100644 index 00000000..955b7745 --- /dev/null +++ b/docs/TweenManager.js.html @@ -0,0 +1,631 @@ + + + + + + Phaser Source: tween/TweenManager.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: tween/TweenManager.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* Phaser - TweenManager
    +* 
    +* @class Phaser.TweenManager
    +* @classdesc 
    +* Phaser.Game has a single instance of the TweenManager through which all Tween objects are created and updated.
    +* Tweens are hooked into the game clock and pause system, adjusting based on the game state.
    +*
    +* TweenManager is based heavily on tween.js by http://soledadpenades.com.
    +* The difference being that tweens belong to a games instance of TweenManager, rather than to a global TWEEN object.
    +* It also has callbacks swapped for Signals and a few issues patched with regard to properties and completion errors.
    +* Please see https://github.com/sole/tween.js for a full list of contributors.
    +* @constructor
    +*
    +* @param {Phaser.Game} game - A reference to the currently running game.
    +*/
    +Phaser.TweenManager = function (game) {
    +
    +	/**
    +	* @property {Phaser.Game} game - Local reference to game.
    +	*/
    +	this.game = game;
    +	
    +	/**
    +	* @property {array} _tweens - Description.
    +	* @private
    +	*/
    +	this._tweens = [];
    +	
    +	/**
    +	* @property {array} _add - Description.
    +	* @private
    +	*/
    +	this._add = [];
    +
    +	this.game.onPause.add(this.pauseAll, this);
    +	this.game.onResume.add(this.resumeAll, this);
    +
    +};
    +
    +Phaser.TweenManager.prototype = {
    +
    +	/**
    +	* Version number of this library.
    +	* @property {string} REVISION
    +	* @default 
    +	*/	
    +	REVISION: '11dev',
    +
    +	/**
    +	* Get all the tween objects in an array.
    +	* @method Phaser.TweenManager#getAll
    +	* @returns {Phaser.Tween[]} Array with all tween objects.
    +	*/
    +	getAll: function () {
    +
    +		return this._tweens;
    +
    +	},
    +
    +	/**
    +	* Remove all tween objects.
    +	* @method Phaser.TweenManager#removeAll
    +	*/
    +	removeAll: function () {
    +
    +		this._tweens = [];
    +
    +	},
    +
    +	/**
    +	* Add a new tween into the TweenManager.
    +	*
    +	* @method Phaser.TweenManager#add
    +	* @param {Phaser.Tween} tween - The tween object you want to add.
    +	* @returns {Phaser.Tween} The tween object you added to the manager.
    +	*/
    +	add: function ( tween ) {
    +
    +		this._add.push( tween );
    +
    +	},
    +
    +	/**
    +	* Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. 
    +	*
    +	* @method Phaser.TweenManager#create
    +	* @param {Object} object - Object the tween will be run on.
    +	* @returns {Phaser.Tween} The newly created tween object.
    +	*/
    +    create: function (object) {
    +
    +        return new Phaser.Tween(object, this.game);
    +
    +    },
    +
    +	/**
    +	* Remove a tween from this manager.
    +	*
    +	* @method Phaser.TweenManager#remove
    +	* @param {Phaser.Tween} tween - The tween object you want to remove.
    +	*/
    +	remove: function ( tween ) {
    +
    +		var i = this._tweens.indexOf( tween );
    +
    +		if ( i !== -1 ) {
    +
    +			this._tweens[i].pendingDelete = true;
    +
    +		}
    +
    +	},
    +
    +	/**
    +	* Update all the tween objects you added to this manager.
    +	*
    +	* @method Phaser.TweenManager#update
    +	* @returns {boolean} Return false if there's no tween to update, otherwise return true.
    +	*/
    +	update: function () {
    +
    +		if ( this._tweens.length === 0 && this._add.length === 0 ) return false;
    +
    +		var i = 0;
    +		var numTweens = this._tweens.length;
    +
    +		while ( i < numTweens ) {
    +
    +			if ( this._tweens[ i ].update( this.game.time.now ) ) {
    +
    +				i++;
    +
    +			} else {
    +
    +				this._tweens.splice( i, 1 );
    +
    +				numTweens--;
    +
    +			}
    +
    +		}
    +
    +		//	If there are any new tweens to be added, do so now - otherwise they can be spliced out of the array before ever running
    +		if (this._add.length > 0)
    +		{
    +			this._tweens = this._tweens.concat(this._add);
    +			this._add.length = 0;
    +		}
    +
    +		return true;
    +
    +	},
    +
    +	/**
    +	* Pauses all currently running tweens.
    +	*
    +	* @method Phaser.TweenManager#update
    +	*/
    +	pauseAll: function () {
    +
    +    	for (var i = this._tweens.length - 1; i >= 0; i--) {
    +    		this._tweens[i].pause();
    +    	};
    +
    +    },
    +
    +	/**
    +	* Pauses all currently paused tweens.
    +	*
    +	* @method Phaser.TweenManager#resumeAll
    +	*/
    +   	resumeAll: function () {
    +
    +    	for (var i = this._tweens.length - 1; i >= 0; i--) {
    +    		this._tweens[i].resume();
    +    	};
    +
    +    }
    +
    +};
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/Utils.js.html b/docs/Utils.js.html new file mode 100644 index 00000000..8383ee03 --- /dev/null +++ b/docs/Utils.js.html @@ -0,0 +1,672 @@ + + + + + + Phaser Source: utils/Utils.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: utils/Utils.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* @class Phaser.Utils
    +* @static
    +*/
    +Phaser.Utils = {
    +	
    +	shuffle: function (array) {
    +
    +	    for (var i = array.length - 1; i > 0; i--)
    +	    {
    +	        var j = Math.floor(Math.random() * (i + 1));
    +	        var temp = array[i];
    +	        array[i] = array[j];
    +	        array[j] = temp;
    +	    }
    +
    +	    return array;
    +	    
    +	},
    +
    +	/**
    +	* Javascript string pad http://www.webtoolkit.info/.
    +	* pad = the string to pad it out with (defaults to a space)<br>
    +	* dir = 1 (left), 2 (right), 3 (both)
    +	* @method Phaser.Utils.pad
    +	* @param {string} str - The target string. 
    +	* @param {number} len - Description.
    +	* @param {number} pad - the string to pad it out with (defaults to a space).
    +	* @param {number} [dir=3] the direction dir = 1 (left), 2 (right), 3 (both).
    +	* @return {string}
    +	*/
    +	pad: function (str, len, pad, dir) {
    +
    +	    if (typeof(len) == "undefined") { var len = 0; }
    +	    if (typeof(pad) == "undefined") { var pad = ' '; }
    +	    if (typeof(dir) == "undefined") { var dir = 3; }
    +
    +	    if (len + 1 >= str.length)
    +	    {
    +	        switch (dir)
    +	        {
    +	            case 1:
    +	                str = Array(len + 1 - str.length).join(pad) + str;
    +		            break;
    +
    +	            case 3:
    +	                var right = Math.ceil((padlen = len - str.length) / 2);
    +	                var left = padlen - right;
    +	                str = Array(left+1).join(pad) + str + Array(right+1).join(pad);
    +		            break;
    +
    +	            default:
    +	                str = str + Array(len + 1 - str.length).join(pad);
    +		            break;
    +	        }
    +	    }
    +
    +	    return str;
    +
    +	},
    +
    +    /**
    +    * This is a slightly modified version of jQuery.isPlainObject. A plain object is an object whose internal class property is [object Object].
    +    * @method Phaser.Utils.isPlainObject
    +    * @param {object} obj - The object to inspect.
    +    * @return {boolean} - true if the object is plain, otherwise false.
    +    */
    +	isPlainObject: function (obj) {
    +
    +		// Not plain objects:
    +		// - Any object or value whose internal [[Class]] property is not "[object Object]"
    +		// - DOM nodes
    +		// - window
    +		if (typeof(obj) !== "object" || obj.nodeType || obj === obj.window)
    +		{
    +			return false;
    +		}
    +
    +		// Support: Firefox <20
    +		// The try/catch suppresses exceptions thrown when attempting to access
    +		// the "constructor" property of certain host objects, ie. |window.location|
    +		// https://bugzilla.mozilla.org/show_bug.cgi?id=814622
    +		try {
    +			if (obj.constructor && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf"))
    +			{
    +				return false;
    +			}
    +		} catch (e) {
    +			return false;
    +		}
    +
    +		// If the function hasn't returned already, we're confident that
    +		// |obj| is a plain object, created by {} or constructed with new Object
    +		return true;
    +	},
    +
    +
    +	//	deep, target, objects to copy to the target object
    +	//	This is a slightly modified version of {@link http://api.jquery.com/jQuery.extend/|jQuery.extend}
    +	//	deep (boolean)
    +	//	target (object to add to)
    +	//	objects ... (objects to recurse and copy from)
    +
    +    /**
    +    * This is a slightly modified version of http://api.jquery.com/jQuery.extend/
    +    * @method Phaser.Utils.extend
    +    * @param {boolean} deep - Perform a deep copy?
    +    * @param {object} target - The target object to copy to.
    +    * @return {object} The extended object.
    +    */
    +	extend: function () {
    +
    +		var options, name, src, copy, copyIsArray, clone,
    +			target = arguments[0] || {},
    +			i = 1,
    +			length = arguments.length,
    +			deep = false;
    +
    +		// Handle a deep copy situation
    +		if (typeof target === "boolean")
    +		{
    +			deep = target;
    +			target = arguments[1] || {};
    +			// skip the boolean and the target
    +			i = 2;
    +		}
    +
    +		// extend Phaser if only one argument is passed
    +		if (length === i)
    +		{
    +			target = this;
    +			--i;
    +		}
    +
    +		for ( ; i < length; i++ )
    +		{
    +			// Only deal with non-null/undefined values
    +			if ((options = arguments[i]) != null)
    +			{
    +				// Extend the base object
    +				for (name in options)
    +				{
    +					src = target[name];
    +					copy = options[name];
    +
    +					// Prevent never-ending loop
    +					if (target === copy)
    +					{
    +						continue;
    +					}
    +
    +					// Recurse if we're merging plain objects or arrays
    +					if (deep && copy && (Phaser.Utils.isPlainObject(copy) || (copyIsArray = Array.isArray(copy))))
    +					{
    +						if (copyIsArray)
    +						{
    +							copyIsArray = false;
    +							clone = src && Array.isArray(src) ? src : [];
    +						}
    +						else
    +						{
    +							clone = src && Phaser.Utils.isPlainObject(src) ? src : {};
    +						}
    +
    +						// Never move original objects, clone them
    +						target[name] = Phaser.Utils.extend(deep, clone, copy);
    +
    +					// Don't bring in undefined values
    +					}
    +					else if (copy !== undefined)
    +					{
    +						target[name] = copy;
    +					}
    +				}
    +			}
    +		}
    +
    +		// Return the modified object
    +		return target;
    +	}
    +
    +};
    +
    +//	Global functions that PIXI needs
    +
    + /**
    + * Converts a hex color number to an [R, G, B] array
    + *
    + * @param {number} hex 
    + * @return {array}
    + */
    +function HEXtoRGB(hex) {
    +	return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
    +}
    +
    + /**
    + * A polyfill for Function.prototype.bind
    + */
    +if (typeof Function.prototype.bind != 'function') {
    +  Function.prototype.bind = (function () {
    +    var slice = Array.prototype.slice;
    +    return function (thisArg) {
    +      var target = this, boundArgs = slice.call(arguments, 1);
    + 
    +      if (typeof target != 'function') throw new TypeError();
    + 
    +      function bound() {
    +	var args = boundArgs.concat(slice.call(arguments));
    +	target.apply(this instanceof bound ? this : thisArg, args);
    +      }
    + 
    +      bound.prototype = (function F(proto) {
    +          proto && (F.prototype = proto);
    +          if (!(this instanceof F)) return new F;          
    +	})(target.prototype);
    + 
    +      return bound;
    +    };
    +  })();
    +}
    +
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/World.js.html b/docs/World.js.html new file mode 100644 index 00000000..37669ab3 --- /dev/null +++ b/docs/World.js.html @@ -0,0 +1,705 @@ + + + + + + Phaser Source: core/World.js + + + + + + + + + + +
    + + +
    + + +
    + +
    + + + +

    Source: core/World.js

    + +
    +
    +
    /**
    +* @author       Richard Davey <rich@photonstorm.com>
    +* @copyright    2013 Photon Storm Ltd.
    +* @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
    +*/
    +
    +/**
    +* "This world is but a canvas to our imagination." - Henry David Thoreau
    +*
    +* A game has only one world. The world is an abstract place in which all game objects live. It is not bound
    +* by stage limits and can be any size. You look into the world via cameras. All game objects live within
    +* the world at world-based coordinates. By default a world is created the same size as your Stage.
    +*
    +* @class Phaser.World
    +* @constructor
    +* @param {Phaser.Game} game - Reference to the current game instance.
    +*/
    +Phaser.World = function (game) {
    +
    +    Phaser.Group.call(this, game, null, '__world', false);
    +
    +    /**
    +    * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one.
    +    */ 
    +    this.scale = new Phaser.Point(1, 1);
    +
    +    /**
    +    * The World has no fixed size, but it does have a bounds outside of which objects are no longer considered as being "in world" and you should use this to clean-up the display list and purge dead objects.
    +    * By default we set the Bounds to be from 0,0 to Game.width,Game.height. I.e. it will match the size given to the game constructor with 0,0 representing the top-left of the display.
    +    * However 0,0 is actually the center of the world, and if you rotate or scale the world all of that will happen from 0,0.
    +    * So if you want to make a game in which the world itself will rotate you should adjust the bounds so that 0,0 is the center point, i.e. set them to -1000,-1000,2000,2000 for a 2000x2000 sized world centered around 0,0.
    +	* @property {Phaser.Rectangle} bounds - Bound of this world that objects can not escape from.
    +	*/
    +	this.bounds = new Phaser.Rectangle(0, 0, game.width, game.height);
    +
    +    /**
    +	* @property {Phaser.Camera} camera - Camera instance.
    +	*/
    +	this.camera = null;
    +
    +    /**
    +	* @property {number} currentRenderOrderID - Reset each frame, keeps a count of the total number of objects updated.
    +	*/
    +	this.currentRenderOrderID = 0;
    +	
    +};
    +
    +Phaser.World.prototype = Object.create(Phaser.Group.prototype);
    +Phaser.World.prototype.constructor = Phaser.World;
    +
    +/**
    +* Initialises the game world.
    +*
    +* @method Phaser.World#boot
    +* @protected
    +*/
    +Phaser.World.prototype.boot = function () {
    +
    +    this.camera = new Phaser.Camera(this.game, 0, 0, 0, this.game.width, this.game.height);
    +
    +    this.camera.displayObject = this._container;
    +
    +    this.game.camera = this.camera;
    +
    +}
    +
    +/**
    +* This is called automatically every frame, and is where main logic happens.
    +* 
    +* @method Phaser.World#update
    +*/
    +Phaser.World.prototype.update = function () {
    +
    +	this.currentRenderOrderID = 0;
    +
    +	if (this.game.stage._stage.first._iNext)
    +	{
    +		var currentNode = this.game.stage._stage.first._iNext;
    +		
    +		do
    +		{
    +			if (currentNode['preUpdate'])
    +			{
    +				currentNode.preUpdate();
    +			}
    +
    +			if (currentNode['update'])
    +			{
    +				currentNode.update();
    +			}
    +			
    +			currentNode = currentNode._iNext;
    +		}
    +		while (currentNode != this.game.stage._stage.last._iNext)
    +	}
    +
    +}
    +
    +/**
    +* This is called automatically every frame, and is where main logic happens.
    +* @method Phaser.World#postUpdate
    +*/
    +Phaser.World.prototype.postUpdate = function () {
    +
    +    this.camera.update();
    +
    +    if (this.game.stage._stage.first._iNext)
    +    {
    +        var currentNode = this.game.stage._stage.first._iNext;
    +        
    +        do  
    +        {
    +            if (currentNode['postUpdate'])
    +            {
    +                currentNode.postUpdate();
    +            }
    +            
    +            currentNode = currentNode._iNext;
    +        }
    +        while (currentNode != this.game.stage._stage.last._iNext)
    +    }
    +
    +}
    +
    +/**
    +* Updates the size of this world. Note that this doesn't modify the world x/y coordinates, just the width and height.
    +* If you need to adjust the bounds of the world
    +* @method Phaser.World#setBounds
    +* @param {number} x - Top left most corner of the world.
    +* @param {number} y - Top left most corner of the world.
    +* @param {number} width - New width of the world.
    +* @param {number} height - New height of the world.
    +*/
    +Phaser.World.prototype.setBounds = function (x, y, width, height) {
    +
    +    this.bounds.setTo(x, y, width, height);
    +
    +    if (this.camera.bounds)
    +    {
    +        this.camera.bounds.setTo(x, y, width, height);
    +    }
    +
    +}
    +
    +/**
    +* Destroyer of worlds.
    +* @method Phaser.World#destroy
    +*/
    +Phaser.World.prototype.destroy = function () {
    +
    +    this.camera.x = 0;
    +    this.camera.y = 0;
    +
    +    this.game.input.reset(true);
    +
    +    this.removeAll();
    +
    +}
    +
    +/**
    +* @name Phaser.World#width
    +* @property {number} width - Gets or sets the current width of the game world.
    +*/
    +Object.defineProperty(Phaser.World.prototype, "width", {
    +
    +    get: function () {
    +        return this.bounds.width;
    +    },
    +
    +    set: function (value) {
    +        this.bounds.width = value;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.World#height
    +* @property {number} height - Gets or sets the current height of the game world.
    +*/
    +Object.defineProperty(Phaser.World.prototype, "height", {
    +
    +    get: function () {
    +        return this.bounds.height;
    +    },
    +
    +    set: function (value) {
    +        this.bounds.height = value;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.World#centerX
    +* @property {number} centerX - Gets the X position corresponding to the center point of the world.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.World.prototype, "centerX", {
    +
    +    get: function () {
    +        return this.bounds.halfWidth;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.World#centerY
    +* @property {number} centerY - Gets the Y position corresponding to the center point of the world.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.World.prototype, "centerY", {
    +
    +    get: function () {
    +        return this.bounds.halfHeight;
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.World#randomX
    +* @property {number} randomX - Gets a random integer which is lesser than or equal to the current width of the game world.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.World.prototype, "randomX", {
    +
    +    get: function () {
    +
    +        if (this.bounds.x < 0)
    +        {
    +            return this.game.rnd.integerInRange(this.bounds.x, (this.bounds.width - Math.abs(this.bounds.x)));
    +        }
    +        else
    +        {
    +            return this.game.rnd.integerInRange(this.bounds.x, this.bounds.width);
    +        }
    +
    +    }
    +
    +});
    +
    +/**
    +* @name Phaser.World#randomY
    +* @property {number} randomY - Gets a random integer which is lesser than or equal to the current height of the game world.
    +* @readonly
    +*/
    +Object.defineProperty(Phaser.World.prototype, "randomY", {
    +
    +    get: function () {
    +
    +        if (this.bounds.y < 0)
    +        {
    +            return this.game.rnd.integerInRange(this.bounds.y, (this.bounds.height - Math.abs(this.bounds.y)));
    +        }
    +        else
    +        {
    +            return this.game.rnd.integerInRange(this.bounds.y, this.bounds.height);
    +        }
    +
    +    }
    +
    +});
    +
    +
    +
    + + + + + +
    + +
    +
    + + + + Phaser Copyright © 2012-2013 Photon Storm Ltd. + +
    + + + Documentation generated by JSDoc 3.3.0-dev + on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the DocStrap template. + +
    +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + diff --git a/docs/build/build dev.bat b/docs/build/build dev.bat new file mode 100644 index 00000000..144602f1 --- /dev/null +++ b/docs/build/build dev.bat @@ -0,0 +1 @@ +jsdoc -c conf_dev.json \ No newline at end of file diff --git a/docs/build/build master.bat b/docs/build/build master.bat new file mode 100644 index 00000000..25b9d2c4 --- /dev/null +++ b/docs/build/build master.bat @@ -0,0 +1 @@ +jsdoc -c conf.json \ No newline at end of file diff --git a/docs/build/conf.json b/docs/build/conf.json new file mode 100644 index 00000000..4bbe4e6c --- /dev/null +++ b/docs/build/conf.json @@ -0,0 +1,57 @@ +{ + "tags": { + "allowUnknownTags": true + }, + "source": { + "include": [ + "../../src/Phaser.js", + "../../src/IntroDocs.js", + "../../src/animation/", + "../../src/core/", + "../../src/gameobjects/", + "../../src/geom/", + "../../src/input/", + "../../src/loader/", + "../../src/math/", + "../../src/net/", + "../../src/particles/", + "../../src/physics/arcade/", + "../../src/sound/", + "../../src/system/", + "../../src/time/", + "../../src/tween/", + "../../src/utils/" + ], + "exclude": [], + "includePattern": ".+\\.js(doc)?$", + "excludePattern": "(^|\\/|\\\\)_" + }, + "plugins" : ["plugins/markdown"], + "templates": { + "cleverLinks" : false, + "monospaceLinks" : false, + "default" : { + "outputSourceFiles" : true + }, + "systemName" : "Phaser", + "footer" : "", + "copyright" : "Phaser Copyright © 2012-2013 Photon Storm Ltd.", + "navType" : "vertical", + "theme" : "cerulean", + "linenums" : true, + "collapseSymbols" : false, + "inverseNav" : true + }, + "markdown" : { + "parser" : "gfm", + "hardwrap" : true + }, + "opts": { + "template": "docstrap-master/template/", + "encoding": "utf8", + "destination": "../", + "recurse": true, + "private": false, + "lenient": true + } +} \ No newline at end of file diff --git a/docs/build/conf_dev.json b/docs/build/conf_dev.json new file mode 100644 index 00000000..4bbe4e6c --- /dev/null +++ b/docs/build/conf_dev.json @@ -0,0 +1,57 @@ +{ + "tags": { + "allowUnknownTags": true + }, + "source": { + "include": [ + "../../src/Phaser.js", + "../../src/IntroDocs.js", + "../../src/animation/", + "../../src/core/", + "../../src/gameobjects/", + "../../src/geom/", + "../../src/input/", + "../../src/loader/", + "../../src/math/", + "../../src/net/", + "../../src/particles/", + "../../src/physics/arcade/", + "../../src/sound/", + "../../src/system/", + "../../src/time/", + "../../src/tween/", + "../../src/utils/" + ], + "exclude": [], + "includePattern": ".+\\.js(doc)?$", + "excludePattern": "(^|\\/|\\\\)_" + }, + "plugins" : ["plugins/markdown"], + "templates": { + "cleverLinks" : false, + "monospaceLinks" : false, + "default" : { + "outputSourceFiles" : true + }, + "systemName" : "Phaser", + "footer" : "", + "copyright" : "Phaser Copyright © 2012-2013 Photon Storm Ltd.", + "navType" : "vertical", + "theme" : "cerulean", + "linenums" : true, + "collapseSymbols" : false, + "inverseNav" : true + }, + "markdown" : { + "parser" : "gfm", + "hardwrap" : true + }, + "opts": { + "template": "docstrap-master/template/", + "encoding": "utf8", + "destination": "../", + "recurse": true, + "private": false, + "lenient": true + } +} \ No newline at end of file diff --git a/docs/build/docstrap-master/.gitignore b/docs/build/docstrap-master/.gitignore new file mode 100644 index 00000000..85fb5cfa --- /dev/null +++ b/docs/build/docstrap-master/.gitignore @@ -0,0 +1,11 @@ +node_modules* +components* +*.map +.idea* +ringojs-0.9* +dox* +testdocs* +themes* + + + diff --git a/docs/build/docstrap-master/.npmignore b/docs/build/docstrap-master/.npmignore new file mode 100644 index 00000000..c42e1be6 --- /dev/null +++ b/docs/build/docstrap-master/.npmignore @@ -0,0 +1,6 @@ +node_modules* +components* +*.map +.idea* +npm-debug.log + diff --git a/docs/build/docstrap-master/Gruntfile.js b/docs/build/docstrap-master/Gruntfile.js new file mode 100644 index 00000000..6e6ee3bd --- /dev/null +++ b/docs/build/docstrap-master/Gruntfile.js @@ -0,0 +1,364 @@ +"use strict"; +/** + * @fileOverview Gruntfile tasks. These tasks are intended to help you when modifying the template. If you are + * just using the template, don't sweat this stuff. To use these tasks, you must install grunt, if you haven't already, + * and install the dependencies. All of this requires node.js, of course. + * + * Install grunt: + * + * npm install -g grunt-cli + * + * Then in the directory where you found this file: + * + * npm install + * + * And you are all set. See the individual tasks for details. + * + * @module Gruntfile + * @requires path + * @requires lodash + * @requires http + * @requires async + * @requires fs + */ +var path = require( "path" ); +var sys = require( "lodash" ); +var http = require( "http" ); +var async = require( "async" ); +var fs = require( "fs" ); + +// this rather odd arrangement of composing tasks like this to make sure this works on both +// windows and linux correctly. We can't depend on Grunt or Node to normalize +// paths for us because we shell out to make this work. So we gather up +// our relative paths here, normalize them later and then pass them into +// the shell to be run by JSDoc3. + +/** + * The definition to run the development test files. This runs the files in `fixtures` with the + * project's `conf.json` file. + * @private + */ +var jsdocTestPages = { + src : ["./fixtures/*.js", "./README.md"], + dest : "./testdocs", + tutorials : "./fixtures/tutorials", + template : "./template", + config : "./template/jsdoc.conf.json", + options : " --lenient --verbose" +}; +/** + * The definition to run the sample files. This runs the files in `fixtures` with the + * sample's `conf.json` file. No task directly exposes this configuration. The `fixtures` task + * modifies this for each swatch it finds and then run the docs command against it. + * @private + */ +var jsdocExamplePages = { + src : ["./fixtures/*.js", "./README.md"], + dest : "./themes", + tutorials : "", + template : "./template", + config : "./fixtures/example.conf.json", + options : " --lenient --verbose --recurse" +}; + +/** + * This definition provides the project's main, published documentation. + * @private + */ +var projectDocs = { + src : ["./Gruntfile*.js", "./README.md", "./template/publish.js"], + dest : "./dox", + tutorials : "", + template : "./template", + config : "./template/jsdoc.conf.json", + options : " --lenient --verbose --recurse --private" +}; + +/** + * Normalizes all paths from a JSDoc task definition and and returns an executable string that can be passed to the shell. + * @param {object} jsdoc A JSDoc definition + * @returns {string} + */ +function jsdocCommand( jsdoc ) { + var cmd = []; + cmd.unshift( jsdoc.options ); + if ( jsdoc.tutorials.length > 0 ) { + cmd.push( "-u " + path.resolve( jsdoc.tutorials ) ); + } + cmd.push( "-d " + path.resolve( jsdoc.dest ) ); + cmd.push( "-t " + path.resolve( jsdoc.template ) ); + cmd.push( "-c " + path.resolve( jsdoc.config ) ); + sys.each( jsdoc.src, function ( src ) { + cmd.push( path.resolve( src ) ); + } ); + cmd.unshift( path.resolve( "./node_modules/jsdoc/jsdoc" ) ); + return cmd.join( " " ); +} + +var tasks = { + shell : { + options : { + stdout : true, + stderr : true + }, + /** + * TASK: Create the a documentation set for testing changes to the template + * @name shell:testdocs + * @memberOf module:Gruntfile + */ + testdocs : { + command : jsdocCommand( jsdocTestPages ) + }, + /** + * TASK: Create project documentation + * @name shell:dox + * @memberOf module:Gruntfile + */ + dox : { + command : jsdocCommand( projectDocs ) + } + }, + /** + * TASK: The less task creates the themed css file from main.less. The file is written to the template styles + * directory as site.[name of theme].css. Later the .conf file will look for the theme to apply based + * on this naming convention. + * @name less + * @memberOf module:Gruntfile + */ + less : { + dev : { + files : { + "template/static/styles/site.<%= jsdocConf.templates.theme %>.css" : "styles/main.less" + } + } + }, + copy : { + docs : { + files : [ + {expand : true, cwd : "dox/", src : ['**'], dest : '../docstrap-dox/'}, + {expand : true, cwd : "themes/", src : ['**'], dest : '../docstrap-dox/themes'} + ] + } + } +}; + +module.exports = function ( grunt ) { + tasks.jsdocConf = grunt.file.readJSON( 'template/jsdoc.conf.json' ); + grunt.initConfig( tasks ); + + grunt.loadNpmTasks( 'grunt-contrib-less' ); + grunt.loadNpmTasks( 'grunt-shell' ); + grunt.loadNpmTasks( 'grunt-contrib-copy' ); + + grunt.registerTask( "default", ["docs"] ); + + /** + * Builds the project's documentation + * @name docs + * @memberof module:Gruntfile + */ + grunt.registerTask( "docs", "Create the project documentation", ["shell:dox"] ); + /** + * Compile the CSS and create the project documentation + * @name dev + * @memberof module:Gruntfile + */ + grunt.registerTask( "dev", "Compile the CSS and create the project documentation", ["less","shell:dox"] ); + /** + * TASK: Builds the main less file and then generates the test documents + * @name testdocs + * @memberof module:Gruntfile + */ + grunt.registerTask( "testdocs", "Builds the main less file and then generates the test documents", ["less:dev", "shell:testdocs"] ); + /** + * TASK: Builds the whole shebang. Which means creating testdocs, the bootswatch fixtures and then resetting the + * styles directory. + * @name build + * @memberof module:Gruntfile + */ + grunt.registerTask( "build", "Builds the whole shebang. Which means creating testdocs, the bootswatch samples and then resetting the styles directory", ["testdocs", "shell:dox", "bootswatch", "examples", "apply", "copy"] ); + /** + * TASK: Applies the theme in the conf file and applies it to the styles directory. + * @name apply + * @memberof module:Gruntfile + */ + grunt.registerTask( "apply", "Applies the theme in the conf file and applies it to the styles directory", function () { + var def = { + less : "http://bootswatch.com/" + tasks.jsdocConf.templates.theme + "/bootswatch.less", + lessVariables : "http://bootswatch.com/" + tasks.jsdocConf.templates.theme + "/variables.less" + }; + grunt.registerTask( "swatch-apply", sys.partial( applyTheme, grunt, def ) ); + grunt.task.run( ["swatch-apply"] ); + } ); + /** + * TASK: Grab all Bootswatch themes and create css from each one based on the main.less in the styles directory. NOTE that this will + * leave the last swatch downloaded in the styles directory, you will want to call "apply" afterwards + * @name bootswatch + * @memberof module:Gruntfile + */ + grunt.registerTask( "bootswatch", "Grab all Bootswatch themes and create css from each one based on the main.less in the styles directory", function () { + var toRun = []; + + var done = this.async(); + getBootSwatchList( function ( err, list ) { + if ( err ) {return done( err );} + + sys.each( list.themes, function ( entry ) { + + toRun.push( "swatch" + entry.name ); + grunt.registerTask( "swatch" + entry.name, sys.partial( applyTheme, grunt, entry ) ); + + var key = "template/static/styles/site." + entry.name.toLowerCase() + ".css"; + var def = {}; + def[key] = "styles/main.less"; + tasks.less["swatch" + entry.name] = { + files : def + }; + toRun.push( "less:swatch" + entry.name ); + } ); + grunt.task.run( toRun ); + done(); + } ); + + } ); + /** + * TASK:Create fixtures from the themes. The files must have been built first from the bootswatch task. + * @name examples + * @memberof module:Gruntfile + */ + grunt.registerTask( "examples", "Create samples from the themes", function () { + var toRun = []; + var done = this.async(); + getBootSwatchList( function ( err, list ) { + if ( err ) {return done( err );} + + sys.each( list.themes, function ( entry ) { + var conf = grunt.file.readJSON( './fixtures/example.conf.json' ); + conf.templates.theme = entry.name.toLowerCase(); + grunt.file.write( "tmp/example.conf." + conf.templates.theme + ".json", JSON.stringify( conf, null, 4 ) ); + + var jsdenv = sys.cloneDeep( jsdocExamplePages ); + jsdenv.config = "./tmp/example.conf." + conf.templates.theme + ".json"; + jsdenv.dest = "./themes/" + conf.templates.theme; + tasks.shell["example" + conf.templates.theme] = { + command : jsdocCommand( jsdenv ) + }; + toRun.push( "shell:example" + conf.templates.theme ); + } ); + + grunt.registerTask( "cleanup", "", function () { + grunt.file["delete"]( "tmp/" ); + } ); + toRun.push( "cleanup" ); + grunt.task.run( toRun ); + done(); + } ); + + } ); +}; + +/** + * Applies one of the Bootswatch themes to the working `styles` directory. When you want to modify a particular theme, this where you + * get the basis for it. The files are written to `./styles/variables.less` and `./styles/bootswatch.less`. The `./styles/main.less` + * file includes them directly, so after you apply the theme, modify `main.less` to your heart's content and then run the `less` task + * as in + * + * grunt less + * + * @param {object} grunt The grunt object reference + * @param {object} definition The swatch definition files + * @param {string} definition.less The url to the `bootswatch.less` file + * @param {string} definition.lessVariables The url to the `variables.less` file + * @private + */ +function applyTheme( grunt, definition ) { + //noinspection JSHint + var done = this.async(); + async.waterfall( [ + function ( cb ) { + getBootSwatchComponent( definition.less, function ( err, swatch ) { + if ( err ) {return cb( err );} + var fullPath = path.join( __dirname, "styles/bootswatch.less" ); + fs.writeFile( fullPath, swatch.replace("http://", "//"), cb ); + } ); + }, + function ( cb ) { + getBootSwatchComponent( definition.lessVariables, function ( err, swatch ) { + if ( err ) {return cb( err );} + var fullPath = path.join( __dirname, "styles/variables.less" ); + fs.writeFile( fullPath, swatch.replace("http://", "//"), cb ); + } ); + } + ], done ); +} + +/** + * Gets the list of available Bootswatches from, well, Bootswatch. + * + * @see http://news.bootswatch.com/post/22193315172/bootswatch-api + * @param {function(err, responseBody)} done The callback when complete + * @param {?object} done.err If an error occurred, you will find it here. + * @param {object} done.responseBody This is a parsed edition of the bootswatch server's response. It's format it defined + * by the return message from [here](http://api.bootswatch.com/) + * @private + */ +function getBootSwatchList( done ) { + var options = { + hostname : 'api.bootswatch.com', + port : 80, + path : '/', + method : 'GET' + }; + var body = ""; + var req = http.request( options, function ( res ) { + res.setEncoding( 'utf8' ); + res.on( 'data', function ( chunk ) { + body += chunk; + } ); + + res.on( 'end', function () { + done( null, JSON.parse( body ) ); + } ); + res.on( 'error', function ( e ) { + done( 'problem with response: ' + e.message ); + } ); + } ); + + req.on( 'error', function ( e ) { + done( 'problem with request: ' + e.message ); + } ); + req.end(); +} + +/** + * This method will get one of the components from Bootswatch, which is generally a `less` file or a `lessVariables` file. + * + * @see http://news.bootswatch.com/post/22193315172/bootswatch-api + * @param {string} url The url to retreive from + * @param {function(err, responseText)} done The callback when complete + * @param {?object} done.err If an error occurred, you will find it here. + * @param {string} done.responseText The body of whatever was returned + * @private + */ +function getBootSwatchComponent( url, done ) { + var body = ""; + var req = http.request( url, function ( res ) { + res.setEncoding( 'utf8' ); + res.on( 'data', function ( chunk ) { + body += chunk; + } ); + + res.on( 'end', function () { + done( null, body ); + } ); + res.on( 'error', function ( e ) { + done( 'problem with response: ' + e.message ); + } ); + } ); + + req.on( 'error', function ( e ) { + done( 'problem with request: ' + e.message ); + } ); + req.end(); +} + diff --git a/docs/build/docstrap-master/LICENSE.md b/docs/build/docstrap-master/LICENSE.md new file mode 100644 index 00000000..f3cc7238 --- /dev/null +++ b/docs/build/docstrap-master/LICENSE.md @@ -0,0 +1,22 @@ +Copyright (c) 2012-13 Terry Weiss. All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/docs/build/docstrap-master/README.md b/docs/build/docstrap-master/README.md new file mode 100644 index 00000000..d47d0974 --- /dev/null +++ b/docs/build/docstrap-master/README.md @@ -0,0 +1,200 @@ +# DocStrap # + +DocStrap is [Bootstrap](http://twitter.github.io/bootstrap/index.html) based template for [JSDoc3](http://usejsdoc.org/). +In addition, it includes all of the themes from [Bootswatch](http://bootswatch.com/) giving you a great deal of look +and feel options for your documentation. Additionally, it adds some options to the conf.json file that gives +you even more flexibility to tweak the template to your needs. It will also make your teeth whiter. + +## Features ## +* Fixed navigation at page top +* Right side TOC for navigation in pages +* Themed +* Customizable + +### What It Looks Like ### +Here are examples of this template with the different Bootswatch themes: + ++ [Amelia](http://terryweiss.github.io/docstrap/themes/amelia) ++ [Cerulean](http://terryweiss.github.io/docstrap/themes/cerulean) ++ [Cosmo](http://terryweiss.github.io/docstrap/themes/cosmo) ++ [Cyborg](http://terryweiss.github.io/docstrap/themes/cyborg) ++ [Flatly](http://terryweiss.github.io/docstrap/themes/flatly) ++ [Journal](http://terryweiss.github.io/docstrap/themes/journal) ++ [Readable](http://terryweiss.github.io/docstrap/themes/readable) ++ [Simplex](http://terryweiss.github.io/docstrap/themes/simplex) ++ [Slate](http://terryweiss.github.io/docstrap/themes/slate) ++ [Spacelab](http://terryweiss.github.io/docstrap/themes/spacelab) ++ [Spruce](http://terryweiss.github.io/docstrap/themes/spruce) ++ [Superhero](http://terryweiss.github.io/docstrap/themes/superhero) ++ [United](http://terryweiss.github.io/docstrap/themes/united) + +To change your theme, just change it in the `conf.json` file. See below for details. +## Ooooh, I want it! How do I get it?## +First grab the [zip file from github.](https://github.com/terryweiss/docstrap/archive/master.zip) Unzip it +to your favorite hard drive and ask JSDoc to use it. Like so: + + /jsoc mysourcefiles/* -t /template -c /conf.json -d / + +Also take a gander at [JSDoc's command line options](http://usejsdoc.org/about-commandline.html). + +## Configuring the template ## + +DocStrap ships with a `conf.json` file in the template/ directory. It is just a regular old +[JSDoc configuration file](http://usejsdoc.org/about-configuring-jsdoc.html), but with the following new options: +``` +"templates": { + "systemName" : "{string}", + "footer" : "{string}", + "copyright" : "{string}", + "navType" : "{vertical|inline}", + "theme" : "{theme}", + "linenums" : {boolean}, + "collapseSymbols" : {boolean}, + "inverseNav" : {boolean} +} +``` +### Options ### + +* __systemName__ + The name of the system being documented. This will appear in the page title for each page +* __footer__ + Any markup want to appear in the footer of each page. This is not processed at all, just printed exactly as you enter it +* __copyright__ + You can add a copyright message below the _footer_ and above the JSDoc timestamp at the bottom of the page +* __navType__ + The template uses top level navigation with dropdowns for the contents of each category. On large systems these dropdowns + can get large enough to expand beyond the page. To make the dropdowns render wider and stack the entries vertically, set this + option to `"inline"`. Otherwise set it to `"vertical"` to make them regular stacked dropdowns. +* __theme__ + This is the name of the them you want to use **in all lowercase**. The valid options are + + `amelia` + + `cerulean` + + `cosmo` + + `cyborg` + + `flatly` + + `journal` + + `readable` + + `simplex` + + `slate` + + `spacelab` + + `spruce` + + `superhero` + + `united` +* __linenums__ + When true, line numbers will appear in the source code listing. If you have + [also turned that on](http://usejsdoc.org/about-configuring-jsdoc.html). +* __collapseSymbols__ + If your pages have a large number of symbols, it can be easy to get lost in all the text. If you turn this to `true` + all of the symbols in the page will roll their contents up so that you just get a list of symbols that can be expanded + and collapsed. +* __inverseNav__ + Bootstrap navbars come in two flavors, regular and inverse where inverse is generally higher contrast. Set this to `true` to + use the inverse header. + +## Customizing DocStrap ## +No template can meet every need and customizing templates is a favorite pastime of....well, no-one, but you may need to anyway. +First make sure you have [bower](https://github.com/bower/bower) and [grunt-cli](https://github.com/gruntjs/grunt-cli) installed. +Fetch the source using `git` or grab the [zip file from github.](https://github.com/terryweiss/docstrap/archive/master.zip) and unzip +it somewhere. Everything that follows happens in the unzip directory. + +Next, prepare the environment: + + bower install + +and + + grunt install + +When that is done, you have all of the tools to start modifying the template. The template, like Bootstrap, used [less](http://lesscss.org/). +The way it works is that `./styles/main.less` pulls in the bootstrap files uncompiled so that you have access to all of bootstraps mixins, colors, +etc, that you would want. There are two more files in that directory, `variables.less`, `bootswatch.less`. These are the +theme files and you can modify them, but keep in mind that if you apply a new theme (see below) those files will be overwritten. It is best +to keep your changes to the `main.less` file. + +To compile your changes to `main.less` and any other files it loads up, + + grunt less + +The output is will be put in `./template/static/styles/site..css`. The next time you create your documentation, it +will have the new css file included. + +To apply a different template to the `styles` directory to modify, open up the `conf.json` in the template directory and +change the `theme` option to the theme you want. Then + + grunt apply + +And the new theme will be in `variables.less`, `bootswatch.less`. Don't forget to compile your changes using `grunt apply` to +get that change into the template. + +**NOTE** that these steps are not necessary to just change the theme, this is only to modify the theme. If all you want to do is +change the theme, just update conf.json with the new theme and build your docs! + +## Contributing ## +Yes! Contribute! Test! Share your ideas! Report Bugs! + +## Roadmap ## + +* Integrate Darkstrap +* Make plain old bootstrap an option (doh!) +* ~~Jump to source line numbers~~ +* Document publish.js + + +## History ## + +### v0.2.0 ### + +* Added jump to source linenumers - still a problem scrolling with fixed header +* changed syntax highlighter to [sunlight](http://sunlightjs.com/) +* Modify incoming bootswatch files to make font calls without protocol. + +### v0.1.0 ### +Initial release + + +## Notices ## +If you like DocStrap, be sure and check out these excellent projects and support them! + +[JSDoc3 is licensed under the Apache License](https://github.com/jsdoc3/jsdoc/blob/master/LICENSE.md) + +[So is Bootstrap](https://github.com/twitter/bootstrap/blob/master/LICENSE) + +[And Bootswatch](https://github.com/thomaspark/bootswatch/blob/gh-pages/LICENSE) + +[TOC is licensed under MIT](https://github.com/jgallen23/toc/blob/master/LICENSE) + +[Grunt is also MIT](https://github.com/gruntjs/grunt-cli/blob/master/LICENSE-MIT) + +DocStrap [is licensed under the MIT license.](https://github.com/terryweiss/docstrap/blob/master/LICENSE.md) + +[Sunlight uses the WTFPL](http://sunlightjs.com/) + +## License ## +DocStrap Copyright (c) 2012-2013Terry Weiss. All rights reserved. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + + + + + + diff --git a/docs/build/docstrap-master/bower.json b/docs/build/docstrap-master/bower.json new file mode 100644 index 00000000..316e2488 --- /dev/null +++ b/docs/build/docstrap-master/bower.json @@ -0,0 +1,12 @@ +{ + "name": "ink-docstrap", + "version": "0.1.0", + "dependencies": { + "bootstrap": "~2.3.1", + "jquery": "~2.0.0", + "darkstrap": "git://github.com/danneu/darkstrap.git#~0.9.2", + "toc": "~0.1.2", + "sunlight": "https://github.com/tmont/sunlight.git", + "jquery.localScroll": "~1.2.8" + } +} diff --git a/docs/build/docstrap-master/component.json b/docs/build/docstrap-master/component.json new file mode 100644 index 00000000..6abff80a --- /dev/null +++ b/docs/build/docstrap-master/component.json @@ -0,0 +1,10 @@ +{ + "name": "ink-docstrap", + "version": "0.1.0", + "dependencies": { + "bootstrap": "~2.3.1", + "jquery": "~2.0.0", + "darkstrap": "git://github.com/danneu/darkstrap.git#~0.9.2", + "toc": "~0.1.2" + } +} diff --git a/docs/build/docstrap-master/fixtures/car.js b/docs/build/docstrap-master/fixtures/car.js new file mode 100644 index 00000000..f07c8878 --- /dev/null +++ b/docs/build/docstrap-master/fixtures/car.js @@ -0,0 +1,45 @@ +"use strict" +/** + @fileOverview Donec sed sapien enim. Duis elementum arcu id velit mattis sed tincidunt dolor posuere. Cras dapibus varius metus et sollicitudin. Quisque egestas placerat lacus, at lobortis mauris volutpat in. Morbi eleifend, sapien ut lobortis malesuada, nulla arcu blandit risus, quis fringilla nunc leo ac turpis. Donec vitae gravida dolor. Pellentesque accumsan, erat ac rutrum sodales, neque odio pellentesque est, vitae rutrum lorem mauris vitae justo. Sed blandit egestas mi at fringilla. Morbi at metus feugiat magna tempor vulputate. Duis dictum sagittis neque quis tempor. Morbi id est ac orci dictum porta. Phasellus tempus adipiscing convallis. + @module docstrap/car + @author Gloria Swanson + @requires lodash + */ + + +/** + * Integer quis ante ut nulla cursus vehicula id eu dolor. Phasellus ut facilisis felis. Praesent eget metus id massa pretium lobortis a et metus. Aliquam erat volutpat. Nulla ac tortor odio, quis facilisis augue. In hendrerit, lectus mollis elementum vestibulum, velit nisi aliquet orci, vitae luctus risus dui sed nisi. Donec aliquam pretium leo sed ultrices. Duis porttitor pharetra vulputate. Aenean sed neque sit amet arcu auctor placerat eget ac tellus. Proin porttitor fringilla eros quis scelerisque. Aliquam erat volutpat. + * @constructor + * @param {Boolean} hybrid Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. + * @example + * // Duis elementum arcu id velit mattis sed tincidunt dolor posuere. + * if (!(key in this.visited)) { + this.visited[key] = true; + + if (this.dependencies[key]) { + Object.keys(this.dependencies[key]).forEach(function(path) { + self.visit(path); + }); + } + + this.sorted.push(key); + } + */ +exports.Car = function (hybrid) { + + /** + * Aenean commodo lorem nec sapien suscipit quis hendrerit dui feugiat. Curabitur pretium congue sollicitudin. Nam eleifend ultricies libero vel iaculis. Maecenas vel elit vel lorem lacinia pellentesque. Vestibulum posuere suscipit lacus, sit amet volutpat erat sagittis vitae. Ut eleifend pretium nulla vitae tempor. + * @type {string} + */ + this.color = null; + +}; + + +/** + * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi congue viverra placerat. Mauris mi nibh, pulvinar ut placerat sit amet, aliquam a diam. Maecenas vitae suscipit nulla. Sed at justo nec ante lobortis fermentum. Quisque sodales libero suscipit mi malesuada pretium. Cras a lectus vitae risus semper sagittis. Sed ultrices aliquet tempus. Nulla id nisi metus, sit amet elementum tortor. Nunc tempor sem quis augue tempor sed posuere nulla volutpat. Phasellus fringilla pulvinar lorem quis venenatis. + * @param {integer} speed Phasellus ut facilisis felis. + */ +exports.Car.prototype.drive = function ( speed ) { + +}; diff --git a/docs/build/docstrap-master/fixtures/example.conf.json b/docs/build/docstrap-master/fixtures/example.conf.json new file mode 100644 index 00000000..ed5b736f --- /dev/null +++ b/docs/build/docstrap-master/fixtures/example.conf.json @@ -0,0 +1,22 @@ +{ + "tags": { + "allowUnknownTags": true + }, + "plugins": ["plugins/markdown"], + "templates": { + "cleverLinks": false, + "monospaceLinks": false, + "default": { + "outputSourceFiles": true + }, + "systemName": "DocStrap", + "footer": "", + "copyright": "Copyright © 2012-2103 Terry Weiss, Eery Wrists. All rights reserved.", + "navType": "vertical", + "theme": "cerulean" + } , + "markdown": { + "parser": "gfm", + "hardwrap": true + } +} diff --git a/docs/build/docstrap-master/fixtures/other.js b/docs/build/docstrap-master/fixtures/other.js new file mode 100644 index 00000000..a37b0175 --- /dev/null +++ b/docs/build/docstrap-master/fixtures/other.js @@ -0,0 +1,50 @@ +/** + * Suspendisse orci massa, hendrerit sagittis lacinia consectetur, sagittis vitae purus. Aliquam id eros diam, eget elementum turpis. Nullam tellus magna, mollis in molestie id, venenatis rhoncus est. Proin id diam justo. Nunc tempus gravida justo at lobortis. Nam vitae venenatis nisi. Donec vel odio massa. Quisque interdum metus sit amet est iaculis tincidunt. Donec bibendum blandit purus, id semper orci aliquam quis. Nam tincidunt dolor eu felis ultricies tempor. Nulla non consectetur erat. + */ +function drift() { + +} + +/** + * Suspendisse orci massa, hendrerit sagittis lacinia consectetur, sagittis vitae purus. Aliquam id eros diam, eget elementum turpis. Nullam tellus magna, mollis in molestie id, venenatis rhoncus est. Proin id diam justo. Nunc tempus gravida justo at lobortis. Nam vitae venenatis nisi. Donec vel odio massa. Quisque interdum metus sit amet est iaculis tincidunt. Donec bibendum blandit purus, id semper orci aliquam quis. Nam tincidunt dolor eu felis ultricies tempor. Nulla non consectetur erat. + */ +function trailBrake() { + +} + +/** + * Suspendisse orci massa, hendrerit sagittis lacinia consectetur, sagittis vitae purus. Aliquam id eros diam, eget elementum turpis. Nullam tellus magna, mollis in molestie id, venenatis rhoncus est. Proin id diam justo. Nunc tempus gravida justo at lobortis. Nam vitae venenatis nisi. Donec vel odio massa. Quisque interdum metus sit amet est iaculis tincidunt. Donec bibendum blandit purus, id semper orci aliquam quis. Nam tincidunt dolor eu felis ultricies tempor. Nulla non consectetur erat. + * @param {integer} bias Nulla ultricies justo ac nisi consectetur posuere. Donec ornare pharetra erat, nec facilisis dui cursus quis. Quisque porttitor porttitor orci, sed facilisis urna facilisis sed. Sed tincidunt adipiscing turpis et hendrerit. Cras posuere orci ut mauris ullamcorper vitae laoreet nisi luctus. In rutrum tristique augue. Nam eleifend dignissim dui. + */ +function brakeBias( bias ) { + +} + +/** + * Suspendisse orci massa, hendrerit sagittis lacinia consectetur, sagittis vitae purus. Aliquam id eros diam, eget elementum turpis. Nullam tellus magna, mollis in molestie id, venenatis rhoncus est. Proin id diam justo. Nunc tempus gravida justo at lobortis. Nam vitae venenatis nisi. Donec vel odio massa. Quisque interdum metus sit amet est iaculis tincidunt. Donec bibendum blandit purus, id semper orci aliquam quis. Nam tincidunt dolor eu felis ultricies tempor. Nulla non consectetur erat. + * @param {module:docstrap/car.Car} car Nulla ultricies justo ac nisi consectetur posuere. Donec ornare pharetra erat, nec facilisis dui cursus quis. Quisque porttitor porttitor orci, sed facilisis urna facilisis sed. Sed tincidunt adipiscing turpis et hendrerit. Cras posuere orci ut mauris ullamcorper vitae laoreet nisi luctus. In rutrum tristique augue. Nam eleifend dignissim dui. + * @param {string} tires Donec viverra egestas tellus non viverra. Aenean est ante, egestas sed scelerisque quis, aliquet sed lacus. Praesent non mauris neque, et adipiscing ante. Vestibulum quis quam vitae ipsum aliquet blandit. Vivamus condimentum euismod orci, in tincidunt justo rutrum faucibus. Phasellus nec lorem arcu. Donec tortor dui, facilisis in rutrum sit amet, pulvinar vitae lacus. + * @param {number} fuel Proin sodales, mi at tincidunt ornare, mi dui sagittis velit, sed dictum risus orci eu erat. Sed nunc leo, congue sed rutrum eget, lobortis ac lectus. Etiam non arcu nulla. + */ +function start( car, tires, fuel ) {} + +/** + * Sed id tristique lorem. Ut sodales turpis nec mauris gravida interdum. Cras pellentesque, purus at suscipit euismod, elit nunc cursus nisi, ut venenatis metus sapien id velit. Sed lectus orci, pharetra non pulvinar vel, ullamcorper id lorem. Donec vulputate tincidunt ipsum, ut lacinia tortor sollicitudin id. Nunc nec nibh ut felis venenatis egestas. Proin risus mauris, eleifend eget interdum in, venenatis sed velit. Praesent sodales elit ut odio viverra posuere. Donec sapien lorem, molestie in egestas eget, vulputate sed orci. Aenean elit sapien, pellentesque vitae tempor sit amet, sagittis et ligula. Mauris aliquam sapien sit amet lacus ultrices rutrum. Curabitur nec dolor sed elit varius dignissim a a lacus. Aliquam ac convallis enim. + * @namespace + */ +var teams = {}; + +/** + * Nunc faucibus lacus eget odio ultricies nec ullamcorper risus pharetra. + * @mixin + */ +var insanity = { + /** + * ras ac justo dui, at faucibus urna. Nunc tristique, velit id feugiat fermentum, dolor enim egestas erat, at vestibulum ante ipsum vel orci. Duis quis ante id justo vehicula eleifend sed et urna. Sed sapien tortor, rutrum id ultrices eu, tincidunt tincidunt mi + */ + goCrazy : function () {}, + /** + * Donec viverra egestas tellus non viverra. Aenean est ante, egestas sed scelerisque quis, aliquet sed lacus. Praesent non mauris neque, et adipiscing ante. Vestibulum quis quam vitae ipsum aliquet blandit. + */ + goSane : function () {} +}; diff --git a/docs/build/docstrap-master/fixtures/person.js b/docs/build/docstrap-master/fixtures/person.js new file mode 100644 index 00000000..ea573a69 --- /dev/null +++ b/docs/build/docstrap-master/fixtures/person.js @@ -0,0 +1,74 @@ +"use strict" +/** + @fileOverview Donec sed sapien enim. Duis elementum arcu id velit mattis sed tincidunt dolor posuere. Cras dapibus varius metus et sollicitudin. Quisque egestas placerat lacus, at lobortis mauris volutpat in. Morbi eleifend, sapien ut lobortis malesuada, nulla arcu blandit risus, quis fringilla nunc leo ac turpis. Donec vitae gravida dolor. Pellentesque accumsan, erat ac rutrum sodales, neque odio pellentesque est, vitae rutrum lorem mauris vitae justo. Sed blandit egestas mi at fringilla. Morbi at metus feugiat magna tempor vulputate. Duis dictum sagittis neque quis tempor. Morbi id est ac orci dictum porta. Phasellus tempus adipiscing convallis. + @module docstrap/person + @author Fred Flinstone + @requires lodash + @requires docstrap/person + */ + +/** + * Integer quis ante ut nulla cursus vehicula id eu dolor. Phasellus ut facilisis felis. Praesent eget metus id massa pretium lobortis a et metus. Aliquam erat volutpat. Nulla ac tortor odio, quis facilisis augue. In hendrerit, lectus mollis elementum vestibulum, velit nisi aliquet orci, vitae luctus risus dui sed nisi. Donec aliquam pretium leo sed ultrices. Duis porttitor pharetra vulputate. Aenean sed neque sit amet arcu auctor placerat eget ac tellus. Proin porttitor fringilla eros quis scelerisque. Aliquam erat volutpat. + * @constructor + */ +exports.Person = function () { + + /** + * Aenean commodo lorem nec sapien suscipit quis hendrerit dui feugiat. Curabitur pretium congue sollicitudin. Nam eleifend ultricies libero vel iaculis. Maecenas vel elit vel lorem lacinia pellentesque. Vestibulum posuere suscipit lacus, sit amet volutpat erat sagittis vitae. Ut eleifend pretium nulla vitae tempor. + * @type {number} + */ + this.eyes = 2; + /** + * Donec tempus vestibulum nunc. Fusce at eleifend nisi. Proin nisl odio, ultrices fermentum eleifend nec, pellentesque in massa. Cras id turpis diam, vitae fringilla turpis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam tempus urna in lacus semper sodales. Etiam a erat in augue rhoncus porta. Aenean nec odio lorem, a tristique dui. + * @type {number} + */ + this.nose = 1; + /** + * Vestibulum viverra magna nec lectus imperdiet in lacinia ante iaculis. Cras nec urna tellus, eget convallis mauris. Fusce volutpat elementum enim, vel fringilla orci elementum vehicula. Nunc in ultrices sem. Sed augue tortor, pellentesque sed suscipit sed, vehicula eu enim. + * @type {number} + */ + this.mouth = 1; +}; + +/** + * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi congue viverra placerat. Mauris mi nibh, pulvinar ut placerat sit amet, aliquam a diam. Maecenas vitae suscipit nulla. Sed at justo nec ante lobortis fermentum. Quisque sodales libero suscipit mi malesuada pretium. Cras a lectus vitae risus semper sagittis. Sed ultrices aliquet tempus. Nulla id nisi metus, sit amet elementum tortor. Nunc tempor sem quis augue tempor sed posuere nulla volutpat. Phasellus fringilla pulvinar lorem quis venenatis. + * @param {boolean} speed Phasellus ut facilisis felis. + */ +exports.Person.prototype.walk = function ( speed ) { + +}; + +/** + * Aliquam interdum lectus ac diam tincidunt vitae fringilla justo faucibus. + * @param {Boolean} well Morbi sit amet tellus at justo tempus tristique. + * @param {function(err)} done Curabitur id nulla mauris, id hendrerit magna. + * @param {object=} done.err Sed pulvinar mollis arcu, at tempus dui egestas cursus. + */ +exports.Person.prototype.think = function ( well, done ) { + +}; + +/** + * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi congue viverra placerat. Mauris mi nibh, pulvinar ut placerat sit amet, aliquam a diam. Maecenas vitae suscipit nulla. Sed at justo nec ante lobortis fermentum. Quisque sodales libero suscipit mi malesuada pretium. Cras a lectus vitae risus semper sagittis. Sed ultrices aliquet tempus. Nulla id nisi metus, sit amet elementum tortor. Nunc tempor sem quis augue tempor sed posuere nulla volutpat. Phasellus fringilla pulvinar lorem quis venenatis. + * @returns {boolean} Sed id erat ut ipsum scelerisque venenatis at nec mauris. + * @fires module:docstrap/person.Person#sneeze + */ +exports.Person.prototype.tickle = function () { + +}; + +/** + * Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit. + * + * @event module:docstrap/person.Person#sneeze + * @type {object} + * @property {boolean} tissue Phasellus non justo a neque pharetra sagittis. + */ + +/** + * Nulla ultricies justo ac nisi consectetur posuere. Donec ornare pharetra erat, nec facilisis dui cursus quis. Quisque porttitor porttitor orci, sed facilisis urna facilisis sed. Sed tincidunt adipiscing turpis et hendrerit. Cras posuere orci ut mauris ullamcorper vitae laoreet nisi luctus. In rutrum tristique augue. Nam eleifend dignissim dui. + * @returns {exports.Person} + */ +exports.create = function(){ + +}; diff --git a/docs/build/docstrap-master/fixtures/tutorials/Brush Teeth.md b/docs/build/docstrap-master/fixtures/tutorials/Brush Teeth.md new file mode 100644 index 00000000..1ff4c061 --- /dev/null +++ b/docs/build/docstrap-master/fixtures/tutorials/Brush Teeth.md @@ -0,0 +1,21 @@ +#Lorem ipsum dolor sit amet + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec viverra, tellus et fermentum tincidunt, massa ligula dignissim augue, ut aliquam tortor odio in odio. In faucibus metus metus. Curabitur est mi, fermentum lacinia tincidunt vitae, mattis sit amet neque. Quisque diam nisl, accumsan ac porta tincidunt, iaculis facilisis ipsum. Nulla facilisi. Aenean a metus tortor. Pellentesque congue, mauris vitae viverra varius, elit nunc dictum nisl, rhoncus ultrices nulla sapien at leo. Duis ultricies porttitor diam. Nulla facilisi. Nullam elementum, lorem eu imperdiet laoreet, est turpis sollicitudin velit, in porttitor justo dolor vel urna. Mauris in ante magna. Curabitur vitae lacus in magna mollis commodo. + +Fusce lacinia, mauris ac aliquam consequat, lacus urna feugiat erat, id viverra mi mi sit amet tortor. Etiam ac ornare erat. Pellentesque et neque lacus, quis posuere orci. Fusce molestie blandit velit, sit amet dictum eros pharetra vitae. In erat urna, condimentum ac feugiat id, rutrum et nisi. Cras ac velit lorem. Nulla facilisi. Maecenas dignissim nulla in turpis tempus sed rhoncus augue dapibus. Nulla feugiat, urna non sagittis laoreet, dolor metus rhoncus justo, sed semper ante lacus eget quam. Sed ac ligula magna. Sed tincidunt pulvinar neque in porta. Nullam quis lacus orci. Pellentesque ornare viverra lacus, id aliquam magna venenatis a. + +Sed id tristique lorem. Ut sodales turpis nec mauris gravida interdum. Cras pellentesque, purus at suscipit euismod, elit nunc cursus nisi, ut venenatis metus sapien id velit. Sed lectus orci, pharetra non pulvinar vel, ullamcorper id lorem. Donec vulputate tincidunt ipsum, ut lacinia tortor sollicitudin id. Nunc nec nibh ut felis venenatis egestas. Proin risus mauris, eleifend eget interdum in, venenatis sed velit. Praesent sodales elit ut odio viverra posuere. Donec sapien lorem, molestie in egestas eget, vulputate sed orci. Aenean elit sapien, pellentesque vitae tempor sit amet, sagittis et ligula. Mauris aliquam sapien sit amet lacus ultrices rutrum. Curabitur nec dolor sed elit varius dignissim a a lacus. Aliquam ac convallis enim. + +Suspendisse orci massa, hendrerit sagittis lacinia consectetur, sagittis vitae purus. Aliquam id eros diam, eget elementum turpis. Nullam tellus magna, mollis in molestie id, venenatis rhoncus est. Proin id diam justo. Nunc tempus gravida justo at lobortis. Nam vitae venenatis nisi. Donec vel odio massa. Quisque interdum metus sit amet est iaculis tincidunt. Donec bibendum blandit purus, id semper orci aliquam quis. Nam tincidunt dolor eu felis ultricies tempor. Nulla non consectetur erat. + +Nunc faucibus lacus eget odio ultricies nec ullamcorper risus pharetra. Nunc nec consequat urna. Curabitur condimentum ante vitae erat tristique vitae gravida quam dapibus. Cras ac justo dui, at faucibus urna. Nunc tristique, velit id feugiat fermentum, dolor enim egestas erat, at vestibulum ante ipsum vel orci. Duis quis ante id justo vehicula eleifend sed et urna. Sed sapien tortor, rutrum id ultrices eu, tincidunt tincidunt mi. Etiam blandit, neque eget interdum dignissim, lacus ante facilisis dolor, non viverra dui lorem vitae nibh. Morbi volutpat augue eget nulla luctus eu aliquam sem facilisis. Pellentesque sollicitudin commodo dolor sit amet vestibulum. Nam dictum posuere quam, in tincidunt erat rutrum eu. + +Etiam nec turpis purus, at lacinia sem. In commodo lacinia euismod. Curabitur tincidunt congue leo, eget iaculis orci volutpat pharetra. Fusce dignissim lacus lacus. Integer consectetur lacus rutrum risus malesuada at consectetur erat rutrum. Sed magna ipsum, fringilla eget auctor non, fringilla nec massa. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum nec tortor id nisi luctus aliquam. Maecenas cursus tincidunt ornare. Nulla a vestibulum odio. Mauris malesuada commodo justo quis mattis. Suspendisse mauris ligula, placerat at egestas in, tincidunt quis nibh. Aliquam ullamcorper elit at augue cursus quis pellentesque purus viverra. + +Nulla ultricies justo ac nisi consectetur posuere. Donec ornare pharetra erat, nec facilisis dui cursus quis. Quisque porttitor porttitor orci, sed facilisis urna facilisis sed. Sed tincidunt adipiscing turpis et hendrerit. Cras posuere orci ut mauris ullamcorper vitae laoreet nisi luctus. In rutrum tristique augue. Nam eleifend dignissim dui. + +Donec viverra egestas tellus non viverra. Aenean est ante, egestas sed scelerisque quis, aliquet sed lacus. Praesent non mauris neque, et adipiscing ante. Vestibulum quis quam vitae ipsum aliquet blandit. Vivamus condimentum euismod orci, in tincidunt justo rutrum faucibus. Phasellus nec lorem arcu. Donec tortor dui, facilisis in rutrum sit amet, pulvinar vitae lacus. Nam sodales sem eu nunc scelerisque vitae ullamcorper dolor facilisis. Duis imperdiet nisi in magna tempor convallis. Fusce at metus augue. Quisque dictum tempus mauris, in mattis ligula dignissim ut. + +Proin sodales, mi at tincidunt ornare, mi dui sagittis velit, sed dictum risus orci eu erat. Sed nunc leo, congue sed rutrum eget, lobortis ac lectus. Etiam non arcu nulla. Vestibulum rutrum dolor pulvinar lorem posuere blandit. Sed quis sapien dui. Nunc sagittis erat commodo quam porta cursus in non erat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin a molestie neque. Aliquam iaculis lacus sed neque hendrerit at dignissim ligula imperdiet. Suspendisse venenatis, lorem at luctus scelerisque, sem purus pellentesque sapien, vitae ornare ipsum quam nec dui. Mauris neque est, interdum nec pulvinar eget, dapibus eleifend tellus. Fusce non lorem tortor. Nullam eget nunc quis felis aliquam consectetur. Aliquam tristique, turpis in feugiat blandit, lectus erat condimentum tortor, non egestas nisl sapien eget nibh. + +Aliquam elit turpis, faucibus et porta et, egestas nec nibh. Sed nisl est, pharetra a eleifend a, pretium ac eros. Sed leo eros, pulvinar vel faucibus dictum, aliquet ut quam. Maecenas et felis non ligula fringilla pretium fringilla sit amet ante. Nam varius imperdiet interdum. Ut non metus mauris, vel volutpat lorem. Nullam sagittis est quis lacus feugiat fringilla. Quisque orci lorem, semper ac accumsan vitae, blandit quis velit. Proin luctus sodales ultrices. Fusce mauris erat, facilisis ut consectetur at, fringilla feugiat orci. Aliquam a nisi a neque interdum suscipit id eget purus. Pellentesque tincidunt justo ut urna posuere non molestie quam auctor. diff --git a/docs/build/docstrap-master/fixtures/tutorials/Drive Car.md b/docs/build/docstrap-master/fixtures/tutorials/Drive Car.md new file mode 100644 index 00000000..a1b0eb10 --- /dev/null +++ b/docs/build/docstrap-master/fixtures/tutorials/Drive Car.md @@ -0,0 +1,10 @@ +#Lorem ipsum dolor sit amet + +Curabitur est mi, fermentum lacinia tincidunt vitae, mattis sit amet neque. Quisque diam nisl, accumsan ac porta tincidunt, iaculis facilisis ipsum. Nulla facilisi. Aenean a metus tortor. Pellentesque congue, mauris vitae viverra varius, elit nunc dictum nisl, rhoncus ultrices nulla sapien at leo. Duis ultricies porttitor diam. Nulla facilisi. Nullam elementum, lorem eu imperdiet laoreet, est turpis sollicitudin velit, in porttitor justo dolor vel urna. Mauris in ante magna. Curabitur vitae lacus in magna mollis commodo. + +##Fusce lacinia, mauris ac aliquam consequat +Fusce molestie blandit velit, sit amet dictum eros pharetra vitae. In erat urna, condimentum ac feugiat id, rutrum et nisi. Cras ac velit lorem. Nulla facilisi. Maecenas dignissim nulla in turpis tempus sed rhoncus augue dapibus. Nulla feugiat, urna non sagittis laoreet, dolor metus rhoncus justo, sed semper ante lacus eget quam. Sed ac ligula magna. Sed tincidunt pulvinar neque in porta. Nullam quis lacus orci. Pellentesque ornare viverra lacus, id aliquam magna venenatis a. + +Sed id tristique lorem. Ut sodales turpis nec mauris gravida interdum. Cras pellentesque, purus at suscipit euismod, elit nunc cursus nisi, ut venenatis metus sapien id velit. Sed lectus orci, pharetra non pulvinar vel, ullamcorper id lorem. Donec vulputate tincidunt ipsum, ut lacinia tortor sollicitudin id. Nunc nec nibh ut felis venenatis egestas. Proin risus mauris, eleifend eget interdum in, venenatis sed velit. Praesent sodales elit ut odio viverra posuere. Donec sapien lorem, molestie in egestas eget, vulputate sed orci. Aenean elit sapien, pellentesque vitae tempor sit amet, sagittis et ligula. Mauris aliquam sapien sit amet lacus ultrices rutrum. Curabitur nec dolor sed elit varius dignissim a a lacus. Aliquam ac convallis enim. + +Suspendisse orci massa, hendrerit sagittis lacinia consectetur, sagittis vitae purus. Aliquam id eros diam, eget elementum turpis. Nullam tellus magna, mollis in molestie id, venenatis rhoncus est. Proin id diam justo. Nunc tempus gravida justo at lobortis. Nam vitae venenatis nisi. Donec vel odio massa. Quisque interdum metus sit amet est iaculis tincidunt. Donec bibendum blandit purus, id semper orci aliquam quis. Nam tincidunt dolor eu felis ultricies tempor. Nulla non consectetur erat. diff --git a/docs/build/docstrap-master/package.json b/docs/build/docstrap-master/package.json new file mode 100644 index 00000000..96683c5d --- /dev/null +++ b/docs/build/docstrap-master/package.json @@ -0,0 +1,36 @@ +{ + "name": "ink-docstrap", + "version": "0.2.0-0", + "decription": "A template for JSDoc3 based on Bootstrap and Bootswatch", + "devDependencies": { + "grunt": "~0.4.1", + "grunt-contrib-less": "~0.5.1", + "jsdoc": "git://github.com/jsdoc3/jsdoc.git", + "grunt-shell": "~0.2.2", + "async": "~0.2.8", + "lodash": "~1.2.1", + "grunt-contrib-copy": "~0.4.1" + }, + "license": "MIT", + "keywords": [ + "docstrap", + "jsdoc3", + "bootstrap", + "bootswatch", + "theme", + "documentation", + "jsdoc" + ], + "author": { + "name": "Terry Weiss", + "email": "me@terryweiss.net" + }, + "bugs": { + "url": "https://github.com/terryweiss/docstrap/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/terryweiss/docstrap.git" + }, + "main": "./template/publish.js" +} diff --git a/docs/build/docstrap-master/styles/bootswatch.less b/docs/build/docstrap-master/styles/bootswatch.less new file mode 100644 index 00000000..e4f0e4cf --- /dev/null +++ b/docs/build/docstrap-master/styles/bootswatch.less @@ -0,0 +1,180 @@ +// Cerulean 2.3.2 +// Bootswatch +// ----------------------------------------------------- + + +// TYPOGRAPHY +// ----------------------------------------------------- + +@import url(//fonts.googleapis.com/css?family=Telex); + +// SCAFFOLDING +// ----------------------------------------------------- + +// NAVBAR +// ----------------------------------------------------- + +.navbar { + + .brand { + padding: 14px 20px 16px; + font-family: @headingsFontFamily; + text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2); + } + + li { + line-height: 20px; + } + + .nav > li > a { + padding: 16px 10px 14px; + font-family: @headingsFontFamily; + text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2); + } + + .search-query { + border: 1px solid darken(@linkColor, 10%); + line-height: normal; + } + + .navbar-text { + padding: 19px 10px 18px; + line-height: 13px; + color: rgba(0, 0, 0, 0.5); + text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3); + } + + &-inverse { + + .navbar-search .search-query { + color: @textColor; + } + } +} + +@media (max-width: @navbarCollapseWidth) { + + .navbar .nav-collapse { + + .nav li > a { + + font-family: @headingsFontFamily; + font-weight: normal; + color: @white; + text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2); + + &:hover { + background-color: #2B7CAC; + } + } + + .nav .active > a { + .box-shadow(none); + background-color: #2B7CAC; + } + + .dropdown-menu li > a:hover, + .dropdown-menu li > a:focus, + .dropdown-submenu:hover > a { + background-image: none; + } + + .navbar-form, + .navbar-search { + border: none; + } + + .nav-header { + color: #2B7CAC; + } + } + + .navbar-inverse .nav-collapse { + + .nav li > a { + color: @navbarInverseLinkColor; + + &:hover { + background-color: rgba(0, 0, 0, 0.1); + } + } + + .nav .active > a, + .nav > li > a:hover, + .dropdown-menu a:hover { + background-color: rgba(0, 0, 0, 0.1) !important; + } + } +} + +div.subnav { + + font-family: @headingsFontFamily; + text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.2); + + &-fixed { + top: @navbarHeight + 1; + } +} + +// NAV +// ----------------------------------------------------- + +// BUTTONS +// ----------------------------------------------------- + +.btn { + #gradient > .vertical-three-colors(@white, @white, 5%, darken(@white, 0%)); + @shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05); + .box-shadow(@shadow); + + &:hover { + background-position: 0 0; + } +} + +.btn-primary { + .buttonBackground(lighten(@btnPrimaryBackground, 5%), @btnPrimaryBackground); +} + +.btn-info { + .buttonBackground(lighten(@btnInfoBackground, 5%), @btnInfoBackground); +} + +.btn-success { + .buttonBackground(lighten(@btnSuccessBackground, 5%), @btnSuccessBackground); +} + +.btn-warning { + .buttonBackground(lighten(@btnWarningBackground, 5%), @btnWarningBackground); +} + +.btn-danger { + .buttonBackground(lighten(@btnDangerBackground, 5%), @btnDangerBackground); +} + +.btn-inverse { + .buttonBackground(lighten(@btnInverseBackground, 5%), @btnInverseBackground); +} + +// TABLES +// ----------------------------------------------------- + +// FORMS +// ----------------------------------------------------- + +// DROPDOWNS +// ----------------------------------------------------- + +// ALERTS, LABELS, BADGES +// ----------------------------------------------------- + +// MISC +// ----------------------------------------------------- + +i[class^="icon-"]{ + opacity: 0.8; +} + +// MEDIA QUERIES +// ----------------------------------------------------- diff --git a/docs/build/docstrap-master/styles/main.less b/docs/build/docstrap-master/styles/main.less new file mode 100644 index 00000000..f1049487 --- /dev/null +++ b/docs/build/docstrap-master/styles/main.less @@ -0,0 +1,152 @@ +@import "../components/bootstrap/less/bootstrap.less"; +@import "variables.less"; +@import "bootswatch.less"; + +@headerHeight: 56px; + +#main { + margin-top : @headerHeight; +} + +.navbar-fixed-top { + .navbar-inner { + padding-left : 20px; + padding-right : 20px; + } + +} + +.navbar { + .dropdown-menu { + padding : 20px; + max-height : 300px; + overflow : auto; + width : 300px; + background-color : @navbarInverseBackground; + a, a:visited { + color : @navbarInverseLinkColor; + } + a:hover { + color : @navbarInverseLinkColorHover; + background-color : @navbarInverseLinkBackgroundHover; + } + a:active { + color : @navbarInverseLinkColorActive; + background-color : @navbarInverseLinkBackgroundActive; + } + a { + padding-left : 0; + padding-right : 5px; + font-weight : 500; + font-size : 115%; + } + } + +} + +#toc { + position : fixed; + top : @headerHeight; + width : 29%; + max-height : 90%; + overflow : auto; + .border-radius(5px); + border : 1px @navbarBackground solid; + padding : 5px; + + .toc-active { + background-color : @navbarLinkBackgroundActive; + color : @navbarLinkColorActive; + .border-radius(3px); + a, a:hover, a:active, a:visited { + background-color : @navbarLinkBackgroundActive; + color : @navbarLinkColorActive; + } + } +} + +.toc-shim { + padding-top : @headerHeight; + margin-top : -@headerHeight; + display : block; +} + +.toc-h1 { + margin-left : 2px; + margin-right : 2px; +} + +.toc-h2 { + margin-left : 7px; + margin-right : 7px; +} + +.toc-h3 { + margin-left : 14px; + margin-right : 7px; +} + +.toc-h4 { + margin-left : 21px; + margin-right : 7px; +} + +.copyright { + font-size : 90%; + text-align : center; + color : @navbarInverseBackground; + width : 100%; + display : block; +} + +.jsdoc-message { + font-size : 90%; + text-align : center; + color : @navbarInverseBackground; + width : 100%; + display : block; +} + +.page-title { + font-size : 220%; + color : @navbarInverseBackground; + font-weight : 700; + padding-top : 10px; + display : block; +} + +footer { + border-top : 1px solid @navbarInverseBackgroundHighlight; + padding-top : 15px; +} + +code { + background-color : none; + border : none; + color : @orange; +} + +.buffered-name { + padding-top : @headerHeight; + margin-top : -@headerHeight; +} + + +.member-collapsed { + background-color : @navbarInverseBackground; + color : @navbarInverseText; +} + +.member-open { + background-color : inherit; + color : inherit; +} + +.member { + .transition(background-color 0.5s linear); + .transition(color 0.5s linear); + .border-radius(5px); + padding : 10px; +} + + diff --git a/docs/build/docstrap-master/styles/variables.less b/docs/build/docstrap-master/styles/variables.less new file mode 100644 index 00000000..4c706d68 --- /dev/null +++ b/docs/build/docstrap-master/styles/variables.less @@ -0,0 +1,301 @@ +// Cerulean 2.3.2 +// Variables +// -------------------------------------------------- + + +// GLOBAL VALUES +// -------------------------------------------------- + + +// Grays +// ------------------------- +@black: #000; +@grayDarker: #222; +@grayDark: #333; +@gray: #555; +@grayLight: #999; +@grayLighter: #F5F5F5; +@white: #fff; + + +// Accent colors +// ------------------------- +@blue: #2FA4E7; +@blueDark: #033C73; +@green: #73A839; +@red: #C71C22; +@yellow: #F7B42C; +@orange: #DD5600; +@pink: #F49AC1; +@purple: #9760B3; + + +// Scaffolding +// ------------------------- +@bodyBackground: @white; +@textColor: @gray; + + +// Links +// ------------------------- +@linkColor: @blue; +@linkColorHover: darken(@linkColor, 15%); + + +// Typography +// ------------------------- +@sansFontFamily: "Helvetica Neue", Helvetica, Arial, sans-serif; +@serifFontFamily: Georgia, "Times New Roman", Times, serif; +@monoFontFamily: Menlo, Monaco, Consolas, "Courier New", monospace; + +@baseFontSize: 14px; +@baseFontFamily: @sansFontFamily; +@baseLineHeight: 20px; +@altFontFamily: @monoFontFamily; + +@headingsFontFamily: 'Telex', sans-serif; // empty to use BS default, @baseFontFamily +@headingsFontWeight: bold; // instead of browser default, bold +@headingsColor: #317EAC; // empty to use BS default, @textColor + + +// Component sizing +// ------------------------- +// Based on 14px font-size and 20px line-height + +@fontSizeLarge: @baseFontSize * 1.25; // ~18px +@fontSizeSmall: @baseFontSize * 0.85; // ~12px +@fontSizeMini: @baseFontSize * 0.75; // ~11px + +@paddingLarge: 11px 19px; // 44px +@paddingSmall: 2px 10px; // 26px +@paddingMini: 0px 6px; // 22px + +@baseBorderRadius: 4px; +@borderRadiusLarge: 6px; +@borderRadiusSmall: 3px; + + +// Tables +// ------------------------- +@tableBackground: transparent; // overall background-color +@tableBackgroundAccent: #f9f9f9; // for striping +@tableBackgroundHover: #f5f5f5; // for hover +@tableBorder: #ddd; // table and cell border + +// Buttons +// ------------------------- +@btnBackground: @white; +@btnBackgroundHighlight: darken(@white, 10%); +@btnBorder: darken(@white, 20%); + +@btnPrimaryBackground: @linkColor; +@btnPrimaryBackgroundHighlight: spin(@btnPrimaryBackground, 15%); + +@btnInfoBackground: @purple; +@btnInfoBackgroundHighlight: #2f96b4; + +@btnSuccessBackground: @green; +@btnSuccessBackgroundHighlight: #51a351; + +@btnWarningBackground: @orange; +@btnWarningBackgroundHighlight: @orange; + +@btnDangerBackground: @red; +@btnDangerBackgroundHighlight: #bd362f; + +@btnInverseBackground: @blueDark; +@btnInverseBackgroundHighlight: @grayDarker; + + +// Forms +// ------------------------- +@inputBackground: @white; +@inputBorder: #ccc; +@inputBorderRadius: @baseBorderRadius; +@inputDisabledBackground: @grayLighter; +@formActionsBackground: #f5f5f5; +@inputHeight: @baseLineHeight + 10px; // base line-height + 8px vertical padding + 2px top/bottom border + + +// Dropdowns +// ------------------------- +@dropdownBackground: @white; +@dropdownBorder: rgba(0,0,0,.2); +@dropdownDividerTop: #e5e5e5; +@dropdownDividerBottom: @white; + +@dropdownLinkColor: @grayDark; +@dropdownLinkColorHover: @white; +@dropdownLinkColorActive: @white; + +@dropdownLinkBackgroundActive: @linkColor; +@dropdownLinkBackgroundHover: @dropdownLinkBackgroundActive; + + + +// COMPONENT VARIABLES +// -------------------------------------------------- + + +// Z-index master list +// ------------------------- +// Used for a bird's eye view of components dependent on the z-axis +// Try to avoid customizing these :) +@zindexDropdown: 1000; +@zindexPopover: 1010; +@zindexTooltip: 1020; +@zindexFixedNavbar: 1030; +@zindexModalBackdrop: 1040; +@zindexModal: 1050; + + +// Sprite icons path +// ------------------------- +@iconSpritePath: "../img/glyphicons-halflings.png"; +@iconWhiteSpritePath: "../img/glyphicons-halflings-white.png"; + + +// Input placeholder text color +// ------------------------- +@placeholderText: @grayLight; + + +// Hr border color +// ------------------------- +@hrBorder: @grayLighter; + + +// Horizontal forms & lists +// ------------------------- +@horizontalComponentOffset: 180px; + + +// Wells +// ------------------------- +@wellBackground: #f5f5f5; + + +// Navbar +// ------------------------- +@navbarCollapseWidth: 979px; +@navbarCollapseDesktopWidth: @navbarCollapseWidth + 1; + +@navbarHeight: 50px; +@navbarBackgroundHighlight: lighten(@navbarBackground, 8%); +@navbarBackground: @blue; +@navbarBorder: darken(@navbarBackground, 8%); + +@navbarText: @grayLighter; +@navbarLinkColor: @white; +@navbarLinkColorHover: @white; +@navbarLinkColorActive: @navbarLinkColorHover; +@navbarLinkBackgroundHover: darken(@navbarBackground, 12%); +@navbarLinkBackgroundActive: darken(@navbarBackground, 12%); + +@navbarBrandColor: @navbarLinkColor; + +// Inverted navbar +@navbarInverseBackground: @blueDark; +@navbarInverseBackgroundHighlight: lighten(@navbarInverseBackground, 5%); +@navbarInverseBorder: darken(@navbarInverseBackground, 3%); + +@navbarInverseText: @white; +@navbarInverseLinkColor: @white; +@navbarInverseLinkColorHover: @white; +@navbarInverseLinkColorActive: @white; +@navbarInverseLinkBackgroundHover: darken(@navbarInverseBackground, 6%); +@navbarInverseLinkBackgroundActive: darken(@navbarInverseBackground, 6%); + +@navbarInverseSearchBackground: @white; +@navbarInverseSearchBackgroundFocus: @white; +@navbarInverseSearchBorder: @navbarInverseBackground; +@navbarInverseSearchPlaceholderColor: @grayLight; + +@navbarInverseBrandColor: @navbarInverseLinkColor; + + +// Pagination +// ------------------------- +@paginationBackground: #fff; +@paginationBorder: #ddd; +@paginationActiveBackground: #f5f5f5; + + +// Hero unit +// ------------------------- +@heroUnitBackground: @grayLighter; +@heroUnitHeadingColor: inherit; +@heroUnitLeadColor: inherit; + + +// Form states and alerts +// ------------------------- +@warningText: @orange; +@warningBackground: #F1CEAB; +@warningBorder: darken(spin(@warningBackground, -10), 3%); + +@errorText: darken(#C45559, 5%); +@errorBackground: #F2BDB1; +@errorBorder: darken(spin(@errorBackground, -10), 3%); + +@successText: darken(@green, 5%); +@successBackground: #D5ECBF; +@successBorder: darken(spin(@successBackground, -10), 5%); + +@infoText: darken(@blue, 10%); +@infoBackground: #A7DFF1; +@infoBorder: darken(spin(@infoBackground, -10), 7%); + + +// Tooltips and popovers +// ------------------------- +@tooltipColor: #fff; +@tooltipBackground: #000; +@tooltipArrowWidth: 5px; +@tooltipArrowColor: @tooltipBackground; + +@popoverBackground: #fff; +@popoverArrowWidth: 10px; +@popoverArrowColor: #fff; +@popoverTitleBackground: darken(@popoverBackground, 3%); + +// Special enhancement for popovers +@popoverArrowOuterWidth: @popoverArrowWidth + 1; +@popoverArrowOuterColor: rgba(0,0,0,.25); + + + +// GRID +// -------------------------------------------------- + + +// Default 940px grid +// ------------------------- +@gridColumns: 12; +@gridColumnWidth: 60px; +@gridGutterWidth: 20px; +@gridRowWidth: (@gridColumns * @gridColumnWidth) + (@gridGutterWidth * (@gridColumns - 1)); + +// 1200px min +@gridColumnWidth1200: 70px; +@gridGutterWidth1200: 30px; +@gridRowWidth1200: (@gridColumns * @gridColumnWidth1200) + (@gridGutterWidth1200 * (@gridColumns - 1)); + +// 768px-979px +@gridColumnWidth768: 42px; +@gridGutterWidth768: 20px; +@gridRowWidth768: (@gridColumns * @gridColumnWidth768) + (@gridGutterWidth768 * (@gridColumns - 1)); + + +// Fluid grid +// ------------------------- +@fluidGridColumnWidth: percentage(@gridColumnWidth/@gridRowWidth); +@fluidGridGutterWidth: percentage(@gridGutterWidth/@gridRowWidth); + +// 1200px min +@fluidGridColumnWidth1200: percentage(@gridColumnWidth1200/@gridRowWidth1200); +@fluidGridGutterWidth1200: percentage(@gridGutterWidth1200/@gridRowWidth1200); + +// 768px-979px +@fluidGridColumnWidth768: percentage(@gridColumnWidth768/@gridRowWidth768); +@fluidGridGutterWidth768: percentage(@gridGutterWidth768/@gridRowWidth768); diff --git a/docs/build/docstrap-master/template/jsdoc.conf.json b/docs/build/docstrap-master/template/jsdoc.conf.json new file mode 100644 index 00000000..a445deed --- /dev/null +++ b/docs/build/docstrap-master/template/jsdoc.conf.json @@ -0,0 +1,25 @@ +{ + "tags" : { + "allowUnknownTags" : true + }, + "plugins" : ["plugins/markdown"], + "templates" : { + "cleverLinks" : false, + "monospaceLinks" : false, + "default" : { + "outputSourceFiles" : true + }, + "systemName" : "DocStrap", + "footer" : "", + "copyright" : "DocStrap Copyright © 2012-2013 The contributors to the JSDoc3 and DocStrap projects.", + "navType" : "vertical", + "theme" : "cerulean", + "linenums" : true, + "collapseSymbols" : false, + "inverseNav" : true + }, + "markdown" : { + "parser" : "gfm", + "hardwrap" : true + } +} diff --git a/docs/build/docstrap-master/template/publish.js b/docs/build/docstrap-master/template/publish.js new file mode 100644 index 00000000..555e7386 --- /dev/null +++ b/docs/build/docstrap-master/template/publish.js @@ -0,0 +1,651 @@ +"use strict"; +/** + * @module template/publish + * @type {*} + */ +/*global env: true */ +var template = require( 'jsdoc/template' ), + fs = require( 'jsdoc/fs' ), + _ = require( 'underscore' ), + path = require( 'jsdoc/path' ), + taffy = require( 'taffydb' ).taffy, + handle = require( 'jsdoc/util/error' ).handle, + helper = require( 'jsdoc/util/templateHelper' ), + htmlsafe = helper.htmlsafe, + linkto = helper.linkto, + resolveAuthorLinks = helper.resolveAuthorLinks, + scopeToPunc = helper.scopeToPunc, + hasOwnProp = Object.prototype.hasOwnProperty, + conf = env.conf.templates || {}, + data, + view, + outdir = env.opts.destination; + +var globalUrl = helper.getUniqueFilename( 'global' ); +var indexUrl = helper.getUniqueFilename( 'index' ); + +var navOptions = { + systemName : conf.systemName || "Documentation", + navType : conf.navType || "vertical", + footer : conf.footer || "", + copyright : conf.copyright || "", + theme : conf.theme || "simplex", + linenums : conf.linenums, + collapseSymbols : conf.collapseSymbols || false, + inverseNav : conf.inverseNav +}; + +var navigationMaster = { + index : { + title : navOptions.systemName, + link : indexUrl, + members : [] + }, + namespace : { + title : "Namespaces", + link : helper.getUniqueFilename( "namespaces.list" ), + members : [] + }, + module : { + title : "Modules", + link : helper.getUniqueFilename( "modules.list" ), + members : [] + }, + class : { + title : "Classes", + link : helper.getUniqueFilename( 'classes.list' ), + members : [] + }, + + mixin : { + title : "Mixins", + link : helper.getUniqueFilename( "mixins.list" ), + members : [] + }, + event : { + title : "Events", + link : helper.getUniqueFilename( "events.list" ), + members : [] + }, + tutorial : { + title : "Tutorials", + link : helper.getUniqueFilename( "tutorials.list" ), + members : [] + }, + global : { + title : "Global", + link : globalUrl, + members : [] + + }, + external : { + title : "Externals", + link : helper.getUniqueFilename( "externals.list" ), + members : [] + } +}; + +function find( spec ) { + return helper.find( data, spec ); +} + +function tutoriallink( tutorial ) { + return helper.toTutorial( tutorial, null, { tag : 'em', classname : 'disabled', prefix : 'Tutorial: ' } ); +} + +function getAncestorLinks( doclet ) { + return helper.getAncestorLinks( data, doclet ); +} + +function hashToLink( doclet, hash ) { + if ( !/^(#.+)/.test( hash ) ) { return hash; } + + var url = helper.createLink( doclet ); + + url = url.replace( /(#.+|$)/, hash ); + return '' + hash + ''; +} + +function needsSignature( doclet ) { + var needsSig = false; + + // function and class definitions always get a signature + if ( doclet.kind === 'function' || doclet.kind === 'class' ) { + needsSig = true; + } + // typedefs that contain functions get a signature, too + else if ( doclet.kind === 'typedef' && doclet.type && doclet.type.names && + doclet.type.names.length ) { + for ( var i = 0, l = doclet.type.names.length; i < l; i++ ) { + if ( doclet.type.names[i].toLowerCase() === 'function' ) { + needsSig = true; + break; + } + } + } + + return needsSig; +} + +function addSignatureParams( f ) { + var params = helper.getSignatureParams( f, 'optional' ); + + f.signature = (f.signature || '') + '(' + params.join( ', ' ) + ')'; +} + +function addSignatureReturns( f ) { + var returnTypes = helper.getSignatureReturns( f ); + + f.signature = '' + (f.signature || '') + '' + '' + (returnTypes.length ? ' → {' + returnTypes.join( '|' ) + '}' : '') + ''; +} + +function addSignatureTypes( f ) { + var types = helper.getSignatureTypes( f ); + + f.signature = (f.signature || '') + '' + (types.length ? ' :' + types.join( '|' ) : '') + ''; +} + +function addAttribs( f ) { + var attribs = helper.getAttribs( f ); + + f.attribs = '' + htmlsafe( attribs.length ? '<' + attribs.join( ', ' ) + '> ' : '' ) + ''; +} + +function shortenPaths( files, commonPrefix ) { + // always use forward slashes + var regexp = new RegExp( '\\\\', 'g' ); + + Object.keys( files ).forEach( function ( file ) { + files[file].shortened = files[file].resolved.replace( commonPrefix, '' ) + .replace( regexp, '/' ); + } ); + + return files; +} + +function resolveSourcePath( filepath ) { + return path.resolve( process.cwd(), filepath ); +} + +function getPathFromDoclet( doclet ) { + if ( !doclet.meta ) { + return; + } + + var filepath = doclet.meta.path && doclet.meta.path !== 'null' ? + doclet.meta.path + '/' + doclet.meta.filename : + doclet.meta.filename; + + return filepath; +} + +function generate( docType, title, docs, filename, resolveLinks ) { + resolveLinks = resolveLinks === false ? false : true; + + var docData = { + title : title, + docs : docs, + docType : docType + }; + + var outpath = path.join( outdir, filename ), + html = view.render( 'container.tmpl', docData ); + + if ( resolveLinks ) { + html = helper.resolveLinks( html ); // turn {@link foo} into foo + } + + fs.writeFileSync( outpath, html, 'utf8' ); +} + +function generateSourceFiles( sourceFiles ) { + Object.keys( sourceFiles ).forEach( function ( file ) { + var source; + // links are keyed to the shortened path in each doclet's `meta.filename` property + var sourceOutfile = helper.getUniqueFilename( sourceFiles[file].shortened ); + helper.registerLink( sourceFiles[file].shortened, sourceOutfile ); + + try { + source = { + kind : 'source', + code : helper.htmlsafe( fs.readFileSync( sourceFiles[file].resolved, 'utf8' ) ) + }; + } + catch ( e ) { + handle( e ); + } + + generate( 'source', 'Source: ' + sourceFiles[file].shortened, [source], sourceOutfile, + false ); + } ); +} + +/** + * Look for classes or functions with the same name as modules (which indicates that the module + * exports only that class or function), then attach the classes or functions to the `module` + * property of the appropriate module doclets. The name of each class or function is also updated + * for display purposes. This function mutates the original arrays. + * + * @private + * @param {Array.} doclets - The array of classes and functions to + * check. + * @param {Array.} modules - The array of module doclets to search. + */ +function attachModuleSymbols( doclets, modules ) { + var symbols = {}; + + // build a lookup table + doclets.forEach( function ( symbol ) { + symbols[symbol.longname] = symbol; + } ); + + return modules.map( function ( module ) { + if ( symbols[module.longname] ) { + module.module = symbols[module.longname]; + module.module.name = module.module.name.replace( 'module:', 'require("' ) + '")'; + } + } ); +} + +/** + * Create the navigation sidebar. + * @param {object} members The members that will be used to create the sidebar. + * @param {array} members.classes + * @param {array} members.externals + * @param {array} members.globals + * @param {array} members.mixins + * @param {array} members.modules + * @param {array} members.namespaces + * @param {array} members.tutorials + * @param {array} members.events + * @return {string} The HTML for the navigation sidebar. + */ +function buildNav( members ) { + + var seen = {}; + var nav = navigationMaster; + if ( members.modules.length ) { + + members.modules.forEach( function ( m ) { + if ( !hasOwnProp.call( seen, m.longname ) ) { + + nav.module.members.push( linkto( m.longname, m.name ) ); + } + seen[m.longname] = true; + } ); + } + + if ( members.externals.length ) { + + members.externals.forEach( function ( e ) { + if ( !hasOwnProp.call( seen, e.longname ) ) { + + nav.external.members.push( linkto( e.longname, e.name.replace( /(^"|"$)/g, '' ) ) ); + } + seen[e.longname] = true; + } ); + } + + if ( members.classes.length ) { + + members.classes.forEach( function ( c ) { + if ( !hasOwnProp.call( seen, c.longname ) ) { + + nav.class.members.push( linkto( c.longname, c.name ) ); + } + seen[c.longname] = true; + } ); + + } + + if ( members.events.length ) { + + members.events.forEach( function ( e ) { + if ( !hasOwnProp.call( seen, e.longname ) ) { + + nav.event.members.push( linkto( e.longname, e.name ) ); + } + seen[e.longname] = true; + } ); + + } + + if ( members.namespaces.length ) { + + members.namespaces.forEach( function ( n ) { + if ( !hasOwnProp.call( seen, n.longname ) ) { + + nav.namespace.members.push( linkto( n.longname, n.name ) ); + } + seen[n.longname] = true; + } ); + + } + + if ( members.mixins.length ) { + + members.mixins.forEach( function ( m ) { + if ( !hasOwnProp.call( seen, m.longname ) ) { + + nav.mixin.members.push( linkto( m.longname, m.name ) ); + } + seen[m.longname] = true; + } ); + + } + + if ( members.tutorials.length ) { + + members.tutorials.forEach( function ( t ) { + + nav.tutorial.members.push( tutoriallink( t.name ) ); + } ); + + } + + if ( members.globals.length ) { + members.globals.forEach( function ( g ) { + if ( g.kind !== 'typedef' && !hasOwnProp.call( seen, g.longname ) ) { + + nav.global.members.push( linkto( g.longname, g.name ) ); + } + seen[g.longname] = true; + } ); + } + + var topLevelNav = []; + _.each( nav, function ( entry, name ) { + if ( entry.members.length > 0 && name !== "index" ) { + topLevelNav.push( { + title : entry.title, + link : entry.link, + members : entry.members + } ); + } + } ); + nav.topLevelNav = topLevelNav; +} + +/** + @param {TAFFY} taffyData See . + @param {object} opts + @param {Tutorial} tutorials + */ +exports.publish = function ( taffyData, opts, tutorials ) { + data = taffyData; + + conf['default'] = conf['default'] || {}; + + var templatePath = opts.template; + view = new template.Template( templatePath + '/tmpl' ); + + // claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness + // doesn't try to hand them out later +// var indexUrl = helper.getUniqueFilename( 'index' ); + // don't call registerLink() on this one! 'index' is also a valid longname + +// var globalUrl = helper.getUniqueFilename( 'global' ); + helper.registerLink( 'global', globalUrl ); + + // set up templating + view.layout = 'layout.tmpl'; + + // set up tutorials for helper + helper.setTutorials( tutorials ); + + data = helper.prune( data ); + data.sort( 'longname, version, since' ); + helper.addEventListeners( data ); + + var sourceFiles = {}; + var sourceFilePaths = []; + data().each( function ( doclet ) { + doclet.attribs = ''; + + if ( doclet.examples ) { + doclet.examples = doclet.examples.map( function ( example ) { + var caption, code; + + if ( example.match( /^\s*([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i ) ) { + caption = RegExp.$1; + code = RegExp.$3; + } + + return { + caption : caption || '', + code : code || example + }; + } ); + } + if ( doclet.see ) { + doclet.see.forEach( function ( seeItem, i ) { + doclet.see[i] = hashToLink( doclet, seeItem ); + } ); + } + + // build a list of source files + var sourcePath; + var resolvedSourcePath; + if ( doclet.meta ) { + sourcePath = getPathFromDoclet( doclet ); + resolvedSourcePath = resolveSourcePath( sourcePath ); + sourceFiles[sourcePath] = { + resolved : resolvedSourcePath, + shortened : null + }; + + sourceFilePaths.push( resolvedSourcePath ); + } + } ); + + // update outdir if necessary, then create outdir + var packageInfo = ( find( {kind : 'package'} ) || [] ) [0]; + if ( packageInfo && packageInfo.name ) { + outdir = path.join( outdir, packageInfo.name, packageInfo.version ); + } + fs.mkPath( outdir ); + + // copy static files to outdir + var fromDir = path.join( templatePath, 'static' ), + staticFiles = fs.ls( fromDir, 3 ); + + staticFiles.forEach( function ( fileName ) { + var toDir = fs.toDir( fileName.replace( fromDir, outdir ) ); + fs.mkPath( toDir ); + fs.copyFileSync( fileName, toDir ); + } ); + + if ( sourceFilePaths.length ) { + sourceFiles = shortenPaths( sourceFiles, path.commonPrefix( sourceFilePaths ) ); + } + data().each( function ( doclet ) { + var url = helper.createLink( doclet ); + helper.registerLink( doclet.longname, url ); + + // replace the filename with a shortened version of the full path + var docletPath; + if ( doclet.meta ) { + docletPath = getPathFromDoclet( doclet ); + docletPath = sourceFiles[docletPath].shortened; + if ( docletPath ) { + doclet.meta.filename = docletPath; + } + } + } ); + + data().each( function ( doclet ) { + var url = helper.longnameToUrl[doclet.longname]; + + if ( url.indexOf( '#' ) > -1 ) { + doclet.id = helper.longnameToUrl[doclet.longname].split( /#/ ).pop(); + } + else { + doclet.id = doclet.name; + } + + if ( needsSignature( doclet ) ) { + addSignatureParams( doclet ); + addSignatureReturns( doclet ); + addAttribs( doclet ); + } + } ); + + // do this after the urls have all been generated + data().each( function ( doclet ) { + doclet.ancestors = getAncestorLinks( doclet ); + + if ( doclet.kind === 'member' ) { + addSignatureTypes( doclet ); + addAttribs( doclet ); + } + + if ( doclet.kind === 'constant' ) { + addSignatureTypes( doclet ); + addAttribs( doclet ); + doclet.kind = 'member'; + } + } ); + + var members = helper.getMembers( data ); + members.tutorials = tutorials.children; + + // add template helpers + view.find = find; + view.linkto = linkto; + view.resolveAuthorLinks = resolveAuthorLinks; + view.tutoriallink = tutoriallink; + view.htmlsafe = htmlsafe; + + // once for all + buildNav( members ); + view.nav = navigationMaster; + view.navOptions = navOptions; + attachModuleSymbols( find( { kind : ['class', 'function'], longname : {left : 'module:'} } ), + members.modules ); + + // only output pretty-printed source files if requested; do this before generating any other + // pages, so the other pages can link to the source files + if ( conf['default'].outputSourceFiles ) { + generateSourceFiles( sourceFiles ); + } + + if ( members.globals.length ) { + generate( 'global', 'Global', [ + {kind : 'globalobj'} + ], globalUrl ); + } + + // some browsers can't make the dropdown work + if ( view.nav.module && view.nav.module.members.length ) { + generate( 'module', view.nav.module.title, [ + {kind : 'sectionIndex', contents : view.nav.module} + ], navigationMaster.module.link ); + } + + if ( view.nav.class && view.nav.class.members.length ) { + generate( 'class', view.nav.class.title, [ + {kind : 'sectionIndex', contents : view.nav.class} + ], navigationMaster.class.link ); + } + + if ( view.nav.namespace && view.nav.namespace.members.length ) { + generate( 'namespace', view.nav.namespace.title, [ + {kind : 'sectionIndex', contents : view.nav.namespace} + ], navigationMaster.namespace.link ); + } + + if ( view.nav.mixin && view.nav.mixin.members.length ) { + generate( 'mixin', view.nav.mixin.title, [ + {kind : 'sectionIndex', contents : view.nav.mixin} + ], navigationMaster.mixin.link ); + } + + if ( view.nav.external && view.nav.external.members.length ) { + generate( 'external', view.nav.external.title, [ + {kind : 'sectionIndex', contents : view.nav.external} + ], navigationMaster.external.link ); + } + + if ( view.nav.tutorial && view.nav.tutorial.members.length ) { + generate( 'tutorial', view.nav.tutorial.title, [ + {kind : 'sectionIndex', contents : view.nav.tutorial} + ], navigationMaster.tutorial.link ); + } + + // index page displays information from package.json and lists files + var files = find( {kind : 'file'} ), + packages = find( {kind : 'package'} ); + + generate( 'index', 'Index', + packages.concat( + [ + {kind : 'mainpage', readme : opts.readme, longname : (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'} + ] + ).concat( files ), + indexUrl ); + + // set up the lists that we'll use to generate pages + var classes = taffy( members.classes ); + var modules = taffy( members.modules ); + var namespaces = taffy( members.namespaces ); + var mixins = taffy( members.mixins ); + var externals = taffy( members.externals ); + + for ( var longname in helper.longnameToUrl ) { + if ( hasOwnProp.call( helper.longnameToUrl, longname ) ) { + var myClasses = helper.find( classes, {longname : longname} ); + if ( myClasses.length ) { + generate( 'class', 'Class: ' + myClasses[0].name, myClasses, helper.longnameToUrl[longname] ); + } + + var myModules = helper.find( modules, {longname : longname} ); + if ( myModules.length ) { + generate( 'module', 'Module: ' + myModules[0].name, myModules, helper.longnameToUrl[longname] ); + } + + var myNamespaces = helper.find( namespaces, {longname : longname} ); + if ( myNamespaces.length ) { + generate( 'namespace', 'Namespace: ' + myNamespaces[0].name, myNamespaces, helper.longnameToUrl[longname] ); + } + + var myMixins = helper.find( mixins, {longname : longname} ); + if ( myMixins.length ) { + generate( 'mixin', 'Mixin: ' + myMixins[0].name, myMixins, helper.longnameToUrl[longname] ); + } + + var myExternals = helper.find( externals, {longname : longname} ); + if ( myExternals.length ) { + generate( 'external', 'External: ' + myExternals[0].name, myExternals, helper.longnameToUrl[longname] ); + } + } + } + + // TODO: move the tutorial functions to templateHelper.js + function generateTutorial( title, tutorial, filename ) { + var tutorialData = { + title : title, + header : tutorial.title, + content : tutorial.parse(), + children : tutorial.children, + docs : null + }; + + var tutorialPath = path.join( outdir, filename ), + html = view.render( 'tutorial.tmpl', tutorialData ); + + // yes, you can use {@link} in tutorials too! + html = helper.resolveLinks( html ); // turn {@link foo} into foo + + fs.writeFileSync( tutorialPath, html, 'utf8' ); + } + + // tutorials can have only one parent so there is no risk for loops + function saveChildren( node ) { + node.children.forEach( function ( child ) { + generateTutorial( 'tutorial' + child.title, child, helper.tutorialToUrl( child.name ) ); + saveChildren( child ); + } ); + } + + saveChildren( tutorials ); +}; diff --git a/docs/build/docstrap-master/template/static/img/glyphicons-halflings-white.png b/docs/build/docstrap-master/template/static/img/glyphicons-halflings-white.png new file mode 100644 index 00000000..3bf6484a Binary files /dev/null and b/docs/build/docstrap-master/template/static/img/glyphicons-halflings-white.png differ diff --git a/docs/build/docstrap-master/template/static/img/glyphicons-halflings.png b/docs/build/docstrap-master/template/static/img/glyphicons-halflings.png new file mode 100644 index 00000000..a9969993 Binary files /dev/null and b/docs/build/docstrap-master/template/static/img/glyphicons-halflings.png differ diff --git a/docs/build/docstrap-master/template/static/scripts/URI.js b/docs/build/docstrap-master/template/static/scripts/URI.js new file mode 100644 index 00000000..91b01ee4 --- /dev/null +++ b/docs/build/docstrap-master/template/static/scripts/URI.js @@ -0,0 +1,1429 @@ +/*! + * URI.js - Mutating URLs + * + * Version: 1.8.3 + * + * Author: Rodney Rehm + * Web: http://medialize.github.com/URI.js/ + * + * Licensed under + * MIT License http://www.opensource.org/licenses/mit-license + * GPL v3 http://opensource.org/licenses/GPL-3.0 + * + */ +(function(root, factory) { + // https://github.com/umdjs/umd/blob/master/returnExports.js + if (typeof exports === 'object') { + // Node + module.exports = factory(require('./punycode'), require('./IPv6'), require('./SecondLevelDomains')); + } else if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['./punycode', './IPv6', './SecondLevelDomains'], factory); + } else { + // Browser globals (root is window) + root.URI = factory(root.punycode, root.IPv6, root.SecondLevelDomains); + } +}(this, function(punycode, IPv6, SLD) { + "use strict"; + + function URI(url, base) { + // Allow instantiation without the 'new' keyword + if (!(this instanceof URI)) { + return new URI(url, base); + } + if (url === undefined) { + if (typeof location !== 'undefined') { + url = location.href + ""; + } else { + url = ""; + } + } + this.href(url); + // resolve to base according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#constructor + if (base !== undefined) { + return this.absoluteTo(base); + } + return this; + }; + var p = URI.prototype; + var hasOwn = Object.prototype.hasOwnProperty; + + function escapeRegEx(string) { + // https://github.com/medialize/URI.js/commit/85ac21783c11f8ccab06106dba9735a31a86924d#commitcomment-821963 + return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); + } + + function isArray(obj) { + return String(Object.prototype.toString.call(obj)) === "[object Array]"; + } + + function filterArrayValues(data, value) { + var lookup = {}; + var i, length; + if (isArray(value)) { + for (i = 0, length = value.length; i < length; i++) { + lookup[value[i]] = true; + } + } else { + lookup[value] = true; + } + for (i = 0, length = data.length; i < length; i++) { + if (lookup[data[i]] !== undefined) { + data.splice(i, 1); + length--; + i--; + } + } + return data; + } + URI._parts = function() { + return { + protocol: null, + username: null, + password: null, + hostname: null, + urn: null, + port: null, + path: null, + query: null, + fragment: null, + // state + duplicateQueryParameters: URI.duplicateQueryParameters + }; + }; + // state: allow duplicate query parameters (a=1&a=1) + URI.duplicateQueryParameters = false; + // static properties + URI.protocol_expression = /^[a-z][a-z0-9-+-]*$/i; + URI.idn_expression = /[^a-z0-9\.-]/i; + URI.punycode_expression = /(xn--)/i; + // well, 333.444.555.666 matches, but it sure ain't no IPv4 - do we care? + URI.ip4_expression = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; + // credits to Rich Brown + // source: http://forums.intermapper.com/viewtopic.php?p=1096#1096 + // specification: http://www.ietf.org/rfc/rfc4291.txt + URI.ip6_expression = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/; + // gruber revised expression - http://rodneyrehm.de/t/url-regex.html + URI.find_uri_expression = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig; + // http://www.iana.org/assignments/uri-schemes.html + // http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers#Well-known_ports + URI.defaultPorts = { + http: "80", + https: "443", + ftp: "21", + gopher: "70", + ws: "80", + wss: "443" + }; + // allowed hostname characters according to RFC 3986 + // ALPHA DIGIT "-" "." "_" "~" "!" "$" "&" "'" "(" ")" "*" "+" "," ";" "=" %encoded + // I've never seen a (non-IDN) hostname other than: ALPHA DIGIT . - + URI.invalid_hostname_characters = /[^a-zA-Z0-9\.-]/; + // encoding / decoding according to RFC3986 + + function strictEncodeURIComponent(string) { + // see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/encodeURIComponent + return encodeURIComponent(string).replace(/[!'()*]/g, escape).replace(/\*/g, "%2A"); + } + URI.encode = strictEncodeURIComponent; + URI.decode = decodeURIComponent; + URI.iso8859 = function() { + URI.encode = escape; + URI.decode = unescape; + }; + URI.unicode = function() { + URI.encode = strictEncodeURIComponent; + URI.decode = decodeURIComponent; + }; + URI.characters = { + pathname: { + encode: { + // RFC3986 2.1: For consistency, URI producers and normalizers should + // use uppercase hexadecimal digits for all percent-encodings. + expression: /%(24|26|2B|2C|3B|3D|3A|40)/ig, + map: { + // -._~!'()* + "%24": "$", + "%26": "&", + "%2B": "+", + "%2C": ",", + "%3B": ";", + "%3D": "=", + "%3A": ":", + "%40": "@" + } + }, + decode: { + expression: /[\/\?#]/g, + map: { + "/": "%2F", + "?": "%3F", + "#": "%23" + } + } + }, + reserved: { + encode: { + // RFC3986 2.1: For consistency, URI producers and normalizers should + // use uppercase hexadecimal digits for all percent-encodings. + expression: /%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig, + map: { + // gen-delims + "%3A": ":", + "%2F": "/", + "%3F": "?", + "%23": "#", + "%5B": "[", + "%5D": "]", + "%40": "@", + // sub-delims + "%21": "!", + "%24": "$", + "%26": "&", + "%27": "'", + "%28": "(", + "%29": ")", + "%2A": "*", + "%2B": "+", + "%2C": ",", + "%3B": ";", + "%3D": "=" + } + } + } + }; + URI.encodeQuery = function(string) { + return URI.encode(string + "").replace(/%20/g, '+'); + }; + URI.decodeQuery = function(string) { + return URI.decode((string + "").replace(/\+/g, '%20')); + }; + URI.recodePath = function(string) { + var segments = (string + "").split('/'); + for (var i = 0, length = segments.length; i < length; i++) { + segments[i] = URI.encodePathSegment(URI.decode(segments[i])); + } + return segments.join('/'); + }; + URI.decodePath = function(string) { + var segments = (string + "").split('/'); + for (var i = 0, length = segments.length; i < length; i++) { + segments[i] = URI.decodePathSegment(segments[i]); + } + return segments.join('/'); + }; + // generate encode/decode path functions + var _parts = { + 'encode': 'encode', + 'decode': 'decode' + }; + var _part; + var generateAccessor = function(_group, _part) { + return function(string) { + return URI[_part](string + "").replace(URI.characters[_group][_part].expression, function(c) { + return URI.characters[_group][_part].map[c]; + }); + }; + }; + for (_part in _parts) { + URI[_part + "PathSegment"] = generateAccessor("pathname", _parts[_part]); + } + URI.encodeReserved = generateAccessor("reserved", "encode"); + URI.parse = function(string, parts) { + var pos, t; + if (!parts) { + parts = {}; + } + // [protocol"://"[username[":"password]"@"]hostname[":"port]"/"?][path]["?"querystring]["#"fragment] + // extract fragment + pos = string.indexOf('#'); + if (pos > -1) { + // escaping? + parts.fragment = string.substring(pos + 1) || null; + string = string.substring(0, pos); + } + // extract query + pos = string.indexOf('?'); + if (pos > -1) { + // escaping? + parts.query = string.substring(pos + 1) || null; + string = string.substring(0, pos); + } + // extract protocol + if (string.substring(0, 2) === '//') { + // relative-scheme + parts.protocol = ''; + string = string.substring(2); + // extract "user:pass@host:port" + string = URI.parseAuthority(string, parts); + } else { + pos = string.indexOf(':'); + if (pos > -1) { + parts.protocol = string.substring(0, pos); + if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) { + // : may be within the path + parts.protocol = undefined; + } else if (parts.protocol === 'file') { + // the file scheme: does not contain an authority + string = string.substring(pos + 3); + } else if (string.substring(pos + 1, pos + 3) === '//') { + string = string.substring(pos + 3); + // extract "user:pass@host:port" + string = URI.parseAuthority(string, parts); + } else { + string = string.substring(pos + 1); + parts.urn = true; + } + } + } + // what's left must be the path + parts.path = string; + // and we're done + return parts; + }; + URI.parseHost = function(string, parts) { + // extract host:port + var pos = string.indexOf('/'); + var bracketPos; + var t; + if (pos === -1) { + pos = string.length; + } + if (string[0] === "[") { + // IPv6 host - http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04#section-6 + // I claim most client software breaks on IPv6 anyways. To simplify things, URI only accepts + // IPv6+port in the format [2001:db8::1]:80 (for the time being) + bracketPos = string.indexOf(']'); + parts.hostname = string.substring(1, bracketPos) || null; + parts.port = string.substring(bracketPos + 2, pos) || null; + } else if (string.indexOf(':') !== string.lastIndexOf(':')) { + // IPv6 host contains multiple colons - but no port + // this notation is actually not allowed by RFC 3986, but we're a liberal parser + parts.hostname = string.substring(0, pos) || null; + parts.port = null; + } else { + t = string.substring(0, pos).split(':'); + parts.hostname = t[0] || null; + parts.port = t[1] || null; + } + if (parts.hostname && string.substring(pos)[0] !== '/') { + pos++; + string = "/" + string; + } + return string.substring(pos) || '/'; + }; + URI.parseAuthority = function(string, parts) { + string = URI.parseUserinfo(string, parts); + return URI.parseHost(string, parts); + }; + URI.parseUserinfo = function(string, parts) { + // extract username:password + var pos = string.indexOf('@'); + var firstSlash = string.indexOf('/'); + var t; + // authority@ must come before /path + if (pos > -1 && (firstSlash === -1 || pos < firstSlash)) { + t = string.substring(0, pos).split(':'); + parts.username = t[0] ? URI.decode(t[0]) : null; + t.shift(); + parts.password = t[0] ? URI.decode(t.join(':')) : null; + string = string.substring(pos + 1); + } else { + parts.username = null; + parts.password = null; + } + return string; + }; + URI.parseQuery = function(string) { + if (!string) { + return {}; + } + // throw out the funky business - "?"[name"="value"&"]+ + string = string.replace(/&+/g, '&').replace(/^\?*&*|&+$/g, ''); + if (!string) { + return {}; + } + var items = {}; + var splits = string.split('&'); + var length = splits.length; + var v, name, value; + for (var i = 0; i < length; i++) { + v = splits[i].split('='); + name = URI.decodeQuery(v.shift()); + // no "=" is null according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#collect-url-parameters + value = v.length ? URI.decodeQuery(v.join('=')) : null; + if (items[name]) { + if (typeof items[name] === "string") { + items[name] = [items[name]]; + } + items[name].push(value); + } else { + items[name] = value; + } + } + return items; + }; + URI.build = function(parts) { + var t = ""; + if (parts.protocol) { + t += parts.protocol + ":"; + } + if (!parts.urn && (t || parts.hostname)) { + t += '//'; + } + t += (URI.buildAuthority(parts) || ''); + if (typeof parts.path === "string") { + if (parts.path[0] !== '/' && typeof parts.hostname === "string") { + t += '/'; + } + t += parts.path; + } + if (typeof parts.query === "string" && parts.query) { + t += '?' + parts.query; + } + if (typeof parts.fragment === "string" && parts.fragment) { + t += '#' + parts.fragment; + } + return t; + }; + URI.buildHost = function(parts) { + var t = ""; + if (!parts.hostname) { + return ""; + } else if (URI.ip6_expression.test(parts.hostname)) { + if (parts.port) { + t += "[" + parts.hostname + "]:" + parts.port; + } else { + // don't know if we should always wrap IPv6 in [] + // the RFC explicitly says SHOULD, not MUST. + t += parts.hostname; + } + } else { + t += parts.hostname; + if (parts.port) { + t += ':' + parts.port; + } + } + return t; + }; + URI.buildAuthority = function(parts) { + return URI.buildUserinfo(parts) + URI.buildHost(parts); + }; + URI.buildUserinfo = function(parts) { + var t = ""; + if (parts.username) { + t += URI.encode(parts.username); + if (parts.password) { + t += ':' + URI.encode(parts.password); + } + t += "@"; + } + return t; + }; + URI.buildQuery = function(data, duplicates) { + // according to http://tools.ietf.org/html/rfc3986 or http://labs.apache.org/webarch/uri/rfc/rfc3986.html + // being »-._~!$&'()*+,;=:@/?« %HEX and alnum are allowed + // the RFC explicitly states ?/foo being a valid use case, no mention of parameter syntax! + // URI.js treats the query string as being application/x-www-form-urlencoded + // see http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type + var t = ""; + var unique, key, i, length; + for (key in data) { + if (hasOwn.call(data, key) && key) { + if (isArray(data[key])) { + unique = {}; + for (i = 0, length = data[key].length; i < length; i++) { + if (data[key][i] !== undefined && unique[data[key][i] + ""] === undefined) { + t += "&" + URI.buildQueryParameter(key, data[key][i]); + if (duplicates !== true) { + unique[data[key][i] + ""] = true; + } + } + } + } else if (data[key] !== undefined) { + t += '&' + URI.buildQueryParameter(key, data[key]); + } + } + } + return t.substring(1); + }; + URI.buildQueryParameter = function(name, value) { + // http://www.w3.org/TR/REC-html40/interact/forms.html#form-content-type -- application/x-www-form-urlencoded + // don't append "=" for null values, according to http://dvcs.w3.org/hg/url/raw-file/tip/Overview.html#url-parameter-serialization + return URI.encodeQuery(name) + (value !== null ? "=" + URI.encodeQuery(value) : ""); + }; + URI.addQuery = function(data, name, value) { + if (typeof name === "object") { + for (var key in name) { + if (hasOwn.call(name, key)) { + URI.addQuery(data, key, name[key]); + } + } + } else if (typeof name === "string") { + if (data[name] === undefined) { + data[name] = value; + return; + } else if (typeof data[name] === "string") { + data[name] = [data[name]]; + } + if (!isArray(value)) { + value = [value]; + } + data[name] = data[name].concat(value); + } else { + throw new TypeError("URI.addQuery() accepts an object, string as the name parameter"); + } + }; + URI.removeQuery = function(data, name, value) { + var i, length, key; + if (isArray(name)) { + for (i = 0, length = name.length; i < length; i++) { + data[name[i]] = undefined; + } + } else if (typeof name === "object") { + for (key in name) { + if (hasOwn.call(name, key)) { + URI.removeQuery(data, key, name[key]); + } + } + } else if (typeof name === "string") { + if (value !== undefined) { + if (data[name] === value) { + data[name] = undefined; + } else if (isArray(data[name])) { + data[name] = filterArrayValues(data[name], value); + } + } else { + data[name] = undefined; + } + } else { + throw new TypeError("URI.addQuery() accepts an object, string as the first parameter"); + } + }; + URI.commonPath = function(one, two) { + var length = Math.min(one.length, two.length); + var pos; + // find first non-matching character + for (pos = 0; pos < length; pos++) { + if (one[pos] !== two[pos]) { + pos--; + break; + } + } + if (pos < 1) { + return one[0] === two[0] && one[0] === '/' ? '/' : ''; + } + // revert to last / + if (one[pos] !== '/') { + pos = one.substring(0, pos).lastIndexOf('/'); + } + return one.substring(0, pos + 1); + }; + URI.withinString = function(string, callback) { + // expression used is "gruber revised" (@gruber v2) determined to be the best solution in + // a regex sprint we did a couple of ages ago at + // * http://mathiasbynens.be/demo/url-regex + // * http://rodneyrehm.de/t/url-regex.html + return string.replace(URI.find_uri_expression, callback); + }; + URI.ensureValidHostname = function(v) { + // Theoretically URIs allow percent-encoding in Hostnames (according to RFC 3986) + // they are not part of DNS and therefore ignored by URI.js + if (v.match(URI.invalid_hostname_characters)) { + // test punycode + if (!punycode) { + throw new TypeError("Hostname '" + v + "' contains characters other than [A-Z0-9.-] and Punycode.js is not available"); + } + if (punycode.toASCII(v).match(URI.invalid_hostname_characters)) { + throw new TypeError("Hostname '" + v + "' contains characters other than [A-Z0-9.-]"); + } + } + }; + p.build = function(deferBuild) { + if (deferBuild === true) { + this._deferred_build = true; + } else if (deferBuild === undefined || this._deferred_build) { + this._string = URI.build(this._parts); + this._deferred_build = false; + } + return this; + }; + p.clone = function() { + return new URI(this); + }; + p.valueOf = p.toString = function() { + return this.build(false)._string; + }; + // generate simple accessors + _parts = { + protocol: 'protocol', + username: 'username', + password: 'password', + hostname: 'hostname', + port: 'port' + }; + generateAccessor = function(_part) { + return function(v, build) { + if (v === undefined) { + return this._parts[_part] || ""; + } else { + this._parts[_part] = v; + this.build(!build); + return this; + } + }; + }; + for (_part in _parts) { + p[_part] = generateAccessor(_parts[_part]); + } + // generate accessors with optionally prefixed input + _parts = { + query: '?', + fragment: '#' + }; + generateAccessor = function(_part, _key) { + return function(v, build) { + if (v === undefined) { + return this._parts[_part] || ""; + } else { + if (v !== null) { + v = v + ""; + if (v[0] === _key) { + v = v.substring(1); + } + } + this._parts[_part] = v; + this.build(!build); + return this; + } + }; + }; + for (_part in _parts) { + p[_part] = generateAccessor(_part, _parts[_part]); + } + // generate accessors with prefixed output + _parts = { + search: ['?', 'query'], + hash: ['#', 'fragment'] + }; + generateAccessor = function(_part, _key) { + return function(v, build) { + var t = this[_part](v, build); + return typeof t === "string" && t.length ? (_key + t) : t; + }; + }; + for (_part in _parts) { + p[_part] = generateAccessor(_parts[_part][1], _parts[_part][0]); + } + p.pathname = function(v, build) { + if (v === undefined || v === true) { + var res = this._parts.path || (this._parts.urn ? '' : '/'); + return v ? URI.decodePath(res) : res; + } else { + this._parts.path = v ? URI.recodePath(v) : "/"; + this.build(!build); + return this; + } + }; + p.path = p.pathname; + p.href = function(href, build) { + var key; + if (href === undefined) { + return this.toString(); + } + this._string = ""; + this._parts = URI._parts(); + var _URI = href instanceof URI; + var _object = typeof href === "object" && (href.hostname || href.path); + // window.location is reported to be an object, but it's not the sort + // of object we're looking for: + // * location.protocol ends with a colon + // * location.query != object.search + // * location.hash != object.fragment + // simply serializing the unknown object should do the trick + // (for location, not for everything...) + if (!_URI && _object && Object.prototype.toString.call(href) !== "[object Object]") { + href = href.toString(); + } + if (typeof href === "string") { + this._parts = URI.parse(href, this._parts); + } else if (_URI || _object) { + var src = _URI ? href._parts : href; + for (key in src) { + if (hasOwn.call(this._parts, key)) { + this._parts[key] = src[key]; + } + } + } else { + throw new TypeError("invalid input"); + } + this.build(!build); + return this; + }; + // identification accessors + p.is = function(what) { + var ip = false; + var ip4 = false; + var ip6 = false; + var name = false; + var sld = false; + var idn = false; + var punycode = false; + var relative = !this._parts.urn; + if (this._parts.hostname) { + relative = false; + ip4 = URI.ip4_expression.test(this._parts.hostname); + ip6 = URI.ip6_expression.test(this._parts.hostname); + ip = ip4 || ip6; + name = !ip; + sld = name && SLD && SLD.has(this._parts.hostname); + idn = name && URI.idn_expression.test(this._parts.hostname); + punycode = name && URI.punycode_expression.test(this._parts.hostname); + } + switch (what.toLowerCase()) { + case 'relative': + return relative; + case 'absolute': + return !relative; + // hostname identification + case 'domain': + case 'name': + return name; + case 'sld': + return sld; + case 'ip': + return ip; + case 'ip4': + case 'ipv4': + case 'inet4': + return ip4; + case 'ip6': + case 'ipv6': + case 'inet6': + return ip6; + case 'idn': + return idn; + case 'url': + return !this._parts.urn; + case 'urn': + return !!this._parts.urn; + case 'punycode': + return punycode; + } + return null; + }; + // component specific input validation + var _protocol = p.protocol; + var _port = p.port; + var _hostname = p.hostname; + p.protocol = function(v, build) { + if (v !== undefined) { + if (v) { + // accept trailing :// + v = v.replace(/:(\/\/)?$/, ''); + if (v.match(/[^a-zA-z0-9\.+-]/)) { + throw new TypeError("Protocol '" + v + "' contains characters other than [A-Z0-9.+-]"); + } + } + } + return _protocol.call(this, v, build); + }; + p.scheme = p.protocol; + p.port = function(v, build) { + if (this._parts.urn) { + return v === undefined ? '' : this; + } + if (v !== undefined) { + if (v === 0) { + v = null; + } + if (v) { + v += ""; + if (v[0] === ":") { + v = v.substring(1); + } + if (v.match(/[^0-9]/)) { + throw new TypeError("Port '" + v + "' contains characters other than [0-9]"); + } + } + } + return _port.call(this, v, build); + }; + p.hostname = function(v, build) { + if (this._parts.urn) { + return v === undefined ? '' : this; + } + if (v !== undefined) { + var x = {}; + URI.parseHost(v, x); + v = x.hostname; + } + return _hostname.call(this, v, build); + }; + // compound accessors + p.host = function(v, build) { + if (this._parts.urn) { + return v === undefined ? '' : this; + } + if (v === undefined) { + return this._parts.hostname ? URI.buildHost(this._parts) : ""; + } else { + URI.parseHost(v, this._parts); + this.build(!build); + return this; + } + }; + p.authority = function(v, build) { + if (this._parts.urn) { + return v === undefined ? '' : this; + } + if (v === undefined) { + return this._parts.hostname ? URI.buildAuthority(this._parts) : ""; + } else { + URI.parseAuthority(v, this._parts); + this.build(!build); + return this; + } + }; + p.userinfo = function(v, build) { + if (this._parts.urn) { + return v === undefined ? '' : this; + } + if (v === undefined) { + if (!this._parts.username) { + return ""; + } + var t = URI.buildUserinfo(this._parts); + return t.substring(0, t.length - 1); + } else { + if (v[v.length - 1] !== '@') { + v += '@'; + } + URI.parseUserinfo(v, this._parts); + this.build(!build); + return this; + } + }; + p.resource = function(v, build) { + var parts; + if (v === undefined) { + return this.path() + this.search() + this.hash(); + } + parts = URI.parse(v); + this._parts.path = parts.path; + this._parts.query = parts.query; + this._parts.fragment = parts.fragment; + this.build(!build); + return this; + }; + // fraction accessors + p.subdomain = function(v, build) { + if (this._parts.urn) { + return v === undefined ? '' : this; + } + // convenience, return "www" from "www.example.org" + if (v === undefined) { + if (!this._parts.hostname || this.is('IP')) { + return ""; + } + // grab domain and add another segment + var end = this._parts.hostname.length - this.domain().length - 1; + return this._parts.hostname.substring(0, end) || ""; + } else { + var e = this._parts.hostname.length - this.domain().length; + var sub = this._parts.hostname.substring(0, e); + var replace = new RegExp('^' + escapeRegEx(sub)); + if (v && v[v.length - 1] !== '.') { + v += "."; + } + if (v) { + URI.ensureValidHostname(v); + } + this._parts.hostname = this._parts.hostname.replace(replace, v); + this.build(!build); + return this; + } + }; + p.domain = function(v, build) { + if (this._parts.urn) { + return v === undefined ? '' : this; + } + if (typeof v === 'boolean') { + build = v; + v = undefined; + } + // convenience, return "example.org" from "www.example.org" + if (v === undefined) { + if (!this._parts.hostname || this.is('IP')) { + return ""; + } + // if hostname consists of 1 or 2 segments, it must be the domain + var t = this._parts.hostname.match(/\./g); + if (t && t.length < 2) { + return this._parts.hostname; + } + // grab tld and add another segment + var end = this._parts.hostname.length - this.tld(build).length - 1; + end = this._parts.hostname.lastIndexOf('.', end - 1) + 1; + return this._parts.hostname.substring(end) || ""; + } else { + if (!v) { + throw new TypeError("cannot set domain empty"); + } + URI.ensureValidHostname(v); + if (!this._parts.hostname || this.is('IP')) { + this._parts.hostname = v; + } else { + var replace = new RegExp(escapeRegEx(this.domain()) + "$"); + this._parts.hostname = this._parts.hostname.replace(replace, v); + } + this.build(!build); + return this; + } + }; + p.tld = function(v, build) { + if (this._parts.urn) { + return v === undefined ? '' : this; + } + if (typeof v === 'boolean') { + build = v; + v = undefined; + } + // return "org" from "www.example.org" + if (v === undefined) { + if (!this._parts.hostname || this.is('IP')) { + return ""; + } + var pos = this._parts.hostname.lastIndexOf('.'); + var tld = this._parts.hostname.substring(pos + 1); + if (build !== true && SLD && SLD.list[tld.toLowerCase()]) { + return SLD.get(this._parts.hostname) || tld; + } + return tld; + } else { + var replace; + if (!v) { + throw new TypeError("cannot set TLD empty"); + } else if (v.match(/[^a-zA-Z0-9-]/)) { + if (SLD && SLD.is(v)) { + replace = new RegExp(escapeRegEx(this.tld()) + "$"); + this._parts.hostname = this._parts.hostname.replace(replace, v); + } else { + throw new TypeError("TLD '" + v + "' contains characters other than [A-Z0-9]"); + } + } else if (!this._parts.hostname || this.is('IP')) { + throw new ReferenceError("cannot set TLD on non-domain host"); + } else { + replace = new RegExp(escapeRegEx(this.tld()) + "$"); + this._parts.hostname = this._parts.hostname.replace(replace, v); + } + this.build(!build); + return this; + } + }; + p.directory = function(v, build) { + if (this._parts.urn) { + return v === undefined ? '' : this; + } + if (v === undefined || v === true) { + if (!this._parts.path && !this._parts.hostname) { + return ''; + } + if (this._parts.path === '/') { + return '/'; + } + var end = this._parts.path.length - this.filename().length - 1; + var res = this._parts.path.substring(0, end) || (this._parts.hostname ? "/" : ""); + return v ? URI.decodePath(res) : res; + } else { + var e = this._parts.path.length - this.filename().length; + var directory = this._parts.path.substring(0, e); + var replace = new RegExp('^' + escapeRegEx(directory)); + // fully qualifier directories begin with a slash + if (!this.is('relative')) { + if (!v) { + v = '/'; + } + if (v[0] !== '/') { + v = "/" + v; + } + } + // directories always end with a slash + if (v && v[v.length - 1] !== '/') { + v += '/'; + } + v = URI.recodePath(v); + this._parts.path = this._parts.path.replace(replace, v); + this.build(!build); + return this; + } + }; + p.filename = function(v, build) { + if (this._parts.urn) { + return v === undefined ? '' : this; + } + if (v === undefined || v === true) { + if (!this._parts.path || this._parts.path === '/') { + return ""; + } + var pos = this._parts.path.lastIndexOf('/'); + var res = this._parts.path.substring(pos + 1); + return v ? URI.decodePathSegment(res) : res; + } else { + var mutatedDirectory = false; + if (v[0] === '/') { + v = v.substring(1); + } + if (v.match(/\.?\//)) { + mutatedDirectory = true; + } + var replace = new RegExp(escapeRegEx(this.filename()) + "$"); + v = URI.recodePath(v); + this._parts.path = this._parts.path.replace(replace, v); + if (mutatedDirectory) { + this.normalizePath(build); + } else { + this.build(!build); + } + return this; + } + }; + p.suffix = function(v, build) { + if (this._parts.urn) { + return v === undefined ? '' : this; + } + if (v === undefined || v === true) { + if (!this._parts.path || this._parts.path === '/') { + return ""; + } + var filename = this.filename(); + var pos = filename.lastIndexOf('.'); + var s, res; + if (pos === -1) { + return ""; + } + // suffix may only contain alnum characters (yup, I made this up.) + s = filename.substring(pos + 1); + res = (/^[a-z0-9%]+$/i).test(s) ? s : ""; + return v ? URI.decodePathSegment(res) : res; + } else { + if (v[0] === '.') { + v = v.substring(1); + } + var suffix = this.suffix(); + var replace; + if (!suffix) { + if (!v) { + return this; + } + this._parts.path += '.' + URI.recodePath(v); + } else if (!v) { + replace = new RegExp(escapeRegEx("." + suffix) + "$"); + } else { + replace = new RegExp(escapeRegEx(suffix) + "$"); + } + if (replace) { + v = URI.recodePath(v); + this._parts.path = this._parts.path.replace(replace, v); + } + this.build(!build); + return this; + } + }; + p.segment = function(segment, v, build) { + var separator = this._parts.urn ? ':' : '/'; + var path = this.path(); + var absolute = path.substring(0, 1) === '/'; + var segments = path.split(separator); + if (typeof segment !== 'number') { + build = v; + v = segment; + segment = undefined; + } + if (segment !== undefined && typeof segment !== 'number') { + throw new Error("Bad segment '" + segment + "', must be 0-based integer"); + } + if (absolute) { + segments.shift(); + } + if (segment < 0) { + // allow negative indexes to address from the end + segment = Math.max(segments.length + segment, 0); + } + if (v === undefined) { + return segment === undefined ? segments : segments[segment]; + } else if (segment === null || segments[segment] === undefined) { + if (isArray(v)) { + segments = v; + } else if (v || (typeof v === "string" && v.length)) { + if (segments[segments.length - 1] === "") { + // empty trailing elements have to be overwritten + // to prefent results such as /foo//bar + segments[segments.length - 1] = v; + } else { + segments.push(v); + } + } + } else { + if (v || (typeof v === "string" && v.length)) { + segments[segment] = v; + } else { + segments.splice(segment, 1); + } + } + if (absolute) { + segments.unshift(""); + } + return this.path(segments.join(separator), build); + }; + // mutating query string + var q = p.query; + p.query = function(v, build) { + if (v === true) { + return URI.parseQuery(this._parts.query); + } else if (v !== undefined && typeof v !== "string") { + this._parts.query = URI.buildQuery(v, this._parts.duplicateQueryParameters); + this.build(!build); + return this; + } else { + return q.call(this, v, build); + } + }; + p.addQuery = function(name, value, build) { + var data = URI.parseQuery(this._parts.query); + URI.addQuery(data, name, value === undefined ? null : value); + this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters); + if (typeof name !== "string") { + build = value; + } + this.build(!build); + return this; + }; + p.removeQuery = function(name, value, build) { + var data = URI.parseQuery(this._parts.query); + URI.removeQuery(data, name, value); + this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters); + if (typeof name !== "string") { + build = value; + } + this.build(!build); + return this; + }; + p.addSearch = p.addQuery; + p.removeSearch = p.removeQuery; + // sanitizing URLs + p.normalize = function() { + if (this._parts.urn) { + return this.normalizeProtocol(false).normalizeQuery(false).normalizeFragment(false).build(); + } + return this.normalizeProtocol(false).normalizeHostname(false).normalizePort(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build(); + }; + p.normalizeProtocol = function(build) { + if (typeof this._parts.protocol === "string") { + this._parts.protocol = this._parts.protocol.toLowerCase(); + this.build(!build); + } + return this; + }; + p.normalizeHostname = function(build) { + if (this._parts.hostname) { + if (this.is('IDN') && punycode) { + this._parts.hostname = punycode.toASCII(this._parts.hostname); + } else if (this.is('IPv6') && IPv6) { + this._parts.hostname = IPv6.best(this._parts.hostname); + } + this._parts.hostname = this._parts.hostname.toLowerCase(); + this.build(!build); + } + return this; + }; + p.normalizePort = function(build) { + // remove port of it's the protocol's default + if (typeof this._parts.protocol === "string" && this._parts.port === URI.defaultPorts[this._parts.protocol]) { + this._parts.port = null; + this.build(!build); + } + return this; + }; + p.normalizePath = function(build) { + if (this._parts.urn) { + return this; + } + if (!this._parts.path || this._parts.path === '/') { + return this; + } + var _was_relative; + var _was_relative_prefix; + var _path = this._parts.path; + var _parent, _pos; + // handle relative paths + if (_path[0] !== '/') { + if (_path[0] === '.') { + _was_relative_prefix = _path.substring(0, _path.indexOf('/')); + } + _was_relative = true; + _path = '/' + _path; + } + // resolve simples + _path = _path.replace(/(\/(\.\/)+)|\/{2,}/g, '/'); + // resolve parents + while (true) { + _parent = _path.indexOf('/../'); + if (_parent === -1) { + // no more ../ to resolve + break; + } else if (_parent === 0) { + // top level cannot be relative... + _path = _path.substring(3); + break; + } + _pos = _path.substring(0, _parent).lastIndexOf('/'); + if (_pos === -1) { + _pos = _parent; + } + _path = _path.substring(0, _pos) + _path.substring(_parent + 3); + } + // revert to relative + if (_was_relative && this.is('relative')) { + if (_was_relative_prefix) { + _path = _was_relative_prefix + _path; + } else { + _path = _path.substring(1); + } + } + _path = URI.recodePath(_path); + this._parts.path = _path; + this.build(!build); + return this; + }; + p.normalizePathname = p.normalizePath; + p.normalizeQuery = function(build) { + if (typeof this._parts.query === "string") { + if (!this._parts.query.length) { + this._parts.query = null; + } else { + this.query(URI.parseQuery(this._parts.query)); + } + this.build(!build); + } + return this; + }; + p.normalizeFragment = function(build) { + if (!this._parts.fragment) { + this._parts.fragment = null; + this.build(!build); + } + return this; + }; + p.normalizeSearch = p.normalizeQuery; + p.normalizeHash = p.normalizeFragment; + p.iso8859 = function() { + // expect unicode input, iso8859 output + var e = URI.encode; + var d = URI.decode; + URI.encode = escape; + URI.decode = decodeURIComponent; + this.normalize(); + URI.encode = e; + URI.decode = d; + return this; + }; + p.unicode = function() { + // expect iso8859 input, unicode output + var e = URI.encode; + var d = URI.decode; + URI.encode = strictEncodeURIComponent; + URI.decode = unescape; + this.normalize(); + URI.encode = e; + URI.decode = d; + return this; + }; + p.readable = function() { + var uri = this.clone(); + // removing username, password, because they shouldn't be displayed according to RFC 3986 + uri.username("").password("").normalize(); + var t = ''; + if (uri._parts.protocol) { + t += uri._parts.protocol + '://'; + } + if (uri._parts.hostname) { + if (uri.is('punycode') && punycode) { + t += punycode.toUnicode(uri._parts.hostname); + if (uri._parts.port) { + t += ":" + uri._parts.port; + } + } else { + t += uri.host(); + } + } + if (uri._parts.hostname && uri._parts.path && uri._parts.path[0] !== '/') { + t += '/'; + } + t += uri.path(true); + if (uri._parts.query) { + var q = ''; + for (var i = 0, qp = uri._parts.query.split('&'), l = qp.length; i < l; i++) { + var kv = (qp[i] || "").split('='); + q += '&' + URI.decodeQuery(kv[0]).replace(/&/g, '%26'); + if (kv[1] !== undefined) { + q += "=" + URI.decodeQuery(kv[1]).replace(/&/g, '%26'); + } + } + t += '?' + q.substring(1); + } + t += uri.hash(); + return t; + }; + // resolving relative and absolute URLs + p.absoluteTo = function(base) { + var resolved = this.clone(); + var properties = ['protocol', 'username', 'password', 'hostname', 'port']; + var basedir, i, p; + if (this._parts.urn) { + throw new Error('URNs do not have any generally defined hierachical components'); + } + if (this._parts.hostname) { + return resolved; + } + if (!(base instanceof URI)) { + base = new URI(base); + } + for (i = 0, p; p = properties[i]; i++) { + resolved._parts[p] = base._parts[p]; + } + properties = ['query', 'path']; + for (i = 0, p; p = properties[i]; i++) { + if (!resolved._parts[p] && base._parts[p]) { + resolved._parts[p] = base._parts[p]; + } + } + if (resolved.path()[0] !== '/') { + basedir = base.directory(); + resolved._parts.path = (basedir ? (basedir + '/') : '') + resolved._parts.path; + resolved.normalizePath(); + } + resolved.build(); + return resolved; + }; + p.relativeTo = function(base) { + var relative = this.clone(); + var properties = ['protocol', 'username', 'password', 'hostname', 'port']; + var common, _base, _this, _base_diff, _this_diff; + if (this._parts.urn) { + throw new Error('URNs do not have any generally defined hierachical components'); + } + if (!(base instanceof URI)) { + base = new URI(base); + } + if (this.path()[0] !== '/' || base.path()[0] !== '/') { + throw new Error('Cannot calculate common path from non-relative URLs'); + } + // determine common sub path + common = URI.commonPath(relative.path(), base.path()); + // no relation if there's nothing in common + if (!common || common === '/') { + return relative; + } + // relative paths don't have authority + for (var i = 0, p; p = properties[i]; i++) { + relative._parts[p] = null; + } + _base = base.directory(); + _this = this.directory(); + // base and this are on the same level + if (_base === _this) { + relative._parts.path = './' + relative.filename(); + return relative.build(); + } + _base_diff = _base.substring(common.length); + _this_diff = _this.substring(common.length); + // this is a descendant of base + if (_base + '/' === common) { + if (_this_diff) { + _this_diff += '/'; + } + relative._parts.path = './' + _this_diff + relative.filename(); + return relative.build(); + } + // this is a descendant of base + var parents = '../'; + var _common = new RegExp('^' + escapeRegEx(common)); + var _parents = _base.replace(_common, '/').match(/\//g).length - 1; + while (_parents--) { + parents += '../'; + } + relative._parts.path = relative._parts.path.replace(_common, parents); + return relative.build(); + }; + // comparing URIs + p.equals = function(uri) { + var one = this.clone(); + var two = new URI(uri); + var one_map = {}; + var two_map = {}; + var checked = {}; + var one_query, two_query, key; + one.normalize(); + two.normalize(); + // exact match + if (one.toString() === two.toString()) { + return true; + } + // extract query string + one_query = one.query(); + two_query = two.query(); + one.query(""); + two.query(""); + // definitely not equal if not even non-query parts match + if (one.toString() !== two.toString()) { + return false; + } + // query parameters have the same length, even if they're permutated + if (one_query.length !== two_query.length) { + return false; + } + one_map = URI.parseQuery(one_query); + two_map = URI.parseQuery(two_query); + for (key in one_map) { + if (hasOwn.call(one_map, key)) { + if (!isArray(one_map[key])) { + if (one_map[key] !== two_map[key]) { + return false; + } + } else { + if (!isArray(two_map[key])) { + return false; + } + // arrays can't be equal if they have different amount of content + if (one_map[key].length !== two_map[key].length) { + return false; + } + one_map[key].sort(); + two_map[key].sort(); + for (var i = 0, l = one_map[key].length; i < l; i++) { + if (one_map[key][i] !== two_map[key][i]) { + return false; + } + } + } + checked[key] = true; + } + } + for (key in two_map) { + if (hasOwn.call(two_map, key)) { + if (!checked[key]) { + // two contains a parameter not present in one + return false; + } + } + } + return true; + }; + // state + p.duplicateQueryParameters = function(v) { + this._parts.duplicateQueryParameters = !! v; + return this; + }; + return URI; +})); \ No newline at end of file diff --git a/docs/build/docstrap-master/template/static/scripts/bootstrap-dropdown.js b/docs/build/docstrap-master/template/static/scripts/bootstrap-dropdown.js new file mode 100644 index 00000000..a1d51519 --- /dev/null +++ b/docs/build/docstrap-master/template/static/scripts/bootstrap-dropdown.js @@ -0,0 +1,165 @@ +/* ============================================================ + * bootstrap-dropdown.js v2.3.1 + * http://twitter.github.com/bootstrap/javascript.html#dropdowns + * ============================================================ + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* DROPDOWN CLASS DEFINITION + * ========================= */ + + var toggle = '[data-toggle=dropdown]' + , Dropdown = function (element) { + var $el = $(element).on('click.dropdown.data-api', this.toggle) + $('html').on('click.dropdown.data-api', function () { + $el.parent().removeClass('open') + }) + } + + Dropdown.prototype = { + + constructor: Dropdown + + , toggle: function (e) { + var $this = $(this) + , $parent + , isActive + + if ($this.is('.disabled, :disabled')) return + + $parent = getParent($this) + + isActive = $parent.hasClass('open') + + clearMenus() + + if (!isActive) { + $parent.toggleClass('open') + } + + $this.focus() + + return false + } + + , keydown: function (e) { + var $this + , $items + , $active + , $parent + , isActive + , index + + if (!/(38|40|27)/.test(e.keyCode)) return + + $this = $(this) + + e.preventDefault() + e.stopPropagation() + + if ($this.is('.disabled, :disabled')) return + + $parent = getParent($this) + + isActive = $parent.hasClass('open') + + if (!isActive || (isActive && e.keyCode == 27)) { + if (e.which == 27) $parent.find(toggle).focus() + return $this.click() + } + + $items = $('[role=menu] li:not(.divider):visible a', $parent) + + if (!$items.length) return + + index = $items.index($items.filter(':focus')) + + if (e.keyCode == 38 && index > 0) index-- // up + if (e.keyCode == 40 && index < $items.length - 1) index++ // down + if (!~index) index = 0 + + $items + .eq(index) + .focus() + } + + } + + function clearMenus() { + $(toggle).each(function () { + getParent($(this)).removeClass('open') + }) + } + + function getParent($this) { + var selector = $this.attr('data-target') + , $parent + + if (!selector) { + selector = $this.attr('href') + selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 + } + + $parent = selector && $(selector) + + if (!$parent || !$parent.length) $parent = $this.parent() + + return $parent + } + + + /* DROPDOWN PLUGIN DEFINITION + * ========================== */ + + var old = $.fn.dropdown + + $.fn.dropdown = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('dropdown') + if (!data) $this.data('dropdown', (data = new Dropdown(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.dropdown.Constructor = Dropdown + + + /* DROPDOWN NO CONFLICT + * ==================== */ + + $.fn.dropdown.noConflict = function () { + $.fn.dropdown = old + return this + } + + + /* APPLY TO STANDARD DROPDOWN ELEMENTS + * =================================== */ + + $(document) + .on('click.dropdown.data-api', clearMenus) + .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) + .on('click.dropdown-menu', function (e) { e.stopPropagation() }) + .on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle) + .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) + +}(window.jQuery); diff --git a/docs/build/docstrap-master/template/static/scripts/bootstrap-tab.js b/docs/build/docstrap-master/template/static/scripts/bootstrap-tab.js new file mode 100644 index 00000000..bd77eb5c --- /dev/null +++ b/docs/build/docstrap-master/template/static/scripts/bootstrap-tab.js @@ -0,0 +1,144 @@ +/* ======================================================== + * bootstrap-tab.js v2.3.0 + * http://twitter.github.com/bootstrap/javascript.html#tabs + * ======================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================== */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* TAB CLASS DEFINITION + * ==================== */ + + var Tab = function (element) { + this.element = $(element) + } + + Tab.prototype = { + + constructor: Tab + + , show: function () { + var $this = this.element + , $ul = $this.closest('ul:not(.dropdown-menu)') + , selector = $this.attr('data-target') + , previous + , $target + , e + + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 + } + + if ( $this.parent('li').hasClass('active') ) return + + previous = $ul.find('.active:last a')[0] + + e = $.Event('show', { + relatedTarget: previous + }) + + $this.trigger(e) + + if (e.isDefaultPrevented()) return + + $target = $(selector) + + this.activate($this.parent('li'), $ul) + this.activate($target, $target.parent(), function () { + $this.trigger({ + type: 'shown' + , relatedTarget: previous + }) + }) + } + + , activate: function ( element, container, callback) { + var $active = container.find('> .active') + , transition = callback + && $.support.transition + && $active.hasClass('fade') + + function next() { + $active + .removeClass('active') + .find('> .dropdown-menu > .active') + .removeClass('active') + + element.addClass('active') + + if (transition) { + element[0].offsetWidth // reflow for transition + element.addClass('in') + } else { + element.removeClass('fade') + } + + if ( element.parent('.dropdown-menu') ) { + element.closest('li.dropdown').addClass('active') + } + + callback && callback() + } + + transition ? + $active.one($.support.transition.end, next) : + next() + + $active.removeClass('in') + } + } + + + /* TAB PLUGIN DEFINITION + * ===================== */ + + var old = $.fn.tab + + $.fn.tab = function ( option ) { + return this.each(function () { + var $this = $(this) + , data = $this.data('tab') + if (!data) $this.data('tab', (data = new Tab(this))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.tab.Constructor = Tab + + + /* TAB NO CONFLICT + * =============== */ + + $.fn.tab.noConflict = function () { + $.fn.tab = old + return this + } + + + /* TAB DATA-API + * ============ */ + + $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { + e.preventDefault() + $(this).tab('show') + }) + +}(window.jQuery); \ No newline at end of file diff --git a/docs/build/docstrap-master/template/static/scripts/jquery.localScroll.js b/docs/build/docstrap-master/template/static/scripts/jquery.localScroll.js new file mode 100644 index 00000000..ef7cc97d --- /dev/null +++ b/docs/build/docstrap-master/template/static/scripts/jquery.localScroll.js @@ -0,0 +1,130 @@ +/*! + * jQuery.LocalScroll + * Copyright (c) 2007-2013 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com + * Dual licensed under MIT and GPL. + * http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html + * @author Ariel Flesler + * @version 1.2.8 + * + * @id jQuery.fn.localScroll + * @param {Object} settings Hash of settings, it is passed in to jQuery.ScrollTo, none is required. + * @return {jQuery} Returns the same jQuery object, for chaining. + * + * @example $('ul.links').localScroll(); + * + * @example $('ul.links').localScroll({ filter:'.animated', duration:400, axis:'x' }); + * + * @example $.localScroll({ target:'#pane', axis:'xy', queue:true, event:'mouseover' }); + * + * Notes: + * - The plugin requires jQuery.ScrollTo. + * - The hash of settings, is passed to jQuery.ScrollTo, so the settings are valid for that plugin as well. + * - jQuery.localScroll can be used if the desired links, are all over the document, it accepts the same settings. + * - If the setting 'lazy' is set to true, then the binding will still work for later added anchors. + * - If onBefore returns false, the event is ignored. + */ +;(function( $ ){ + var URI = location.href.replace(/#.*/,''); // local url without hash + + var $localScroll = $.localScroll = function( settings ){ + $('body').localScroll( settings ); + }; + + // Many of these defaults, belong to jQuery.ScrollTo, check it's demo for an example of each option. + // @see http://flesler.demos.com/jquery/scrollTo/ + // The defaults are public and can be overriden. + $localScroll.defaults = { + duration:1000, // How long to animate. + axis:'y', // Which of top and left should be modified. + event:'click', // On which event to react. + stop:true, // Avoid queuing animations + target: window, // What to scroll (selector or element). The whole window by default. + reset: true // Used by $.localScroll.hash. If true, elements' scroll is resetted before actual scrolling + /* + lock:false, // ignore events if already animating + lazy:false, // if true, links can be added later, and will still work. + filter:null, // filter some anchors out of the matched elements. + hash: false // if true, the hash of the selected link, will appear on the address bar. + */ + }; + + // If the URL contains a hash, it will scroll to the pointed element + $localScroll.hash = function( settings ){ + if( location.hash ){ + settings = $.extend( {}, $localScroll.defaults, settings ); + settings.hash = false; // can't be true + + if( settings.reset ){ + var d = settings.duration; + delete settings.duration; + $(settings.target).scrollTo( 0, settings ); + settings.duration = d; + } + scroll( 0, location, settings ); + } + }; + + $.fn.localScroll = function( settings ){ + settings = $.extend( {}, $localScroll.defaults, settings ); + + return settings.lazy ? + // use event delegation, more links can be added later. + this.bind( settings.event, function( e ){ + // Could use closest(), but that would leave out jQuery -1.3.x + var a = $([e.target, e.target.parentNode]).filter(filter)[0]; + // if a valid link was clicked + if( a ) + scroll( e, a, settings ); // do scroll. + }) : + // bind concretely, to each matching link + this.find('a,area') + .filter( filter ).bind( settings.event, function(e){ + scroll( e, this, settings ); + }).end() + .end(); + + function filter(){// is this a link that points to an anchor and passes a possible filter ? href is checked to avoid a bug in FF. + return !!this.href && !!this.hash && this.href.replace(this.hash,'') == URI && (!settings.filter || $(this).is( settings.filter )); + }; + }; + + function scroll( e, link, settings ){ + var id = link.hash.slice(1), + elem = document.getElementById(id) || document.getElementsByName(id)[0]; + + if ( !elem ) + return; + + if( e ) + e.preventDefault(); + + var $target = $( settings.target ); + + if( settings.lock && $target.is(':animated') || + settings.onBefore && settings.onBefore(e, elem, $target) === false ) + return; + + if( settings.stop ) + $target._scrollable().stop(true); // remove all its animations + + if( settings.hash ){ + var attr = elem.id == id ? 'id' : 'name', + $a = $(' ').attr(attr, id).css({ + position:'absolute', + top: $(window).scrollTop(), + left: $(window).scrollLeft() + }); + + elem[attr] = ''; + $('body').prepend($a); + location = link.hash; + $a.remove(); + elem[attr] = id; + } + + $target + .scrollTo( elem, settings ) // do scroll + .trigger('notify.serialScroll',[elem]); // notify serialScroll about this change + }; + +})( jQuery ); \ No newline at end of file diff --git a/docs/build/docstrap-master/template/static/scripts/jquery.min.js b/docs/build/docstrap-master/template/static/scripts/jquery.min.js new file mode 100644 index 00000000..c73b79b9 --- /dev/null +++ b/docs/build/docstrap-master/template/static/scripts/jquery.min.js @@ -0,0 +1,3522 @@ +/*! jQuery v1.8.3 jquery.com | jquery.org/license */ +(function(e, t) { + function _(e) { + var t = M[e] = {}; + return v.each(e.split(y), function(e, n) { + t[n] = !0 + }), t + } + + function H(e, n, r) { + if (r === t && e.nodeType === 1) { + var i = "data-" + n.replace(P, "-$1").toLowerCase(); + r = e.getAttribute(i); + if (typeof r == "string") { + try { + r = r === "true" ? !0 : r === "false" ? !1 : r === "null" ? null : +r + "" === r ? +r : D.test(r) ? v.parseJSON(r) : r + } catch (s) {} + v.data(e, n, r) + } else r = t + } + return r + } + + function B(e) { + var t; + for (t in e) { + if (t === "data" && v.isEmptyObject(e[t])) continue; + if (t !== "toJSON") return !1 + } + return !0 + } + + function et() { + return !1 + } + + function tt() { + return !0 + } + + function ut(e) { + return !e || !e.parentNode || e.parentNode.nodeType === 11 + } + + function at(e, t) { + do e = e[t]; + while (e && e.nodeType !== 1); + return e + } + + function ft(e, t, n) { + t = t || 0; + if (v.isFunction(t)) return v.grep(e, function(e, r) { + var i = !! t.call(e, r, e); + return i === n + }); + if (t.nodeType) return v.grep(e, function(e, r) { + return e === t === n + }); + if (typeof t == "string") { + var r = v.grep(e, function(e) { + return e.nodeType === 1 + }); + if (it.test(t)) return v.filter(t, r, !n); + t = v.filter(t, r) + } + return v.grep(e, function(e, r) { + return v.inArray(e, t) >= 0 === n + }) + } + + function lt(e) { + var t = ct.split("|"), + n = e.createDocumentFragment(); + if (n.createElement) while (t.length) n.createElement(t.pop()); + return n + } + + function Lt(e, t) { + return e.getElementsByTagName(t)[0] || e.appendChild(e.ownerDocument.createElement(t)) + } + + function At(e, t) { + if (t.nodeType !== 1 || !v.hasData(e)) return; + var n, r, i, s = v._data(e), + o = v._data(t, s), + u = s.events; + if (u) { + delete o.handle, o.events = {}; + for (n in u) for (r = 0, i = u[n].length; r < i; r++) v.event.add(t, n, u[n][r]) + } + o.data && (o.data = v.extend({}, o.data)) + } + + function Ot(e, t) { + var n; + if (t.nodeType !== 1) return; + t.clearAttributes && t.clearAttributes(), t.mergeAttributes && t.mergeAttributes(e), n = t.nodeName.toLowerCase(), n === "object" ? (t.parentNode && (t.outerHTML = e.outerHTML), v.support.html5Clone && e.innerHTML && !v.trim(t.innerHTML) && (t.innerHTML = e.innerHTML)) : n === "input" && Et.test(e.type) ? (t.defaultChecked = t.checked = e.checked, t.value !== e.value && (t.value = e.value)) : n === "option" ? t.selected = e.defaultSelected : n === "input" || n === "textarea" ? t.defaultValue = e.defaultValue : n === "script" && t.text !== e.text && (t.text = e.text), t.removeAttribute(v.expando) + } + + function Mt(e) { + return typeof e.getElementsByTagName != "undefined" ? e.getElementsByTagName("*") : typeof e.querySelectorAll != "undefined" ? e.querySelectorAll("*") : [] + } + + function _t(e) { + Et.test(e.type) && (e.defaultChecked = e.checked) + } + + function Qt(e, t) { + if (t in e) return t; + var n = t.charAt(0).toUpperCase() + t.slice(1), + r = t, + i = Jt.length; + while (i--) { + t = Jt[i] + n; + if (t in e) return t + } + return r + } + + function Gt(e, t) { + return e = t || e, v.css(e, "display") === "none" || !v.contains(e.ownerDocument, e) + } + + function Yt(e, t) { + var n, r, i = [], + s = 0, + o = e.length; + for (; s < o; s++) { + n = e[s]; + if (!n.style) continue; + i[s] = v._data(n, "olddisplay"), t ? (!i[s] && n.style.display === "none" && (n.style.display = ""), n.style.display === "" && Gt(n) && (i[s] = v._data(n, "olddisplay", nn(n.nodeName)))) : (r = Dt(n, "display"), !i[s] && r !== "none" && v._data(n, "olddisplay", r)) + } + for (s = 0; s < o; s++) { + n = e[s]; + if (!n.style) continue; + if (!t || n.style.display === "none" || n.style.display === "") n.style.display = t ? i[s] || "" : "none" + } + return e + } + + function Zt(e, t, n) { + var r = Rt.exec(t); + return r ? Math.max(0, r[1] - (n || 0)) + (r[2] || "px") : t + } + + function en(e, t, n, r) { + var i = n === (r ? "border" : "content") ? 4 : t === "width" ? 1 : 0, + s = 0; + for (; i < 4; i += 2) n === "margin" && (s += v.css(e, n + $t[i], !0)), r ? (n === "content" && (s -= parseFloat(Dt(e, "padding" + $t[i])) || 0), n !== "margin" && (s -= parseFloat(Dt(e, "border" + $t[i] + "Width")) || 0)) : (s += parseFloat(Dt(e, "padding" + $t[i])) || 0, n !== "padding" && (s += parseFloat(Dt(e, "border" + $t[i] + "Width")) || 0)); + return s + } + + function tn(e, t, n) { + var r = t === "width" ? e.offsetWidth : e.offsetHeight, + i = !0, + s = v.support.boxSizing && v.css(e, "boxSizing") === "border-box"; + if (r <= 0 || r == null) { + r = Dt(e, t); + if (r < 0 || r == null) r = e.style[t]; + if (Ut.test(r)) return r; + i = s && (v.support.boxSizingReliable || r === e.style[t]), r = parseFloat(r) || 0 + } + return r + en(e, t, n || (s ? "border" : "content"), i) + "px" + } + + function nn(e) { + if (Wt[e]) return Wt[e]; + var t = v("<" + e + ">").appendTo(i.body), + n = t.css("display"); + t.remove(); + if (n === "none" || n === "") { + Pt = i.body.appendChild(Pt || v.extend(i.createElement("iframe"), { + frameBorder: 0, + width: 0, + height: 0 + })); + if (!Ht || !Pt.createElement) Ht = (Pt.contentWindow || Pt.contentDocument).document, Ht.write(""), Ht.close(); + t = Ht.body.appendChild(Ht.createElement(e)), n = Dt(t, "display"), i.body.removeChild(Pt) + } + return Wt[e] = n, n + } + + function fn(e, t, n, r) { + var i; + if (v.isArray(t)) v.each(t, function(t, i) { + n || sn.test(e) ? r(e, i) : fn(e + "[" + (typeof i == "object" ? t : "") + "]", i, n, r) + }); + else if (!n && v.type(t) === "object") for (i in t) fn(e + "[" + i + "]", t[i], n, r); + else r(e, t) + } + + function Cn(e) { + return function(t, n) { + typeof t != "string" && (n = t, t = "*"); + var r, i, s, o = t.toLowerCase().split(y), + u = 0, + a = o.length; + if (v.isFunction(n)) for (; u < a; u++) r = o[u], s = /^\+/.test(r), s && (r = r.substr(1) || "*"), i = e[r] = e[r] || [], i[s ? "unshift" : "push"](n) + } + } + + function kn(e, n, r, i, s, o) { + s = s || n.dataTypes[0], o = o || {}, o[s] = !0; + var u, a = e[s], + f = 0, + l = a ? a.length : 0, + c = e === Sn; + for (; f < l && (c || !u); f++) u = a[f](n, r, i), typeof u == "string" && (!c || o[u] ? u = t : (n.dataTypes.unshift(u), u = kn(e, n, r, i, u, o))); + return (c || !u) && !o["*"] && (u = kn(e, n, r, i, "*", o)), u + } + + function Ln(e, n) { + var r, i, s = v.ajaxSettings.flatOptions || {}; + for (r in n) n[r] !== t && ((s[r] ? e : i || (i = {}))[r] = n[r]); + i && v.extend(!0, e, i) + } + + function An(e, n, r) { + var i, s, o, u, a = e.contents, + f = e.dataTypes, + l = e.responseFields; + for (s in l) s in r && (n[l[s]] = r[s]); + while (f[0] === "*") f.shift(), i === t && (i = e.mimeType || n.getResponseHeader("content-type")); + if (i) for (s in a) if (a[s] && a[s].test(i)) { + f.unshift(s); + break + } + if (f[0] in r) o = f[0]; + else { + for (s in r) { + if (!f[0] || e.converters[s + " " + f[0]]) { + o = s; + break + } + u || (u = s) + } + o = o || u + } + if (o) return o !== f[0] && f.unshift(o), r[o] + } + + function On(e, t) { + var n, r, i, s, o = e.dataTypes.slice(), + u = o[0], + a = {}, + f = 0; + e.dataFilter && (t = e.dataFilter(t, e.dataType)); + if (o[1]) for (n in e.converters) a[n.toLowerCase()] = e.converters[n]; + for (; i = o[++f];) if (i !== "*") { + if (u !== "*" && u !== i) { + n = a[u + " " + i] || a["* " + i]; + if (!n) for (r in a) { + s = r.split(" "); + if (s[1] === i) { + n = a[u + " " + s[0]] || a["* " + s[0]]; + if (n) { + n === !0 ? n = a[r] : a[r] !== !0 && (i = s[0], o.splice(f--, 0, i)); + break + } + } + } + if (n !== !0) if (n && e["throws"]) t = n(t); + else try { + t = n(t) + } catch (l) { + return { + state: "parsererror", + error: n ? l : "No conversion from " + u + " to " + i + } + } + } + u = i + } + return { + state: "success", + data: t + } + } + + function Fn() { + try { + return new e.XMLHttpRequest + } catch (t) {} + } + + function In() { + try { + return new e.ActiveXObject("Microsoft.XMLHTTP") + } catch (t) {} + } + + function $n() { + return setTimeout(function() { + qn = t + }, 0), qn = v.now() + } + + function Jn(e, t) { + v.each(t, function(t, n) { + var r = (Vn[t] || []).concat(Vn["*"]), + i = 0, + s = r.length; + for (; i < s; i++) if (r[i].call(e, t, n)) return + }) + } + + function Kn(e, t, n) { + var r, i = 0, + s = 0, + o = Xn.length, + u = v.Deferred().always(function() { + delete a.elem + }), + a = function() { + var t = qn || $n(), + n = Math.max(0, f.startTime + f.duration - t), + r = n / f.duration || 0, + i = 1 - r, + s = 0, + o = f.tweens.length; + for (; s < o; s++) f.tweens[s].run(i); + return u.notifyWith(e, [f, i, n]), i < 1 && o ? n : (u.resolveWith(e, [f]), !1) + }, + f = u.promise({ + elem: e, + props: v.extend({}, t), + opts: v.extend(!0, { + specialEasing: {} + }, n), + originalProperties: t, + originalOptions: n, + startTime: qn || $n(), + duration: n.duration, + tweens: [], + createTween: function(t, n, r) { + var i = v.Tween(e, f.opts, t, n, f.opts.specialEasing[t] || f.opts.easing); + return f.tweens.push(i), i + }, + stop: function(t) { + var n = 0, + r = t ? f.tweens.length : 0; + for (; n < r; n++) f.tweens[n].run(1); + return t ? u.resolveWith(e, [f, t]) : u.rejectWith(e, [f, t]), this + } + }), + l = f.props; + Qn(l, f.opts.specialEasing); + for (; i < o; i++) { + r = Xn[i].call(f, e, l, f.opts); + if (r) return r + } + return Jn(f, l), v.isFunction(f.opts.start) && f.opts.start.call(e, f), v.fx.timer(v.extend(a, { + anim: f, + queue: f.opts.queue, + elem: e + })), f.progress(f.opts.progress).done(f.opts.done, f.opts.complete).fail(f.opts.fail).always(f.opts.always) + } + + function Qn(e, t) { + var n, r, i, s, o; + for (n in e) { + r = v.camelCase(n), i = t[r], s = e[n], v.isArray(s) && (i = s[1], s = e[n] = s[0]), n !== r && (e[r] = s, delete e[n]), o = v.cssHooks[r]; + if (o && "expand" in o) { + s = o.expand(s), delete e[r]; + for (n in s) n in e || (e[n] = s[n], t[n] = i) + } else t[r] = i + } + } + + function Gn(e, t, n) { + var r, i, s, o, u, a, f, l, c, h = this, + p = e.style, + d = {}, + m = [], + g = e.nodeType && Gt(e); + n.queue || (l = v._queueHooks(e, "fx"), l.unqueued == null && (l.unqueued = 0, c = l.empty.fire, l.empty.fire = function() { + l.unqueued || c() + }), l.unqueued++, h.always(function() { + h.always(function() { + l.unqueued--, v.queue(e, "fx").length || l.empty.fire() + }) + })), e.nodeType === 1 && ("height" in t || "width" in t) && (n.overflow = [p.overflow, p.overflowX, p.overflowY], v.css(e, "display") === "inline" && v.css(e, "float") === "none" && (!v.support.inlineBlockNeedsLayout || nn(e.nodeName) === "inline" ? p.display = "inline-block" : p.zoom = 1)), n.overflow && (p.overflow = "hidden", v.support.shrinkWrapBlocks || h.done(function() { + p.overflow = n.overflow[0], p.overflowX = n.overflow[1], p.overflowY = n.overflow[2] + })); + for (r in t) { + s = t[r]; + if (Un.exec(s)) { + delete t[r], a = a || s === "toggle"; + if (s === (g ? "hide" : "show")) continue; + m.push(r) + } + } + o = m.length; + if (o) { + u = v._data(e, "fxshow") || v._data(e, "fxshow", {}), "hidden" in u && (g = u.hidden), a && (u.hidden = !g), g ? v(e).show() : h.done(function() { + v(e).hide() + }), h.done(function() { + var t; + v.removeData(e, "fxshow", !0); + for (t in d) v.style(e, t, d[t]) + }); + for (r = 0; r < o; r++) i = m[r], f = h.createTween(i, g ? u[i] : 0), d[i] = u[i] || v.style(e, i), i in u || (u[i] = f.start, g && (f.end = f.start, f.start = i === "width" || i === "height" ? 1 : 0)) + } + } + + function Yn(e, t, n, r, i) { + return new Yn.prototype.init(e, t, n, r, i) + } + + function Zn(e, t) { + var n, r = { + height: e + }, + i = 0; + t = t ? 1 : 0; + for (; i < 4; i += 2 - t) n = $t[i], r["margin" + n] = r["padding" + n] = e; + return t && (r.opacity = r.width = e), r + } + + function tr(e) { + return v.isWindow(e) ? e : e.nodeType === 9 ? e.defaultView || e.parentWindow : !1 + } + var n, r, i = e.document, + s = e.location, + o = e.navigator, + u = e.jQuery, + a = e.$, + f = Array.prototype.push, + l = Array.prototype.slice, + c = Array.prototype.indexOf, + h = Object.prototype.toString, + p = Object.prototype.hasOwnProperty, + d = String.prototype.trim, + v = function(e, t) { + return new v.fn.init(e, t, n) + }, + m = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source, + g = /\S/, + y = /\s+/, + b = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, + w = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + E = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, + S = /^[\],:{}\s]*$/, + x = /(?:^|:|,)(?:\s*\[)+/g, + T = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g, + N = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g, + C = /^-ms-/, + k = /-([\da-z])/gi, + L = function(e, t) { + return (t + "").toUpperCase() + }, + A = function() { + i.addEventListener ? (i.removeEventListener("DOMContentLoaded", A, !1), v.ready()) : i.readyState === "complete" && (i.detachEvent("onreadystatechange", A), v.ready()) + }, + O = {}; + v.fn = v.prototype = { + constructor: v, + init: function(e, n, r) { + var s, o, u, a; + if (!e) return this; + if (e.nodeType) return this.context = this[0] = e, this.length = 1, this; + if (typeof e == "string") { + e.charAt(0) === "<" && e.charAt(e.length - 1) === ">" && e.length >= 3 ? s = [null, e, null] : s = w.exec(e); + if (s && (s[1] || !n)) { + if (s[1]) return n = n instanceof v ? n[0] : n, a = n && n.nodeType ? n.ownerDocument || n : i, e = v.parseHTML(s[1], a, !0), E.test(s[1]) && v.isPlainObject(n) && this.attr.call(e, n, !0), v.merge(this, e); + o = i.getElementById(s[2]); + if (o && o.parentNode) { + if (o.id !== s[2]) return r.find(e); + this.length = 1, this[0] = o + } + return this.context = i, this.selector = e, this + } + return !n || n.jquery ? (n || r).find(e) : this.constructor(n).find(e) + } + return v.isFunction(e) ? r.ready(e) : (e.selector !== t && (this.selector = e.selector, this.context = e.context), v.makeArray(e, this)) + }, + selector: "", + jquery: "1.8.3", + length: 0, + size: function() { + return this.length + }, + toArray: function() { + return l.call(this) + }, + get: function(e) { + return e == null ? this.toArray() : e < 0 ? this[this.length + e] : this[e] + }, + pushStack: function(e, t, n) { + var r = v.merge(this.constructor(), e); + return r.prevObject = this, r.context = this.context, t === "find" ? r.selector = this.selector + (this.selector ? " " : "") + n : t && (r.selector = this.selector + "." + t + "(" + n + ")"), r + }, + each: function(e, t) { + return v.each(this, e, t) + }, + ready: function(e) { + return v.ready.promise().done(e), this + }, + eq: function(e) { + return e = +e, e === -1 ? this.slice(e) : this.slice(e, e + 1) + }, + first: function() { + return this.eq(0) + }, + last: function() { + return this.eq(-1) + }, + slice: function() { + return this.pushStack(l.apply(this, arguments), "slice", l.call(arguments).join(",")) + }, + map: function(e) { + return this.pushStack(v.map(this, function(t, n) { + return e.call(t, n, t) + })) + }, + end: function() { + return this.prevObject || this.constructor(null) + }, + push: f, + sort: [].sort, + splice: [].splice + }, v.fn.init.prototype = v.fn, v.extend = v.fn.extend = function() { + var e, n, r, i, s, o, u = arguments[0] || {}, + a = 1, + f = arguments.length, + l = !1; + typeof u == "boolean" && (l = u, u = arguments[1] || {}, a = 2), typeof u != "object" && !v.isFunction(u) && (u = {}), f === a && (u = this, --a); + for (; a < f; a++) if ((e = arguments[a]) != null) for (n in e) { + r = u[n], i = e[n]; + if (u === i) continue; + l && i && (v.isPlainObject(i) || (s = v.isArray(i))) ? (s ? (s = !1, o = r && v.isArray(r) ? r : []) : o = r && v.isPlainObject(r) ? r : {}, u[n] = v.extend(l, o, i)) : i !== t && (u[n] = i) + } + return u + }, v.extend({ + noConflict: function(t) { + return e.$ === v && (e.$ = a), t && e.jQuery === v && (e.jQuery = u), v + }, + isReady: !1, + readyWait: 1, + holdReady: function(e) { + e ? v.readyWait++ : v.ready(!0) + }, + ready: function(e) { + if (e === !0 ? --v.readyWait : v.isReady) return; + if (!i.body) return setTimeout(v.ready, 1); + v.isReady = !0; + if (e !== !0 && --v.readyWait > 0) return; + r.resolveWith(i, [v]), v.fn.trigger && v(i).trigger("ready").off("ready") + }, + isFunction: function(e) { + return v.type(e) === "function" + }, + isArray: Array.isArray || + function(e) { + return v.type(e) === "array" + }, + isWindow: function(e) { + return e != null && e == e.window + }, + isNumeric: function(e) { + return !isNaN(parseFloat(e)) && isFinite(e) + }, + type: function(e) { + return e == null ? String(e) : O[h.call(e)] || "object" + }, + isPlainObject: function(e) { + if (!e || v.type(e) !== "object" || e.nodeType || v.isWindow(e)) return !1; + try { + if (e.constructor && !p.call(e, "constructor") && !p.call(e.constructor.prototype, "isPrototypeOf")) return !1 + } catch (n) { + return !1 + } + var r; + for (r in e); + return r === t || p.call(e, r) + }, + isEmptyObject: function(e) { + var t; + for (t in e) return !1; + return !0 + }, + error: function(e) { + throw new Error(e) + }, + parseHTML: function(e, t, n) { + var r; + return !e || typeof e != "string" ? null : (typeof t == "boolean" && (n = t, t = 0), t = t || i, (r = E.exec(e)) ? [t.createElement(r[1])] : (r = v.buildFragment([e], t, n ? null : []), v.merge([], (r.cacheable ? v.clone(r.fragment) : r.fragment).childNodes))) + }, + parseJSON: function(t) { + if (!t || typeof t != "string") return null; + t = v.trim(t); + if (e.JSON && e.JSON.parse) return e.JSON.parse(t); + if (S.test(t.replace(T, "@").replace(N, "]").replace(x, ""))) return (new Function("return " + t))(); + v.error("Invalid JSON: " + t) + }, + parseXML: function(n) { + var r, i; + if (!n || typeof n != "string") return null; + try { + e.DOMParser ? (i = new DOMParser, r = i.parseFromString(n, "text/xml")) : (r = new ActiveXObject("Microsoft.XMLDOM"), r.async = "false", r.loadXML(n)) + } catch (s) { + r = t + } + return (!r || !r.documentElement || r.getElementsByTagName("parsererror").length) && v.error("Invalid XML: " + n), r + }, + noop: function() {}, + globalEval: function(t) { + t && g.test(t) && (e.execScript || + function(t) { + e.eval.call(e, t) + })(t) + }, + camelCase: function(e) { + return e.replace(C, "ms-").replace(k, L) + }, + nodeName: function(e, t) { + return e.nodeName && e.nodeName.toLowerCase() === t.toLowerCase() + }, + each: function(e, n, r) { + var i, s = 0, + o = e.length, + u = o === t || v.isFunction(e); + if (r) { + if (u) { + for (i in e) if (n.apply(e[i], r) === !1) break + } else for (; s < o;) if (n.apply(e[s++], r) === !1) break + } else if (u) { + for (i in e) if (n.call(e[i], i, e[i]) === !1) break + } else for (; s < o;) if (n.call(e[s], s, e[s++]) === !1) break; + return e + }, + trim: d && !d.call("\ufeff\u00a0") ? + function(e) { + return e == null ? "" : d.call(e) + } : function(e) { + return e == null ? "" : (e + "").replace(b, "") + }, + makeArray: function(e, t) { + var n, r = t || []; + return e != null && (n = v.type(e), e.length == null || n === "string" || n === "function" || n === "regexp" || v.isWindow(e) ? f.call(r, e) : v.merge(r, e)), r + }, + inArray: function(e, t, n) { + var r; + if (t) { + if (c) return c.call(t, e, n); + r = t.length, n = n ? n < 0 ? Math.max(0, r + n) : n : 0; + for (; n < r; n++) if (n in t && t[n] === e) return n + } + return -1 + }, + merge: function(e, n) { + var r = n.length, + i = e.length, + s = 0; + if (typeof r == "number") for (; s < r; s++) e[i++] = n[s]; + else while (n[s] !== t) e[i++] = n[s++]; + return e.length = i, e + }, + grep: function(e, t, n) { + var r, i = [], + s = 0, + o = e.length; + n = !! n; + for (; s < o; s++) r = !! t(e[s], s), n !== r && i.push(e[s]); + return i + }, + map: function(e, n, r) { + var i, s, o = [], + u = 0, + a = e.length, + f = e instanceof v || a !== t && typeof a == "number" && (a > 0 && e[0] && e[a - 1] || a === 0 || v.isArray(e)); + if (f) for (; u < a; u++) i = n(e[u], u, r), i != null && (o[o.length] = i); + else for (s in e) i = n(e[s], s, r), i != null && (o[o.length] = i); + return o.concat.apply([], o) + }, + guid: 1, + proxy: function(e, n) { + var r, i, s; + return typeof n == "string" && (r = e[n], n = e, e = r), v.isFunction(e) ? (i = l.call(arguments, 2), s = function() { + return e.apply(n, i.concat(l.call(arguments))) + }, s.guid = e.guid = e.guid || v.guid++, s) : t + }, + access: function(e, n, r, i, s, o, u) { + var a, f = r == null, + l = 0, + c = e.length; + if (r && typeof r == "object") { + for (l in r) v.access(e, n, l, r[l], 1, o, i); + s = 1 + } else if (i !== t) { + a = u === t && v.isFunction(i), f && (a ? (a = n, n = function(e, t, n) { + return a.call(v(e), n) + }) : (n.call(e, i), n = null)); + if (n) for (; l < c; l++) n(e[l], r, a ? i.call(e[l], l, n(e[l], r)) : i, u); + s = 1 + } + return s ? e : f ? n.call(e) : c ? n(e[0], r) : o + }, + now: function() { + return (new Date).getTime() + } + }), v.ready.promise = function(t) { + if (!r) { + r = v.Deferred(); + if (i.readyState === "complete") setTimeout(v.ready, 1); + else if (i.addEventListener) i.addEventListener("DOMContentLoaded", A, !1), e.addEventListener("load", v.ready, !1); + else { + i.attachEvent("onreadystatechange", A), e.attachEvent("onload", v.ready); + var n = !1; + try { + n = e.frameElement == null && i.documentElement + } catch (s) {} + n && n.doScroll && + function o() { + if (!v.isReady) { + try { + n.doScroll("left") + } catch (e) { + return setTimeout(o, 50) + } + v.ready() + } + }() + } + } + return r.promise(t) + }, v.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(e, t) { + O["[object " + t + "]"] = t.toLowerCase() + }), n = v(i); + var M = {}; + v.Callbacks = function(e) { + e = typeof e == "string" ? M[e] || _(e) : v.extend({}, e); + var n, r, i, s, o, u, a = [], + f = !e.once && [], + l = function(t) { + n = e.memory && t, r = !0, u = s || 0, s = 0, o = a.length, i = !0; + for (; a && u < o; u++) if (a[u].apply(t[0], t[1]) === !1 && e.stopOnFalse) { + n = !1; + break + } + i = !1, a && (f ? f.length && l(f.shift()) : n ? a = [] : c.disable()) + }, + c = { + add: function() { + if (a) { + var t = a.length; + (function r(t) { + v.each(t, function(t, n) { + var i = v.type(n); + i === "function" ? (!e.unique || !c.has(n)) && a.push(n) : n && n.length && i !== "string" && r(n) + }) + })(arguments), i ? o = a.length : n && (s = t, l(n)) + } + return this + }, + remove: function() { + return a && v.each(arguments, function(e, t) { + var n; + while ((n = v.inArray(t, a, n)) > -1) a.splice(n, 1), i && (n <= o && o--, n <= u && u--) + }), this + }, + has: function(e) { + return v.inArray(e, a) > -1 + }, + empty: function() { + return a = [], this + }, + disable: function() { + return a = f = n = t, this + }, + disabled: function() { + return !a + }, + lock: function() { + return f = t, n || c.disable(), this + }, + locked: function() { + return !f + }, + fireWith: function(e, t) { + return t = t || [], t = [e, t.slice ? t.slice() : t], a && (!r || f) && (i ? f.push(t) : l(t)), this + }, + fire: function() { + return c.fireWith(this, arguments), this + }, + fired: function() { + return !!r + } + }; + return c + }, v.extend({ + Deferred: function(e) { + var t = [ + ["resolve", "done", v.Callbacks("once memory"), "resolved"], + ["reject", "fail", v.Callbacks("once memory"), "rejected"], + ["notify", "progress", v.Callbacks("memory")] + ], + n = "pending", + r = { + state: function() { + return n + }, + always: function() { + return i.done(arguments).fail(arguments), this + }, + then: function() { + var e = arguments; + return v.Deferred(function(n) { + v.each(t, function(t, r) { + var s = r[0], + o = e[t]; + i[r[1]](v.isFunction(o) ? + function() { + var e = o.apply(this, arguments); + e && v.isFunction(e.promise) ? e.promise().done(n.resolve).fail(n.reject).progress(n.notify) : n[s + "With"](this === i ? n : this, [e]) + } : n[s]) + }), e = null + }).promise() + }, + promise: function(e) { + return e != null ? v.extend(e, r) : r + } + }, + i = {}; + return r.pipe = r.then, v.each(t, function(e, s) { + var o = s[2], + u = s[3]; + r[s[1]] = o.add, u && o.add(function() { + n = u + }, t[e ^ 1][2].disable, t[2][2].lock), i[s[0]] = o.fire, i[s[0] + "With"] = o.fireWith + }), r.promise(i), e && e.call(i, i), i + }, + when: function(e) { + var t = 0, + n = l.call(arguments), + r = n.length, + i = r !== 1 || e && v.isFunction(e.promise) ? r : 0, + s = i === 1 ? e : v.Deferred(), + o = function(e, t, n) { + return function(r) { + t[e] = this, n[e] = arguments.length > 1 ? l.call(arguments) : r, n === u ? s.notifyWith(t, n) : --i || s.resolveWith(t, n) + } + }, + u, a, f; + if (r > 1) { + u = new Array(r), a = new Array(r), f = new Array(r); + for (; t < r; t++) n[t] && v.isFunction(n[t].promise) ? n[t].promise().done(o(t, f, n)).fail(s.reject).progress(o(t, a, u)) : --i + } + return i || s.resolveWith(f, n), s.promise() + } + }), v.support = function() { + var t, n, r, s, o, u, a, f, l, c, h, p = i.createElement("div"); + p.setAttribute("className", "t"), p.innerHTML = "
    a", n = p.getElementsByTagName("*"), r = p.getElementsByTagName("a")[0]; + if (!n || !r || !n.length) return {}; + s = i.createElement("select"), o = s.appendChild(i.createElement("option")), u = p.getElementsByTagName("input")[0], r.style.cssText = "top:1px;float:left;opacity:.5", t = { + leadingWhitespace: p.firstChild.nodeType === 3, + tbody: !p.getElementsByTagName("tbody").length, + htmlSerialize: !! p.getElementsByTagName("link").length, + style: /top/.test(r.getAttribute("style")), + hrefNormalized: r.getAttribute("href") === "/a", + opacity: /^0.5/.test(r.style.opacity), + cssFloat: !! r.style.cssFloat, + checkOn: u.value === "on", + optSelected: o.selected, + getSetAttribute: p.className !== "t", + enctype: !! i.createElement("form").enctype, + html5Clone: i.createElement("nav").cloneNode(!0).outerHTML !== "<:nav>", + boxModel: i.compatMode === "CSS1Compat", + submitBubbles: !0, + changeBubbles: !0, + focusinBubbles: !1, + deleteExpando: !0, + noCloneEvent: !0, + inlineBlockNeedsLayout: !1, + shrinkWrapBlocks: !1, + reliableMarginRight: !0, + boxSizingReliable: !0, + pixelPosition: !1 + }, u.checked = !0, t.noCloneChecked = u.cloneNode(!0).checked, s.disabled = !0, t.optDisabled = !o.disabled; + try { + delete p.test + } catch (d) { + t.deleteExpando = !1 + }!p.addEventListener && p.attachEvent && p.fireEvent && (p.attachEvent("onclick", h = function() { + t.noCloneEvent = !1 + }), p.cloneNode(!0).fireEvent("onclick"), p.detachEvent("onclick", h)), u = i.createElement("input"), u.value = "t", u.setAttribute("type", "radio"), t.radioValue = u.value === "t", u.setAttribute("checked", "checked"), u.setAttribute("name", "t"), p.appendChild(u), a = i.createDocumentFragment(), a.appendChild(p.lastChild), t.checkClone = a.cloneNode(!0).cloneNode(!0).lastChild.checked, t.appendChecked = u.checked, a.removeChild(u), a.appendChild(p); + if (p.attachEvent) for (l in { + submit: !0, + change: !0, + focusin: !0 + }) f = "on" + l, c = f in p, c || (p.setAttribute(f, "return;"), c = typeof p[f] == "function"), t[l + "Bubbles"] = c; + return v(function() { + var n, r, s, o, u = "padding:0;margin:0;border:0;display:block;overflow:hidden;", + a = i.getElementsByTagName("body")[0]; + if (!a) return; + n = i.createElement("div"), n.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px", a.insertBefore(n, a.firstChild), r = i.createElement("div"), n.appendChild(r), r.innerHTML = "
    t
    ", s = r.getElementsByTagName("td"), s[0].style.cssText = "padding:0;margin:0;border:0;display:none", c = s[0].offsetHeight === 0, s[0].style.display = "", s[1].style.display = "none", t.reliableHiddenOffsets = c && s[0].offsetHeight === 0, r.innerHTML = "", r.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;", t.boxSizing = r.offsetWidth === 4, t.doesNotIncludeMarginInBodyOffset = a.offsetTop !== 1, e.getComputedStyle && (t.pixelPosition = (e.getComputedStyle(r, null) || {}).top !== "1%", t.boxSizingReliable = (e.getComputedStyle(r, null) || { + width: "4px" + }).width === "4px", o = i.createElement("div"), o.style.cssText = r.style.cssText = u, o.style.marginRight = o.style.width = "0", r.style.width = "1px", r.appendChild(o), t.reliableMarginRight = !parseFloat((e.getComputedStyle(o, null) || {}).marginRight)), typeof r.style.zoom != "undefined" && (r.innerHTML = "", r.style.cssText = u + "width:1px;padding:1px;display:inline;zoom:1", t.inlineBlockNeedsLayout = r.offsetWidth === 3, r.style.display = "block", r.style.overflow = "visible", r.innerHTML = "
    ", r.firstChild.style.width = "5px", t.shrinkWrapBlocks = r.offsetWidth !== 3, n.style.zoom = 1), a.removeChild(n), n = r = s = o = null + }), a.removeChild(p), n = r = s = o = u = a = p = null, t + }(); + var D = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/, + P = /([A-Z])/g; + v.extend({ + cache: {}, + deletedIds: [], + uuid: 0, + expando: "jQuery" + (v.fn.jquery + Math.random()).replace(/\D/g, ""), + noData: { + embed: !0, + object: "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + applet: !0 + }, + hasData: function(e) { + return e = e.nodeType ? v.cache[e[v.expando]] : e[v.expando], !! e && !B(e) + }, + data: function(e, n, r, i) { + if (!v.acceptData(e)) return; + var s, o, u = v.expando, + a = typeof n == "string", + f = e.nodeType, + l = f ? v.cache : e, + c = f ? e[u] : e[u] && u; + if ((!c || !l[c] || !i && !l[c].data) && a && r === t) return; + c || (f ? e[u] = c = v.deletedIds.pop() || v.guid++ : c = u), l[c] || (l[c] = {}, f || (l[c].toJSON = v.noop)); + if (typeof n == "object" || typeof n == "function") i ? l[c] = v.extend(l[c], n) : l[c].data = v.extend(l[c].data, n); + return s = l[c], i || (s.data || (s.data = {}), s = s.data), r !== t && (s[v.camelCase(n)] = r), a ? (o = s[n], o == null && (o = s[v.camelCase(n)])) : o = s, o + }, + removeData: function(e, t, n) { + if (!v.acceptData(e)) return; + var r, i, s, o = e.nodeType, + u = o ? v.cache : e, + a = o ? e[v.expando] : v.expando; + if (!u[a]) return; + if (t) { + r = n ? u[a] : u[a].data; + if (r) { + v.isArray(t) || (t in r ? t = [t] : (t = v.camelCase(t), t in r ? t = [t] : t = t.split(" "))); + for (i = 0, s = t.length; i < s; i++) delete r[t[i]]; + if (!(n ? B : v.isEmptyObject)(r)) return + } + } + if (!n) { + delete u[a].data; + if (!B(u[a])) return + } + o ? v.cleanData([e], !0) : v.support.deleteExpando || u != u.window ? delete u[a] : u[a] = null + }, + _data: function(e, t, n) { + return v.data(e, t, n, !0) + }, + acceptData: function(e) { + var t = e.nodeName && v.noData[e.nodeName.toLowerCase()]; + return !t || t !== !0 && e.getAttribute("classid") === t + } + }), v.fn.extend({ + data: function(e, n) { + var r, i, s, o, u, a = this[0], + f = 0, + l = null; + if (e === t) { + if (this.length) { + l = v.data(a); + if (a.nodeType === 1 && !v._data(a, "parsedAttrs")) { + s = a.attributes; + for (u = s.length; f < u; f++) o = s[f].name, o.indexOf("data-") || (o = v.camelCase(o.substring(5)), H(a, o, l[o])); + v._data(a, "parsedAttrs", !0) + } + } + return l + } + return typeof e == "object" ? this.each(function() { + v.data(this, e) + }) : (r = e.split(".", 2), r[1] = r[1] ? "." + r[1] : "", i = r[1] + "!", v.access(this, function(n) { + if (n === t) return l = this.triggerHandler("getData" + i, [r[0]]), l === t && a && (l = v.data(a, e), l = H(a, e, l)), l === t && r[1] ? this.data(r[0]) : l; + r[1] = n, this.each(function() { + var t = v(this); + t.triggerHandler("setData" + i, r), v.data(this, e, n), t.triggerHandler("changeData" + i, r) + }) + }, null, n, arguments.length > 1, null, !1)) + }, + removeData: function(e) { + return this.each(function() { + v.removeData(this, e) + }) + } + }), v.extend({ + queue: function(e, t, n) { + var r; + if (e) return t = (t || "fx") + "queue", r = v._data(e, t), n && (!r || v.isArray(n) ? r = v._data(e, t, v.makeArray(n)) : r.push(n)), r || [] + }, + dequeue: function(e, t) { + t = t || "fx"; + var n = v.queue(e, t), + r = n.length, + i = n.shift(), + s = v._queueHooks(e, t), + o = function() { + v.dequeue(e, t) + }; + i === "inprogress" && (i = n.shift(), r--), i && (t === "fx" && n.unshift("inprogress"), delete s.stop, i.call(e, o, s)), !r && s && s.empty.fire() + }, + _queueHooks: function(e, t) { + var n = t + "queueHooks"; + return v._data(e, n) || v._data(e, n, { + empty: v.Callbacks("once memory").add(function() { + v.removeData(e, t + "queue", !0), v.removeData(e, n, !0) + }) + }) + } + }), v.fn.extend({ + queue: function(e, n) { + var r = 2; + return typeof e != "string" && (n = e, e = "fx", r--), arguments.length < r ? v.queue(this[0], e) : n === t ? this : this.each(function() { + var t = v.queue(this, e, n); + v._queueHooks(this, e), e === "fx" && t[0] !== "inprogress" && v.dequeue(this, e) + }) + }, + dequeue: function(e) { + return this.each(function() { + v.dequeue(this, e) + }) + }, + delay: function(e, t) { + return e = v.fx ? v.fx.speeds[e] || e : e, t = t || "fx", this.queue(t, function(t, n) { + var r = setTimeout(t, e); + n.stop = function() { + clearTimeout(r) + } + }) + }, + clearQueue: function(e) { + return this.queue(e || "fx", []) + }, + promise: function(e, n) { + var r, i = 1, + s = v.Deferred(), + o = this, + u = this.length, + a = function() { + --i || s.resolveWith(o, [o]) + }; + typeof e != "string" && (n = e, e = t), e = e || "fx"; + while (u--) r = v._data(o[u], e + "queueHooks"), r && r.empty && (i++, r.empty.add(a)); + return a(), s.promise(n) + } + }); + var j, F, I, q = /[\t\r\n]/g, + R = /\r/g, + U = /^(?:button|input)$/i, + z = /^(?:button|input|object|select|textarea)$/i, + W = /^a(?:rea|)$/i, + X = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + V = v.support.getSetAttribute; + v.fn.extend({ + attr: function(e, t) { + return v.access(this, v.attr, e, t, arguments.length > 1) + }, + removeAttr: function(e) { + return this.each(function() { + v.removeAttr(this, e) + }) + }, + prop: function(e, t) { + return v.access(this, v.prop, e, t, arguments.length > 1) + }, + removeProp: function(e) { + return e = v.propFix[e] || e, this.each(function() { + try { + this[e] = t, delete this[e] + } catch (n) {} + }) + }, + addClass: function(e) { + var t, n, r, i, s, o, u; + if (v.isFunction(e)) return this.each(function(t) { + v(this).addClass(e.call(this, t, this.className)) + }); + if (e && typeof e == "string") { + t = e.split(y); + for (n = 0, r = this.length; n < r; n++) { + i = this[n]; + if (i.nodeType === 1) if (!i.className && t.length === 1) i.className = e; + else { + s = " " + i.className + " "; + for (o = 0, u = t.length; o < u; o++) s.indexOf(" " + t[o] + " ") < 0 && (s += t[o] + " "); + i.className = v.trim(s) + } + } + } + return this + }, + removeClass: function(e) { + var n, r, i, s, o, u, a; + if (v.isFunction(e)) return this.each(function(t) { + v(this).removeClass(e.call(this, t, this.className)) + }); + if (e && typeof e == "string" || e === t) { + n = (e || "").split(y); + for (u = 0, a = this.length; u < a; u++) { + i = this[u]; + if (i.nodeType === 1 && i.className) { + r = (" " + i.className + " ").replace(q, " "); + for (s = 0, o = n.length; s < o; s++) while (r.indexOf(" " + n[s] + " ") >= 0) r = r.replace(" " + n[s] + " ", " "); + i.className = e ? v.trim(r) : "" + } + } + } + return this + }, + toggleClass: function(e, t) { + var n = typeof e, + r = typeof t == "boolean"; + return v.isFunction(e) ? this.each(function(n) { + v(this).toggleClass(e.call(this, n, this.className, t), t) + }) : this.each(function() { + if (n === "string") { + var i, s = 0, + o = v(this), + u = t, + a = e.split(y); + while (i = a[s++]) u = r ? u : !o.hasClass(i), o[u ? "addClass" : "removeClass"](i) + } else if (n === "undefined" || n === "boolean") this.className && v._data(this, "__className__", this.className), this.className = this.className || e === !1 ? "" : v._data(this, "__className__") || "" + }) + }, + hasClass: function(e) { + var t = " " + e + " ", + n = 0, + r = this.length; + for (; n < r; n++) if (this[n].nodeType === 1 && (" " + this[n].className + " ").replace(q, " ").indexOf(t) >= 0) return !0; + return !1 + }, + val: function(e) { + var n, r, i, s = this[0]; + if (!arguments.length) { + if (s) return n = v.valHooks[s.type] || v.valHooks[s.nodeName.toLowerCase()], n && "get" in n && (r = n.get(s, "value")) !== t ? r : (r = s.value, typeof r == "string" ? r.replace(R, "") : r == null ? "" : r); + return + } + return i = v.isFunction(e), this.each(function(r) { + var s, o = v(this); + if (this.nodeType !== 1) return; + i ? s = e.call(this, r, o.val()) : s = e, s == null ? s = "" : typeof s == "number" ? s += "" : v.isArray(s) && (s = v.map(s, function(e) { + return e == null ? "" : e + "" + })), n = v.valHooks[this.type] || v.valHooks[this.nodeName.toLowerCase()]; + if (!n || !("set" in n) || n.set(this, s, "value") === t) this.value = s + }) + } + }), v.extend({ + valHooks: { + option: { + get: function(e) { + var t = e.attributes.value; + return !t || t.specified ? e.value : e.text + } + }, + select: { + get: function(e) { + var t, n, r = e.options, + i = e.selectedIndex, + s = e.type === "select-one" || i < 0, + o = s ? null : [], + u = s ? i + 1 : r.length, + a = i < 0 ? u : s ? i : 0; + for (; a < u; a++) { + n = r[a]; + if ((n.selected || a === i) && (v.support.optDisabled ? !n.disabled : n.getAttribute("disabled") === null) && (!n.parentNode.disabled || !v.nodeName(n.parentNode, "optgroup"))) { + t = v(n).val(); + if (s) return t; + o.push(t) + } + } + return o + }, + set: function(e, t) { + var n = v.makeArray(t); + return v(e).find("option").each(function() { + this.selected = v.inArray(v(this).val(), n) >= 0 + }), n.length || (e.selectedIndex = -1), n + } + } + }, + attrFn: {}, + attr: function(e, n, r, i) { + var s, o, u, a = e.nodeType; + if (!e || a === 3 || a === 8 || a === 2) return; + if (i && v.isFunction(v.fn[n])) return v(e)[n](r); + if (typeof e.getAttribute == "undefined") return v.prop(e, n, r); + u = a !== 1 || !v.isXMLDoc(e), u && (n = n.toLowerCase(), o = v.attrHooks[n] || (X.test(n) ? F : j)); + if (r !== t) { + if (r === null) { + v.removeAttr(e, n); + return + } + return o && "set" in o && u && (s = o.set(e, r, n)) !== t ? s : (e.setAttribute(n, r + ""), r) + } + return o && "get" in o && u && (s = o.get(e, n)) !== null ? s : (s = e.getAttribute(n), s === null ? t : s) + }, + removeAttr: function(e, t) { + var n, r, i, s, o = 0; + if (t && e.nodeType === 1) { + r = t.split(y); + for (; o < r.length; o++) i = r[o], i && (n = v.propFix[i] || i, s = X.test(i), s || v.attr(e, i, ""), e.removeAttribute(V ? i : n), s && n in e && (e[n] = !1)) + } + }, + attrHooks: { + type: { + set: function(e, t) { + if (U.test(e.nodeName) && e.parentNode) v.error("type property can't be changed"); + else if (!v.support.radioValue && t === "radio" && v.nodeName(e, "input")) { + var n = e.value; + return e.setAttribute("type", t), n && (e.value = n), t + } + } + }, + value: { + get: function(e, t) { + return j && v.nodeName(e, "button") ? j.get(e, t) : t in e ? e.value : null + }, + set: function(e, t, n) { + if (j && v.nodeName(e, "button")) return j.set(e, t, n); + e.value = t + } + } + }, + propFix: { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder", + contenteditable: "contentEditable" + }, + prop: function(e, n, r) { + var i, s, o, u = e.nodeType; + if (!e || u === 3 || u === 8 || u === 2) return; + return o = u !== 1 || !v.isXMLDoc(e), o && (n = v.propFix[n] || n, s = v.propHooks[n]), r !== t ? s && "set" in s && (i = s.set(e, r, n)) !== t ? i : e[n] = r : s && "get" in s && (i = s.get(e, n)) !== null ? i : e[n] + }, + propHooks: { + tabIndex: { + get: function(e) { + var n = e.getAttributeNode("tabindex"); + return n && n.specified ? parseInt(n.value, 10) : z.test(e.nodeName) || W.test(e.nodeName) && e.href ? 0 : t + } + } + } + }), F = { + get: function(e, n) { + var r, i = v.prop(e, n); + return i === !0 || typeof i != "boolean" && (r = e.getAttributeNode(n)) && r.nodeValue !== !1 ? n.toLowerCase() : t + }, + set: function(e, t, n) { + var r; + return t === !1 ? v.removeAttr(e, n) : (r = v.propFix[n] || n, r in e && (e[r] = !0), e.setAttribute(n, n.toLowerCase())), n + } + }, V || (I = { + name: !0, + id: !0, + coords: !0 + }, j = v.valHooks.button = { + get: function(e, n) { + var r; + return r = e.getAttributeNode(n), r && (I[n] ? r.value !== "" : r.specified) ? r.value : t + }, + set: function(e, t, n) { + var r = e.getAttributeNode(n); + return r || (r = i.createAttribute(n), e.setAttributeNode(r)), r.value = t + "" + } + }, v.each(["width", "height"], function(e, t) { + v.attrHooks[t] = v.extend(v.attrHooks[t], { + set: function(e, n) { + if (n === "") return e.setAttribute(t, "auto"), n + } + }) + }), v.attrHooks.contenteditable = { + get: j.get, + set: function(e, t, n) { + t === "" && (t = "false"), j.set(e, t, n) + } + }), v.support.hrefNormalized || v.each(["href", "src", "width", "height"], function(e, n) { + v.attrHooks[n] = v.extend(v.attrHooks[n], { + get: function(e) { + var r = e.getAttribute(n, 2); + return r === null ? t : r + } + }) + }), v.support.style || (v.attrHooks.style = { + get: function(e) { + return e.style.cssText.toLowerCase() || t + }, + set: function(e, t) { + return e.style.cssText = t + "" + } + }), v.support.optSelected || (v.propHooks.selected = v.extend(v.propHooks.selected, { + get: function(e) { + var t = e.parentNode; + return t && (t.selectedIndex, t.parentNode && t.parentNode.selectedIndex), null + } + })), v.support.enctype || (v.propFix.enctype = "encoding"), v.support.checkOn || v.each(["radio", "checkbox"], function() { + v.valHooks[this] = { + get: function(e) { + return e.getAttribute("value") === null ? "on" : e.value + } + } + }), v.each(["radio", "checkbox"], function() { + v.valHooks[this] = v.extend(v.valHooks[this], { + set: function(e, t) { + if (v.isArray(t)) return e.checked = v.inArray(v(e).val(), t) >= 0 + } + }) + }); + var $ = /^(?:textarea|input|select)$/i, + J = /^([^\.]*|)(?:\.(.+)|)$/, + K = /(?:^|\s)hover(\.\S+|)\b/, + Q = /^key/, + G = /^(?:mouse|contextmenu)|click/, + Y = /^(?:focusinfocus|focusoutblur)$/, + Z = function(e) { + return v.event.special.hover ? e : e.replace(K, "mouseenter$1 mouseleave$1") + }; + v.event = { + add: function(e, n, r, i, s) { + var o, u, a, f, l, c, h, p, d, m, g; + if (e.nodeType === 3 || e.nodeType === 8 || !n || !r || !(o = v._data(e))) return; + r.handler && (d = r, r = d.handler, s = d.selector), r.guid || (r.guid = v.guid++), a = o.events, a || (o.events = a = {}), u = o.handle, u || (o.handle = u = function(e) { + return typeof v == "undefined" || !! e && v.event.triggered === e.type ? t : v.event.dispatch.apply(u.elem, arguments) + }, u.elem = e), n = v.trim(Z(n)).split(" "); + for (f = 0; f < n.length; f++) { + l = J.exec(n[f]) || [], c = l[1], h = (l[2] || "").split(".").sort(), g = v.event.special[c] || {}, c = (s ? g.delegateType : g.bindType) || c, g = v.event.special[c] || {}, p = v.extend({ + type: c, + origType: l[1], + data: i, + handler: r, + guid: r.guid, + selector: s, + needsContext: s && v.expr.match.needsContext.test(s), + namespace: h.join(".") + }, d), m = a[c]; + if (!m) { + m = a[c] = [], m.delegateCount = 0; + if (!g.setup || g.setup.call(e, i, h, u) === !1) e.addEventListener ? e.addEventListener(c, u, !1) : e.attachEvent && e.attachEvent("on" + c, u) + } + g.add && (g.add.call(e, p), p.handler.guid || (p.handler.guid = r.guid)), s ? m.splice(m.delegateCount++, 0, p) : m.push(p), v.event.global[c] = !0 + } + e = null + }, + global: {}, + remove: function(e, t, n, r, i) { + var s, o, u, a, f, l, c, h, p, d, m, g = v.hasData(e) && v._data(e); + if (!g || !(h = g.events)) return; + t = v.trim(Z(t || "")).split(" "); + for (s = 0; s < t.length; s++) { + o = J.exec(t[s]) || [], u = a = o[1], f = o[2]; + if (!u) { + for (u in h) v.event.remove(e, u + t[s], n, r, !0); + continue + } + p = v.event.special[u] || {}, u = (r ? p.delegateType : p.bindType) || u, d = h[u] || [], l = d.length, f = f ? new RegExp("(^|\\.)" + f.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null; + for (c = 0; c < d.length; c++) m = d[c], (i || a === m.origType) && (!n || n.guid === m.guid) && (!f || f.test(m.namespace)) && (!r || r === m.selector || r === "**" && m.selector) && (d.splice(c--, 1), m.selector && d.delegateCount--, p.remove && p.remove.call(e, m)); + d.length === 0 && l !== d.length && ((!p.teardown || p.teardown.call(e, f, g.handle) === !1) && v.removeEvent(e, u, g.handle), delete h[u]) + } + v.isEmptyObject(h) && (delete g.handle, v.removeData(e, "events", !0)) + }, + customEvent: { + getData: !0, + setData: !0, + changeData: !0 + }, + trigger: function(n, r, s, o) { + if (!s || s.nodeType !== 3 && s.nodeType !== 8) { + var u, a, f, l, c, h, p, d, m, g, y = n.type || n, + b = []; + if (Y.test(y + v.event.triggered)) return; + y.indexOf("!") >= 0 && (y = y.slice(0, -1), a = !0), y.indexOf(".") >= 0 && (b = y.split("."), y = b.shift(), b.sort()); + if ((!s || v.event.customEvent[y]) && !v.event.global[y]) return; + n = typeof n == "object" ? n[v.expando] ? n : new v.Event(y, n) : new v.Event(y), n.type = y, n.isTrigger = !0, n.exclusive = a, n.namespace = b.join("."), n.namespace_re = n.namespace ? new RegExp("(^|\\.)" + b.join("\\.(?:.*\\.|)") + "(\\.|$)") : null, h = y.indexOf(":") < 0 ? "on" + y : ""; + if (!s) { + u = v.cache; + for (f in u) u[f].events && u[f].events[y] && v.event.trigger(n, r, u[f].handle.elem, !0); + return + } + n.result = t, n.target || (n.target = s), r = r != null ? v.makeArray(r) : [], r.unshift(n), p = v.event.special[y] || {}; + if (p.trigger && p.trigger.apply(s, r) === !1) return; + m = [ + [s, p.bindType || y] + ]; + if (!o && !p.noBubble && !v.isWindow(s)) { + g = p.delegateType || y, l = Y.test(g + y) ? s : s.parentNode; + for (c = s; l; l = l.parentNode) m.push([l, g]), c = l; + c === (s.ownerDocument || i) && m.push([c.defaultView || c.parentWindow || e, g]) + } + for (f = 0; f < m.length && !n.isPropagationStopped(); f++) l = m[f][0], n.type = m[f][1], d = (v._data(l, "events") || {})[n.type] && v._data(l, "handle"), d && d.apply(l, r), d = h && l[h], d && v.acceptData(l) && d.apply && d.apply(l, r) === !1 && n.preventDefault(); + return n.type = y, !o && !n.isDefaultPrevented() && (!p._default || p._default.apply(s.ownerDocument, r) === !1) && (y !== "click" || !v.nodeName(s, "a")) && v.acceptData(s) && h && s[y] && (y !== "focus" && y !== "blur" || n.target.offsetWidth !== 0) && !v.isWindow(s) && (c = s[h], c && (s[h] = null), v.event.triggered = y, s[y](), v.event.triggered = t, c && (s[h] = c)), n.result + } + return + }, + dispatch: function(n) { + n = v.event.fix(n || e.event); + var r, i, s, o, u, a, f, c, h, p, d = (v._data(this, "events") || {})[n.type] || [], + m = d.delegateCount, + g = l.call(arguments), + y = !n.exclusive && !n.namespace, + b = v.event.special[n.type] || {}, + w = []; + g[0] = n, n.delegateTarget = this; + if (b.preDispatch && b.preDispatch.call(this, n) === !1) return; + if (m && (!n.button || n.type !== "click")) for (s = n.target; s != this; s = s.parentNode || this) if (s.disabled !== !0 || n.type !== "click") { + u = {}, f = []; + for (r = 0; r < m; r++) c = d[r], h = c.selector, u[h] === t && (u[h] = c.needsContext ? v(h, this).index(s) >= 0 : v.find(h, this, null, [s]).length), u[h] && f.push(c); + f.length && w.push({ + elem: s, + matches: f + }) + } + d.length > m && w.push({ + elem: this, + matches: d.slice(m) + }); + for (r = 0; r < w.length && !n.isPropagationStopped(); r++) { + a = w[r], n.currentTarget = a.elem; + for (i = 0; i < a.matches.length && !n.isImmediatePropagationStopped(); i++) { + c = a.matches[i]; + if (y || !n.namespace && !c.namespace || n.namespace_re && n.namespace_re.test(c.namespace)) n.data = c.data, n.handleObj = c, o = ((v.event.special[c.origType] || {}).handle || c.handler).apply(a.elem, g), o !== t && (n.result = o, o === !1 && (n.preventDefault(), n.stopPropagation())) + } + } + return b.postDispatch && b.postDispatch.call(this, n), n.result + }, + props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + fixHooks: {}, + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function(e, t) { + return e.which == null && (e.which = t.charCode != null ? t.charCode : t.keyCode), e + } + }, + mouseHooks: { + props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function(e, n) { + var r, s, o, u = n.button, + a = n.fromElement; + return e.pageX == null && n.clientX != null && (r = e.target.ownerDocument || i, s = r.documentElement, o = r.body, e.pageX = n.clientX + (s && s.scrollLeft || o && o.scrollLeft || 0) - (s && s.clientLeft || o && o.clientLeft || 0), e.pageY = n.clientY + (s && s.scrollTop || o && o.scrollTop || 0) - (s && s.clientTop || o && o.clientTop || 0)), !e.relatedTarget && a && (e.relatedTarget = a === e.target ? n.toElement : a), !e.which && u !== t && (e.which = u & 1 ? 1 : u & 2 ? 3 : u & 4 ? 2 : 0), e + } + }, + fix: function(e) { + if (e[v.expando]) return e; + var t, n, r = e, + s = v.event.fixHooks[e.type] || {}, + o = s.props ? this.props.concat(s.props) : this.props; + e = v.Event(r); + for (t = o.length; t;) n = o[--t], e[n] = r[n]; + return e.target || (e.target = r.srcElement || i), e.target.nodeType === 3 && (e.target = e.target.parentNode), e.metaKey = !! e.metaKey, s.filter ? s.filter(e, r) : e + }, + special: { + load: { + noBubble: !0 + }, + focus: { + delegateType: "focusin" + }, + blur: { + delegateType: "focusout" + }, + beforeunload: { + setup: function(e, t, n) { + v.isWindow(this) && (this.onbeforeunload = n) + }, + teardown: function(e, t) { + this.onbeforeunload === t && (this.onbeforeunload = null) + } + } + }, + simulate: function(e, t, n, r) { + var i = v.extend(new v.Event, n, { + type: e, + isSimulated: !0, + originalEvent: {} + }); + r ? v.event.trigger(i, null, t) : v.event.dispatch.call(t, i), i.isDefaultPrevented() && n.preventDefault() + } + }, v.event.handle = v.event.dispatch, v.removeEvent = i.removeEventListener ? + function(e, t, n) { + e.removeEventListener && e.removeEventListener(t, n, !1) + } : function(e, t, n) { + var r = "on" + t; + e.detachEvent && (typeof e[r] == "undefined" && (e[r] = null), e.detachEvent(r, n)) + }, v.Event = function(e, t) { + if (!(this instanceof v.Event)) return new v.Event(e, t); + e && e.type ? (this.originalEvent = e, this.type = e.type, this.isDefaultPrevented = e.defaultPrevented || e.returnValue === !1 || e.getPreventDefault && e.getPreventDefault() ? tt : et) : this.type = e, t && v.extend(this, t), this.timeStamp = e && e.timeStamp || v.now(), this[v.expando] = !0 + }, v.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = tt; + var e = this.originalEvent; + if (!e) return; + e.preventDefault ? e.preventDefault() : e.returnValue = !1 + }, + stopPropagation: function() { + this.isPropagationStopped = tt; + var e = this.originalEvent; + if (!e) return; + e.stopPropagation && e.stopPropagation(), e.cancelBubble = !0 + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = tt, this.stopPropagation() + }, + isDefaultPrevented: et, + isPropagationStopped: et, + isImmediatePropagationStopped: et + }, v.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" + }, function(e, t) { + v.event.special[e] = { + delegateType: t, + bindType: t, + handle: function(e) { + var n, r = this, + i = e.relatedTarget, + s = e.handleObj, + o = s.selector; + if (!i || i !== r && !v.contains(r, i)) e.type = s.origType, n = s.handler.apply(this, arguments), e.type = t; + return n + } + } + }), v.support.submitBubbles || (v.event.special.submit = { + setup: function() { + if (v.nodeName(this, "form")) return !1; + v.event.add(this, "click._submit keypress._submit", function(e) { + var n = e.target, + r = v.nodeName(n, "input") || v.nodeName(n, "button") ? n.form : t; + r && !v._data(r, "_submit_attached") && (v.event.add(r, "submit._submit", function(e) { + e._submit_bubble = !0 + }), v._data(r, "_submit_attached", !0)) + }) + }, + postDispatch: function(e) { + e._submit_bubble && (delete e._submit_bubble, this.parentNode && !e.isTrigger && v.event.simulate("submit", this.parentNode, e, !0)) + }, + teardown: function() { + if (v.nodeName(this, "form")) return !1; + v.event.remove(this, "._submit") + } + }), v.support.changeBubbles || (v.event.special.change = { + setup: function() { + if ($.test(this.nodeName)) { + if (this.type === "checkbox" || this.type === "radio") v.event.add(this, "propertychange._change", function(e) { + e.originalEvent.propertyName === "checked" && (this._just_changed = !0) + }), v.event.add(this, "click._change", function(e) { + this._just_changed && !e.isTrigger && (this._just_changed = !1), v.event.simulate("change", this, e, !0) + }); + return !1 + } + v.event.add(this, "beforeactivate._change", function(e) { + var t = e.target; + $.test(t.nodeName) && !v._data(t, "_change_attached") && (v.event.add(t, "change._change", function(e) { + this.parentNode && !e.isSimulated && !e.isTrigger && v.event.simulate("change", this.parentNode, e, !0) + }), v._data(t, "_change_attached", !0)) + }) + }, + handle: function(e) { + var t = e.target; + if (this !== t || e.isSimulated || e.isTrigger || t.type !== "radio" && t.type !== "checkbox") return e.handleObj.handler.apply(this, arguments) + }, + teardown: function() { + return v.event.remove(this, "._change"), !$.test(this.nodeName) + } + }), v.support.focusinBubbles || v.each({ + focus: "focusin", + blur: "focusout" + }, function(e, t) { + var n = 0, + r = function(e) { + v.event.simulate(t, e.target, v.event.fix(e), !0) + }; + v.event.special[t] = { + setup: function() { + n++ === 0 && i.addEventListener(e, r, !0) + }, + teardown: function() { + --n === 0 && i.removeEventListener(e, r, !0) + } + } + }), v.fn.extend({ + on: function(e, n, r, i, s) { + var o, u; + if (typeof e == "object") { + typeof n != "string" && (r = r || n, n = t); + for (u in e) this.on(u, n, r, e[u], s); + return this + } + r == null && i == null ? (i = n, r = n = t) : i == null && (typeof n == "string" ? (i = r, r = t) : (i = r, r = n, n = t)); + if (i === !1) i = et; + else if (!i) return this; + return s === 1 && (o = i, i = function(e) { + return v().off(e), o.apply(this, arguments) + }, i.guid = o.guid || (o.guid = v.guid++)), this.each(function() { + v.event.add(this, e, i, r, n) + }) + }, + one: function(e, t, n, r) { + return this.on(e, t, n, r, 1) + }, + off: function(e, n, r) { + var i, s; + if (e && e.preventDefault && e.handleObj) return i = e.handleObj, v(e.delegateTarget).off(i.namespace ? i.origType + "." + i.namespace : i.origType, i.selector, i.handler), this; + if (typeof e == "object") { + for (s in e) this.off(s, n, e[s]); + return this + } + if (n === !1 || typeof n == "function") r = n, n = t; + return r === !1 && (r = et), this.each(function() { + v.event.remove(this, e, r, n) + }) + }, + bind: function(e, t, n) { + return this.on(e, null, t, n) + }, + unbind: function(e, t) { + return this.off(e, null, t) + }, + live: function(e, t, n) { + return v(this.context).on(e, this.selector, t, n), this + }, + die: function(e, t) { + return v(this.context).off(e, this.selector || "**", t), this + }, + delegate: function(e, t, n, r) { + return this.on(t, e, n, r) + }, + undelegate: function(e, t, n) { + return arguments.length === 1 ? this.off(e, "**") : this.off(t, e || "**", n) + }, + trigger: function(e, t) { + return this.each(function() { + v.event.trigger(e, t, this) + }) + }, + triggerHandler: function(e, t) { + if (this[0]) return v.event.trigger(e, t, this[0], !0) + }, + toggle: function(e) { + var t = arguments, + n = e.guid || v.guid++, + r = 0, + i = function(n) { + var i = (v._data(this, "lastToggle" + e.guid) || 0) % r; + return v._data(this, "lastToggle" + e.guid, i + 1), n.preventDefault(), t[i].apply(this, arguments) || !1 + }; + i.guid = n; + while (r < t.length) t[r++].guid = n; + return this.click(i) + }, + hover: function(e, t) { + return this.mouseenter(e).mouseleave(t || e) + } + }), v.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "), function(e, t) { + v.fn[t] = function(e, n) { + return n == null && (n = e, e = null), arguments.length > 0 ? this.on(t, null, e, n) : this.trigger(t) + }, Q.test(t) && (v.event.fixHooks[t] = v.event.keyHooks), G.test(t) && (v.event.fixHooks[t] = v.event.mouseHooks) + }), function(e, t) { + function nt(e, t, n, r) { + n = n || [], t = t || g; + var i, s, a, f, l = t.nodeType; + if (!e || typeof e != "string") return n; + if (l !== 1 && l !== 9) return []; + a = o(t); + if (!a && !r) if (i = R.exec(e)) if (f = i[1]) { + if (l === 9) { + s = t.getElementById(f); + if (!s || !s.parentNode) return n; + if (s.id === f) return n.push(s), n + } else if (t.ownerDocument && (s = t.ownerDocument.getElementById(f)) && u(t, s) && s.id === f) return n.push(s), n + } else { + if (i[2]) return S.apply(n, x.call(t.getElementsByTagName(e), 0)), n; + if ((f = i[3]) && Z && t.getElementsByClassName) return S.apply(n, x.call(t.getElementsByClassName(f), 0)), n + } + return vt(e.replace(j, "$1"), t, n, r, a) + } + + function rt(e) { + return function(t) { + var n = t.nodeName.toLowerCase(); + return n === "input" && t.type === e + } + } + + function it(e) { + return function(t) { + var n = t.nodeName.toLowerCase(); + return (n === "input" || n === "button") && t.type === e + } + } + + function st(e) { + return N(function(t) { + return t = +t, N(function(n, r) { + var i, s = e([], n.length, t), + o = s.length; + while (o--) n[i = s[o]] && (n[i] = !(r[i] = n[i])) + }) + }) + } + + function ot(e, t, n) { + if (e === t) return n; + var r = e.nextSibling; + while (r) { + if (r === t) return -1; + r = r.nextSibling + } + return 1 + } + + function ut(e, t) { + var n, r, s, o, u, a, f, l = L[d][e + " "]; + if (l) return t ? 0 : l.slice(0); + u = e, a = [], f = i.preFilter; + while (u) { + if (!n || (r = F.exec(u))) r && (u = u.slice(r[0].length) || u), a.push(s = []); + n = !1; + if (r = I.exec(u)) s.push(n = new m(r.shift())), u = u.slice(n.length), n.type = r[0].replace(j, " "); + for (o in i.filter)(r = J[o].exec(u)) && (!f[o] || (r = f[o](r))) && (s.push(n = new m(r.shift())), u = u.slice(n.length), n.type = o, n.matches = r); + if (!n) break + } + return t ? u.length : u ? nt.error(e) : L(e, a).slice(0) + } + + function at(e, t, r) { + var i = t.dir, + s = r && t.dir === "parentNode", + o = w++; + return t.first ? + function(t, n, r) { + while (t = t[i]) if (s || t.nodeType === 1) return e(t, n, r) + } : function(t, r, u) { + if (!u) { + var a, f = b + " " + o + " ", + l = f + n; + while (t = t[i]) if (s || t.nodeType === 1) { + if ((a = t[d]) === l) return t.sizset; + if (typeof a == "string" && a.indexOf(f) === 0) { + if (t.sizset) return t + } else { + t[d] = l; + if (e(t, r, u)) return t.sizset = !0, t; + t.sizset = !1 + } + } + } else while (t = t[i]) if (s || t.nodeType === 1) if (e(t, r, u)) return t + } + } + + function ft(e) { + return e.length > 1 ? + function(t, n, r) { + var i = e.length; + while (i--) if (!e[i](t, n, r)) return !1; + return !0 + } : e[0] + } + + function lt(e, t, n, r, i) { + var s, o = [], + u = 0, + a = e.length, + f = t != null; + for (; u < a; u++) if (s = e[u]) if (!n || n(s, r, i)) o.push(s), f && t.push(u); + return o + } + + function ct(e, t, n, r, i, s) { + return r && !r[d] && (r = ct(r)), i && !i[d] && (i = ct(i, s)), N(function(s, o, u, a) { + var f, l, c, h = [], + p = [], + d = o.length, + v = s || dt(t || "*", u.nodeType ? [u] : u, []), + m = e && (s || !t) ? lt(v, h, e, u, a) : v, + g = n ? i || (s ? e : d || r) ? [] : o : m; + n && n(m, g, u, a); + if (r) { + f = lt(g, p), r(f, [], u, a), l = f.length; + while (l--) if (c = f[l]) g[p[l]] = !(m[p[l]] = c) + } + if (s) { + if (i || e) { + if (i) { + f = [], l = g.length; + while (l--)(c = g[l]) && f.push(m[l] = c); + i(null, g = [], f, a) + } + l = g.length; + while (l--)(c = g[l]) && (f = i ? T.call(s, c) : h[l]) > -1 && (s[f] = !(o[f] = c)) + } + } else g = lt(g === o ? g.splice(d, g.length) : g), i ? i(null, o, g, a) : S.apply(o, g) + }) + } + + function ht(e) { + var t, n, r, s = e.length, + o = i.relative[e[0].type], + u = o || i.relative[" "], + a = o ? 1 : 0, + f = at(function(e) { + return e === t + }, u, !0), + l = at(function(e) { + return T.call(t, e) > -1 + }, u, !0), + h = [function(e, n, r) { + return !o && (r || n !== c) || ((t = n).nodeType ? f(e, n, r) : l(e, n, r)) + }]; + for (; a < s; a++) if (n = i.relative[e[a].type]) h = [at(ft(h), n)]; + else { + n = i.filter[e[a].type].apply(null, e[a].matches); + if (n[d]) { + r = ++a; + for (; r < s; r++) if (i.relative[e[r].type]) break; + return ct(a > 1 && ft(h), a > 1 && e.slice(0, a - 1).join("").replace(j, "$1"), n, a < r && ht(e.slice(a, r)), r < s && ht(e = e.slice(r)), r < s && e.join("")) + } + h.push(n) + } + return ft(h) + } + + function pt(e, t) { + var r = t.length > 0, + s = e.length > 0, + o = function(u, a, f, l, h) { + var p, d, v, m = [], + y = 0, + w = "0", + x = u && [], + T = h != null, + N = c, + C = u || s && i.find.TAG("*", h && a.parentNode || a), + k = b += N == null ? 1 : Math.E; + T && (c = a !== g && a, n = o.el); + for (; + (p = C[w]) != null; w++) { + if (s && p) { + for (d = 0; v = e[d]; d++) if (v(p, a, f)) { + l.push(p); + break + } + T && (b = k, n = ++o.el) + } + r && ((p = !v && p) && y--, u && x.push(p)) + } + y += w; + if (r && w !== y) { + for (d = 0; v = t[d]; d++) v(x, m, a, f); + if (u) { + if (y > 0) while (w--)!x[w] && !m[w] && (m[w] = E.call(l)); + m = lt(m) + } + S.apply(l, m), T && !u && m.length > 0 && y + t.length > 1 && nt.uniqueSort(l) + } + return T && (b = k, c = N), x + }; + return o.el = 0, r ? N(o) : o + } + + function dt(e, t, n) { + var r = 0, + i = t.length; + for (; r < i; r++) nt(e, t[r], n); + return n + } + + function vt(e, t, n, r, s) { + var o, u, f, l, c, h = ut(e), + p = h.length; + if (!r && h.length === 1) { + u = h[0] = h[0].slice(0); + if (u.length > 2 && (f = u[0]).type === "ID" && t.nodeType === 9 && !s && i.relative[u[1].type]) { + t = i.find.ID(f.matches[0].replace($, ""), t, s)[0]; + if (!t) return n; + e = e.slice(u.shift().length) + } + for (o = J.POS.test(e) ? -1 : u.length - 1; o >= 0; o--) { + f = u[o]; + if (i.relative[l = f.type]) break; + if (c = i.find[l]) if (r = c(f.matches[0].replace($, ""), z.test(u[0].type) && t.parentNode || t, s)) { + u.splice(o, 1), e = r.length && u.join(""); + if (!e) return S.apply(n, x.call(r, 0)), n; + break + } + } + } + return a(e, h)(r, t, s, n, z.test(e)), n + } + + function mt() {} + var n, r, i, s, o, u, a, f, l, c, h = !0, + p = "undefined", + d = ("sizcache" + Math.random()).replace(".", ""), + m = String, + g = e.document, + y = g.documentElement, + b = 0, + w = 0, + E = [].pop, + S = [].push, + x = [].slice, + T = [].indexOf || + function(e) { + var t = 0, + n = this.length; + for (; t < n; t++) if (this[t] === e) return t; + return -1 + }, + N = function(e, t) { + return e[d] = t == null || t, e + }, + C = function() { + var e = {}, + t = []; + return N(function(n, r) { + return t.push(n) > i.cacheLength && delete e[t.shift()], e[n + " "] = r + }, e) + }, + k = C(), + L = C(), + A = C(), + O = "[\\x20\\t\\r\\n\\f]", + M = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+", + _ = M.replace("w", "w#"), + D = "([*^$|!~]?=)", + P = "\\[" + O + "*(" + M + ")" + O + "*(?:" + D + O + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + _ + ")|)|)" + O + "*\\]", + H = ":(" + M + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + P + ")|[^:]|\\\\.)*|.*))\\)|)", + B = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + O + "*((?:-\\d)?\\d*)" + O + "*\\)|)(?=[^-]|$)", + j = new RegExp("^" + O + "+|((?:^|[^\\\\])(?:\\\\.)*)" + O + "+$", "g"), + F = new RegExp("^" + O + "*," + O + "*"), + I = new RegExp("^" + O + "*([\\x20\\t\\r\\n\\f>+~])" + O + "*"), + q = new RegExp(H), + R = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/, + U = /^:not/, + z = /[\x20\t\r\n\f]*[+~]/, + W = /:not\($/, + X = /h\d/i, + V = /input|select|textarea|button/i, + $ = /\\(?!\\)/g, + J = { + ID: new RegExp("^#(" + M + ")"), + CLASS: new RegExp("^\\.(" + M + ")"), + NAME: new RegExp("^\\[name=['\"]?(" + M + ")['\"]?\\]"), + TAG: new RegExp("^(" + M.replace("w", "w*") + ")"), + ATTR: new RegExp("^" + P), + PSEUDO: new RegExp("^" + H), + POS: new RegExp(B, "i"), + CHILD: new RegExp("^:(only|nth|first|last)-child(?:\\(" + O + "*(even|odd|(([+-]|)(\\d*)n|)" + O + "*(?:([+-]|)" + O + "*(\\d+)|))" + O + "*\\)|)", "i"), + needsContext: new RegExp("^" + O + "*[>+~]|" + B, "i") + }, + K = function(e) { + var t = g.createElement("div"); + try { + return e(t) + } catch (n) { + return !1 + } finally { + t = null + } + }, + Q = K(function(e) { + return e.appendChild(g.createComment("")), !e.getElementsByTagName("*").length + }), + G = K(function(e) { + return e.innerHTML = "", e.firstChild && typeof e.firstChild.getAttribute !== p && e.firstChild.getAttribute("href") === "#" + }), + Y = K(function(e) { + e.innerHTML = ""; + var t = typeof e.lastChild.getAttribute("multiple"); + return t !== "boolean" && t !== "string" + }), + Z = K(function(e) { + return e.innerHTML = "", !e.getElementsByClassName || !e.getElementsByClassName("e").length ? !1 : (e.lastChild.className = "e", e.getElementsByClassName("e").length === 2) + }), + et = K(function(e) { + e.id = d + 0, e.innerHTML = "
    ", y.insertBefore(e, y.firstChild); + var t = g.getElementsByName && g.getElementsByName(d).length === 2 + g.getElementsByName(d + 0).length; + return r = !g.getElementById(d), y.removeChild(e), t + }); + try { + x.call(y.childNodes, 0)[0].nodeType + } catch (tt) { + x = function(e) { + var t, n = []; + for (; t = this[e]; e++) n.push(t); + return n + } + } + nt.matches = function(e, t) { + return nt(e, null, null, t) + }, nt.matchesSelector = function(e, t) { + return nt(t, null, null, [e]).length > 0 + }, s = nt.getText = function(e) { + var t, n = "", + r = 0, + i = e.nodeType; + if (i) { + if (i === 1 || i === 9 || i === 11) { + if (typeof e.textContent == "string") return e.textContent; + for (e = e.firstChild; e; e = e.nextSibling) n += s(e) + } else if (i === 3 || i === 4) return e.nodeValue + } else for (; t = e[r]; r++) n += s(t); + return n + }, o = nt.isXML = function(e) { + var t = e && (e.ownerDocument || e).documentElement; + return t ? t.nodeName !== "HTML" : !1 + }, u = nt.contains = y.contains ? + function(e, t) { + var n = e.nodeType === 9 ? e.documentElement : e, + r = t && t.parentNode; + return e === r || !! (r && r.nodeType === 1 && n.contains && n.contains(r)) + } : y.compareDocumentPosition ? + function(e, t) { + return t && !! (e.compareDocumentPosition(t) & 16) + } : function(e, t) { + while (t = t.parentNode) if (t === e) return !0; + return !1 + }, nt.attr = function(e, t) { + var n, r = o(e); + return r || (t = t.toLowerCase()), (n = i.attrHandle[t]) ? n(e) : r || Y ? e.getAttribute(t) : (n = e.getAttributeNode(t), n ? typeof e[t] == "boolean" ? e[t] ? t : null : n.specified ? n.value : null : null) + }, i = nt.selectors = { + cacheLength: 50, + createPseudo: N, + match: J, + attrHandle: G ? {} : { + href: function(e) { + return e.getAttribute("href", 2) + }, + type: function(e) { + return e.getAttribute("type") + } + }, + find: { + ID: r ? + function(e, t, n) { + if (typeof t.getElementById !== p && !n) { + var r = t.getElementById(e); + return r && r.parentNode ? [r] : [] + } + } : function(e, n, r) { + if (typeof n.getElementById !== p && !r) { + var i = n.getElementById(e); + return i ? i.id === e || typeof i.getAttributeNode !== p && i.getAttributeNode("id").value === e ? [i] : t : [] + } + }, + TAG: Q ? + function(e, t) { + if (typeof t.getElementsByTagName !== p) return t.getElementsByTagName(e) + } : function(e, t) { + var n = t.getElementsByTagName(e); + if (e === "*") { + var r, i = [], + s = 0; + for (; r = n[s]; s++) r.nodeType === 1 && i.push(r); + return i + } + return n + }, + NAME: et && + function(e, t) { + if (typeof t.getElementsByName !== p) return t.getElementsByName(name) + }, + CLASS: Z && + function(e, t, n) { + if (typeof t.getElementsByClassName !== p && !n) return t.getElementsByClassName(e) + } + }, + relative: { + ">": { + dir: "parentNode", + first: !0 + }, + " ": { + dir: "parentNode" + }, + "+": { + dir: "previousSibling", + first: !0 + }, + "~": { + dir: "previousSibling" + } + }, + preFilter: { + ATTR: function(e) { + return e[1] = e[1].replace($, ""), e[3] = (e[4] || e[5] || "").replace($, ""), e[2] === "~=" && (e[3] = " " + e[3] + " "), e.slice(0, 4) + }, + CHILD: function(e) { + return e[1] = e[1].toLowerCase(), e[1] === "nth" ? (e[2] || nt.error(e[0]), e[3] = +(e[3] ? e[4] + (e[5] || 1) : 2 * (e[2] === "even" || e[2] === "odd")), e[4] = +(e[6] + e[7] || e[2] === "odd")) : e[2] && nt.error(e[0]), e + }, + PSEUDO: function(e) { + var t, n; + if (J.CHILD.test(e[0])) return null; + if (e[3]) e[2] = e[3]; + else if (t = e[4]) q.test(t) && (n = ut(t, !0)) && (n = t.indexOf(")", t.length - n) - t.length) && (t = t.slice(0, n), e[0] = e[0].slice(0, n)), e[2] = t; + return e.slice(0, 3) + } + }, + filter: { + ID: r ? + function(e) { + return e = e.replace($, ""), function(t) { + return t.getAttribute("id") === e + } + } : function(e) { + return e = e.replace($, ""), function(t) { + var n = typeof t.getAttributeNode !== p && t.getAttributeNode("id"); + return n && n.value === e + } + }, + TAG: function(e) { + return e === "*" ? + function() { + return !0 + } : (e = e.replace($, "").toLowerCase(), function(t) { + return t.nodeName && t.nodeName.toLowerCase() === e + }) + }, + CLASS: function(e) { + var t = k[d][e + " "]; + return t || (t = new RegExp("(^|" + O + ")" + e + "(" + O + "|$)")) && k(e, function(e) { + return t.test(e.className || typeof e.getAttribute !== p && e.getAttribute("class") || "") + }) + }, + ATTR: function(e, t, n) { + return function(r, i) { + var s = nt.attr(r, e); + return s == null ? t === "!=" : t ? (s += "", t === "=" ? s === n : t === "!=" ? s !== n : t === "^=" ? n && s.indexOf(n) === 0 : t === "*=" ? n && s.indexOf(n) > -1 : t === "$=" ? n && s.substr(s.length - n.length) === n : t === "~=" ? (" " + s + " ").indexOf(n) > -1 : t === "|=" ? s === n || s.substr(0, n.length + 1) === n + "-" : !1) : !0 + } + }, + CHILD: function(e, t, n, r) { + return e === "nth" ? + function(e) { + var t, i, s = e.parentNode; + if (n === 1 && r === 0) return !0; + if (s) { + i = 0; + for (t = s.firstChild; t; t = t.nextSibling) if (t.nodeType === 1) { + i++; + if (e === t) break + } + } + return i -= r, i === n || i % n === 0 && i / n >= 0 + } : function(t) { + var n = t; + switch (e) { + case "only": + case "first": + while (n = n.previousSibling) if (n.nodeType === 1) return !1; + if (e === "first") return !0; + n = t; + case "last": + while (n = n.nextSibling) if (n.nodeType === 1) return !1; + return !0 + } + } + }, + PSEUDO: function(e, t) { + var n, r = i.pseudos[e] || i.setFilters[e.toLowerCase()] || nt.error("unsupported pseudo: " + e); + return r[d] ? r(t) : r.length > 1 ? (n = [e, e, "", t], i.setFilters.hasOwnProperty(e.toLowerCase()) ? N(function(e, n) { + var i, s = r(e, t), + o = s.length; + while (o--) i = T.call(e, s[o]), e[i] = !(n[i] = s[o]) + }) : function(e) { + return r(e, 0, n) + }) : r + } + }, + pseudos: { + not: N(function(e) { + var t = [], + n = [], + r = a(e.replace(j, "$1")); + return r[d] ? N(function(e, t, n, i) { + var s, o = r(e, null, i, []), + u = e.length; + while (u--) if (s = o[u]) e[u] = !(t[u] = s) + }) : function(e, i, s) { + return t[0] = e, r(t, null, s, n), !n.pop() + } + }), + has: N(function(e) { + return function(t) { + return nt(e, t).length > 0 + } + }), + contains: N(function(e) { + return function(t) { + return (t.textContent || t.innerText || s(t)).indexOf(e) > -1 + } + }), + enabled: function(e) { + return e.disabled === !1 + }, + disabled: function(e) { + return e.disabled === !0 + }, + checked: function(e) { + var t = e.nodeName.toLowerCase(); + return t === "input" && !! e.checked || t === "option" && !! e.selected + }, + selected: function(e) { + return e.parentNode && e.parentNode.selectedIndex, e.selected === !0 + }, + parent: function(e) { + return !i.pseudos.empty(e) + }, + empty: function(e) { + var t; + e = e.firstChild; + while (e) { + if (e.nodeName > "@" || (t = e.nodeType) === 3 || t === 4) return !1; + e = e.nextSibling + } + return !0 + }, + header: function(e) { + return X.test(e.nodeName) + }, + text: function(e) { + var t, n; + return e.nodeName.toLowerCase() === "input" && (t = e.type) === "text" && ((n = e.getAttribute("type")) == null || n.toLowerCase() === t) + }, + radio: rt("radio"), + checkbox: rt("checkbox"), + file: rt("file"), + password: rt("password"), + image: rt("image"), + submit: it("submit"), + reset: it("reset"), + button: function(e) { + var t = e.nodeName.toLowerCase(); + return t === "input" && e.type === "button" || t === "button" + }, + input: function(e) { + return V.test(e.nodeName) + }, + focus: function(e) { + var t = e.ownerDocument; + return e === t.activeElement && (!t.hasFocus || t.hasFocus()) && !! (e.type || e.href || ~e.tabIndex) + }, + active: function(e) { + return e === e.ownerDocument.activeElement + }, + first: st(function() { + return [0] + }), + last: st(function(e, t) { + return [t - 1] + }), + eq: st(function(e, t, n) { + return [n < 0 ? n + t : n] + }), + even: st(function(e, t) { + for (var n = 0; n < t; n += 2) e.push(n); + return e + }), + odd: st(function(e, t) { + for (var n = 1; n < t; n += 2) e.push(n); + return e + }), + lt: st(function(e, t, n) { + for (var r = n < 0 ? n + t : n; --r >= 0;) e.push(r); + return e + }), + gt: st(function(e, t, n) { + for (var r = n < 0 ? n + t : n; ++r < t;) e.push(r); + return e + }) + } + }, f = y.compareDocumentPosition ? + function(e, t) { + return e === t ? (l = !0, 0) : (!e.compareDocumentPosition || !t.compareDocumentPosition ? e.compareDocumentPosition : e.compareDocumentPosition(t) & 4) ? -1 : 1 + } : function(e, t) { + if (e === t) return l = !0, 0; + if (e.sourceIndex && t.sourceIndex) return e.sourceIndex - t.sourceIndex; + var n, r, i = [], + s = [], + o = e.parentNode, + u = t.parentNode, + a = o; + if (o === u) return ot(e, t); + if (!o) return -1; + if (!u) return 1; + while (a) i.unshift(a), a = a.parentNode; + a = u; + while (a) s.unshift(a), a = a.parentNode; + n = i.length, r = s.length; + for (var f = 0; f < n && f < r; f++) if (i[f] !== s[f]) return ot(i[f], s[f]); + return f === n ? ot(e, s[f], -1) : ot(i[f], t, 1) + }, [0, 0].sort(f), h = !l, nt.uniqueSort = function(e) { + var t, n = [], + r = 1, + i = 0; + l = h, e.sort(f); + if (l) { + for (; t = e[r]; r++) t === e[r - 1] && (i = n.push(r)); + while (i--) e.splice(n[i], 1) + } + return e + }, nt.error = function(e) { + throw new Error("Syntax error, unrecognized expression: " + e) + }, a = nt.compile = function(e, t) { + var n, r = [], + i = [], + s = A[d][e + " "]; + if (!s) { + t || (t = ut(e)), n = t.length; + while (n--) s = ht(t[n]), s[d] ? r.push(s) : i.push(s); + s = A(e, pt(i, r)) + } + return s + }, g.querySelectorAll && + function() { + var e, t = vt, + n = /'|\\/g, + r = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g, + i = [":focus"], + s = [":active"], + u = y.matchesSelector || y.mozMatchesSelector || y.webkitMatchesSelector || y.oMatchesSelector || y.msMatchesSelector; + K(function(e) { + e.innerHTML = "", e.querySelectorAll("[selected]").length || i.push("\\[" + O + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)"), e.querySelectorAll(":checked").length || i.push(":checked") + }), K(function(e) { + e.innerHTML = "

    ", e.querySelectorAll("[test^='']").length && i.push("[*^$]=" + O + "*(?:\"\"|'')"), e.innerHTML = "", e.querySelectorAll(":enabled").length || i.push(":enabled", ":disabled") + }), i = new RegExp(i.join("|")), vt = function(e, r, s, o, u) { + if (!o && !u && !i.test(e)) { + var a, f, l = !0, + c = d, + h = r, + p = r.nodeType === 9 && e; + if (r.nodeType === 1 && r.nodeName.toLowerCase() !== "object") { + a = ut(e), (l = r.getAttribute("id")) ? c = l.replace(n, "\\$&") : r.setAttribute("id", c), c = "[id='" + c + "'] ", f = a.length; + while (f--) a[f] = c + a[f].join(""); + h = z.test(e) && r.parentNode || r, p = a.join(",") + } + if (p) try { + return S.apply(s, x.call(h.querySelectorAll(p), 0)), s + } catch (v) {} finally { + l || r.removeAttribute("id") + } + } + return t(e, r, s, o, u) + }, u && (K(function(t) { + e = u.call(t, "div"); + try { + u.call(t, "[test!='']:sizzle"), s.push("!=", H) + } catch (n) {} + }), s = new RegExp(s.join("|")), nt.matchesSelector = function(t, n) { + n = n.replace(r, "='$1']"); + if (!o(t) && !s.test(n) && !i.test(n)) try { + var a = u.call(t, n); + if (a || e || t.document && t.document.nodeType !== 11) return a + } catch (f) {} + return nt(n, null, null, [t]).length > 0 + }) + }(), i.pseudos.nth = i.pseudos.eq, i.filters = mt.prototype = i.pseudos, i.setFilters = new mt, nt.attr = v.attr, v.find = nt, v.expr = nt.selectors, v.expr[":"] = v.expr.pseudos, v.unique = nt.uniqueSort, v.text = nt.getText, v.isXMLDoc = nt.isXML, v.contains = nt.contains + }(e); + var nt = /Until$/, + rt = /^(?:parents|prev(?:Until|All))/, + it = /^.[^:#\[\.,]*$/, + st = v.expr.match.needsContext, + ot = { + children: !0, + contents: !0, + next: !0, + prev: !0 + }; + v.fn.extend({ + find: function(e) { + var t, n, r, i, s, o, u = this; + if (typeof e != "string") return v(e).filter(function() { + for (t = 0, n = u.length; t < n; t++) if (v.contains(u[t], this)) return !0 + }); + o = this.pushStack("", "find", e); + for (t = 0, n = this.length; t < n; t++) { + r = o.length, v.find(e, this[t], o); + if (t > 0) for (i = r; i < o.length; i++) for (s = 0; s < r; s++) if (o[s] === o[i]) { + o.splice(i--, 1); + break + } + } + return o + }, + has: function(e) { + var t, n = v(e, this), + r = n.length; + return this.filter(function() { + for (t = 0; t < r; t++) if (v.contains(this, n[t])) return !0 + }) + }, + not: function(e) { + return this.pushStack(ft(this, e, !1), "not", e) + }, + filter: function(e) { + return this.pushStack(ft(this, e, !0), "filter", e) + }, + is: function(e) { + return !!e && (typeof e == "string" ? st.test(e) ? v(e, this.context).index(this[0]) >= 0 : v.filter(e, this).length > 0 : this.filter(e).length > 0) + }, + closest: function(e, t) { + var n, r = 0, + i = this.length, + s = [], + o = st.test(e) || typeof e != "string" ? v(e, t || this.context) : 0; + for (; r < i; r++) { + n = this[r]; + while (n && n.ownerDocument && n !== t && n.nodeType !== 11) { + if (o ? o.index(n) > -1 : v.find.matchesSelector(n, e)) { + s.push(n); + break + } + n = n.parentNode + } + } + return s = s.length > 1 ? v.unique(s) : s, this.pushStack(s, "closest", e) + }, + index: function(e) { + return e ? typeof e == "string" ? v.inArray(this[0], v(e)) : v.inArray(e.jquery ? e[0] : e, this) : this[0] && this[0].parentNode ? this.prevAll().length : -1 + }, + add: function(e, t) { + var n = typeof e == "string" ? v(e, t) : v.makeArray(e && e.nodeType ? [e] : e), + r = v.merge(this.get(), n); + return this.pushStack(ut(n[0]) || ut(r[0]) ? r : v.unique(r)) + }, + addBack: function(e) { + return this.add(e == null ? this.prevObject : this.prevObject.filter(e)) + } + }), v.fn.andSelf = v.fn.addBack, v.each({ + parent: function(e) { + var t = e.parentNode; + return t && t.nodeType !== 11 ? t : null + }, + parents: function(e) { + return v.dir(e, "parentNode") + }, + parentsUntil: function(e, t, n) { + return v.dir(e, "parentNode", n) + }, + next: function(e) { + return at(e, "nextSibling") + }, + prev: function(e) { + return at(e, "previousSibling") + }, + nextAll: function(e) { + return v.dir(e, "nextSibling") + }, + prevAll: function(e) { + return v.dir(e, "previousSibling") + }, + nextUntil: function(e, t, n) { + return v.dir(e, "nextSibling", n) + }, + prevUntil: function(e, t, n) { + return v.dir(e, "previousSibling", n) + }, + siblings: function(e) { + return v.sibling((e.parentNode || {}).firstChild, e) + }, + children: function(e) { + return v.sibling(e.firstChild) + }, + contents: function(e) { + return v.nodeName(e, "iframe") ? e.contentDocument || e.contentWindow.document : v.merge([], e.childNodes) + } + }, function(e, t) { + v.fn[e] = function(n, r) { + var i = v.map(this, t, n); + return nt.test(e) || (r = n), r && typeof r == "string" && (i = v.filter(r, i)), i = this.length > 1 && !ot[e] ? v.unique(i) : i, this.length > 1 && rt.test(e) && (i = i.reverse()), this.pushStack(i, e, l.call(arguments).join(",")) + } + }), v.extend({ + filter: function(e, t, n) { + return n && (e = ":not(" + e + ")"), t.length === 1 ? v.find.matchesSelector(t[0], e) ? [t[0]] : [] : v.find.matches(e, t) + }, + dir: function(e, n, r) { + var i = [], + s = e[n]; + while (s && s.nodeType !== 9 && (r === t || s.nodeType !== 1 || !v(s).is(r))) s.nodeType === 1 && i.push(s), s = s[n]; + return i + }, + sibling: function(e, t) { + var n = []; + for (; e; e = e.nextSibling) e.nodeType === 1 && e !== t && n.push(e); + return n + } + }); + var ct = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", + ht = / jQuery\d+="(?:null|\d+)"/g, + pt = /^\s+/, + dt = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, + vt = /<([\w:]+)/, + mt = /]", "i"), + Et = /^(?:checkbox|radio)$/, + St = /checked\s*(?:[^=]|=\s*.checked.)/i, + xt = /\/(java|ecma)script/i, + Tt = /^\s*\s*$/g, + Nt = { + option: [1, ""], + legend: [1, "
    ", "
    "], + thead: [1, "", "
    "], + tr: [2, "", "
    "], + td: [3, "", "
    "], + col: [2, "", "
    "], + area: [1, "", ""], + _default: [0, "", ""] + }, + Ct = lt(i), + kt = Ct.appendChild(i.createElement("div")); + Nt.optgroup = Nt.option, Nt.tbody = Nt.tfoot = Nt.colgroup = Nt.caption = Nt.thead, Nt.th = Nt.td, v.support.htmlSerialize || (Nt._default = [1, "X
    ", "
    "]), v.fn.extend({ + text: function(e) { + return v.access(this, function(e) { + return e === t ? v.text(this) : this.empty().append((this[0] && this[0].ownerDocument || i).createTextNode(e)) + }, null, e, arguments.length) + }, + wrapAll: function(e) { + if (v.isFunction(e)) return this.each(function(t) { + v(this).wrapAll(e.call(this, t)) + }); + if (this[0]) { + var t = v(e, this[0].ownerDocument).eq(0).clone(!0); + this[0].parentNode && t.insertBefore(this[0]), t.map(function() { + var e = this; + while (e.firstChild && e.firstChild.nodeType === 1) e = e.firstChild; + return e + }).append(this) + } + return this + }, + wrapInner: function(e) { + return v.isFunction(e) ? this.each(function(t) { + v(this).wrapInner(e.call(this, t)) + }) : this.each(function() { + var t = v(this), + n = t.contents(); + n.length ? n.wrapAll(e) : t.append(e) + }) + }, + wrap: function(e) { + var t = v.isFunction(e); + return this.each(function(n) { + v(this).wrapAll(t ? e.call(this, n) : e) + }) + }, + unwrap: function() { + return this.parent().each(function() { + v.nodeName(this, "body") || v(this).replaceWith(this.childNodes) + }).end() + }, + append: function() { + return this.domManip(arguments, !0, function(e) { + (this.nodeType === 1 || this.nodeType === 11) && this.appendChild(e) + }) + }, + prepend: function() { + return this.domManip(arguments, !0, function(e) { + (this.nodeType === 1 || this.nodeType === 11) && this.insertBefore(e, this.firstChild) + }) + }, + before: function() { + if (!ut(this[0])) return this.domManip(arguments, !1, function(e) { + this.parentNode.insertBefore(e, this) + }); + if (arguments.length) { + var e = v.clean(arguments); + return this.pushStack(v.merge(e, this), "before", this.selector) + } + }, + after: function() { + if (!ut(this[0])) return this.domManip(arguments, !1, function(e) { + this.parentNode.insertBefore(e, this.nextSibling) + }); + if (arguments.length) { + var e = v.clean(arguments); + return this.pushStack(v.merge(this, e), "after", this.selector) + } + }, + remove: function(e, t) { + var n, r = 0; + for (; + (n = this[r]) != null; r++) if (!e || v.filter(e, [n]).length)!t && n.nodeType === 1 && (v.cleanData(n.getElementsByTagName("*")), v.cleanData([n])), n.parentNode && n.parentNode.removeChild(n); + return this + }, + empty: function() { + var e, t = 0; + for (; + (e = this[t]) != null; t++) { + e.nodeType === 1 && v.cleanData(e.getElementsByTagName("*")); + while (e.firstChild) e.removeChild(e.firstChild) + } + return this + }, + clone: function(e, t) { + return e = e == null ? !1 : e, t = t == null ? e : t, this.map(function() { + return v.clone(this, e, t) + }) + }, + html: function(e) { + return v.access(this, function(e) { + var n = this[0] || {}, + r = 0, + i = this.length; + if (e === t) return n.nodeType === 1 ? n.innerHTML.replace(ht, "") : t; + if (typeof e == "string" && !yt.test(e) && (v.support.htmlSerialize || !wt.test(e)) && (v.support.leadingWhitespace || !pt.test(e)) && !Nt[(vt.exec(e) || ["", ""])[1].toLowerCase()]) { + e = e.replace(dt, "<$1>"); + try { + for (; r < i; r++) n = this[r] || {}, n.nodeType === 1 && (v.cleanData(n.getElementsByTagName("*")), n.innerHTML = e); + n = 0 + } catch (s) {} + } + n && this.empty().append(e) + }, null, e, arguments.length) + }, + replaceWith: function(e) { + return ut(this[0]) ? this.length ? this.pushStack(v(v.isFunction(e) ? e() : e), "replaceWith", e) : this : v.isFunction(e) ? this.each(function(t) { + var n = v(this), + r = n.html(); + n.replaceWith(e.call(this, t, r)) + }) : (typeof e != "string" && (e = v(e).detach()), this.each(function() { + var t = this.nextSibling, + n = this.parentNode; + v(this).remove(), t ? v(t).before(e) : v(n).append(e) + })) + }, + detach: function(e) { + return this.remove(e, !0) + }, + domManip: function(e, n, r) { + e = [].concat.apply([], e); + var i, s, o, u, a = 0, + f = e[0], + l = [], + c = this.length; + if (!v.support.checkClone && c > 1 && typeof f == "string" && St.test(f)) return this.each(function() { + v(this).domManip(e, n, r) + }); + if (v.isFunction(f)) return this.each(function(i) { + var s = v(this); + e[0] = f.call(this, i, n ? s.html() : t), s.domManip(e, n, r) + }); + if (this[0]) { + i = v.buildFragment(e, this, l), o = i.fragment, s = o.firstChild, o.childNodes.length === 1 && (o = s); + if (s) { + n = n && v.nodeName(s, "tr"); + for (u = i.cacheable || c - 1; a < c; a++) r.call(n && v.nodeName(this[a], "table") ? Lt(this[a], "tbody") : this[a], a === u ? o : v.clone(o, !0, !0)) + } + o = s = null, l.length && v.each(l, function(e, t) { + t.src ? v.ajax ? v.ajax({ + url: t.src, + type: "GET", + dataType: "script", + async: !1, + global: !1, + "throws": !0 + }) : v.error("no ajax") : v.globalEval((t.text || t.textContent || t.innerHTML || "").replace(Tt, "")), t.parentNode && t.parentNode.removeChild(t) + }) + } + return this + } + }), v.buildFragment = function(e, n, r) { + var s, o, u, a = e[0]; + return n = n || i, n = !n.nodeType && n[0] || n, n = n.ownerDocument || n, e.length === 1 && typeof a == "string" && a.length < 512 && n === i && a.charAt(0) === "<" && !bt.test(a) && (v.support.checkClone || !St.test(a)) && (v.support.html5Clone || !wt.test(a)) && (o = !0, s = v.fragments[a], u = s !== t), s || (s = n.createDocumentFragment(), v.clean(e, n, s, r), o && (v.fragments[a] = u && s)), { + fragment: s, + cacheable: o + } + }, v.fragments = {}, v.each({ + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" + }, function(e, t) { + v.fn[e] = function(n) { + var r, i = 0, + s = [], + o = v(n), + u = o.length, + a = this.length === 1 && this[0].parentNode; + if ((a == null || a && a.nodeType === 11 && a.childNodes.length === 1) && u === 1) return o[t](this[0]), this; + for (; i < u; i++) r = (i > 0 ? this.clone(!0) : this).get(), v(o[i])[t](r), s = s.concat(r); + return this.pushStack(s, e, o.selector) + } + }), v.extend({ + clone: function(e, t, n) { + var r, i, s, o; + v.support.html5Clone || v.isXMLDoc(e) || !wt.test("<" + e.nodeName + ">") ? o = e.cloneNode(!0) : (kt.innerHTML = e.outerHTML, kt.removeChild(o = kt.firstChild)); + if ((!v.support.noCloneEvent || !v.support.noCloneChecked) && (e.nodeType === 1 || e.nodeType === 11) && !v.isXMLDoc(e)) { + Ot(e, o), r = Mt(e), i = Mt(o); + for (s = 0; r[s]; ++s) i[s] && Ot(r[s], i[s]) + } + if (t) { + At(e, o); + if (n) { + r = Mt(e), i = Mt(o); + for (s = 0; r[s]; ++s) At(r[s], i[s]) + } + } + return r = i = null, o + }, + clean: function(e, t, n, r) { + var s, o, u, a, f, l, c, h, p, d, m, g, y = t === i && Ct, + b = []; + if (!t || typeof t.createDocumentFragment == "undefined") t = i; + for (s = 0; + (u = e[s]) != null; s++) { + typeof u == "number" && (u += ""); + if (!u) continue; + if (typeof u == "string") if (!gt.test(u)) u = t.createTextNode(u); + else { + y = y || lt(t), c = t.createElement("div"), y.appendChild(c), u = u.replace(dt, "<$1>"), a = (vt.exec(u) || ["", ""])[1].toLowerCase(), f = Nt[a] || Nt._default, l = f[0], c.innerHTML = f[1] + u + f[2]; + while (l--) c = c.lastChild; + if (!v.support.tbody) { + h = mt.test(u), p = a === "table" && !h ? c.firstChild && c.firstChild.childNodes : f[1] === "" && !h ? c.childNodes : []; + for (o = p.length - 1; o >= 0; --o) v.nodeName(p[o], "tbody") && !p[o].childNodes.length && p[o].parentNode.removeChild(p[o]) + }!v.support.leadingWhitespace && pt.test(u) && c.insertBefore(t.createTextNode(pt.exec(u)[0]), c.firstChild), u = c.childNodes, c.parentNode.removeChild(c) + } + u.nodeType ? b.push(u) : v.merge(b, u) + } + c && (u = c = y = null); + if (!v.support.appendChecked) for (s = 0; + (u = b[s]) != null; s++) v.nodeName(u, "input") ? _t(u) : typeof u.getElementsByTagName != "undefined" && v.grep(u.getElementsByTagName("input"), _t); + if (n) { + m = function(e) { + if (!e.type || xt.test(e.type)) return r ? r.push(e.parentNode ? e.parentNode.removeChild(e) : e) : n.appendChild(e) + }; + for (s = 0; + (u = b[s]) != null; s++) if (!v.nodeName(u, "script") || !m(u)) n.appendChild(u), typeof u.getElementsByTagName != "undefined" && (g = v.grep(v.merge([], u.getElementsByTagName("script")), m), b.splice.apply(b, [s + 1, 0].concat(g)), s += g.length) + } + return b + }, + cleanData: function(e, t) { + var n, r, i, s, o = 0, + u = v.expando, + a = v.cache, + f = v.support.deleteExpando, + l = v.event.special; + for (; + (i = e[o]) != null; o++) if (t || v.acceptData(i)) { + r = i[u], n = r && a[r]; + if (n) { + if (n.events) for (s in n.events) l[s] ? v.event.remove(i, s) : v.removeEvent(i, s, n.handle); + a[r] && (delete a[r], f ? delete i[u] : i.removeAttribute ? i.removeAttribute(u) : i[u] = null, v.deletedIds.push(r)) + } + } + } + }), function() { + var e, t; + v.uaMatch = function(e) { + e = e.toLowerCase(); + var t = /(chrome)[ \/]([\w.]+)/.exec(e) || /(webkit)[ \/]([\w.]+)/.exec(e) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e) || /(msie) ([\w.]+)/.exec(e) || e.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e) || []; + return { + browser: t[1] || "", + version: t[2] || "0" + } + }, e = v.uaMatch(o.userAgent), t = {}, e.browser && (t[e.browser] = !0, t.version = e.version), t.chrome ? t.webkit = !0 : t.webkit && (t.safari = !0), v.browser = t, v.sub = function() { + function e(t, n) { + return new e.fn.init(t, n) + } + v.extend(!0, e, this), e.superclass = this, e.fn = e.prototype = this(), e.fn.constructor = e, e.sub = this.sub, e.fn.init = function(r, i) { + return i && i instanceof v && !(i instanceof e) && (i = e(i)), v.fn.init.call(this, r, i, t) + }, e.fn.init.prototype = e.fn; + var t = e(i); + return e + } + }(); + var Dt, Pt, Ht, Bt = /alpha\([^)]*\)/i, + jt = /opacity=([^)]*)/, + Ft = /^(top|right|bottom|left)$/, + It = /^(none|table(?!-c[ea]).+)/, + qt = /^margin/, + Rt = new RegExp("^(" + m + ")(.*)$", "i"), + Ut = new RegExp("^(" + m + ")(?!px)[a-z%]+$", "i"), + zt = new RegExp("^([-+])=(" + m + ")", "i"), + Wt = { + BODY: "block" + }, + Xt = { + position: "absolute", + visibility: "hidden", + display: "block" + }, + Vt = { + letterSpacing: 0, + fontWeight: 400 + }, + $t = ["Top", "Right", "Bottom", "Left"], + Jt = ["Webkit", "O", "Moz", "ms"], + Kt = v.fn.toggle; + v.fn.extend({ + css: function(e, n) { + return v.access(this, function(e, n, r) { + return r !== t ? v.style(e, n, r) : v.css(e, n) + }, e, n, arguments.length > 1) + }, + show: function() { + return Yt(this, !0) + }, + hide: function() { + return Yt(this) + }, + toggle: function(e, t) { + var n = typeof e == "boolean"; + return v.isFunction(e) && v.isFunction(t) ? Kt.apply(this, arguments) : this.each(function() { + (n ? e : Gt(this)) ? v(this).show() : v(this).hide() + }) + } + }), v.extend({ + cssHooks: { + opacity: { + get: function(e, t) { + if (t) { + var n = Dt(e, "opacity"); + return n === "" ? "1" : n + } + } + } + }, + cssNumber: { + fillOpacity: !0, + fontWeight: !0, + lineHeight: !0, + opacity: !0, + orphans: !0, + widows: !0, + zIndex: !0, + zoom: !0 + }, + cssProps: { + "float": v.support.cssFloat ? "cssFloat" : "styleFloat" + }, + style: function(e, n, r, i) { + if (!e || e.nodeType === 3 || e.nodeType === 8 || !e.style) return; + var s, o, u, a = v.camelCase(n), + f = e.style; + n = v.cssProps[a] || (v.cssProps[a] = Qt(f, a)), u = v.cssHooks[n] || v.cssHooks[a]; + if (r === t) return u && "get" in u && (s = u.get(e, !1, i)) !== t ? s : f[n]; + o = typeof r, o === "string" && (s = zt.exec(r)) && (r = (s[1] + 1) * s[2] + parseFloat(v.css(e, n)), o = "number"); + if (r == null || o === "number" && isNaN(r)) return; + o === "number" && !v.cssNumber[a] && (r += "px"); + if (!u || !("set" in u) || (r = u.set(e, r, i)) !== t) try { + f[n] = r + } catch (l) {} + }, + css: function(e, n, r, i) { + var s, o, u, a = v.camelCase(n); + return n = v.cssProps[a] || (v.cssProps[a] = Qt(e.style, a)), u = v.cssHooks[n] || v.cssHooks[a], u && "get" in u && (s = u.get(e, !0, i)), s === t && (s = Dt(e, n)), s === "normal" && n in Vt && (s = Vt[n]), r || i !== t ? (o = parseFloat(s), r || v.isNumeric(o) ? o || 0 : s) : s + }, + swap: function(e, t, n) { + var r, i, s = {}; + for (i in t) s[i] = e.style[i], e.style[i] = t[i]; + r = n.call(e); + for (i in t) e.style[i] = s[i]; + return r + } + }), e.getComputedStyle ? Dt = function(t, n) { + var r, i, s, o, u = e.getComputedStyle(t, null), + a = t.style; + return u && (r = u.getPropertyValue(n) || u[n], r === "" && !v.contains(t.ownerDocument, t) && (r = v.style(t, n)), Ut.test(r) && qt.test(n) && (i = a.width, s = a.minWidth, o = a.maxWidth, a.minWidth = a.maxWidth = a.width = r, r = u.width, a.width = i, a.minWidth = s, a.maxWidth = o)), r + } : i.documentElement.currentStyle && (Dt = function(e, t) { + var n, r, i = e.currentStyle && e.currentStyle[t], + s = e.style; + return i == null && s && s[t] && (i = s[t]), Ut.test(i) && !Ft.test(t) && (n = s.left, r = e.runtimeStyle && e.runtimeStyle.left, r && (e.runtimeStyle.left = e.currentStyle.left), s.left = t === "fontSize" ? "1em" : i, i = s.pixelLeft + "px", s.left = n, r && (e.runtimeStyle.left = r)), i === "" ? "auto" : i + }), v.each(["height", "width"], function(e, t) { + v.cssHooks[t] = { + get: function(e, n, r) { + if (n) return e.offsetWidth === 0 && It.test(Dt(e, "display")) ? v.swap(e, Xt, function() { + return tn(e, t, r) + }) : tn(e, t, r) + }, + set: function(e, n, r) { + return Zt(e, n, r ? en(e, t, r, v.support.boxSizing && v.css(e, "boxSizing") === "border-box") : 0) + } + } + }), v.support.opacity || (v.cssHooks.opacity = { + get: function(e, t) { + return jt.test((t && e.currentStyle ? e.currentStyle.filter : e.style.filter) || "") ? .01 * parseFloat(RegExp.$1) + "" : t ? "1" : "" + }, + set: function(e, t) { + var n = e.style, + r = e.currentStyle, + i = v.isNumeric(t) ? "alpha(opacity=" + t * 100 + ")" : "", + s = r && r.filter || n.filter || ""; + n.zoom = 1; + if (t >= 1 && v.trim(s.replace(Bt, "")) === "" && n.removeAttribute) { + n.removeAttribute("filter"); + if (r && !r.filter) return + } + n.filter = Bt.test(s) ? s.replace(Bt, i) : s + " " + i + } + }), v(function() { + v.support.reliableMarginRight || (v.cssHooks.marginRight = { + get: function(e, t) { + return v.swap(e, { + display: "inline-block" + }, function() { + if (t) return Dt(e, "marginRight") + }) + } + }), !v.support.pixelPosition && v.fn.position && v.each(["top", "left"], function(e, t) { + v.cssHooks[t] = { + get: function(e, n) { + if (n) { + var r = Dt(e, t); + return Ut.test(r) ? v(e).position()[t] + "px" : r + } + } + } + }) + }), v.expr && v.expr.filters && (v.expr.filters.hidden = function(e) { + return e.offsetWidth === 0 && e.offsetHeight === 0 || !v.support.reliableHiddenOffsets && (e.style && e.style.display || Dt(e, "display")) === "none" + }, v.expr.filters.visible = function(e) { + return !v.expr.filters.hidden(e) + }), v.each({ + margin: "", + padding: "", + border: "Width" + }, function(e, t) { + v.cssHooks[e + t] = { + expand: function(n) { + var r, i = typeof n == "string" ? n.split(" ") : [n], + s = {}; + for (r = 0; r < 4; r++) s[e + $t[r] + t] = i[r] || i[r - 2] || i[0]; + return s + } + }, qt.test(e) || (v.cssHooks[e + t].set = Zt) + }); + var rn = /%20/g, + sn = /\[\]$/, + on = /\r?\n/g, + un = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, + an = /^(?:select|textarea)/i; + v.fn.extend({ + serialize: function() { + return v.param(this.serializeArray()) + }, + serializeArray: function() { + return this.map(function() { + return this.elements ? v.makeArray(this.elements) : this + }).filter(function() { + return this.name && !this.disabled && (this.checked || an.test(this.nodeName) || un.test(this.type)) + }).map(function(e, t) { + var n = v(this).val(); + return n == null ? null : v.isArray(n) ? v.map(n, function(e, n) { + return { + name: t.name, + value: e.replace(on, "\r\n") + } + }) : { + name: t.name, + value: n.replace(on, "\r\n") + } + }).get() + } + }), v.param = function(e, n) { + var r, i = [], + s = function(e, t) { + t = v.isFunction(t) ? t() : t == null ? "" : t, i[i.length] = encodeURIComponent(e) + "=" + encodeURIComponent(t) + }; + n === t && (n = v.ajaxSettings && v.ajaxSettings.traditional); + if (v.isArray(e) || e.jquery && !v.isPlainObject(e)) v.each(e, function() { + s(this.name, this.value) + }); + else for (r in e) fn(r, e[r], n, s); + return i.join("&").replace(rn, "+") + }; + var ln, cn, hn = /#.*$/, + pn = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, + dn = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, + vn = /^(?:GET|HEAD)$/, + mn = /^\/\//, + gn = /\?/, + yn = /)<[^<]*)*<\/script>/gi, + bn = /([?&])_=[^&]*/, + wn = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/, + En = v.fn.load, + Sn = {}, + xn = {}, + Tn = ["*/"] + ["*"]; + try { + cn = s.href + } catch (Nn) { + cn = i.createElement("a"), cn.href = "", cn = cn.href + } + ln = wn.exec(cn.toLowerCase()) || [], v.fn.load = function(e, n, r) { + if (typeof e != "string" && En) return En.apply(this, arguments); + if (!this.length) return this; + var i, s, o, u = this, + a = e.indexOf(" "); + return a >= 0 && (i = e.slice(a, e.length), e = e.slice(0, a)), v.isFunction(n) ? (r = n, n = t) : n && typeof n == "object" && (s = "POST"), v.ajax({ + url: e, + type: s, + dataType: "html", + data: n, + complete: function(e, t) { + r && u.each(r, o || [e.responseText, t, e]) + } + }).done(function(e) { + o = arguments, u.html(i ? v("
    ").append(e.replace(yn, "")).find(i) : e) + }), this + }, v.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function(e, t) { + v.fn[t] = function(e) { + return this.on(t, e) + } + }), v.each(["get", "post"], function(e, n) { + v[n] = function(e, r, i, s) { + return v.isFunction(r) && (s = s || i, i = r, r = t), v.ajax({ + type: n, + url: e, + data: r, + success: i, + dataType: s + }) + } + }), v.extend({ + getScript: function(e, n) { + return v.get(e, t, n, "script") + }, + getJSON: function(e, t, n) { + return v.get(e, t, n, "json") + }, + ajaxSetup: function(e, t) { + return t ? Ln(e, v.ajaxSettings) : (t = e, e = v.ajaxSettings), Ln(e, t), e + }, + ajaxSettings: { + url: cn, + isLocal: dn.test(ln[1]), + global: !0, + type: "GET", + contentType: "application/x-www-form-urlencoded; charset=UTF-8", + processData: !0, + async: !0, + accepts: { + xml: "application/xml, text/xml", + html: "text/html", + text: "text/plain", + json: "application/json, text/javascript", + "*": Tn + }, + contents: { + xml: /xml/, + html: /html/, + json: /json/ + }, + responseFields: { + xml: "responseXML", + text: "responseText" + }, + converters: { + "* text": e.String, + "text html": !0, + "text json": v.parseJSON, + "text xml": v.parseXML + }, + flatOptions: { + context: !0, + url: !0 + } + }, + ajaxPrefilter: Cn(Sn), + ajaxTransport: Cn(xn), + ajax: function(e, n) { + function T(e, n, s, a) { + var l, y, b, w, S, T = n; + if (E === 2) return; + E = 2, u && clearTimeout(u), o = t, i = a || "", x.readyState = e > 0 ? 4 : 0, s && (w = An(c, x, s)); + if (e >= 200 && e < 300 || e === 304) c.ifModified && (S = x.getResponseHeader("Last-Modified"), S && (v.lastModified[r] = S), S = x.getResponseHeader("Etag"), S && (v.etag[r] = S)), e === 304 ? (T = "notmodified", l = !0) : (l = On(c, w), T = l.state, y = l.data, b = l.error, l = !b); + else { + b = T; + if (!T || e) T = "error", e < 0 && (e = 0) + } + x.status = e, x.statusText = (n || T) + "", l ? d.resolveWith(h, [y, T, x]) : d.rejectWith(h, [x, T, b]), x.statusCode(g), g = t, f && p.trigger("ajax" + (l ? "Success" : "Error"), [x, c, l ? y : b]), m.fireWith(h, [x, T]), f && (p.trigger("ajaxComplete", [x, c]), --v.active || v.event.trigger("ajaxStop")) + } + typeof e == "object" && (n = e, e = t), n = n || {}; + var r, i, s, o, u, a, f, l, c = v.ajaxSetup({}, n), + h = c.context || c, + p = h !== c && (h.nodeType || h instanceof v) ? v(h) : v.event, + d = v.Deferred(), + m = v.Callbacks("once memory"), + g = c.statusCode || {}, + b = {}, + w = {}, + E = 0, + S = "canceled", + x = { + readyState: 0, + setRequestHeader: function(e, t) { + if (!E) { + var n = e.toLowerCase(); + e = w[n] = w[n] || e, b[e] = t + } + return this + }, + getAllResponseHeaders: function() { + return E === 2 ? i : null + }, + getResponseHeader: function(e) { + var n; + if (E === 2) { + if (!s) { + s = {}; + while (n = pn.exec(i)) s[n[1].toLowerCase()] = n[2] + } + n = s[e.toLowerCase()] + } + return n === t ? null : n + }, + overrideMimeType: function(e) { + return E || (c.mimeType = e), this + }, + abort: function(e) { + return e = e || S, o && o.abort(e), T(0, e), this + } + }; + d.promise(x), x.success = x.done, x.error = x.fail, x.complete = m.add, x.statusCode = function(e) { + if (e) { + var t; + if (E < 2) for (t in e) g[t] = [g[t], e[t]]; + else t = e[x.status], x.always(t) + } + return this + }, c.url = ((e || c.url) + "").replace(hn, "").replace(mn, ln[1] + "//"), c.dataTypes = v.trim(c.dataType || "*").toLowerCase().split(y), c.crossDomain == null && (a = wn.exec(c.url.toLowerCase()), c.crossDomain = !(!a || a[1] === ln[1] && a[2] === ln[2] && (a[3] || (a[1] === "http:" ? 80 : 443)) == (ln[3] || (ln[1] === "http:" ? 80 : 443)))), c.data && c.processData && typeof c.data != "string" && (c.data = v.param(c.data, c.traditional)), kn(Sn, c, n, x); + if (E === 2) return x; + f = c.global, c.type = c.type.toUpperCase(), c.hasContent = !vn.test(c.type), f && v.active++ === 0 && v.event.trigger("ajaxStart"); + if (!c.hasContent) { + c.data && (c.url += (gn.test(c.url) ? "&" : "?") + c.data, delete c.data), r = c.url; + if (c.cache === !1) { + var N = v.now(), + C = c.url.replace(bn, "$1_=" + N); + c.url = C + (C === c.url ? (gn.test(c.url) ? "&" : "?") + "_=" + N : "") + } + }(c.data && c.hasContent && c.contentType !== !1 || n.contentType) && x.setRequestHeader("Content-Type", c.contentType), c.ifModified && (r = r || c.url, v.lastModified[r] && x.setRequestHeader("If-Modified-Since", v.lastModified[r]), v.etag[r] && x.setRequestHeader("If-None-Match", v.etag[r])), x.setRequestHeader("Accept", c.dataTypes[0] && c.accepts[c.dataTypes[0]] ? c.accepts[c.dataTypes[0]] + (c.dataTypes[0] !== "*" ? ", " + Tn + "; q=0.01" : "") : c.accepts["*"]); + for (l in c.headers) x.setRequestHeader(l, c.headers[l]); + if (!c.beforeSend || c.beforeSend.call(h, x, c) !== !1 && E !== 2) { + S = "abort"; + for (l in { + success: 1, + error: 1, + complete: 1 + }) x[l](c[l]); + o = kn(xn, c, n, x); + if (!o) T(-1, "No Transport"); + else { + x.readyState = 1, f && p.trigger("ajaxSend", [x, c]), c.async && c.timeout > 0 && (u = setTimeout(function() { + x.abort("timeout") + }, c.timeout)); + try { + E = 1, o.send(b, T) + } catch (k) { + if (!(E < 2)) throw k; + T(-1, k) + } + } + return x + } + return x.abort() + }, + active: 0, + lastModified: {}, + etag: {} + }); + var Mn = [], + _n = /\?/, + Dn = /(=)\?(?=&|$)|\?\?/, + Pn = v.now(); + v.ajaxSetup({ + jsonp: "callback", + jsonpCallback: function() { + var e = Mn.pop() || v.expando + "_" + Pn++; + return this[e] = !0, e + } + }), v.ajaxPrefilter("json jsonp", function(n, r, i) { + var s, o, u, a = n.data, + f = n.url, + l = n.jsonp !== !1, + c = l && Dn.test(f), + h = l && !c && typeof a == "string" && !(n.contentType || "").indexOf("application/x-www-form-urlencoded") && Dn.test(a); + if (n.dataTypes[0] === "jsonp" || c || h) return s = n.jsonpCallback = v.isFunction(n.jsonpCallback) ? n.jsonpCallback() : n.jsonpCallback, o = e[s], c ? n.url = f.replace(Dn, "$1" + s) : h ? n.data = a.replace(Dn, "$1" + s) : l && (n.url += (_n.test(f) ? "&" : "?") + n.jsonp + "=" + s), n.converters["script json"] = function() { + return u || v.error(s + " was not called"), u[0] + }, n.dataTypes[0] = "json", e[s] = function() { + u = arguments + }, i.always(function() { + e[s] = o, n[s] && (n.jsonpCallback = r.jsonpCallback, Mn.push(s)), u && v.isFunction(o) && o(u[0]), u = o = t + }), "script" + }), v.ajaxSetup({ + accepts: { + script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" + }, + contents: { + script: /javascript|ecmascript/ + }, + converters: { + "text script": function(e) { + return v.globalEval(e), e + } + } + }), v.ajaxPrefilter("script", function(e) { + e.cache === t && (e.cache = !1), e.crossDomain && (e.type = "GET", e.global = !1) + }), v.ajaxTransport("script", function(e) { + if (e.crossDomain) { + var n, r = i.head || i.getElementsByTagName("head")[0] || i.documentElement; + return { + send: function(s, o) { + n = i.createElement("script"), n.async = "async", e.scriptCharset && (n.charset = e.scriptCharset), n.src = e.url, n.onload = n.onreadystatechange = function(e, i) { + if (i || !n.readyState || /loaded|complete/.test(n.readyState)) n.onload = n.onreadystatechange = null, r && n.parentNode && r.removeChild(n), n = t, i || o(200, "success") + }, r.insertBefore(n, r.firstChild) + }, + abort: function() { + n && n.onload(0, 1) + } + } + } + }); + var Hn, Bn = e.ActiveXObject ? + function() { + for (var e in Hn) Hn[e](0, 1) + } : !1, + jn = 0; + v.ajaxSettings.xhr = e.ActiveXObject ? + function() { + return !this.isLocal && Fn() || In() + } : Fn, function(e) { + v.extend(v.support, { + ajax: !! e, + cors: !! e && "withCredentials" in e + }) + }(v.ajaxSettings.xhr()), v.support.ajax && v.ajaxTransport(function(n) { + if (!n.crossDomain || v.support.cors) { + var r; + return { + send: function(i, s) { + var o, u, a = n.xhr(); + n.username ? a.open(n.type, n.url, n.async, n.username, n.password) : a.open(n.type, n.url, n.async); + if (n.xhrFields) for (u in n.xhrFields) a[u] = n.xhrFields[u]; + n.mimeType && a.overrideMimeType && a.overrideMimeType(n.mimeType), !n.crossDomain && !i["X-Requested-With"] && (i["X-Requested-With"] = "XMLHttpRequest"); + try { + for (u in i) a.setRequestHeader(u, i[u]) + } catch (f) {} + a.send(n.hasContent && n.data || null), r = function(e, i) { + var u, f, l, c, h; + try { + if (r && (i || a.readyState === 4)) { + r = t, o && (a.onreadystatechange = v.noop, Bn && delete Hn[o]); + if (i) a.readyState !== 4 && a.abort(); + else { + u = a.status, l = a.getAllResponseHeaders(), c = {}, h = a.responseXML, h && h.documentElement && (c.xml = h); + try { + c.text = a.responseText + } catch (p) {} + try { + f = a.statusText + } catch (p) { + f = "" + }!u && n.isLocal && !n.crossDomain ? u = c.text ? 200 : 404 : u === 1223 && (u = 204) + } + } + } catch (d) { + i || s(-1, d) + } + c && s(u, f, c, l) + }, n.async ? a.readyState === 4 ? setTimeout(r, 0) : (o = ++jn, Bn && (Hn || (Hn = {}, v(e).unload(Bn)), Hn[o] = r), a.onreadystatechange = r) : r() + }, + abort: function() { + r && r(0, 1) + } + } + } + }); + var qn, Rn, Un = /^(?:toggle|show|hide)$/, + zn = new RegExp("^(?:([-+])=|)(" + m + ")([a-z%]*)$", "i"), + Wn = /queueHooks$/, + Xn = [Gn], + Vn = { + "*": [function(e, t) { + var n, r, i = this.createTween(e, t), + s = zn.exec(t), + o = i.cur(), + u = +o || 0, + a = 1, + f = 20; + if (s) { + n = +s[2], r = s[3] || (v.cssNumber[e] ? "" : "px"); + if (r !== "px" && u) { + u = v.css(i.elem, e, !0) || n || 1; + do a = a || ".5", u /= a, v.style(i.elem, e, u + r); + while (a !== (a = i.cur() / o) && a !== 1 && --f) + } + i.unit = r, i.start = u, i.end = s[1] ? u + (s[1] + 1) * n : n + } + return i + }] + }; + v.Animation = v.extend(Kn, { + tweener: function(e, t) { + v.isFunction(e) ? (t = e, e = ["*"]) : e = e.split(" "); + var n, r = 0, + i = e.length; + for (; r < i; r++) n = e[r], Vn[n] = Vn[n] || [], Vn[n].unshift(t) + }, + prefilter: function(e, t) { + t ? Xn.unshift(e) : Xn.push(e) + } + }), v.Tween = Yn, Yn.prototype = { + constructor: Yn, + init: function(e, t, n, r, i, s) { + this.elem = e, this.prop = n, this.easing = i || "swing", this.options = t, this.start = this.now = this.cur(), this.end = r, this.unit = s || (v.cssNumber[n] ? "" : "px") + }, + cur: function() { + var e = Yn.propHooks[this.prop]; + return e && e.get ? e.get(this) : Yn.propHooks._default.get(this) + }, + run: function(e) { + var t, n = Yn.propHooks[this.prop]; + return this.options.duration ? this.pos = t = v.easing[this.easing](e, this.options.duration * e, 0, 1, this.options.duration) : this.pos = t = e, this.now = (this.end - this.start) * t + this.start, this.options.step && this.options.step.call(this.elem, this.now, this), n && n.set ? n.set(this) : Yn.propHooks._default.set(this), this + } + }, Yn.prototype.init.prototype = Yn.prototype, Yn.propHooks = { + _default: { + get: function(e) { + var t; + return e.elem[e.prop] == null || !! e.elem.style && e.elem.style[e.prop] != null ? (t = v.css(e.elem, e.prop, !1, ""), !t || t === "auto" ? 0 : t) : e.elem[e.prop] + }, + set: function(e) { + v.fx.step[e.prop] ? v.fx.step[e.prop](e) : e.elem.style && (e.elem.style[v.cssProps[e.prop]] != null || v.cssHooks[e.prop]) ? v.style(e.elem, e.prop, e.now + e.unit) : e.elem[e.prop] = e.now + } + } + }, Yn.propHooks.scrollTop = Yn.propHooks.scrollLeft = { + set: function(e) { + e.elem.nodeType && e.elem.parentNode && (e.elem[e.prop] = e.now) + } + }, v.each(["toggle", "show", "hide"], function(e, t) { + var n = v.fn[t]; + v.fn[t] = function(r, i, s) { + return r == null || typeof r == "boolean" || !e && v.isFunction(r) && v.isFunction(i) ? n.apply(this, arguments) : this.animate(Zn(t, !0), r, i, s) + } + }), v.fn.extend({ + fadeTo: function(e, t, n, r) { + return this.filter(Gt).css("opacity", 0).show().end().animate({ + opacity: t + }, e, n, r) + }, + animate: function(e, t, n, r) { + var i = v.isEmptyObject(e), + s = v.speed(t, n, r), + o = function() { + var t = Kn(this, v.extend({}, e), s); + i && t.stop(!0) + }; + return i || s.queue === !1 ? this.each(o) : this.queue(s.queue, o) + }, + stop: function(e, n, r) { + var i = function(e) { + var t = e.stop; + delete e.stop, t(r) + }; + return typeof e != "string" && (r = n, n = e, e = t), n && e !== !1 && this.queue(e || "fx", []), this.each(function() { + var t = !0, + n = e != null && e + "queueHooks", + s = v.timers, + o = v._data(this); + if (n) o[n] && o[n].stop && i(o[n]); + else for (n in o) o[n] && o[n].stop && Wn.test(n) && i(o[n]); + for (n = s.length; n--;) s[n].elem === this && (e == null || s[n].queue === e) && (s[n].anim.stop(r), t = !1, s.splice(n, 1)); + (t || !r) && v.dequeue(this, e) + }) + } + }), v.each({ + slideDown: Zn("show"), + slideUp: Zn("hide"), + slideToggle: Zn("toggle"), + fadeIn: { + opacity: "show" + }, + fadeOut: { + opacity: "hide" + }, + fadeToggle: { + opacity: "toggle" + } + }, function(e, t) { + v.fn[e] = function(e, n, r) { + return this.animate(t, e, n, r) + } + }), v.speed = function(e, t, n) { + var r = e && typeof e == "object" ? v.extend({}, e) : { + complete: n || !n && t || v.isFunction(e) && e, + duration: e, + easing: n && t || t && !v.isFunction(t) && t + }; + r.duration = v.fx.off ? 0 : typeof r.duration == "number" ? r.duration : r.duration in v.fx.speeds ? v.fx.speeds[r.duration] : v.fx.speeds._default; + if (r.queue == null || r.queue === !0) r.queue = "fx"; + return r.old = r.complete, r.complete = function() { + v.isFunction(r.old) && r.old.call(this), r.queue && v.dequeue(this, r.queue) + }, r + }, v.easing = { + linear: function(e) { + return e + }, + swing: function(e) { + return.5 - Math.cos(e * Math.PI) / 2 + } + }, v.timers = [], v.fx = Yn.prototype.init, v.fx.tick = function() { + var e, n = v.timers, + r = 0; + qn = v.now(); + for (; r < n.length; r++) e = n[r], !e() && n[r] === e && n.splice(r--, 1); + n.length || v.fx.stop(), qn = t + }, v.fx.timer = function(e) { + e() && v.timers.push(e) && !Rn && (Rn = setInterval(v.fx.tick, v.fx.interval)) + }, v.fx.interval = 13, v.fx.stop = function() { + clearInterval(Rn), Rn = null + }, v.fx.speeds = { + slow: 600, + fast: 200, + _default: 400 + }, v.fx.step = {}, v.expr && v.expr.filters && (v.expr.filters.animated = function(e) { + return v.grep(v.timers, function(t) { + return e === t.elem + }).length + }); + var er = /^(?:body|html)$/i; + v.fn.offset = function(e) { + if (arguments.length) return e === t ? this : this.each(function(t) { + v.offset.setOffset(this, e, t) + }); + var n, r, i, s, o, u, a, f = { + top: 0, + left: 0 + }, + l = this[0], + c = l && l.ownerDocument; + if (!c) return; + return (r = c.body) === l ? v.offset.bodyOffset(l) : (n = c.documentElement, v.contains(n, l) ? (typeof l.getBoundingClientRect != "undefined" && (f = l.getBoundingClientRect()), i = tr(c), s = n.clientTop || r.clientTop || 0, o = n.clientLeft || r.clientLeft || 0, u = i.pageYOffset || n.scrollTop, a = i.pageXOffset || n.scrollLeft, { + top: f.top + u - s, + left: f.left + a - o + }) : f) + }, v.offset = { + bodyOffset: function(e) { + var t = e.offsetTop, + n = e.offsetLeft; + return v.support.doesNotIncludeMarginInBodyOffset && (t += parseFloat(v.css(e, "marginTop")) || 0, n += parseFloat(v.css(e, "marginLeft")) || 0), { + top: t, + left: n + } + }, + setOffset: function(e, t, n) { + var r = v.css(e, "position"); + r === "static" && (e.style.position = "relative"); + var i = v(e), + s = i.offset(), + o = v.css(e, "top"), + u = v.css(e, "left"), + a = (r === "absolute" || r === "fixed") && v.inArray("auto", [o, u]) > -1, + f = {}, + l = {}, + c, h; + a ? (l = i.position(), c = l.top, h = l.left) : (c = parseFloat(o) || 0, h = parseFloat(u) || 0), v.isFunction(t) && (t = t.call(e, n, s)), t.top != null && (f.top = t.top - s.top + c), t.left != null && (f.left = t.left - s.left + h), "using" in t ? t.using.call(e, f) : i.css(f) + } + }, v.fn.extend({ + position: function() { + if (!this[0]) return; + var e = this[0], + t = this.offsetParent(), + n = this.offset(), + r = er.test(t[0].nodeName) ? { + top: 0, + left: 0 + } : t.offset(); + return n.top -= parseFloat(v.css(e, "marginTop")) || 0, n.left -= parseFloat(v.css(e, "marginLeft")) || 0, r.top += parseFloat(v.css(t[0], "borderTopWidth")) || 0, r.left += parseFloat(v.css(t[0], "borderLeftWidth")) || 0, { + top: n.top - r.top, + left: n.left - r.left + } + }, + offsetParent: function() { + return this.map(function() { + var e = this.offsetParent || i.body; + while (e && !er.test(e.nodeName) && v.css(e, "position") === "static") e = e.offsetParent; + return e || i.body + }) + } + }), v.each({ + scrollLeft: "pageXOffset", + scrollTop: "pageYOffset" + }, function(e, n) { + var r = /Y/.test(n); + v.fn[e] = function(i) { + return v.access(this, function(e, i, s) { + var o = tr(e); + if (s === t) return o ? n in o ? o[n] : o.document.documentElement[i] : e[i]; + o ? o.scrollTo(r ? v(o).scrollLeft() : s, r ? s : v(o).scrollTop()) : e[i] = s + }, e, i, arguments.length, null) + } + }), v.each({ + Height: "height", + Width: "width" + }, function(e, n) { + v.each({ + padding: "inner" + e, + content: n, + "": "outer" + e + }, function(r, i) { + v.fn[i] = function(i, s) { + var o = arguments.length && (r || typeof i != "boolean"), + u = r || (i === !0 || s === !0 ? "margin" : "border"); + return v.access(this, function(n, r, i) { + var s; + return v.isWindow(n) ? n.document.documentElement["client" + e] : n.nodeType === 9 ? (s = n.documentElement, Math.max(n.body["scroll" + e], s["scroll" + e], n.body["offset" + e], s["offset" + e], s["client" + e])) : i === t ? v.css(n, r, i, u) : v.style(n, r, i, u) + }, n, o ? i : t, o, null) + } + }) + }), e.jQuery = e.$ = v, typeof define == "function" && define.amd && define.amd.jQuery && define("jquery", [], function() { + return v + }) +})(window); \ No newline at end of file diff --git a/docs/build/docstrap-master/template/static/scripts/jquery.scrollTo.js b/docs/build/docstrap-master/template/static/scripts/jquery.scrollTo.js new file mode 100644 index 00000000..33d36157 --- /dev/null +++ b/docs/build/docstrap-master/template/static/scripts/jquery.scrollTo.js @@ -0,0 +1,217 @@ +/*! + * jQuery.ScrollTo + * Copyright (c) 2007-2013 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com + * Dual licensed under MIT and GPL. + * + * @projectDescription Easy element scrolling using jQuery. + * http://flesler.blogspot.com/2007/10/jqueryscrollto.html + * @author Ariel Flesler + * @version 1.4.5 + * + * @id jQuery.scrollTo + * @id jQuery.fn.scrollTo + * @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements. + * The different options for target are: + * - A number position (will be applied to all axes). + * - A string position ('44', '100px', '+=90', etc ) will be applied to all axes + * - A jQuery/DOM element ( logically, child of the element to scroll ) + * - A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc ) + * - A hash { top:x, left:y }, x and y can be any kind of number/string like above. + * - A percentage of the container's dimension/s, for example: 50% to go to the middle. + * - The string 'max' for go-to-end. + * @param {Number, Function} duration The OVERALL length of the animation, this argument can be the settings object instead. + * @param {Object,Function} settings Optional set of settings or the onAfter callback. + * @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'. + * @option {Number, Function} duration The OVERALL length of the animation. + * @option {String} easing The easing method for the animation. + * @option {Boolean} margin If true, the margin of the target element will be deducted from the final position. + * @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }. + * @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes. + * @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends. + * @option {Function} onAfter Function to be called after the scrolling ends. + * @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends. + * @return {jQuery} Returns the same jQuery object, for chaining. + * + * @desc Scroll to a fixed position + * @example $('div').scrollTo( 340 ); + * + * @desc Scroll relatively to the actual position + * @example $('div').scrollTo( '+=340px', { axis:'y' } ); + * + * @desc Scroll using a selector (relative to the scrolled element) + * @example $('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } ); + * + * @desc Scroll to a DOM element (same for jQuery object) + * @example var second_child = document.getElementById('container').firstChild.nextSibling; + * $('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){ + * alert('scrolled!!'); + * }}); + * + * @desc Scroll on both axes, to different values + * @example $('div').scrollTo( { top: 300, left:'+=200' }, { axis:'xy', offset:-20 } ); + */ + +;(function( $ ){ + + var $scrollTo = $.scrollTo = function( target, duration, settings ){ + $(window).scrollTo( target, duration, settings ); + }; + + $scrollTo.defaults = { + axis:'xy', + duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1, + limit:true + }; + + // Returns the element that needs to be animated to scroll the window. + // Kept for backwards compatibility (specially for localScroll & serialScroll) + $scrollTo.window = function( scope ){ + return $(window)._scrollable(); + }; + + // Hack, hack, hack :) + // Returns the real elements to scroll (supports window/iframes, documents and regular nodes) + $.fn._scrollable = function(){ + return this.map(function(){ + var elem = this, + isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1; + + if( !isWin ) + return elem; + + var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem; + + return /webkit/i.test(navigator.userAgent) || doc.compatMode == 'BackCompat' ? + doc.body : + doc.documentElement; + }); + }; + + $.fn.scrollTo = function( target, duration, settings ){ + if( typeof duration == 'object' ){ + settings = duration; + duration = 0; + } + if( typeof settings == 'function' ) + settings = { onAfter:settings }; + + if( target == 'max' ) + target = 9e9; + + settings = $.extend( {}, $scrollTo.defaults, settings ); + // Speed is still recognized for backwards compatibility + duration = duration || settings.duration; + // Make sure the settings are given right + settings.queue = settings.queue && settings.axis.length > 1; + + if( settings.queue ) + // Let's keep the overall duration + duration /= 2; + settings.offset = both( settings.offset ); + settings.over = both( settings.over ); + + return this._scrollable().each(function(){ + // Null target yields nothing, just like jQuery does + if (target == null) return; + + var elem = this, + $elem = $(elem), + targ = target, toff, attr = {}, + win = $elem.is('html,body'); + + switch( typeof targ ){ + // A number will pass the regex + case 'number': + case 'string': + if( /^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ) ){ + targ = both( targ ); + // We are done + break; + } + // Relative selector, no break! + targ = $(targ,this); + if (!targ.length) return; + case 'object': + // DOMElement / jQuery + if( targ.is || targ.style ) + // Get the real position of the target + toff = (targ = $(targ)).offset(); + } + $.each( settings.axis.split(''), function( i, axis ){ + var Pos = axis == 'x' ? 'Left' : 'Top', + pos = Pos.toLowerCase(), + key = 'scroll' + Pos, + old = elem[key], + max = $scrollTo.max(elem, axis); + + if( toff ){// jQuery / DOMElement + attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] ); + + // If it's a dom element, reduce the margin + if( settings.margin ){ + attr[key] -= parseInt(targ.css('margin'+Pos)) || 0; + attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0; + } + + attr[key] += settings.offset[pos] || 0; + + if( settings.over[pos] ) + // Scroll to a fraction of its width/height + attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos]; + }else{ + var val = targ[pos]; + // Handle percentage values + attr[key] = val.slice && val.slice(-1) == '%' ? + parseFloat(val) / 100 * max + : val; + } + + // Number or 'number' + if( settings.limit && /^\d+$/.test(attr[key]) ) + // Check the limits + attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max ); + + // Queueing axes + if( !i && settings.queue ){ + // Don't waste time animating, if there's no need. + if( old != attr[key] ) + // Intermediate animation + animate( settings.onAfterFirst ); + // Don't animate this axis again in the next iteration. + delete attr[key]; + } + }); + + animate( settings.onAfter ); + + function animate( callback ){ + $elem.animate( attr, duration, settings.easing, callback && function(){ + callback.call(this, target, settings); + }); + }; + + }).end(); + }; + + // Max scrolling position, works on quirks mode + // It only fails (not too badly) on IE, quirks mode. + $scrollTo.max = function( elem, axis ){ + var Dim = axis == 'x' ? 'Width' : 'Height', + scroll = 'scroll'+Dim; + + if( !$(elem).is('html,body') ) + return elem[scroll] - $(elem)[Dim.toLowerCase()](); + + var size = 'client' + Dim, + html = elem.ownerDocument.documentElement, + body = elem.ownerDocument.body; + + return Math.max( html[scroll], body[scroll] ) + - Math.min( html[size] , body[size] ); + }; + + function both( val ){ + return typeof val == 'object' ? val : { top:val, left:val }; + }; + +})( jQuery ); \ No newline at end of file diff --git a/docs/build/docstrap-master/template/static/scripts/jquery.sunlight.js b/docs/build/docstrap-master/template/static/scripts/jquery.sunlight.js new file mode 100644 index 00000000..03e3bfb8 --- /dev/null +++ b/docs/build/docstrap-master/template/static/scripts/jquery.sunlight.js @@ -0,0 +1,18 @@ +/** + * jQuery plugin for Sunlight http://sunlightjs.com/ + * + * by Tommy Montgomery http://tmont.com/ + * licensed under WTFPL http://sam.zoy.org/wtfpl/ + */ +(function($, window){ + + $.fn.sunlight = function(options) { + var highlighter = new window.Sunlight.Highlighter(options); + this.each(function() { + highlighter.highlightNode(this); + }); + + return this; + }; + +}(jQuery, this)); \ No newline at end of file diff --git a/Docs/API/assets/vendor/prettify/COPYING b/docs/build/docstrap-master/template/static/scripts/prettify/Apache-License-2.0.txt similarity index 100% rename from Docs/API/assets/vendor/prettify/COPYING rename to docs/build/docstrap-master/template/static/scripts/prettify/Apache-License-2.0.txt diff --git a/docs/build/docstrap-master/template/static/scripts/prettify/jquery.min.js b/docs/build/docstrap-master/template/static/scripts/prettify/jquery.min.js new file mode 100644 index 00000000..b18e05a9 --- /dev/null +++ b/docs/build/docstrap-master/template/static/scripts/prettify/jquery.min.js @@ -0,0 +1,6 @@ +/*! jQuery v2.0.0 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license +//@ sourceMappingURL=jquery.min.map +*/ +(function(e,undefined){var t,n,r=typeof undefined,i=e.location,o=e.document,s=o.documentElement,a=e.jQuery,u=e.$,l={},c=[],f="2.0.0",p=c.concat,h=c.push,d=c.slice,g=c.indexOf,m=l.toString,y=l.hasOwnProperty,v=f.trim,x=function(e,n){return new x.fn.init(e,n,t)},b=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,w=/\S+/g,T=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,k=/^-ms-/,N=/-([\da-z])/gi,E=function(e,t){return t.toUpperCase()},S=function(){o.removeEventListener("DOMContentLoaded",S,!1),e.removeEventListener("load",S,!1),x.ready()};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,t,n){var r,i;if(!e)return this;if("string"==typeof e){if(r="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:T.exec(e),!r||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof x?t[0]:t,x.merge(this,x.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:o,!0)),C.test(r[1])&&x.isPlainObject(t))for(r in t)x.isFunction(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return i=o.getElementById(r[2]),i&&i.parentNode&&(this.length=1,this[0]=i),this.context=o,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?n.ready(e):(e.selector!==undefined&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return d.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,t,n,r,i,o,s=arguments[0]||{},a=1,u=arguments.length,l=!1;for("boolean"==typeof s&&(l=s,s=arguments[1]||{},a=2),"object"==typeof s||x.isFunction(s)||(s={}),u===a&&(s=this,--a);u>a;a++)if(null!=(e=arguments[a]))for(t in e)n=s[t],r=e[t],s!==r&&(l&&r&&(x.isPlainObject(r)||(i=x.isArray(r)))?(i?(i=!1,o=n&&x.isArray(n)?n:[]):o=n&&x.isPlainObject(n)?n:{},s[t]=x.extend(l,o,r)):r!==undefined&&(s[t]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=a),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){(e===!0?--x.readyWait:x.isReady)||(x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(o,[x]),x.fn.trigger&&x(o).trigger("ready").off("ready")))},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray,isWindow:function(e){return null!=e&&e===e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[m.call(e)]||"object":typeof e},isPlainObject:function(e){if("object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!y.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}return!0},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||o;var r=C.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:JSON.parse,parseXML:function(e){var t,n;if(!e||"string"!=typeof e)return null;try{n=new DOMParser,t=n.parseFromString(e,"text/xml")}catch(r){t=undefined}return(!t||t.getElementsByTagName("parsererror").length)&&x.error("Invalid XML: "+e),t},noop:function(){},globalEval:function(e){var t,n=eval;e=x.trim(e),e&&(1===e.indexOf("use strict")?(t=o.createElement("script"),t.text=e,o.head.appendChild(t).parentNode.removeChild(t)):n(e))},camelCase:function(e){return e.replace(k,"ms-").replace(N,E)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,s=j(e);if(n){if(s){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(s){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:function(e){return null==e?"":v.call(e)},makeArray:function(e,t){var n=t||[];return null!=e&&(j(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:g.call(t,e,n)},merge:function(e,t){var n=t.length,r=e.length,i=0;if("number"==typeof n)for(;n>i;i++)e[r++]=t[i];else while(t[i]!==undefined)e[r++]=t[i++];return e.length=r,e},grep:function(e,t,n){var r,i=[],o=0,s=e.length;for(n=!!n;s>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,s=j(e),a=[];if(s)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(a[a.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(a[a.length]=r);return p.apply([],a)},guid:1,proxy:function(e,t){var n,r,i;return"string"==typeof t&&(n=e[t],t=e,e=n),x.isFunction(e)?(r=d.call(arguments,2),i=function(){return e.apply(t||this,r.concat(d.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):undefined},access:function(e,t,n,r,i,o,s){var a=0,u=e.length,l=null==n;if("object"===x.type(n)){i=!0;for(a in n)x.access(e,t,a,n[a],!0,o,s)}else if(r!==undefined&&(i=!0,x.isFunction(r)||(s=!0),l&&(s?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(x(e),n)})),t))for(;u>a;a++)t(e[a],n,s?r:r.call(e[a],a,t(e[a],n)));return i?e:l?t.call(e):u?t(e[0],n):o},now:Date.now,swap:function(e,t,n,r){var i,o,s={};for(o in t)s[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=s[o];return i}}),x.ready.promise=function(t){return n||(n=x.Deferred(),"complete"===o.readyState?setTimeout(x.ready):(o.addEventListener("DOMContentLoaded",S,!1),e.addEventListener("load",S,!1))),n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function j(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}t=x(o),function(e,undefined){var t,n,r,i,o,s,a,u,l,c,f,p,h,d,g,m,y="sizzle"+-new Date,v=e.document,b={},w=0,T=0,C=ot(),k=ot(),N=ot(),E=!1,S=function(){return 0},j=typeof undefined,D=1<<31,A=[],L=A.pop,q=A.push,H=A.push,O=A.slice,F=A.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},P="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",R="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=M.replace("w","w#"),$="\\["+R+"*("+M+")"+R+"*(?:([*^$|!~]?=)"+R+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+R+"*\\]",B=":("+M+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",I=RegExp("^"+R+"+|((?:^|[^\\\\])(?:\\\\.)*)"+R+"+$","g"),z=RegExp("^"+R+"*,"+R+"*"),_=RegExp("^"+R+"*([>+~]|"+R+")"+R+"*"),X=RegExp(R+"*[+~]"),U=RegExp("="+R+"*([^\\]'\"]*)"+R+"*\\]","g"),Y=RegExp(B),V=RegExp("^"+W+"$"),G={ID:RegExp("^#("+M+")"),CLASS:RegExp("^\\.("+M+")"),TAG:RegExp("^("+M.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+B),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+R+"*(even|odd|(([+-]|)(\\d*)n|)"+R+"*(?:([+-]|)"+R+"*(\\d+)|))"+R+"*\\)|)","i"),"boolean":RegExp("^(?:"+P+")$","i"),needsContext:RegExp("^"+R+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+R+"*((?:-\\d)?\\d*)"+R+"*\\)|)(?=[^-]|$)","i")},J=/^[^{]+\{\s*\[native \w/,Q=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,et=/'|\\/g,tt=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,nt=function(e,t){var n="0x"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{H.apply(A=O.call(v.childNodes),v.childNodes),A[v.childNodes.length].nodeType}catch(rt){H={apply:A.length?function(e,t){q.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function it(e){return J.test(e+"")}function ot(){var e,t=[];return e=function(n,i){return t.push(n+=" ")>r.cacheLength&&delete e[t.shift()],e[n]=i}}function st(e){return e[y]=!0,e}function at(e){var t=c.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ut(e,t,n,r){var i,o,s,a,u,f,d,g,x,w;if((t?t.ownerDocument||t:v)!==c&&l(t),t=t||c,n=n||[],!e||"string"!=typeof e)return n;if(1!==(a=t.nodeType)&&9!==a)return[];if(p&&!r){if(i=Q.exec(e))if(s=i[1]){if(9===a){if(o=t.getElementById(s),!o||!o.parentNode)return n;if(o.id===s)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(s))&&m(t,o)&&o.id===s)return n.push(o),n}else{if(i[2])return H.apply(n,t.getElementsByTagName(e)),n;if((s=i[3])&&b.getElementsByClassName&&t.getElementsByClassName)return H.apply(n,t.getElementsByClassName(s)),n}if(b.qsa&&(!h||!h.test(e))){if(g=d=y,x=t,w=9===a&&e,1===a&&"object"!==t.nodeName.toLowerCase()){f=gt(e),(d=t.getAttribute("id"))?g=d.replace(et,"\\$&"):t.setAttribute("id",g),g="[id='"+g+"'] ",u=f.length;while(u--)f[u]=g+mt(f[u]);x=X.test(e)&&t.parentNode||t,w=f.join(",")}if(w)try{return H.apply(n,x.querySelectorAll(w)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return kt(e.replace(I,"$1"),t,n,r)}o=ut.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},l=ut.setDocument=function(e){var t=e?e.ownerDocument||e:v;return t!==c&&9===t.nodeType&&t.documentElement?(c=t,f=t.documentElement,p=!o(t),b.getElementsByTagName=at(function(e){return e.appendChild(t.createComment("")),!e.getElementsByTagName("*").length}),b.attributes=at(function(e){return e.className="i",!e.getAttribute("className")}),b.getElementsByClassName=at(function(e){return e.innerHTML="
    ",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),b.sortDetached=at(function(e){return 1&e.compareDocumentPosition(c.createElement("div"))}),b.getById=at(function(e){return f.appendChild(e).id=y,!t.getElementsByName||!t.getElementsByName(y).length}),b.getById?(r.find.ID=function(e,t){if(typeof t.getElementById!==j&&p){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},r.filter.ID=function(e){var t=e.replace(tt,nt);return function(e){return e.getAttribute("id")===t}}):(r.find.ID=function(e,t){if(typeof t.getElementById!==j&&p){var n=t.getElementById(e);return n?n.id===e||typeof n.getAttributeNode!==j&&n.getAttributeNode("id").value===e?[n]:undefined:[]}},r.filter.ID=function(e){var t=e.replace(tt,nt);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),r.find.TAG=b.getElementsByTagName?function(e,t){return typeof t.getElementsByTagName!==j?t.getElementsByTagName(e):undefined}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=b.getElementsByClassName&&function(e,t){return typeof t.getElementsByClassName!==j&&p?t.getElementsByClassName(e):undefined},d=[],h=[],(b.qsa=it(t.querySelectorAll))&&(at(function(e){e.innerHTML="",e.querySelectorAll("[selected]").length||h.push("\\["+R+"*(?:value|"+P+")"),e.querySelectorAll(":checked").length||h.push(":checked")}),at(function(e){var t=c.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&h.push("[*^$]="+R+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||h.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),h.push(",.*:")})),(b.matchesSelector=it(g=f.webkitMatchesSelector||f.mozMatchesSelector||f.oMatchesSelector||f.msMatchesSelector))&&at(function(e){b.disconnectedMatch=g.call(e,"div"),g.call(e,"[s!='']:x"),d.push("!=",B)}),h=h.length&&RegExp(h.join("|")),d=d.length&&RegExp(d.join("|")),m=it(f.contains)||f.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},S=f.compareDocumentPosition?function(e,n){if(e===n)return E=!0,0;var r=n.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(n);return r?1&r||!b.sortDetached&&n.compareDocumentPosition(e)===r?e===t||m(v,e)?-1:n===t||m(v,n)?1:u?F.call(u,e)-F.call(u,n):0:4&r?-1:1:e.compareDocumentPosition?-1:1}:function(e,n){var r,i=0,o=e.parentNode,s=n.parentNode,a=[e],l=[n];if(e===n)return E=!0,0;if(!o||!s)return e===t?-1:n===t?1:o?-1:s?1:u?F.call(u,e)-F.call(u,n):0;if(o===s)return lt(e,n);r=e;while(r=r.parentNode)a.unshift(r);r=n;while(r=r.parentNode)l.unshift(r);while(a[i]===l[i])i++;return i?lt(a[i],l[i]):a[i]===v?-1:l[i]===v?1:0},c):c},ut.matches=function(e,t){return ut(e,null,null,t)},ut.matchesSelector=function(e,t){if((e.ownerDocument||e)!==c&&l(e),t=t.replace(U,"='$1']"),!(!b.matchesSelector||!p||d&&d.test(t)||h&&h.test(t)))try{var n=g.call(e,t);if(n||b.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return ut(t,c,null,[e]).length>0},ut.contains=function(e,t){return(e.ownerDocument||e)!==c&&l(e),m(e,t)},ut.attr=function(e,t){(e.ownerDocument||e)!==c&&l(e);var n=r.attrHandle[t.toLowerCase()],i=n&&n(e,t,!p);return i===undefined?b.attributes||!p?e.getAttribute(t):(i=e.getAttributeNode(t))&&i.specified?i.value:null:i},ut.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},ut.uniqueSort=function(e){var t,n=[],r=0,i=0;if(E=!b.detectDuplicates,u=!b.sortStable&&e.slice(0),e.sort(S),E){while(t=e[i++])t===e[i]&&(r=n.push(i));while(r--)e.splice(n[r],1)}return e};function lt(e,t){var n=t&&e,r=n&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function ct(e,t,n){var r;return n?undefined:(r=e.getAttributeNode(t))&&r.specified?r.value:e[t]===!0?t.toLowerCase():null}function ft(e,t,n){var r;return n?undefined:r=e.getAttribute(t,"type"===t.toLowerCase()?1:2)}function pt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function ht(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function dt(e){return st(function(t){return t=+t,st(function(n,r){var i,o=e([],n.length,t),s=o.length;while(s--)n[i=o[s]]&&(n[i]=!(r[i]=n[i]))})})}i=ut.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===o||4===o)return e.nodeValue}else for(;t=e[r];r++)n+=i(t);return n},r=ut.selectors={cacheLength:50,createPseudo:st,match:G,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(tt,nt),e[3]=(e[4]||e[5]||"").replace(tt,nt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||ut.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&ut.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return G.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&Y.test(n)&&(t=gt(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(tt,nt).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=C[e+" "];return t||(t=RegExp("(^|"+R+")"+e+"("+R+"|$)"))&&C(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=ut.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),s="last"!==e.slice(-4),a="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,h,d,g=o!==s?"nextSibling":"previousSibling",m=t.parentNode,v=a&&t.nodeName.toLowerCase(),x=!u&&!a;if(m){if(o){while(g){f=t;while(f=f[g])if(a?f.nodeName.toLowerCase()===v:1===f.nodeType)return!1;d=g="only"===e&&!d&&"nextSibling"}return!0}if(d=[s?m.firstChild:m.lastChild],s&&x){c=m[y]||(m[y]={}),l=c[e]||[],h=l[0]===w&&l[1],p=l[0]===w&&l[2],f=h&&m.childNodes[h];while(f=++h&&f&&f[g]||(p=h=0)||d.pop())if(1===f.nodeType&&++p&&f===t){c[e]=[w,h,p];break}}else if(x&&(l=(t[y]||(t[y]={}))[e])&&l[0]===w)p=l[1];else while(f=++h&&f&&f[g]||(p=h=0)||d.pop())if((a?f.nodeName.toLowerCase()===v:1===f.nodeType)&&++p&&(x&&((f[y]||(f[y]={}))[e]=[w,p]),f===t))break;return p-=i,p===r||0===p%r&&p/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||ut.error("unsupported pseudo: "+e);return i[y]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?st(function(e,n){var r,o=i(e,t),s=o.length;while(s--)r=F.call(e,o[s]),e[r]=!(n[r]=o[s])}):function(e){return i(e,0,n)}):i}},pseudos:{not:st(function(e){var t=[],n=[],r=s(e.replace(I,"$1"));return r[y]?st(function(e,t,n,i){var o,s=r(e,null,i,[]),a=e.length;while(a--)(o=s[a])&&(e[a]=!(t[a]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:st(function(e){return function(t){return ut(e,t).length>0}}),contains:st(function(e){return function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:st(function(e){return V.test(e||"")||ut.error("unsupported lang: "+e),e=e.replace(tt,nt).toLowerCase(),function(t){var n;do if(n=p?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===f},focus:function(e){return e===c.activeElement&&(!c.hasFocus||c.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!r.pseudos.empty(e)},header:function(e){return Z.test(e.nodeName)},input:function(e){return K.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:dt(function(){return[0]}),last:dt(function(e,t){return[t-1]}),eq:dt(function(e,t,n){return[0>n?n+t:n]}),even:dt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:dt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:dt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:dt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(t in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})r.pseudos[t]=pt(t);for(t in{submit:!0,reset:!0})r.pseudos[t]=ht(t);function gt(e,t){var n,i,o,s,a,u,l,c=k[e+" "];if(c)return t?0:c.slice(0);a=e,u=[],l=r.preFilter;while(a){(!n||(i=z.exec(a)))&&(i&&(a=a.slice(i[0].length)||a),u.push(o=[])),n=!1,(i=_.exec(a))&&(n=i.shift(),o.push({value:n,type:i[0].replace(I," ")}),a=a.slice(n.length));for(s in r.filter)!(i=G[s].exec(a))||l[s]&&!(i=l[s](i))||(n=i.shift(),o.push({value:n,type:s,matches:i}),a=a.slice(n.length));if(!n)break}return t?a.length:a?ut.error(e):k(e,u).slice(0)}function mt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function yt(e,t,r){var i=t.dir,o=r&&"parentNode"===i,s=T++;return t.first?function(t,n,r){while(t=t[i])if(1===t.nodeType||o)return e(t,n,r)}:function(t,r,a){var u,l,c,f=w+" "+s;if(a){while(t=t[i])if((1===t.nodeType||o)&&e(t,r,a))return!0}else while(t=t[i])if(1===t.nodeType||o)if(c=t[y]||(t[y]={}),(l=c[i])&&l[0]===f){if((u=l[1])===!0||u===n)return u===!0}else if(l=c[i]=[f],l[1]=e(t,r,a)||n,l[1]===!0)return!0}}function vt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function xt(e,t,n,r,i){var o,s=[],a=0,u=e.length,l=null!=t;for(;u>a;a++)(o=e[a])&&(!n||n(o,r,i))&&(s.push(o),l&&t.push(a));return s}function bt(e,t,n,r,i,o){return r&&!r[y]&&(r=bt(r)),i&&!i[y]&&(i=bt(i,o)),st(function(o,s,a,u){var l,c,f,p=[],h=[],d=s.length,g=o||Ct(t||"*",a.nodeType?[a]:a,[]),m=!e||!o&&t?g:xt(g,p,e,a,u),y=n?i||(o?e:d||r)?[]:s:m;if(n&&n(m,y,a,u),r){l=xt(y,h),r(l,[],a,u),c=l.length;while(c--)(f=l[c])&&(y[h[c]]=!(m[h[c]]=f))}if(o){if(i||e){if(i){l=[],c=y.length;while(c--)(f=y[c])&&l.push(m[c]=f);i(null,y=[],l,u)}c=y.length;while(c--)(f=y[c])&&(l=i?F.call(o,f):p[c])>-1&&(o[l]=!(s[l]=f))}}else y=xt(y===s?y.splice(d,y.length):y),i?i(null,s,y,u):H.apply(s,y)})}function wt(e){var t,n,i,o=e.length,s=r.relative[e[0].type],u=s||r.relative[" "],l=s?1:0,c=yt(function(e){return e===t},u,!0),f=yt(function(e){return F.call(t,e)>-1},u,!0),p=[function(e,n,r){return!s&&(r||n!==a)||((t=n).nodeType?c(e,n,r):f(e,n,r))}];for(;o>l;l++)if(n=r.relative[e[l].type])p=[yt(vt(p),n)];else{if(n=r.filter[e[l].type].apply(null,e[l].matches),n[y]){for(i=++l;o>i;i++)if(r.relative[e[i].type])break;return bt(l>1&&vt(p),l>1&&mt(e.slice(0,l-1)).replace(I,"$1"),n,i>l&&wt(e.slice(l,i)),o>i&&wt(e=e.slice(i)),o>i&&mt(e))}p.push(n)}return vt(p)}function Tt(e,t){var i=0,o=t.length>0,s=e.length>0,u=function(u,l,f,p,h){var d,g,m,y=[],v=0,x="0",b=u&&[],T=null!=h,C=a,k=u||s&&r.find.TAG("*",h&&l.parentNode||l),N=w+=null==C?1:Math.random()||.1;for(T&&(a=l!==c&&l,n=i);null!=(d=k[x]);x++){if(s&&d){g=0;while(m=e[g++])if(m(d,l,f)){p.push(d);break}T&&(w=N,n=++i)}o&&((d=!m&&d)&&v--,u&&b.push(d))}if(v+=x,o&&x!==v){g=0;while(m=t[g++])m(b,y,l,f);if(u){if(v>0)while(x--)b[x]||y[x]||(y[x]=L.call(p));y=xt(y)}H.apply(p,y),T&&!u&&y.length>0&&v+t.length>1&&ut.uniqueSort(p)}return T&&(w=N,a=C),b};return o?st(u):u}s=ut.compile=function(e,t){var n,r=[],i=[],o=N[e+" "];if(!o){t||(t=gt(e)),n=t.length;while(n--)o=wt(t[n]),o[y]?r.push(o):i.push(o);o=N(e,Tt(i,r))}return o};function Ct(e,t,n){var r=0,i=t.length;for(;i>r;r++)ut(e,t[r],n);return n}function kt(e,t,n,i){var o,a,u,l,c,f=gt(e);if(!i&&1===f.length){if(a=f[0]=f[0].slice(0),a.length>2&&"ID"===(u=a[0]).type&&9===t.nodeType&&p&&r.relative[a[1].type]){if(t=(r.find.ID(u.matches[0].replace(tt,nt),t)||[])[0],!t)return n;e=e.slice(a.shift().value.length)}o=G.needsContext.test(e)?0:a.length;while(o--){if(u=a[o],r.relative[l=u.type])break;if((c=r.find[l])&&(i=c(u.matches[0].replace(tt,nt),X.test(a[0].type)&&t.parentNode||t))){if(a.splice(o,1),e=i.length&&mt(a),!e)return H.apply(n,i),n;break}}}return s(e,f)(i,t,!p,n,X.test(e)),n}r.pseudos.nth=r.pseudos.eq;function Nt(){}Nt.prototype=r.filters=r.pseudos,r.setFilters=new Nt,b.sortStable=y.split("").sort(S).join("")===y,l(),[0,0].sort(S),b.detectDuplicates=E,at(function(e){if(e.innerHTML="
    ","#"!==e.firstChild.getAttribute("href")){var t="type|href|height|width".split("|"),n=t.length;while(n--)r.attrHandle[t[n]]=ft}}),at(function(e){if(null!=e.getAttribute("disabled")){var t=P.split("|"),n=t.length;while(n--)r.attrHandle[t[n]]=ct}}),x.find=ut,x.expr=ut.selectors,x.expr[":"]=x.expr.pseudos,x.unique=ut.uniqueSort,x.text=ut.getText,x.isXMLDoc=ut.isXML,x.contains=ut.contains}(e);var D={};function A(e){var t=D[e]={};return x.each(e.match(w)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?D[e]||A(e):x.extend({},e);var t,n,r,i,o,s,a=[],u=!e.once&&[],l=function(f){for(t=e.memory&&f,n=!0,s=i||0,i=0,o=a.length,r=!0;a&&o>s;s++)if(a[s].apply(f[0],f[1])===!1&&e.stopOnFalse){t=!1;break}r=!1,a&&(u?u.length&&l(u.shift()):t?a=[]:c.disable())},c={add:function(){if(a){var n=a.length;(function s(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&c.has(n)||a.push(n):n&&n.length&&"string"!==r&&s(n)})})(arguments),r?o=a.length:t&&(i=n,l(t))}return this},remove:function(){return a&&x.each(arguments,function(e,t){var n;while((n=x.inArray(t,a,n))>-1)a.splice(n,1),r&&(o>=n&&o--,s>=n&&s--)}),this},has:function(e){return e?x.inArray(e,a)>-1:!(!a||!a.length)},empty:function(){return a=[],o=0,this},disable:function(){return a=u=t=undefined,this},disabled:function(){return!a},lock:function(){return u=undefined,t||c.disable(),this},locked:function(){return!u},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!a||n&&!u||(r?u.push(t):l(t)),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!n}};return c},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var s=o[0],a=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=a&&a.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[s+"With"](this===r?n.promise():this,a?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var s=o[2],a=o[3];r[o[1]]=s.add,a&&s.add(function(){n=a},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=s.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=d.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),s=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?d.call(arguments):r,n===a?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},a,u,l;if(r>1)for(a=Array(r),u=Array(r),l=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(s(t,l,n)).fail(o.reject).progress(s(t,u,a)):--i;return i||o.resolveWith(l,n),o.promise()}}),x.support=function(t){var n=o.createElement("input"),r=o.createDocumentFragment(),i=o.createElement("div"),s=o.createElement("select"),a=s.appendChild(o.createElement("option"));return n.type?(n.type="checkbox",t.checkOn=""!==n.value,t.optSelected=a.selected,t.reliableMarginRight=!0,t.boxSizingReliable=!0,t.pixelPosition=!1,n.checked=!0,t.noCloneChecked=n.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!a.disabled,n=o.createElement("input"),n.value="t",n.type="radio",t.radioValue="t"===n.value,n.setAttribute("checked","t"),n.setAttribute("name","t"),r.appendChild(n),t.checkClone=r.cloneNode(!0).cloneNode(!0).lastChild.checked,t.focusinBubbles="onfocusin"in e,i.style.backgroundClip="content-box",i.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===i.style.backgroundClip,x(function(){var n,r,s="padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box",a=o.getElementsByTagName("body")[0];a&&(n=o.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",a.appendChild(n).appendChild(i),i.innerHTML="",i.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%",x.swap(a,null!=a.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===i.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(i,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(i,null)||{width:"4px"}).width,r=i.appendChild(o.createElement("div")),r.style.cssText=i.style.cssText=s,r.style.marginRight=r.style.width="0",i.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),a.removeChild(n))}),t):t}({});var L,q,H=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,O=/([A-Z])/g;function F(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=x.expando+Math.random()}F.uid=1,F.accepts=function(e){return e.nodeType?1===e.nodeType||9===e.nodeType:!0},F.prototype={key:function(e){if(!F.accepts(e))return 0;var t={},n=e[this.expando];if(!n){n=F.uid++;try{t[this.expando]={value:n},Object.defineProperties(e,t)}catch(r){t[this.expando]=n,x.extend(e,t)}}return this.cache[n]||(this.cache[n]={}),n},set:function(e,t,n){var r,i=this.key(e),o=this.cache[i];if("string"==typeof t)o[t]=n;else if(x.isEmptyObject(o))this.cache[i]=t;else for(r in t)o[r]=t[r]},get:function(e,t){var n=this.cache[this.key(e)];return t===undefined?n:n[t]},access:function(e,t,n){return t===undefined||t&&"string"==typeof t&&n===undefined?this.get(e,t):(this.set(e,t,n),n!==undefined?n:t)},remove:function(e,t){var n,r,i=this.key(e),o=this.cache[i];if(t===undefined)this.cache[i]={};else{x.isArray(t)?r=t.concat(t.map(x.camelCase)):t in o?r=[t]:(r=x.camelCase(t),r=r in o?[r]:r.match(w)||[]),n=r.length;while(n--)delete o[r[n]]}},hasData:function(e){return!x.isEmptyObject(this.cache[e[this.expando]]||{})},discard:function(e){delete this.cache[this.key(e)]}},L=new F,q=new F,x.extend({acceptData:F.accepts,hasData:function(e){return L.hasData(e)||q.hasData(e)},data:function(e,t,n){return L.access(e,t,n)},removeData:function(e,t){L.remove(e,t)},_data:function(e,t,n){return q.access(e,t,n)},_removeData:function(e,t){q.remove(e,t)}}),x.fn.extend({data:function(e,t){var n,r,i=this[0],o=0,s=null;if(e===undefined){if(this.length&&(s=L.get(i),1===i.nodeType&&!q.get(i,"hasDataAttrs"))){for(n=i.attributes;n.length>o;o++)r=n[o].name,0===r.indexOf("data-")&&(r=x.camelCase(r.substring(5)),P(i,r,s[r]));q.set(i,"hasDataAttrs",!0)}return s}return"object"==typeof e?this.each(function(){L.set(this,e)}):x.access(this,function(t){var n,r=x.camelCase(e);if(i&&t===undefined){if(n=L.get(i,e),n!==undefined)return n;if(n=L.get(i,r),n!==undefined)return n;if(n=P(i,r,undefined),n!==undefined)return n}else this.each(function(){var n=L.get(this,r);L.set(this,r,t),-1!==e.indexOf("-")&&n!==undefined&&L.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){L.remove(this,e)})}});function P(e,t,n){var r;if(n===undefined&&1===e.nodeType)if(r="data-"+t.replace(O,"-$1").toLowerCase(),n=e.getAttribute(r),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:H.test(n)?JSON.parse(n):n}catch(i){}L.set(e,t,n)}else n=undefined;return n}x.extend({queue:function(e,t,n){var r;return e?(t=(t||"fx")+"queue",r=q.get(e,t),n&&(!r||x.isArray(n)?r=q.access(e,t,x.makeArray(n)):r.push(n)),r||[]):undefined},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),s=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),o.cur=i,i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,s,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return q.get(e,n)||q.access(e,n,{empty:x.Callbacks("once memory").add(function(){q.remove(e,[t+"queue",n])})})}}),x.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),n>arguments.length?x.queue(this[0],e):t===undefined?this:this.each(function(){var n=x.queue(this,e,t); +x._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=x.Deferred(),o=this,s=this.length,a=function(){--r||i.resolveWith(o,[o])};"string"!=typeof e&&(t=e,e=undefined),e=e||"fx";while(s--)n=q.get(o[s],e+"queueHooks"),n&&n.empty&&(r++,n.empty.add(a));return a(),i.promise(t)}});var R,M,W=/[\t\r\n]/g,$=/\r/g,B=/^(?:input|select|textarea|button)$/i;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[x.propFix[e]||e]})},addClass:function(e){var t,n,r,i,o,s=0,a=this.length,u="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];a>s;s++)if(n=this[s],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(W," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,s=0,a=this.length,u=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(w)||[];a>s;s++)if(n=this[s],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(W," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,i="boolean"==typeof t;return x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,s=0,a=x(this),u=t,l=e.match(w)||[];while(o=l[s++])u=i?u:!a.hasClass(o),a[u?"addClass":"removeClass"](o)}else(n===r||"boolean"===n)&&(this.className&&q.set(this,"__className__",this.className),this.className=this.className||e===!1?"":q.get(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(W," ").indexOf(t)>=0)return!0;return!1},val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=x.isFunction(e),this.each(function(n){var i,o=x(this);1===this.nodeType&&(i=r?e.call(this,n,o.val()):e,null==i?i="":"number"==typeof i?i+="":x.isArray(i)&&(i=x.map(i,function(e){return null==e?"":e+""})),t=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],t&&"set"in t&&t.set(this,i,"value")!==undefined||(this.value=i))});if(i)return t=x.valHooks[i.type]||x.valHooks[i.nodeName.toLowerCase()],t&&"get"in t&&(n=t.get(i,"value"))!==undefined?n:(n=i.value,"string"==typeof n?n.replace($,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,s=o?null:[],a=o?i+1:r.length,u=0>i?a:o?i:0;for(;a>u;u++)if(n=r[u],!(!n.selected&&u!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;s.push(t)}return s},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),s=i.length;while(s--)r=i[s],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,t,n){var i,o,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===r?x.prop(e,t,n):(1===s&&x.isXMLDoc(e)||(t=t.toLowerCase(),i=x.attrHooks[t]||(x.expr.match.boolean.test(t)?M:R)),n===undefined?i&&"get"in i&&null!==(o=i.get(e,t))?o:(o=x.find.attr(e,t),null==o?undefined:o):null!==n?i&&"set"in i&&(o=i.set(e,n,t))!==undefined?o:(e.setAttribute(t,n+""),n):(x.removeAttr(e,t),undefined))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(w);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.boolean.test(n)&&(e[r]=!1),e.removeAttribute(n)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,t,n){var r,i,o,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return o=1!==s||!x.isXMLDoc(e),o&&(t=x.propFix[t]||t,i=x.propHooks[t]),n!==undefined?i&&"set"in i&&(r=i.set(e,n,t))!==undefined?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){return e.hasAttribute("tabindex")||B.test(e.nodeName)||e.href?e.tabIndex:-1}}}}),M={set:function(e,t,n){return t===!1?x.removeAttr(e,n):e.setAttribute(n,n),n}},x.each(x.expr.match.boolean.source.match(/\w+/g),function(e,t){var n=x.expr.attrHandle[t]||x.find.attr;x.expr.attrHandle[t]=function(e,t,r){var i=x.expr.attrHandle[t],o=r?undefined:(x.expr.attrHandle[t]=undefined)!=n(e,t,r)?t.toLowerCase():null;return x.expr.attrHandle[t]=i,o}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,t){return x.isArray(t)?e.checked=x.inArray(x(e).val(),t)>=0:undefined}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var I=/^key/,z=/^(?:mouse|contextmenu)|click/,_=/^(?:focusinfocus|focusoutblur)$/,X=/^([^.]*)(?:\.(.+)|)$/;function U(){return!0}function Y(){return!1}function V(){try{return o.activeElement}catch(e){}}x.event={global:{},add:function(e,t,n,i,o){var s,a,u,l,c,f,p,h,d,g,m,y=q.get(e);if(y){n.handler&&(s=n,n=s.handler,o=s.selector),n.guid||(n.guid=x.guid++),(l=y.events)||(l=y.events={}),(a=y.handle)||(a=y.handle=function(e){return typeof x===r||e&&x.event.triggered===e.type?undefined:x.event.dispatch.apply(a.elem,arguments)},a.elem=e),t=(t||"").match(w)||[""],c=t.length;while(c--)u=X.exec(t[c])||[],d=m=u[1],g=(u[2]||"").split(".").sort(),d&&(p=x.event.special[d]||{},d=(o?p.delegateType:p.bindType)||d,p=x.event.special[d]||{},f=x.extend({type:d,origType:m,data:i,handler:n,guid:n.guid,selector:o,needsContext:o&&x.expr.match.needsContext.test(o),namespace:g.join(".")},s),(h=l[d])||(h=l[d]=[],h.delegateCount=0,p.setup&&p.setup.call(e,i,g,a)!==!1||e.addEventListener&&e.addEventListener(d,a,!1)),p.add&&(p.add.call(e,f),f.handler.guid||(f.handler.guid=n.guid)),o?h.splice(h.delegateCount++,0,f):h.push(f),x.event.global[d]=!0);e=null}},remove:function(e,t,n,r,i){var o,s,a,u,l,c,f,p,h,d,g,m=q.hasData(e)&&q.get(e);if(m&&(u=m.events)){t=(t||"").match(w)||[""],l=t.length;while(l--)if(a=X.exec(t[l])||[],h=g=a[1],d=(a[2]||"").split(".").sort(),h){f=x.event.special[h]||{},h=(r?f.delegateType:f.bindType)||h,p=u[h]||[],a=a[2]&&RegExp("(^|\\.)"+d.join("\\.(?:.*\\.|)")+"(\\.|$)"),s=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||a&&!a.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));s&&!p.length&&(f.teardown&&f.teardown.call(e,d,m.handle)!==!1||x.removeEvent(e,h,m.handle),delete u[h])}else for(h in u)x.event.remove(e,h+t[l],n,r,!0);x.isEmptyObject(u)&&(delete m.handle,q.remove(e,"events"))}},trigger:function(t,n,r,i){var s,a,u,l,c,f,p,h=[r||o],d=y.call(t,"type")?t.type:t,g=y.call(t,"namespace")?t.namespace.split("."):[];if(a=u=r=r||o,3!==r.nodeType&&8!==r.nodeType&&!_.test(d+x.event.triggered)&&(d.indexOf(".")>=0&&(g=d.split("."),d=g.shift(),g.sort()),c=0>d.indexOf(":")&&"on"+d,t=t[x.expando]?t:new x.Event(d,"object"==typeof t&&t),t.isTrigger=i?2:3,t.namespace=g.join("."),t.namespace_re=t.namespace?RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=undefined,t.target||(t.target=r),n=null==n?[t]:x.makeArray(n,[t]),p=x.event.special[d]||{},i||!p.trigger||p.trigger.apply(r,n)!==!1)){if(!i&&!p.noBubble&&!x.isWindow(r)){for(l=p.delegateType||d,_.test(l+d)||(a=a.parentNode);a;a=a.parentNode)h.push(a),u=a;u===(r.ownerDocument||o)&&h.push(u.defaultView||u.parentWindow||e)}s=0;while((a=h[s++])&&!t.isPropagationStopped())t.type=s>1?l:p.bindType||d,f=(q.get(a,"events")||{})[t.type]&&q.get(a,"handle"),f&&f.apply(a,n),f=c&&a[c],f&&x.acceptData(a)&&f.apply&&f.apply(a,n)===!1&&t.preventDefault();return t.type=d,i||t.isDefaultPrevented()||p._default&&p._default.apply(h.pop(),n)!==!1||!x.acceptData(r)||c&&x.isFunction(r[d])&&!x.isWindow(r)&&(u=r[c],u&&(r[c]=null),x.event.triggered=d,r[d](),x.event.triggered=undefined,u&&(r[c]=u)),t.result}},dispatch:function(e){e=x.event.fix(e);var t,n,r,i,o,s=[],a=d.call(arguments),u=(q.get(this,"events")||{})[e.type]||[],l=x.event.special[e.type]||{};if(a[0]=e,e.delegateTarget=this,!l.preDispatch||l.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),t=0;while((i=s[t++])&&!e.isPropagationStopped()){e.currentTarget=i.elem,n=0;while((o=i.handlers[n++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(o.namespace))&&(e.handleObj=o,e.data=o.data,r=((x.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,a),r!==undefined&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return l.postDispatch&&l.postDispatch.call(this,e),e.result}},handlers:function(e,t){var n,r,i,o,s=[],a=t.delegateCount,u=e.target;if(a&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!==this;u=u.parentNode||this)if(u.disabled!==!0||"click"!==e.type){for(r=[],n=0;a>n;n++)o=t[n],i=o.selector+" ",r[i]===undefined&&(r[i]=o.needsContext?x(i,this).index(u)>=0:x.find(i,this,null,[u]).length),r[i]&&r.push(o);r.length&&s.push({elem:u,handlers:r})}return t.length>a&&s.push({elem:this,handlers:t.slice(a)}),s},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,t){var n,r,i,s=t.button;return null==e.pageX&&null!=t.clientX&&(n=e.target.ownerDocument||o,r=n.documentElement,i=n.body,e.pageX=t.clientX+(r&&r.scrollLeft||i&&i.scrollLeft||0)-(r&&r.clientLeft||i&&i.clientLeft||0),e.pageY=t.clientY+(r&&r.scrollTop||i&&i.scrollTop||0)-(r&&r.clientTop||i&&i.clientTop||0)),e.which||s===undefined||(e.which=1&s?1:2&s?3:4&s?2:0),e}},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=z.test(i)?this.mouseHooks:I.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return 3===e.target.nodeType&&(e.target=e.target.parentNode),s.filter?s.filter(e,o):e},special:{load:{noBubble:!0},focus:{trigger:function(){return this!==V()&&this.focus?(this.focus(),!1):undefined},delegateType:"focusin"},blur:{trigger:function(){return this===V()&&this.blur?(this.blur(),!1):undefined},delegateType:"focusout"},click:{trigger:function(){return"checkbox"===this.type&&this.click&&x.nodeName(this,"input")?(this.click(),!1):undefined},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==undefined&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)},x.Event=function(e,t){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.getPreventDefault&&e.getPreventDefault()?U:Y):this.type=e,t&&x.extend(this,t),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,undefined):new x.Event(e,t)},x.Event.prototype={isDefaultPrevented:Y,isPropagationStopped:Y,isImmediatePropagationStopped:Y,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=U,e&&e.preventDefault&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=U,e&&e.stopPropagation&&e.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=U,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&o.addEventListener(e,r,!0)},teardown:function(){0===--n&&o.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,t,n,r,i){var o,s;if("object"==typeof e){"string"!=typeof t&&(n=n||t,t=undefined);for(s in e)this.on(s,t,n,e[s],i);return this}if(null==n&&null==r?(r=t,n=t=undefined):null==r&&("string"==typeof t?(r=n,n=undefined):(r=n,n=t,t=undefined)),r===!1)r=Y;else if(!r)return this;return 1===i&&(o=r,r=function(e){return x().off(e),o.apply(this,arguments)},r.guid=o.guid||(o.guid=x.guid++)),this.each(function(){x.event.add(this,e,r,n,t)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,x(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof e){for(i in e)this.off(i,t,e[i]);return this}return(t===!1||"function"==typeof t)&&(n=t,t=undefined),n===!1&&(n=Y),this.each(function(){x.event.remove(this,e,n,t)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];return n?x.event.trigger(e,t,n,!0):undefined}});var G=/^.[^:#\[\.,]*$/,J=x.expr.match.needsContext,Q={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n,r,i=this.length;if("string"!=typeof e)return t=this,this.pushStack(x(e).filter(function(){for(r=0;i>r;r++)if(x.contains(t[r],this))return!0}));for(n=[],r=0;i>r;r++)x.find(e,this[r],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=(this.selector?this.selector+" ":"")+e,n},has:function(e){var t=x(e,this),n=t.length;return this.filter(function(){var e=0;for(;n>e;e++)if(x.contains(this,t[e]))return!0})},not:function(e){return this.pushStack(Z(this,e||[],!0))},filter:function(e){return this.pushStack(Z(this,e||[],!1))},is:function(e){return!!e&&("string"==typeof e?J.test(e)?x(e,this.context).index(this[0])>=0:x.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,o=[],s=J.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(s?s.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?g.call(x(e),this[0]):g.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function K(e,t){while((e=e[t])&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return K(e,"nextSibling")},prev:function(e){return K(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(Q[e]||x.unique(i),"p"===e[0]&&i.reverse()),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,t,n){var r=[],i=n!==undefined;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&x(e).is(n))break;r.push(e)}return r},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function Z(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(G.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return g.call(t,e)>=0!==n})}var et=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,tt=/<([\w:]+)/,nt=/<|&#?\w+;/,rt=/<(?:script|style|link)/i,it=/^(?:checkbox|radio)$/i,ot=/checked\s*(?:[^=]|=\s*.checked.)/i,st=/^$|\/(?:java|ecma)script/i,at=/^true\/(.*)/,ut=/^\s*\s*$/g,lt={option:[1,""],thead:[1,"
    ","
    "],tr:[2,"","
    "],td:[3,"","
    "],_default:[0,"",""]};lt.optgroup=lt.option,lt.tbody=lt.tfoot=lt.colgroup=lt.caption=lt.col=lt.thead,lt.th=lt.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===undefined?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||o).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=ct(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=ct(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(gt(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&ht(gt(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++)1===e.nodeType&&(x.cleanData(gt(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var t=this[0]||{},n=0,r=this.length;if(e===undefined&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!rt.test(e)&&!lt[(tt.exec(e)||["",""])[1].toLowerCase()]){e=e.replace(et,"<$1>");try{for(;r>n;n++)t=this[n]||{},1===t.nodeType&&(x.cleanData(gt(t,!1)),t.innerHTML=e);t=0}catch(i){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=p.apply([],e);var r,i,o,s,a,u,l=0,c=this.length,f=this,h=c-1,d=e[0],g=x.isFunction(d);if(g||!(1>=c||"string"!=typeof d||x.support.checkClone)&&ot.test(d))return this.each(function(r){var i=f.eq(r);g&&(e[0]=d.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(r=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),i=r.firstChild,1===r.childNodes.length&&(r=i),i)){for(o=x.map(gt(r,"script"),ft),s=o.length;c>l;l++)a=r,l!==h&&(a=x.clone(a,!0,!0),s&&x.merge(o,gt(a,"script"))),t.call(this[l],a,l);if(s)for(u=o[o.length-1].ownerDocument,x.map(o,pt),l=0;s>l;l++)a=o[l],st.test(a.type||"")&&!q.access(a,"globalEval")&&x.contains(u,a)&&(a.src?x._evalUrl(a.src):x.globalEval(a.textContent.replace(ut,"")))}return this}}),x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=[],i=x(e),o=i.length-1,s=0;for(;o>=s;s++)n=s===o?this:this.clone(!0),x(i[s])[t](n),h.apply(r,n.get());return this.pushStack(r)}}),x.extend({clone:function(e,t,n){var r,i,o,s,a=e.cloneNode(!0),u=x.contains(e.ownerDocument,e);if(!(x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(s=gt(a),o=gt(e),r=0,i=o.length;i>r;r++)mt(o[r],s[r]);if(t)if(n)for(o=o||gt(e),s=s||gt(a),r=0,i=o.length;i>r;r++)dt(o[r],s[r]);else dt(e,a);return s=gt(a,"script"),s.length>0&&ht(s,!u&>(e,"script")),a},buildFragment:function(e,t,n,r){var i,o,s,a,u,l,c=0,f=e.length,p=t.createDocumentFragment(),h=[];for(;f>c;c++)if(i=e[c],i||0===i)if("object"===x.type(i))x.merge(h,i.nodeType?[i]:i);else if(nt.test(i)){o=o||p.appendChild(t.createElement("div")),s=(tt.exec(i)||["",""])[1].toLowerCase(),a=lt[s]||lt._default,o.innerHTML=a[1]+i.replace(et,"<$1>")+a[2],l=a[0];while(l--)o=o.firstChild;x.merge(h,o.childNodes),o=p.firstChild,o.textContent=""}else h.push(t.createTextNode(i));p.textContent="",c=0;while(i=h[c++])if((!r||-1===x.inArray(i,r))&&(u=x.contains(i.ownerDocument,i),o=gt(p.appendChild(i),"script"),u&&ht(o),n)){l=0;while(i=o[l++])st.test(i.type||"")&&n.push(i)}return p},cleanData:function(e){var t,n,r,i=e.length,o=0,s=x.event.special;for(;i>o;o++){if(n=e[o],x.acceptData(n)&&(t=q.access(n)))for(r in t.events)s[r]?x.event.remove(n,r):x.removeEvent(n,r,t.handle);L.discard(n),q.discard(n)}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"text",async:!1,global:!1,success:x.globalEval})}});function ct(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function ft(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function pt(e){var t=at.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function ht(e,t){var n=e.length,r=0;for(;n>r;r++)q.set(e[r],"globalEval",!t||q.get(t[r],"globalEval"))}function dt(e,t){var n,r,i,o,s,a,u,l;if(1===t.nodeType){if(q.hasData(e)&&(o=q.access(e),s=x.extend({},o),l=o.events,q.set(t,s),l)){delete s.handle,s.events={};for(i in l)for(n=0,r=l[i].length;r>n;n++)x.event.add(t,i,l[i][n])}L.hasData(e)&&(a=L.access(e),u=x.extend({},a),L.set(t,u))}}function gt(e,t){var n=e.getElementsByTagName?e.getElementsByTagName(t||"*"):e.querySelectorAll?e.querySelectorAll(t||"*"):[];return t===undefined||t&&x.nodeName(e,t)?x.merge([e],n):n}function mt(e,t){var n=t.nodeName.toLowerCase();"input"===n&&it.test(e.type)?t.checked=e.checked:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}x.fn.extend({wrapAll:function(e){var t;return x.isFunction(e)?this.each(function(t){x(this).wrapAll(e.call(this,t))}):(this[0]&&(t=x(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this)},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var yt,vt,xt=/^(none|table(?!-c[ea]).+)/,bt=/^margin/,wt=RegExp("^("+b+")(.*)$","i"),Tt=RegExp("^("+b+")(?!px)[a-z%]+$","i"),Ct=RegExp("^([+-])=("+b+")","i"),kt={BODY:"block"},Nt={position:"absolute",visibility:"hidden",display:"block"},Et={letterSpacing:0,fontWeight:400},St=["Top","Right","Bottom","Left"],jt=["Webkit","O","Moz","ms"];function Dt(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=jt.length;while(i--)if(t=jt[i]+n,t in e)return t;return r}function At(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function Lt(t){return e.getComputedStyle(t,null)}function qt(e,t){var n,r,i,o=[],s=0,a=e.length;for(;a>s;s++)r=e[s],r.style&&(o[s]=q.get(r,"olddisplay"),n=r.style.display,t?(o[s]||"none"!==n||(r.style.display=""),""===r.style.display&&At(r)&&(o[s]=q.access(r,"olddisplay",Pt(r.nodeName)))):o[s]||(i=At(r),(n&&"none"!==n||!i)&&q.set(r,"olddisplay",i?n:x.css(r,"display"))));for(s=0;a>s;s++)r=e[s],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[s]||"":"none"));return e}x.fn.extend({css:function(e,t){return x.access(this,function(e,t,n){var r,i,o={},s=0;if(x.isArray(t)){for(r=Lt(e),i=t.length;i>s;s++)o[t[s]]=x.css(e,t[s],!1,r);return o}return n!==undefined?x.style(e,t,n):x.css(e,t)},e,t,arguments.length>1)},show:function(){return qt(this,!0)},hide:function(){return qt(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:At(this))?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=yt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,s,a=x.camelCase(t),u=e.style;return t=x.cssProps[a]||(x.cssProps[a]=Dt(u,a)),s=x.cssHooks[t]||x.cssHooks[a],n===undefined?s&&"get"in s&&(i=s.get(e,!1,r))!==undefined?i:u[t]:(o=typeof n,"string"===o&&(i=Ct.exec(n))&&(n=(i[1]+1)*i[2]+parseFloat(x.css(e,t)),o="number"),null==n||"number"===o&&isNaN(n)||("number"!==o||x.cssNumber[a]||(n+="px"),x.support.clearCloneStyle||""!==n||0!==t.indexOf("background")||(u[t]="inherit"),s&&"set"in s&&(n=s.set(e,n,r))===undefined||(u[t]=n)),undefined)}},css:function(e,t,n,r){var i,o,s,a=x.camelCase(t);return t=x.cssProps[a]||(x.cssProps[a]=Dt(e.style,a)),s=x.cssHooks[t]||x.cssHooks[a],s&&"get"in s&&(i=s.get(e,!0,n)),i===undefined&&(i=yt(e,t,r)),"normal"===i&&t in Et&&(i=Et[t]),""===n||n?(o=parseFloat(i),n===!0||x.isNumeric(o)?o||0:i):i}}),yt=function(e,t,n){var r,i,o,s=n||Lt(e),a=s?s.getPropertyValue(t)||s[t]:undefined,u=e.style;return s&&(""!==a||x.contains(e.ownerDocument,e)||(a=x.style(e,t)),Tt.test(a)&&bt.test(t)&&(r=u.width,i=u.minWidth,o=u.maxWidth,u.minWidth=u.maxWidth=u.width=a,a=s.width,u.width=r,u.minWidth=i,u.maxWidth=o)),a};function Ht(e,t,n){var r=wt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function Ot(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,s=0;for(;4>o;o+=2)"margin"===n&&(s+=x.css(e,n+St[o],!0,i)),r?("content"===n&&(s-=x.css(e,"padding"+St[o],!0,i)),"margin"!==n&&(s-=x.css(e,"border"+St[o]+"Width",!0,i))):(s+=x.css(e,"padding"+St[o],!0,i),"padding"!==n&&(s+=x.css(e,"border"+St[o]+"Width",!0,i)));return s}function Ft(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Lt(e),s=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=yt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Tt.test(i))return i;r=s&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+Ot(e,t,n||(s?"border":"content"),r,o)+"px"}function Pt(e){var t=o,n=kt[e];return n||(n=Rt(e,t),"none"!==n&&n||(vt=(vt||x(" + + + \ No newline at end of file diff --git a/examples/sprites/add a sprite.js b/examples/sprites/add a sprite.js new file mode 100644 index 00000000..142af540 --- /dev/null +++ b/examples/sprites/add a sprite.js @@ -0,0 +1,15 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.image('mushroom', 'assets/sprites/mushroom2.png'); + +} + +function create() { + + // This simply creates a sprite using the mushroom image we loaded above and positions it at 200 x 200 + var test = game.add.sprite(200, 200, 'mushroom'); + +} diff --git a/examples/sprites/add several sprites.js b/examples/sprites/add several sprites.js new file mode 100644 index 00000000..685e83f9 --- /dev/null +++ b/examples/sprites/add several sprites.js @@ -0,0 +1,49 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update }); + +var timer = 0; +var total = 0; + +function preload() { + + // 37x45 is the size of each frame + // There are 18 frames in the PNG - you can leave this value blank if the frames fill up the entire PNG, but in this case there are some + // blank frames at the end, so we tell the loader how many to load + game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18); + +} + +function create() { + + releaseMummy(); + +} + +function releaseMummy() { + + var mummy = game.add.sprite(-(Math.random() * 800), game.world.randomY, 'mummy'); + + mummy.scale.setTo(2, 2); + + // If you prefer to work in degrees rather than radians then you can use Phaser.Sprite.angle + // otherwise use Phaser.Sprite.rotation + mummy.angle = game.rnd.angle(); + + mummy.animations.add('walk'); + mummy.animations.play('walk', 20, true); + + game.add.tween(mummy).to({ x: game.width + (1600 + mummy.x) }, 20000, Phaser.Easing.Linear.None, true); + + total++; + timer = game.time.now + 100; + +} + +function update() { + + if (total < 200 && game.time.now > timer) + { + releaseMummy(); + } + +} diff --git a/examples/sprites/collide world bounds.js b/examples/sprites/collide world bounds.js new file mode 100644 index 00000000..48b10333 --- /dev/null +++ b/examples/sprites/collide world bounds.js @@ -0,0 +1,26 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + game.load.image('pineapple', 'assets/sprites/pineapple.png'); + +} + +var pineapples; + +function create() { + + pineapples = game.add.group(); + + for (var i = 0; i < 10; i++) + { + var pineapple = pineapples.create(200 + i * 48,50, 'pineapple'); + + //This allows your sprite to collide with the world bounds like they were rigid objects + pineapple.body.collideWorldBounds=true; + pineapple.body.gravity.x = game.rnd.integerInRange(-5,5); + pineapple.body.gravity.y = 5 + Math.random() * 10; + pineapple.body.bounce.setTo(0.7,0.4); + } + +} diff --git a/examples/sprites/destroy.js b/examples/sprites/destroy.js new file mode 100644 index 00000000..38d65a18 --- /dev/null +++ b/examples/sprites/destroy.js @@ -0,0 +1,31 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.image('plane', 'assets/misc/boss1.png'); + game.load.image('sky', 'assets/tests/sky-2x.png'); + +} + +function create() { + + game.add.sprite(0, 0, 'sky'); + + for (var i = 0; i < 15; i++) + { + var sprite = game.add.sprite(game.world.randomX, game.world.randomY, 'plane'); + + sprite.inputEnabled = true; + + sprite.input.useHandCursor = true; + + sprite.events.onInputDown.add(destoyIt, this); + } + +} + +function destoyIt (sprite) { + + sprite.destroy(); +} diff --git a/examples/sprites/dynamic crop.js b/examples/sprites/dynamic crop.js new file mode 100644 index 00000000..9922d0a0 --- /dev/null +++ b/examples/sprites/dynamic crop.js @@ -0,0 +1,35 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg'); +} + +var pic; + +function create() { + + pic = game.add.sprite(0, 0, 'trsi'); + + pic.cropEnabled = true; + + pic.crop.width = 128; + pic.crop.height = 128; + +} + +function update() { + + pic.x = game.input.x; + pic.y = game.input.y; + + pic.crop.x = game.input.x; + pic.crop.y = game.input.y; + +} + +function render() { + + game.debug.renderText('x: ' + game.input.x + ' y: ' + game.input.y, 32, 32); + +} diff --git a/examples/sprites/extending sprite demo 1.js b/examples/sprites/extending sprite demo 1.js new file mode 100644 index 00000000..2d0da102 --- /dev/null +++ b/examples/sprites/extending sprite demo 1.js @@ -0,0 +1,42 @@ + +// Here is a custom game object +MonsterBunny = function (game, x, y, rotateSpeed) { + + Phaser.Sprite.call(this, game, x, y, 'bunny'); + + this.rotateSpeed = rotateSpeed; + +}; + +MonsterBunny.prototype = Object.create(Phaser.Sprite.prototype); +MonsterBunny.prototype.constructor = MonsterBunny; + +/** + * Automatically called by World.update + */ +MonsterBunny.prototype.update = function() { + + this.angle += this.rotateSpeed; + +}; + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.image('bunny', 'assets/sprites/bunny.png'); + +} + +function create() { + + var wabbit = new MonsterBunny(game, 200, 300, 1); + wabbit.anchor.setTo(0.5, 0.5); + + var wabbit2 = new MonsterBunny(game, 600, 300, 0.5); + wabbit2.anchor.setTo(0.5, 0.5); + + game.add.existing(wabbit); + game.add.existing(wabbit2); + +} diff --git a/examples/sprites/extending sprite demo 2.js b/examples/sprites/extending sprite demo 2.js new file mode 100644 index 00000000..20a2583f --- /dev/null +++ b/examples/sprites/extending sprite demo 2.js @@ -0,0 +1,45 @@ + +MonsterBunny = function (game, rotateSpeed) { + + // We call the Phaser.Sprite passing in the game reference + // We're giving it a random X/Y position here, just for the sake of this demo - you could also pass the x/y in the constructor + Phaser.Sprite.call(this, game, game.world.randomX, game.world.randomY, 'bunny'); + + this.anchor.setTo(0.5, 0.5); + + this.rotateSpeed = rotateSpeed; + + var randomScale = 0.1 + Math.random(); + + this.scale.setTo(randomScale, randomScale) + + game.add.existing(this); + +}; + +MonsterBunny.prototype = Object.create(Phaser.Sprite.prototype); +MonsterBunny.prototype.constructor = MonsterBunny; + +MonsterBunny.prototype.update = function() { + + // Automatically called by World.update + this.angle += this.rotateSpeed; + +}; + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.image('bunny', 'assets/sprites/bunny.png'); + +} + +function create() { + + for (var i = 0.1; i < 2; i += 0.1) + { + new MonsterBunny(game, i); + } + +} diff --git a/examples/sprites/horizontal crop.js b/examples/sprites/horizontal crop.js new file mode 100644 index 00000000..77f66dc7 --- /dev/null +++ b/examples/sprites/horizontal crop.js @@ -0,0 +1,23 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg'); +} + +function create() { + + var pic = game.add.sprite(game.world.centerX, 550, 'trsi'); + + pic.anchor.setTo(0.5, 1); + + // By default Sprites ignore the crop setting, you have to explicitly enable it like this: + pic.cropEnabled = true; + + // Set the crop rect width to zero + pic.crop.width = 0; + + // Here we'll tween the crop rect, from a width of zero to full width, and back again + game.add.tween(pic.crop).to( { width: pic.width }, 3000, Phaser.Easing.Bounce.Out, true, 0, 1000, true); + +} diff --git a/examples/sprites/move a sprite.js b/examples/sprites/move a sprite.js new file mode 100644 index 00000000..1d784c94 --- /dev/null +++ b/examples/sprites/move a sprite.js @@ -0,0 +1,48 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json'); +} + +var s; + +function create() { + + s = game.add.sprite(game.world.centerX, game.world.centerY, 'bot'); + // s.anchor.setTo(0.5, 0.5); + s.scale.setTo(2, 2); + + s.animations.add('run'); + s.animations.play('run', 10, true); + +} + +function update() { + + if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) + { + s.x -= 4; + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) + { + s.x += 4; + } + + if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) + { + s.y -= 4; + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) + { + s.y += 4; + } + +} + +function render() { + + game.debug.renderSpriteCorners(s, false, false); + game.debug.renderSpriteInfo(s, 20, 32); + +} diff --git a/examples/sprites/out of bounds.js b/examples/sprites/out of bounds.js new file mode 100644 index 00000000..94ffc31f --- /dev/null +++ b/examples/sprites/out of bounds.js @@ -0,0 +1,42 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.image('alien', 'assets/sprites/space-baddie.png'); + game.load.image('ship', 'assets/sprites/shmup-ship.png'); + +} + +var player; +var aliens; + +function create() { + + player = game.add.sprite(400, 500, 'ship'); + player.anchor.setTo(0.5, 0.5); + + aliens = game.add.group(); + + for (var y = 0; y < 4; y++) + { + for (var x = 0; x < 10; x++) + { + var alien = aliens.create(200 + x * 48, y * 50, 'alien'); + alien.name = 'alien' + x.toString() + y.toString(); + alien.events.onOutOfBounds.add(alienOut, this); + alien.body.velocity.y = 50 + Math.random() * 200; + } + } + +} + +function alienOut(alien) { + + // Move the alien to the top of the screen again + alien.reset(alien.x, -32); + + // And give it a new random velocity + alien.body.velocity.y = 50 + Math.random() * 200; + +} diff --git a/examples/sprites/scale a sprite.js b/examples/sprites/scale a sprite.js new file mode 100644 index 00000000..acf38dc2 --- /dev/null +++ b/examples/sprites/scale a sprite.js @@ -0,0 +1,29 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create}); + +function preload() { + + game.load.image('disk', 'assets/sprites/darkwing_crazy.png'); + +} + +function create() { + + for (var i = 0; i < 15; i++) + { + // Create 15 sprites at random x/y locations + var sprite = game.add.sprite(game.world.randomX, game.world.randomY, 'disk'); + + // Pick a random number between -2 and 6 + var rand = game.rnd.realInRange(-2, 6); + + // Set the scale of the sprite to the random value + sprite.scale.setTo(rand, rand); + + // You can also scale sprites like this: + // sprite.scale.x = value; + // sprite.scale.y = value; + + } + +} diff --git a/examples/sprites/shared sprite textures.js b/examples/sprites/shared sprite textures.js new file mode 100644 index 00000000..294d0f0d --- /dev/null +++ b/examples/sprites/shared sprite textures.js @@ -0,0 +1,41 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + // We load a TexturePacker JSON file and image and show you how to make several unique sprites from the same file + game.load.atlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json'); + +} + +var chick; +var car; +var mech; +var robot; +var cop; + +function create() { + + game.stage.backgroundColor = '#404040'; + + chick = game.add.sprite(64, 64, 'atlas'); + + // You can set the frame based on the frame name (which TexturePacker usually sets to be the filename of the image itself) + chick.frameName = 'budbrain_chick.png'; + + // Or by setting the frame index + //chick.frame = 0; + + cop = game.add.sprite(600, 64, 'atlas'); + cop.frameName = 'ladycop.png'; + + robot = game.add.sprite(50, 300, 'atlas'); + robot.frameName = 'robot.png'; + + car = game.add.sprite(100, 400, 'atlas'); + car.frameName = 'supercars_parsec.png'; + + mech = game.add.sprite(250, 100, 'atlas'); + mech.frameName = 'titan_mech.png'; + +} diff --git a/examples/sprites/sprite rotation.js b/examples/sprites/sprite rotation.js new file mode 100644 index 00000000..5ee44391 --- /dev/null +++ b/examples/sprites/sprite rotation.js @@ -0,0 +1,37 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + game.load.image('arrow', 'assets/sprites/arrow.png'); +} + +var sprite; + +function create() { + + game.stage.backgroundColor = '#0072bc'; + + sprite = game.add.sprite(400, 300, 'arrow'); + sprite.anchor.setTo(0.5, 0.5); + +} + +function update() { + + sprite.angle += 1; + + // Note: Due to a bug in Chrome the following doesn't work atm: + // sprite.angle++; + // See: https://code.google.com/p/chromium/issues/detail?id=306851 + +} + +function render() { + + game.debug.renderSpriteInfo(sprite, 32, 32); + game.debug.renderText('angularVelocity: ' + sprite.body.angularVelocity, 32, 200); + game.debug.renderText('angularAcceleration: ' + sprite.body.angularAcceleration, 32, 232); + game.debug.renderText('angularDrag: ' + sprite.body.angularDrag, 32, 264); + game.debug.renderText('deltaZ: ' + sprite.body.deltaZ(), 32, 296); + +} diff --git a/examples/sprites/sprite1.php b/examples/sprites/sprite1.php deleted file mode 100644 index e3e563b1..00000000 --- a/examples/sprites/sprite1.php +++ /dev/null @@ -1,31 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/sprites/sprite3.php b/examples/sprites/sprite3.php deleted file mode 100644 index 115418a3..00000000 --- a/examples/sprites/sprite3.php +++ /dev/null @@ -1,61 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/sprites/sprite4.php b/examples/sprites/sprite4.php deleted file mode 100644 index 161c1830..00000000 --- a/examples/sprites/sprite4.php +++ /dev/null @@ -1,64 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/sprites/sprite_extend.php b/examples/sprites/sprite_extend.php deleted file mode 100644 index 3a259b3c..00000000 --- a/examples/sprites/sprite_extend.php +++ /dev/null @@ -1,52 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/sprites/spritesheet.js b/examples/sprites/spritesheet.js new file mode 100644 index 00000000..6039a2f3 --- /dev/null +++ b/examples/sprites/spritesheet.js @@ -0,0 +1,37 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update }); + +var sprite; + +function preload() { + + // 37x45 is the size of each frame + // There are 18 frames in the PNG - you can leave this value blank if the frames fill up the entire PNG, but in this case there are some + // blank frames at the end, so we tell the loader how many to load + game.load.spritesheet('ms', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18); + +} + +function create() { + + sprite = game.add.sprite(40, 100, 'ms'); + + sprite.animations.add('walk'); + + sprite.animations.play('walk', 50, true); + + game.add.tween(sprite).to({ x: game.width }, 10000, Phaser.Easing.Linear.None, true); + +} + +// update isn't called until 'create' has completed. If you need to process stuff before that point (i.e. while the preload is still happening) +// then create a function called loadUpdate() and use that +function update() { + + if (sprite.x >= 300) + { + sprite.scale.x += 0.01; + sprite.scale.y += 0.01; + } + +} diff --git a/examples/sprites/spritesheet.php b/examples/sprites/spritesheet.php deleted file mode 100644 index 9bdfec57..00000000 --- a/examples/sprites/spritesheet.php +++ /dev/null @@ -1,51 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/sprites/vertical crop.js b/examples/sprites/vertical crop.js new file mode 100644 index 00000000..09bd2887 --- /dev/null +++ b/examples/sprites/vertical crop.js @@ -0,0 +1,23 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg'); +} + +function create() { + + var pic = game.add.sprite(game.world.centerX, 550, 'trsi'); + + pic.anchor.setTo(0.5, 1); + + // By default Sprites ignore the crop setting, you have to explicitly enable it like this: + pic.cropEnabled = true; + + // Set the crop rect height to zero + pic.crop.height = 0; + + // Here we'll tween the crop rect, from a height of zero to full height, and back again + game.add.tween(pic.crop).to( { height: pic.height }, 3000, Phaser.Easing.Bounce.Out, true, 0, 1000, true); + +} diff --git a/examples/template.php b/examples/template.php deleted file mode 100644 index 89019d30..00000000 --- a/examples/template.php +++ /dev/null @@ -1,36 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/text/bitmap fonts.js b/examples/text/bitmap fonts.js new file mode 100644 index 00000000..4a819604 --- /dev/null +++ b/examples/text/bitmap fonts.js @@ -0,0 +1,22 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update }); + +function preload() { + + game.load.bitmapFont('desyrel', 'assets/fonts/desyrel.png', 'assets/fonts/desyrel.xml'); + +} + +var text; + +function create() { + + text = game.add.bitmapText(200, 100, 'Phaser & Pixi\nrocking!', { font: '64px Desyrel', align: 'center' }); + +} + +function update() { + + text.setText('Phaser & Pixi\nrocking!\n' + Math.round(game.time.now)); + +} diff --git a/examples/text/bitmap fonts.php b/examples/text/bitmap fonts.php deleted file mode 100644 index 27c7c9fb..00000000 --- a/examples/text/bitmap fonts.php +++ /dev/null @@ -1,29 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/text/hello arial.js b/examples/text/hello arial.js new file mode 100644 index 00000000..df40c8cb --- /dev/null +++ b/examples/text/hello arial.js @@ -0,0 +1,12 @@ +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create }); + +function create() { + + var text = "- phaser -\nwith a sprinkle of\npixi dust"; + var style = { font: "65px Arial", fill: "#ff0044", align: "center" }; + + var t = game.add.text(game.world.centerX, game.world.centerY, text, style); + + t.anchor.setTo(0.5, 0.5); + +} \ No newline at end of file diff --git a/examples/text/hello arial.php b/examples/text/hello arial.php deleted file mode 100644 index 5f58cbc2..00000000 --- a/examples/text/hello arial.php +++ /dev/null @@ -1,28 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/text/kern of duty.js b/examples/text/kern of duty.js new file mode 100644 index 00000000..5d0d6d86 --- /dev/null +++ b/examples/text/kern of duty.js @@ -0,0 +1,62 @@ + +var game = new Phaser.Game(800, 480, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update }); + +var content = [ + " ", + "photon storm presents", + "a phaser production", + " ", + "Kern of Duty", + " ", + "directed by rich davey", + "rendering by mat groves", + " ", + "03:45, November 4th, 2014", + "somewhere in the north pacific", + "mission control bravo ...", +]; + +var t = 0; +var s; +var index = 0; +var line = ''; + +function preload() { + game.load.image('cod', 'assets/pics/cod.jpg'); +} + +function create() { + + game.add.sprite(0, 0, 'cod'); + + var style = { font: "30pt Courier", fill: "#19cb65", stroke: "#119f4e", strokeThickness: 2 }; + + s = game.add.text(32, 380, '', style); + t = game.time.now + 80; + +} + +function update() { + + if (game.time.now > t && index < content.length) + { + // get the next character in the line + if (line.length < content[index].length) + { + line = content[index].substr(0, line.length + 1); + s.setText(line); + t = game.time.now + 80; + } + else + { + t = game.time.now + 2000; + + if (index < content.length) + { + index++; + line = ''; + } + } + } + +} diff --git a/examples/text/kern of duty.php b/examples/text/kern of duty.php deleted file mode 100644 index 442a02b3..00000000 --- a/examples/text/kern of duty.php +++ /dev/null @@ -1,78 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/text/remove text.js b/examples/text/remove text.js new file mode 100644 index 00000000..dd58c1d3 --- /dev/null +++ b/examples/text/remove text.js @@ -0,0 +1,19 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create }); + +var text; + +function create() { + + text = game.add.text(game.world.centerX, game.world.centerY, "- phaser -\nclick to remove", { font: "65px Arial", fill: "#ff0044", align: "center" }); + text.anchor.setTo(0.5, 0.5); + + game.input.onDown.addOnce(removeText, this); + +} + +function removeText() { + + text.destroy(); + +} diff --git a/examples/text/text stroke.js b/examples/text/text stroke.js new file mode 100644 index 00000000..5922c82c --- /dev/null +++ b/examples/text/text stroke.js @@ -0,0 +1,18 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create, update: update }); + +var s; + +function create() { + + var text = "--- phaser ---\nwith a sprinkle of\npixi dust"; + var style = { font: "bold 40pt Arial", fill: "#ffffff", align: "center", stroke: "#258acc", strokeThickness: 8 }; + + s = game.add.text(game.world.centerX, game.world.centerY, text, style); + s.anchor.setTo(0.5, 0.5); + +} + +function update() { + s.angle += 1; +} diff --git a/examples/text/text stroke.php b/examples/text/text stroke.php deleted file mode 100644 index 7d0a4d7f..00000000 --- a/examples/text/text stroke.php +++ /dev/null @@ -1,34 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/texture crop/crop.php b/examples/texture crop/crop.php deleted file mode 100644 index 11bfb125..00000000 --- a/examples/texture crop/crop.php +++ /dev/null @@ -1,42 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/texture crop/crop2.php b/examples/texture crop/crop2.php deleted file mode 100644 index 6823b7b3..00000000 --- a/examples/texture crop/crop2.php +++ /dev/null @@ -1,42 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/texture crop/crop3.php b/examples/texture crop/crop3.php deleted file mode 100644 index 778102d9..00000000 --- a/examples/texture crop/crop3.php +++ /dev/null @@ -1,44 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/tile sprites/animated tiling sprite.js b/examples/tile sprites/animated tiling sprite.js new file mode 100644 index 00000000..9977d266 --- /dev/null +++ b/examples/tile sprites/animated tiling sprite.js @@ -0,0 +1,43 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update }); + +function preload() { + game.load.image('disk', 'assets/sprites/p2.jpeg'); +} + +var s; +var count = 0; + +function create() { + s = game.add.tileSprite(0, 0, 512, 512, 'disk'); +} + +function update() { + + count += 0.005 + + s.tileScale.x = 2 + Math.sin(count); + s.tileScale.y = 2 + Math.cos(count); + + s.tilePosition.x += 1; + s.tilePosition.y += 1; + + if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) + { + s.x -= 4; + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) + { + s.x += 4; + } + + if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) + { + s.y -= 4; + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) + { + s.y += 4; + } + +} diff --git a/examples/tile sprites/tilesprite1.php b/examples/tile sprites/tilesprite1.php deleted file mode 100644 index f32533d5..00000000 --- a/examples/tile sprites/tilesprite1.php +++ /dev/null @@ -1,59 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/tile sprites/tilesprite2.php b/examples/tile sprites/tilesprite2.php deleted file mode 100644 index 5b90b0fe..00000000 --- a/examples/tile sprites/tilesprite2.php +++ /dev/null @@ -1,50 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/tile sprites/tiling sprite.js b/examples/tile sprites/tiling sprite.js new file mode 100644 index 00000000..97485825 --- /dev/null +++ b/examples/tile sprites/tiling sprite.js @@ -0,0 +1,34 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update }); + +var s; + +function preload() { + game.load.image('starfield', 'assets/misc/starfield.jpg'); +} + +function create() { + s = game.add.tileSprite(0, 0, 800, 600, 'starfield'); +} + +function update() { + + if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) + { + s.tilePosition.x += 8; + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) + { + s.tilePosition.x -= 8; + } + + if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) + { + s.tilePosition.y += 8; + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) + { + s.tilePosition.y -= 8; + } + +} diff --git a/examples/tilemaps/fill tiles.js b/examples/tilemaps/fill tiles.js new file mode 100644 index 00000000..9670ce19 --- /dev/null +++ b/examples/tilemaps/fill tiles.js @@ -0,0 +1,76 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('desert', 'assets/maps/desert.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/tiles/tmw_desert_spacing.png', 32, 32, -1, 1, 1); + game.load.image('car', 'assets/sprites/car90.png'); + +} + +var map; +var tileset; +var layer; + +var cursors; +var sprite; + +function create() { + + map = game.add.tilemap('desert'); + + tileset = game.add.tileset('tiles'); + + layer = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0); + + layer.resizeWorld(); + + sprite = game.add.sprite(450, 80, 'car'); + sprite.anchor.setTo(0.5, 0.5); + + game.camera.follow(sprite); + + cursors = game.input.keyboard.createCursorKeys(); + + game.input.onDown.add(fillTiles, this); + +} + +function fillTiles() { + + map.fill(31, layer.getTileX(sprite.x), layer.getTileY(sprite.y), 6, 6); + +} + +function update() { + + game.physics.collide(sprite, layer); + + sprite.body.velocity.x = 0; + sprite.body.velocity.y = 0; + sprite.body.angularVelocity = 0; + + if (cursors.left.isDown) + { + sprite.body.angularVelocity = -200; + } + else if (cursors.right.isDown) + { + sprite.body.angularVelocity = 200; + } + + if (cursors.up.isDown) + { + sprite.body.velocity.copyFrom(game.physics.velocityFromAngle(sprite.angle, 300)); + } + +} + +function render() { + + game.debug.renderText('Click to fill tiles', 32, 32, 'rgb(0,0,0)'); + game.debug.renderText('Tile X: ' + layer.getTileX(sprite.x), 32, 48, 'rgb(0,0,0)'); + game.debug.renderText('Tile Y: ' + layer.getTileY(sprite.y), 32, 64, 'rgb(0,0,0)'); + +} diff --git a/examples/tilemaps/mapcollide.js b/examples/tilemaps/mapcollide.js new file mode 100644 index 00000000..1a426d3e --- /dev/null +++ b/examples/tilemaps/mapcollide.js @@ -0,0 +1,76 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('mario', 'assets/maps/mario1.png', 'assets/maps/mario1.json', null, Phaser.Tilemap.JSON); + game.load.image('player', 'assets/sprites/phaser-dude.png'); + +} + +var map; +var p; +var cursors; + +function create() { + + game.stage.backgroundColor = '#787878'; + + map = game.add.tilemap(0, 0, 'mario'); + + // floor + map.setCollisionRange(80, 97, true, true, true, true); + + // one-ways + map.setCollisionRange(15, 17, true, true, false, true); + + p = game.add.sprite(32, 32, 'player'); + + p.body.gravity.y = 10; + p.body.bounce.y = 0.4; + p.body.collideWorldBounds = true; + + game.world.setBounds(0, 0, map.width, 600); + + game.camera.follow(p); + + cursors = game.input.keyboard.createCursorKeys(); + +} + +function update() { + + map.collide(p); + + p.body.velocity.x = 0; + + if (cursors.up.isDown) + { + if (p.body.touching.down) + { + p.body.velocity.y = -400; + } + } + else if (cursors.down.isDown) + { + // game.camera.y += 4; + } + + if (cursors.left.isDown) + { + p.body.velocity.x = -150; + } + else if (cursors.right.isDown) + { + p.body.velocity.x = 150; + } + +} + +function render() { + + game.debug.renderCameraInfo(game.camera, 32, 32); + // game.debug.renderSpriteCorners(p); + game.debug.renderSpriteCollision(p, 32, 320); + +} diff --git a/examples/tilemaps/mapcollide.php b/examples/tilemaps/mapcollide.php deleted file mode 100644 index d995a90e..00000000 --- a/examples/tilemaps/mapcollide.php +++ /dev/null @@ -1,81 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/tilemaps/mario.js b/examples/tilemaps/mario.js new file mode 100644 index 00000000..cc06313c --- /dev/null +++ b/examples/tilemaps/mario.js @@ -0,0 +1,41 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('mario', 'assets/maps/mario1.png', 'assets/maps/mario1.json', null, Phaser.Tilemap.JSON); + +} + +function create() { + + game.stage.backgroundColor = '#787878'; + + game.add.tilemap(0, 0, 'mario'); + +} + +function update() { + + if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) + { + game.camera.x -= 8; + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) + { + game.camera.x += 8; + } + + if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) + { + game.camera.y -= 8; + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) + { + game.camera.y += 8; + } + +} + +function render() { +} diff --git a/examples/tilemaps/mario.php b/examples/tilemaps/mario.php deleted file mode 100644 index 0c783545..00000000 --- a/examples/tilemaps/mario.php +++ /dev/null @@ -1,56 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/tilemaps/mariotogether.js b/examples/tilemaps/mariotogether.js new file mode 100644 index 00000000..ccddc3e1 --- /dev/null +++ b/examples/tilemaps/mariotogether.js @@ -0,0 +1,26 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.tilemap('nes', 'assets/maps/mario1.png', 'assets/maps/mario1.json', null, Phaser.Tilemap.JSON); + game.load.tilemap('snes', 'assets/maps/smb_tiles.png', 'assets/maps/smb_level1.json', null, Phaser.Tilemap.JSON); + +} + +function create() { + + game.stage.backgroundColor = '#5c94fc'; + + game.add.tilemap(0, 0, 'nes'); + game.add.tilemap(0, 168, 'snes'); + + game.add.tween(game.camera).to( { x: 5120-800 }, 30000, Phaser.Easing.Linear.None, true, 0, 1000, true); + + game.input.onDown.add(goFull, this); + +} + +function goFull() { + game.stage.scale.startFullScreen(); +} diff --git a/examples/tilemaps/mariotogether.php b/examples/tilemaps/mariotogether.php deleted file mode 100644 index b52347d7..00000000 --- a/examples/tilemaps/mariotogether.php +++ /dev/null @@ -1,41 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/tilemaps/paint tiles.js b/examples/tilemaps/paint tiles.js new file mode 100644 index 00000000..65bc94c0 --- /dev/null +++ b/examples/tilemaps/paint tiles.js @@ -0,0 +1,61 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('desert', 'assets/maps/desert.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/tiles/tmw_desert_spacing.png', 32, 32, -1, 1, 1); + +} + +var map; +var tileset; +var layer; + +var marker; +var currentTile = 0; + +function create() { + + map = game.add.tilemap('desert'); + + tileset = game.add.tileset('tiles'); + + layer = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0); + + layer.resizeWorld(); + + marker = game.add.graphics(); + marker.lineStyle(2, 0x000000, 1); + marker.drawRect(0, 0, 32, 32); + +} + +function update() { + + marker.x = layer.getTileX(game.input.activePointer.worldX) * 32; + marker.y = layer.getTileY(game.input.activePointer.worldY) * 32; + + if (game.input.mousePointer.isDown) + { + if (game.input.keyboard.isDown(Phaser.Keyboard.SHIFT)) + { + currentTile = map.getTile(layer.getTileX(marker.x), layer.getTileY(marker.y)); + } + else + { + if (map.getTile(layer.getTileX(marker.x), layer.getTileY(marker.y)) != currentTile) + { + map.putTile(currentTile, layer.getTileX(marker.x), layer.getTileY(marker.y)) + } + } + } + +} + +function render() { + + game.debug.renderText('Left-click to paint. Shift + Left-click to select tile.', 32, 32, 'rgb(0,0,0)'); + game.debug.renderText('Tile: ' + map.getTile(layer.getTileX(marker.x), layer.getTileY(marker.y)), 32, 48, 'rgb(0,0,0)'); + +} diff --git a/examples/tilemaps/randomise tiles.js b/examples/tilemaps/randomise tiles.js new file mode 100644 index 00000000..1adf705e --- /dev/null +++ b/examples/tilemaps/randomise tiles.js @@ -0,0 +1,81 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('desert', 'assets/maps/desert.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/tiles/tmw_desert_spacing.png', 32, 32, -1, 1, 1); + game.load.image('car', 'assets/sprites/car90.png'); + +} + +var map; +var tileset; +var layer; + +var cursors; +var sprite; + +function create() { + + map = game.add.tilemap('desert'); + + tileset = game.add.tileset('tiles'); + + layer = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0); + + layer.resizeWorld(); + + sprite = game.add.sprite(450, 80, 'car'); + sprite.anchor.setTo(0.5, 0.5); + + game.camera.follow(sprite); + + cursors = game.input.keyboard.createCursorKeys(); + + game.input.onDown.add(randomiseTiles, this); + +} + +function randomiseTiles() { + + // This will replace every instance of tile 31 (cactus plant) with tile 46 (the sign post). + // It does this across the whole layer of the map unless a region is specified. + + // You can also pass in x, y, width, height values to control the area in which the replace happens + + map.shuffle(layer.getTileX(sprite.x), layer.getTileY(sprite.y), 6, 6); + +} + +function update() { + + game.physics.collide(sprite, layer); + + sprite.body.velocity.x = 0; + sprite.body.velocity.y = 0; + sprite.body.angularVelocity = 0; + + if (cursors.left.isDown) + { + sprite.body.angularVelocity = -200; + } + else if (cursors.right.isDown) + { + sprite.body.angularVelocity = 200; + } + + if (cursors.up.isDown) + { + sprite.body.velocity.copyFrom(game.physics.velocityFromAngle(sprite.angle, 300)); + } + +} + +function render() { + + game.debug.renderText('Click to randomise tiles', 32, 32, 'rgb(0,0,0)'); + game.debug.renderText('Tile X: ' + layer.getTileX(sprite.x), 32, 48, 'rgb(0,0,0)'); + game.debug.renderText('Tile Y: ' + layer.getTileY(sprite.y), 32, 64, 'rgb(0,0,0)'); + +} diff --git a/examples/tilemaps/replace tiles.js b/examples/tilemaps/replace tiles.js new file mode 100644 index 00000000..45dd75cb --- /dev/null +++ b/examples/tilemaps/replace tiles.js @@ -0,0 +1,81 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('desert', 'assets/maps/desert.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/tiles/tmw_desert_spacing.png', 32, 32, -1, 1, 1); + game.load.image('car', 'assets/sprites/car90.png'); + +} + +var map; +var tileset; +var layer; + +var cursors; +var sprite; + +function create() { + + map = game.add.tilemap('desert'); + + tileset = game.add.tileset('tiles'); + + layer = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0); + + layer.resizeWorld(); + + sprite = game.add.sprite(450, 80, 'car'); + sprite.anchor.setTo(0.5, 0.5); + + game.camera.follow(sprite); + + cursors = game.input.keyboard.createCursorKeys(); + + game.input.onDown.addOnce(replaceTiles, this); + +} + +function replaceTiles() { + + // This will replace every instance of tile 31 (cactus plant) with tile 46 (the sign post). + // It does this across the whole layer of the map unless a region is specified. + + // You can also pass in x, y, width, height values to control the area in which the replace happens + + map.replace(31, 46); + +} + +function update() { + + game.physics.collide(sprite, layer); + + sprite.body.velocity.x = 0; + sprite.body.velocity.y = 0; + sprite.body.angularVelocity = 0; + + if (cursors.left.isDown) + { + sprite.body.angularVelocity = -200; + } + else if (cursors.right.isDown) + { + sprite.body.angularVelocity = 200; + } + + if (cursors.up.isDown) + { + sprite.body.velocity.copyFrom(game.physics.velocityFromAngle(sprite.angle, 300)); + } + +} + +function render() { + + game.debug.renderText('Click to replace tiles', 32, 32, 'rgb(0,0,0)'); + game.debug.renderText('Tile X: ' + layer.getTileX(sprite.x), 32, 48, 'rgb(0,0,0)'); + game.debug.renderText('Tile Y: ' + layer.getTileY(sprite.y), 32, 64, 'rgb(0,0,0)'); + +} diff --git a/examples/tilemaps/sci fly.js b/examples/tilemaps/sci fly.js new file mode 100644 index 00000000..e5de4111 --- /dev/null +++ b/examples/tilemaps/sci fly.js @@ -0,0 +1,109 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update }); + +function preload() { + + game.load.tilemap('level3', 'assets/maps/cybernoid.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/maps/cybernoid.png', 16, 16); + game.load.image('phaser', 'assets/sprites/phaser-ship.png'); + game.load.image('diamond', 'assets/sprites/chunk.png'); + +} + +var map; +var tileset; +var layer; +var cursors; +var overlap; +var sprite; +var emitter; + +function create() { + + game.stage.backgroundColor = '#3d3d3d'; + + // A Tilemap object just holds the data needed to describe the map (i.e. the json exported from Tiled, or the CSV exported from elsewhere). + // You can add your own data or manipulate the data (swap tiles around, etc) but in order to display it you need to create a TilemapLayer. + map = game.add.tilemap('level3'); + + // A Tileset is a single image containing a strip of tiles. Each tile is broken down into its own Phaser.Tile object on import. + // You can set properties on the Tile objects, such as collision, n-way movement and meta data. + // A Tilemap uses a Tileset to render. The indexes in the map corresponding to the Tileset indexes. + // This way multiple levels can share the same single Tileset without requiring one each. + tileset = game.add.tileset('tiles'); + + // Basically this sets EVERY SINGLE tile to fully collide on all faces + tileset.setCollisionRange(0, tileset.total - 1, true, true, true, true); + + // And this turns off collision on the only tile we don't want collision on :) + tileset.setCollision(6, false, false, false, false); + tileset.setCollision(31, false, false, false, false); + tileset.setCollision(34, false, false, false, false); + tileset.setCollision(35, false, false, false, false); + tileset.setCollision(46, false, false, false, false); + + // A TilemapLayer consists of an x,y coordinate (position), a width and height, a Tileset and a Tilemap which it uses for map data. + // The x/y coordinates are in World space and you can place the tilemap layer anywhere in the world. + // The width/height is the rendered size of the layer in pixels, not the size of the map data itself. + + layer = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0); + + layer.resizeWorld(); + + sprite = game.add.sprite(450, 80, 'phaser'); + sprite.anchor.setTo(0.5, 0.5); + + game.camera.follow(sprite); + game.camera.deadzone = new Phaser.Rectangle(160, 160, layer.renderWidth-320, layer.renderHeight-320); + + cursors = game.input.keyboard.createCursorKeys(); + + emitter = game.add.emitter(0, 0, 200); + + emitter.makeParticles('diamond'); + emitter.minRotation = 0; + emitter.maxRotation = 0; + emitter.gravity = 5; + emitter.bounce.setTo(0.5, 0.5); + + game.input.onDown.add(particleBurst, this); + +} + +function particleBurst() { + + emitter.x = game.input.worldX; + emitter.y = game.input.worldY; + emitter.start(true, 4000, null, 10); + +} + +function update() { + + game.physics.collide(sprite, layer); + game.physics.collide(emitter, layer); + + sprite.body.velocity.x = 0; + sprite.body.velocity.y = 0; + + if (cursors.up.isDown) + { + sprite.body.velocity.y = -150; + } + else if (cursors.down.isDown) + { + sprite.body.velocity.y = 150; + } + + if (cursors.left.isDown) + { + sprite.body.velocity.x = -150; + sprite.scale.x = -1; + } + else if (cursors.right.isDown) + { + sprite.body.velocity.x = 150; + sprite.scale.x = 1; + } + +} diff --git a/examples/tilemaps/supermario.js b/examples/tilemaps/supermario.js new file mode 100644 index 00000000..04a67023 --- /dev/null +++ b/examples/tilemaps/supermario.js @@ -0,0 +1,43 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('background', 'assets/maps/smb_bg.png', 'assets/maps/smb_bg.json', null, Phaser.Tilemap.JSON); + game.load.tilemap('level1', 'assets/maps/smb_tiles.png', 'assets/maps/smb_level1.json', null, Phaser.Tilemap.JSON); + +} + +function create() { + + game.stage.backgroundColor = '#787878'; + + game.add.tilemap(0, 0, 'background'); + game.add.tilemap(0, 0, 'level1'); + +} + +function update() { + + if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) + { + game.camera.x -= 8; + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) + { + game.camera.x += 8; + } + + if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) + { + game.camera.y -= 8; + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) + { + game.camera.y += 8; + } + +} + +function render() { +} diff --git a/examples/tilemaps/supermario.php b/examples/tilemaps/supermario.php deleted file mode 100644 index 1092e0d9..00000000 --- a/examples/tilemaps/supermario.php +++ /dev/null @@ -1,58 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/tilemaps/supermario2.js b/examples/tilemaps/supermario2.js new file mode 100644 index 00000000..bb960ea2 --- /dev/null +++ b/examples/tilemaps/supermario2.js @@ -0,0 +1,58 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update }); + +function preload() { + + game.load.tilemap('background', 'assets/maps/smb_bg.png', 'assets/maps/smb_bg.json', null, Phaser.Tilemap.JSON); + game.load.tilemap('level1', 'assets/maps/smb_tiles.png', 'assets/maps/smb_level1.json', null, Phaser.Tilemap.JSON); + game.load.spritesheet('balls', 'assets/sprites/balls.png', 17, 17); + +} + +var balls; +var map; + +function create() { + + game.stage.backgroundColor = '#787878'; + + game.add.tilemap(0, 0, 'background'); + + map = game.add.tilemap(0, 0, 'level1'); + map.setCollisionByIndex([9,10,11,14,15,16,18,19,22,23,24,32,37,38], true, true, true, true); + + balls = game.add.emitter(300, 50, 500); + balls.bounce = 0.5; + balls.makeParticles('balls', [0,1,2,3,4,5], 500, 1); + balls.minParticleSpeed.setTo(-150, 150); + balls.maxParticleSpeed.setTo(100, 100); + balls.gravity = 8; + balls.start(false, 5000, 50); + + game.add.tween(balls).to({ x: 4000 }, 7500, Phaser.Easing.Sinusoidal.InOut, true, 0, 1000, true); + +} + +function update() { + + game.physics.collide(balls, map); + + if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) + { + game.camera.x -= 8; + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) + { + game.camera.x += 8; + } + + if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) + { + game.camera.y -= 8; + } + else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) + { + game.camera.y += 8; + } + +} diff --git a/examples/tilemaps/supermario2.php b/examples/tilemaps/supermario2.php deleted file mode 100644 index 695dadbe..00000000 --- a/examples/tilemaps/supermario2.php +++ /dev/null @@ -1,73 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/tilemaps/swap tiles.js b/examples/tilemaps/swap tiles.js new file mode 100644 index 00000000..55c2bdd2 --- /dev/null +++ b/examples/tilemaps/swap tiles.js @@ -0,0 +1,81 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('desert', 'assets/maps/desert.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/tiles/tmw_desert_spacing.png', 32, 32, -1, 1, 1); + game.load.image('car', 'assets/sprites/car90.png'); + +} + +var map; +var tileset; +var layer; + +var cursors; +var sprite; + +function create() { + + map = game.add.tilemap('desert'); + + tileset = game.add.tileset('tiles'); + + layer = game.add.tilemapLayer(0, 0, 800, 600, tileset, map, 0); + + layer.resizeWorld(); + + sprite = game.add.sprite(450, 80, 'car'); + sprite.anchor.setTo(0.5, 0.5); + + game.camera.follow(sprite); + + cursors = game.input.keyboard.createCursorKeys(); + + game.input.onDown.addOnce(swapTiles, this); + +} + +function swapTiles() { + + // This will swap every instance of tile 30 (empty ground) with tile 31 (the cactus plant), it also does the opposite, + // so tile 31 (cactus plants) will become empty ground (tile 30). It does this across the whole layer of the map. + + // You can also pass in x, y, width, height values to control the area in which the swap happens + + map.swap(30, 31); + +} + +function update() { + + game.physics.collide(sprite, layer); + + sprite.body.velocity.x = 0; + sprite.body.velocity.y = 0; + sprite.body.angularVelocity = 0; + + if (cursors.left.isDown) + { + sprite.body.angularVelocity = -200; + } + else if (cursors.right.isDown) + { + sprite.body.angularVelocity = 200; + } + + if (cursors.up.isDown) + { + sprite.body.velocity.copyFrom(game.physics.velocityFromAngle(sprite.angle, 300)); + } + +} + +function render() { + + game.debug.renderText('Click to swap tiles', 32, 32, 'rgb(0,0,0)'); + game.debug.renderText('Tile X: ' + layer.getTileX(sprite.x), 32, 48, 'rgb(0,0,0)'); + game.debug.renderText('Tile Y: ' + layer.getTileY(sprite.y), 32, 64, 'rgb(0,0,0)'); + +} diff --git a/examples/tweens/bounce.js b/examples/tweens/bounce.js new file mode 100644 index 00000000..cbb7185e --- /dev/null +++ b/examples/tweens/bounce.js @@ -0,0 +1,29 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.image('ball', 'assets/sprites/yellow_ball.png'); + +} + +var ball; + +function create() { + + ball = game.add.sprite(300, 0, 'ball'); + + startBounceTween(); +} + +function startBounceTween() { + + ball.y = 0; + + var bounce=game.add.tween(ball); + + bounce.to({ y: game.world.height-ball.height }, 1000 + Math.random() * 3000, Phaser.Easing.Bounce.In); + bounce.onComplete.add(startBounceTween, this); + bounce.start(); + +} diff --git a/examples/tweens/bubbles.js b/examples/tweens/bubbles.js new file mode 100644 index 00000000..e71f967d --- /dev/null +++ b/examples/tweens/bubbles.js @@ -0,0 +1,26 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.image('space', 'assets/misc/starfield.png', 138, 15); + game.load.image('ball', 'assets/sprites/shinyball.png'); + +} + +function create() { + + game.add.tileSprite(0, 0, 800, 600, 'space'); + + for (var i = 0; i < 30; i++) + { + var sprite = game.add.sprite(game.world.randomX,game.world.randomY,'ball'); + + // Fade in a sprite + game.add.tween(sprite).to({ y: -50 }, Math.random() * 4500, Phaser.Easing.Cubic.Out, true); + + // This tween starts with a random length delay + game.add.tween(sprite).to({ alpha: 0 }, Math.random() * 4500, Phaser.Easing.Quadratic.InOut, true, Math.random() * 500); + } + +} diff --git a/examples/tweens/chained tweens.js b/examples/tweens/chained tweens.js new file mode 100644 index 00000000..e324d043 --- /dev/null +++ b/examples/tweens/chained tweens.js @@ -0,0 +1,24 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.image('diamond', 'assets/sprites/diamond.png'); + +} + +function create() { + + game.stage.backgroundColor = 0x2d2d2d; + + var sprite = game.add.sprite(100, 100, 'diamond'); + + // Here we'll chain 4 different tweens together and play through them all in a loop + var tween = game.add.tween(sprite).to({ x: 600 }, 2000, Phaser.Easing.Linear.None) + .to({ y: 300 }, 1000, Phaser.Easing.Linear.None) + .to({ x: 100 }, 2000, Phaser.Easing.Linear.None) + .to({ y: 100 }, 1000, Phaser.Easing.Linear.None) + .loop() + .start(); + +} diff --git a/examples/tweens/chained tweens.php b/examples/tweens/chained tweens.php deleted file mode 100644 index cb77634f..00000000 --- a/examples/tweens/chained tweens.php +++ /dev/null @@ -1,44 +0,0 @@ - - - - - \ No newline at end of file diff --git a/examples/tweens/combined tweens.js b/examples/tweens/combined tweens.js new file mode 100644 index 00000000..b228b1c9 --- /dev/null +++ b/examples/tweens/combined tweens.js @@ -0,0 +1,52 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', {preload:preload,create: create }); + +function preload() { + + game.load.spritesheet('pig', 'assets/sprites/invaderpig.png', 124, 104); + game.load.image('starfield', 'assets/misc/starfield.jpg'); + game.load.image('mushroom', 'assets/sprites/mushroom2.png'); + +} + +var mushroom; +var pig; +var pigArrives; +var s; + +function create() { + + game.add.tileSprite(0, 0, 800, 600, 'starfield'); + + pig = game.add.sprite(-50, 200, 'pig', 1); + + pig.scale.setTo(0.5, 0.5); + + mushroom = game.add.sprite(380, 200, 'mushroom'); + mushroom.anchor.setTo(0.5, 0.5); + + pigArrives = game.add.tween(pig); + + pigArrives.to({x:150}, 1000, Phaser.Easing.Bounce.Out); + pigArrives.onComplete.add(firstTween, this); + pigArrives.start(); + +} + +function firstTween() { + + s = game.add.tween(mushroom.scale); + s.to({x: 2, y:2}, 1000, Phaser.Easing.Linear.None); + s.onComplete.addOnce(theEnd, this); + s.start(); + +} + +function theEnd() { + + e = game.add.tween(pig); + + e.to({ x: -150 }, 1000, Phaser.Easing.Bounce.Out); + e.start(); + +} diff --git a/examples/tweens/easing spritesheets.js b/examples/tweens/easing spritesheets.js new file mode 100644 index 00000000..02d93b80 --- /dev/null +++ b/examples/tweens/easing spritesheets.js @@ -0,0 +1,25 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', {preload:preload,create: create }); + +function preload() { + + game.load.spritesheet('phaser', 'assets/tests/tween/phaser.png', 70, 90); + game.load.image('starfield', 'assets/misc/starfield.jpg'); + +} + +function create() { + + var item; + + game.add.tileSprite(0, 0, 800, 600, 'starfield'); + + for (var i = 0; i < 6; i++) + { + item = game.add.sprite(190 + 69 * i, -90, 'phaser', i); + + // Add a simple bounce tween to each character's position. + game.add.tween(item).to({y: 240}, 2400, Phaser.Easing.Bounce.Out, true, 1000 + 400 * i, false); + } + +} diff --git a/examples/tweens/easing.js b/examples/tweens/easing.js new file mode 100644 index 00000000..c3a2174b --- /dev/null +++ b/examples/tweens/easing.js @@ -0,0 +1,46 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.spritesheet('shadow', 'assets/tests/tween/shadow.png', 138, 15); + game.load.spritesheet('phaser', 'assets/tests/tween/phaser.png', 70, 90); + +} + +function create() { + + var item; + var shadow; + var tween; + + // Sets background color to white. + game.stage.backgroundColor = '#ffffff'; + + for (var i = 0; i < 6; i++) + { + // Add a shadow to the location which characters will land on. + // And tween their size to make them look like a real shadow. + // Put the following code before items to give shadow a lower + // render order. + shadow = game.add.sprite(190 + 69 * i, 284, 'shadow'); + + // Set shadow's size 0 so that it'll be invisible at the beginning. + shadow.scale.setTo(0.0, 0.0); + + // Also set the origin to the center since we don't want to + // see the shadow scale to the left top. + shadow.anchor.setTo(0.5, 0.5); + game.add.tween(shadow.scale).to({x: 1.0, y: 1.0}, 2400, Phaser.Easing.Bounce.Out); + + // Add characters on top of shadows. + item = game.add.sprite(190 + 69 * i, -100, 'phaser', i); + + // Set origin to the center to make the rotation look better. + item.anchor.setTo(0.5, 0.5); + + // Add a simple bounce tween to each character's position. + tween = game.add.tween(item).to({y: 240}, 2400, Phaser.Easing.Bounce.Out); + } + +} diff --git a/examples/tweens/fading in a sprite.js b/examples/tweens/fading in a sprite.js new file mode 100644 index 00000000..5b43a76e --- /dev/null +++ b/examples/tweens/fading in a sprite.js @@ -0,0 +1,22 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.image('space', 'assets/misc/starfield.png', 138, 15); + game.load.image('logo', 'assets/sprites/phaser2.png'); + +} + +function create() { + + game.add.tileSprite(0, 0, 800, 600, 'space'); + + var sprite = game.add.sprite(game.world.centerX, game.world.centerY, 'logo'); + + sprite.anchor.setTo(0.5, 0.5); + sprite.alpha = 0; + + game.add.tween(sprite).to( { alpha: 1 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true); + +} diff --git a/examples/tweens/pause tween.js b/examples/tweens/pause tween.js new file mode 100644 index 00000000..c6689e95 --- /dev/null +++ b/examples/tweens/pause tween.js @@ -0,0 +1,41 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +var p; +var tween; +var button; +var flag = true; + +function preload() { + + game.load.image('diamond', 'assets/sprites/diamond.png'); + game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71); + +} + +function create() { + + game.stage.backgroundColor = 0x2d2d2d; + + p = game.add.sprite(100, 100, 'diamond'); + + tween = game.add.tween(p).to({ x: 600 }, 4000, Phaser.Easing.Linear.None, true, 0, 1000, true) + + button = game.add.button(game.world.centerX, 400, 'button', actionOnClick, this, 2, 1, 0); + +} + +function actionOnClick() { + + if (flag) + { + tween.pause(); + } + else + { + tween.resume(); + } + + flag = !flag; + +} diff --git a/examples/tweens/tween several properties.js b/examples/tweens/tween several properties.js new file mode 100644 index 00000000..ff72610e --- /dev/null +++ b/examples/tweens/tween several properties.js @@ -0,0 +1,29 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.image('sky', 'assets/skies/sky4.png'); + game.load.spritesheet('phaser', 'assets/tests/tween/phaser.png', 70, 90); + +} + +function create() { + + game.add.sprite(0, 0, 'sky'); + + var item; + + for (var i = 0; i < 6; i++) + { + item = game.add.sprite(190 + 69 * i, -100, 'phaser', i); + item.anchor.setTo(0.5,0.5); + + // Add a simple bounce tween to each character's position. + game.add.tween(item).to({y: 240}, 2400, Phaser.Easing.Bounce.Out, true, 1000 + 400 * i, false); + + // Add another rotation tween to the same character. + game.add.tween(item).to({angle: 360}, 2400, Phaser.Easing.Cubic.In, true, 1000 + 400 * i, false); + } + +} diff --git a/examples/wip/body test.js b/examples/wip/body test.js new file mode 100644 index 00000000..a99df386 --- /dev/null +++ b/examples/wip/body test.js @@ -0,0 +1,77 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.image('atari1', 'assets/sprites/atari130xe.png'); + game.load.image('coke', 'assets/sprites/cokecan.png'); + game.load.image('mushroom', 'assets/sprites/mushroom2.png'); + +} + +var group; +var group2; + +var atari; +var coke; +var dropper; + +function create() { + + // make our world wider + game.world.setBounds(0, 0, 2000, 600); + + // shift the camera (still works) + // game.camera.x = 400; + game.world.angle = 10; + + // base group + group = game.add.group(); + // group.angle = 10; + group.y = 200; + + atari = group.create(0, 0, 'atari1'); + coke = group.create(340, 0, 'coke'); + + // dropper group + group2 = game.add.group(); + + dropper = group2.create(400, 0, 'mushroom'); + dropper.inputEnabled = true; + dropper.input.enableDrag(); + dropper.events.onDragStop.add(checkDrop, this); + + group2.y = 400; + +} + +function checkDrop() { + + if (Phaser.Rectangle.intersects(dropper.body, atari.body)) + { + atari.alpha = 0.3; + } + else if (Phaser.Rectangle.intersects(dropper.body, coke.body)) + { + coke.alpha = 0.3; + } + +} + +function update() { + + group.x += 0.5; + +} + +function render() { + + game.debug.renderWorldTransformInfo(dropper, 32, 32); + game.debug.renderText(dropper.position.x, 200, 32); + game.debug.renderText(dropper.position.y, 260, 32); + + game.debug.renderRectangle(atari.body, 'rgba(255,0,0,0.3)'); + game.debug.renderRectangle(coke.body, 'rgba(255,0,0,0.3)'); + game.debug.renderRectangle(dropper.body, 'rgba(0,255,0,0.3)'); + +} diff --git a/examples/wip/button size.js b/examples/wip/button size.js new file mode 100644 index 00000000..365e6184 --- /dev/null +++ b/examples/wip/button size.js @@ -0,0 +1,42 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render }); + +function preload() { + + game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71); + game.load.image('background','assets/misc/starfield.jpg'); + +} + +var button; +var background; + +function create() { + + game.stage.backgroundColor = '#182d3b'; + + background = game.add.tileSprite(0, 0, 800, 600, 'background'); + + button = game.add.button(game.world.centerX - 95, 200, 'button', actionOnClick, this, 2, 1, 0); + button.anchor.setTo(0.5, 0.5); + + button.scale.setTo(2, 2); + // button.width = 100; + // button.height = 300; + button.angle = 10; + +} + +function actionOnClick () { + + background.visible =! background.visible; + +} + +function render () { + + game.debug.renderSpriteCorners(button); + + game.debug.renderPoint(button.input._tempPoint); + +} diff --git a/examples/wip/crop.js b/examples/wip/crop.js new file mode 100644 index 00000000..f6f846a0 --- /dev/null +++ b/examples/wip/crop.js @@ -0,0 +1,24 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update }); + +function preload() { + + game.load.image('atari1', 'assets/sprites/atari130xe.png'); + +} + +var atari; + +function create() { + + atari = game.add.sprite(300, 300, 'atari1'); + + // atari.crop = new Phaser.Rectangle(0, 0, 10, atari.height); + +} + +function update() { + + atari.crop.width -= 1; + +} diff --git a/examples/wip/fiddle.js b/examples/wip/fiddle.js new file mode 100644 index 00000000..62c9427e --- /dev/null +++ b/examples/wip/fiddle.js @@ -0,0 +1,29 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.image('ball', 'assets/sprites/yellow_ball.png'); + +} + +var ball; + +function create() { + + ball = game.add.sprite(300, 0, 'ball'); + + TweenLite.to(ball, 10, { y: 400 }); +} + +function startBounceTween() { + + // ball.y = 0; + + // var bounce=game.add.tween(ball); + + // bounce.to({ y: game.world.height-ball.height }, 1000 + Math.random() * 3000, Phaser.Easing.Bounce.In); + // bounce.onComplete.add(startBounceTween, this); + // bounce.start(); + +} diff --git a/examples/wip/index.php b/examples/wip/index.php new file mode 100644 index 00000000..5f7a6174 --- /dev/null +++ b/examples/wip/index.php @@ -0,0 +1,110 @@ + $value) + { + if (is_array($value) && count($value) > 0) + { + $total += count($value); + } + } + + function getFile() { + + global $files, $dir, $filename, $title, $code; + + if (isset($_GET['d']) && isset($_GET['f'])) + { + $dir = urldecode($_GET['d']); + $filename = urldecode($_GET['d']) . '/' . urldecode($_GET['f']); + $title = urldecode($_GET['t']); + + if (file_exists($filename)) + { + $code = file_get_contents($filename); + $files = dirToArray($dir); + } + } + + } + + function dirToArray($dir) { + + $ignore = array('.', '..', '_site', 'assets', 'states'); + $result = array(); + $root = scandir($dir); + $dirs = array_diff($root, $ignore); + + foreach ($dirs as $key => $value) + { + if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) + { + $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value); + } + else + { + if (substr($value, -3) == '.js') + { + $result[] = $value; + } + } + } + + return $result; + } + + function printJSLinks($dir, $files) { + + $output = ""; + + foreach ($files as $key => $value) + { + $value2 = substr($value, 0, -3); + $file = urlencode($value); + + $output .= "$value2
    "; + } + + return $output; + + } +?> + + + + + phaser + + + + + + + + + +
    + +

    work in progress examples

    + + + + + \ No newline at end of file diff --git a/examples/wip/input active.js b/examples/wip/input active.js new file mode 100644 index 00000000..71e00e67 --- /dev/null +++ b/examples/wip/input active.js @@ -0,0 +1,39 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create }); + +function preload() { + + game.load.image('atari1', 'assets/sprites/atari130xe.png'); + game.load.image('coke', 'assets/sprites/cokecan.png'); + game.load.image('mushroom', 'assets/sprites/mushroom2.png'); + +} + +var dropper; + +function create() { + + dropper = game.add.sprite(200, 400, 'mushroom'); + dropper.inputEnabled = true; + dropper.input.enableDrag(); + dropper.events.onDragStart.add(prepareToKill, this); + +} + +function prepareToKill() { + + console.log('3 sec warning'); + + var t = { time: 0 }; + + var tween = game.add.tween(t).to({time: 1}, 3000, Phaser.Easing.Linear.None, true); + tween.onComplete.add(nukeIt, this); + +} + +function nukeIt() { + + console.log('nuked'); + dropper.destroy(); + +} diff --git a/examples/wip/wip1.js b/examples/wip/wip1.js new file mode 100644 index 00000000..28c2593f --- /dev/null +++ b/examples/wip/wip1.js @@ -0,0 +1,158 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('level3', 'assets/maps/cybernoid.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/maps/cybernoid.png', 16, 16); + +} + +var map; +var tileset; +var layer; +var cursors; +var sprite2; +var overlap; + +function create() { + + game.stage.backgroundColor = '#3d3d3d'; + + // A Tilemap object just holds the data needed to describe the map (i.e. the json exported from Tiled, or the CSV exported from elsewhere). + // You can add your own data or manipulate the data (swap tiles around, etc) but in order to display it you need to create a TilemapLayer. + map = new Phaser.Tilemap(game, 'level3'); + + // A Tileset is a single image containing a strip of tiles. Each tile is broken down into its own Phaser.Tile object on import. + // You can set properties on the Tile objects, such as collision, n-way movement and meta data. + // A Tilemap uses a Tileset to render. The indexes in the map corresponding to the Tileset indexes. + // This way multiple levels can share the same single Tileset without requiring one each. + tileset = game.cache.getTileset('tiles'); + + // Basically this sets EVERY SINGLE tile to fully collide on all faces + tileset.setCollisionRange(0, tileset.total - 1, true, true, true, true); + + // And this turns off collision on the only tile we don't want collision on :) + tileset.setCollision(6, false, false, false, false); + + // A TilemapLayer consists of an x,y coordinate (position), a width and height, a Tileset and a Tilemap which it uses for map data. + // The x/y coordinates are in World space and you can place the tilemap layer anywhere in the world. + // The width/height is the rendered size of the layer in pixels, not the size of the map data itself. + + // This one gives tileset as a string, the other an object + // layer = new Phaser.TilemapLayer(game, 0, 0, 640, 400, 'tiles', map, 0); + layer = new Phaser.TilemapLayer(game, 0, 0, 640, 400, tileset, map, 0); + + // To set tiles for collision you need to modify the Tileset, which is a property of the layer + + // Task now + // + // 1) Get tiles that will collide with sprites new position (hullX and hullY) + // 2) Separate x/y + + + // Collision is based on the layer.x/y value + + // layer.sprite.anchor.setTo(0.5, 0.5); + + game.world.add(layer.sprite); + + // This is a bit nuts, ought to find a way to automate it, but it looks cool :) + map.debugMap = [ '#000000', + '#e40058', '#e40058', '#e40058', '#80d010', '#bcbcbc', '#e40058', '#000000', '#0070ec', '#bcbcbc', '#bcbcbc', '#bcbcbc', + '#bcbcbc', '#bcbcbc', '#e40058', '#e40058', '#0070ec', '#0070ec', '#80d010', '#80d010', '#80d010', '#bcbcbc', '#bcbcbc', + '#bcbcbc', '#80d010', '#80d010', '#80d010', '#0070ec', '#0070ec', '#80d010', '#80d010', '#80d010', '#80d010', '#0070ec', + '#0070ec', '#24188c', '#24188c', '#80d010', '#80d010', '#80d010', '#bcbcbc', '#80d010', '#80d010', '#80d010', '#e40058', + '#e40058', '#bcbcbc', '#e40058', '#bcbcbc', '#e40058', '#bcbcbc', '#80d010', '#bcbcbc', '#80d010', '#000000', '#80d010', + '#80d010', '#80d010', '#bcbcbc', '#e40058', '#80d010', '#80d010', '#e40058', '#e40058', '#bcbcbc', '#bcbcbc', '#bcbcbc', + '#0070ec', '#0070ec', '#bcbcbc', '#bcbcbc', '#0070ec', '#0070ec', '#bcbcbc', '#bcbcbc', '#bcbcbc', '#bcbcbc', '#bcbcbc', + '#bcbcbc', '#bcbcbc' + ]; + + // map.dump(); + + // layer.sprite.scale.setTo(2, 2); + + // Works a treat :) + // game.add.sprite(320, 0, layer.texture, layer.frame); + // game.add.sprite(0, 200, layer.texture, layer.frame); + // game.add.sprite(320, 200, layer.texture, layer.frame); + + // game.world.setBounds(0, 0, 2000, 2000); + // game.camera.x = 400; + + cursors = game.input.keyboard.createCursorKeys(); +} + +function update() { + + // layer.sprite.angle += 0.5; + + if (cursors.up.isDown) + { + layer.y -= 4; + } + else if (cursors.down.isDown) + { + layer.y += 4; + } + + if (cursors.left.isDown) + { + layer.x -= 4; + } + else if (cursors.right.isDown) + { + layer.x += 4; + } + + // getTiles: function (x, y, width, height, collides, layer) { + overlap = layer.getTiles(layer.x, layer.y, 128, 128); + +} + +function render() { + + layer.render(); + + game.context.save(); + game.context.setTransform(1, 0, 0, 1, 0, 0); + game.context.fillStyle = 'rgba(255, 0, 0, 0.5)'; + + if (overlap.length > 1) + { + var x = 0; + var y = 0; + + for (var i = 1; i < overlap.length; i++) + { + game.context.drawImage( + overlap[i].tile.tileset.image, + overlap[i].tile.x, + overlap[i].tile.y, + overlap[i].tile.width, + overlap[i].tile.height, + 0 + (x * overlap[i].tile.width), + 420 + (y * overlap[i].tile.height), + overlap[i].tile.width, + overlap[i].tile.height + ); + + if (overlap[i].tile.collideNone == false) + { + game.context.fillRect(0 + (x * overlap[i].tile.width), 420 + (y * overlap[i].tile.height), overlap[i].tile.width, overlap[i].tile.height); + } + + x++; + + if (x == overlap[0].tw) + { + x = 0; + y++; + } + } + } + + game.context.restore(); + +} diff --git a/examples/wip/wip2.js b/examples/wip/wip2.js new file mode 100644 index 00000000..1e9e7400 --- /dev/null +++ b/examples/wip/wip2.js @@ -0,0 +1,189 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('level3', 'assets/maps/cybernoid.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/maps/cybernoid.png', 16, 16); + // game.load.image('phaser', 'assets/sprites/phaser-dude.png'); + game.load.image('phaser', 'assets/sprites/space-baddie.png'); + +} + +var map; +var tileset; +var layer; +var cursors; +var overlap; +var sprite; + +function create() { + + game.stage.backgroundColor = '#3d3d3d'; + + // A Tilemap object just holds the data needed to describe the map (i.e. the json exported from Tiled, or the CSV exported from elsewhere). + // You can add your own data or manipulate the data (swap tiles around, etc) but in order to display it you need to create a TilemapLayer. + map = new Phaser.Tilemap(game, 'level3'); + + // A Tileset is a single image containing a strip of tiles. Each tile is broken down into its own Phaser.Tile object on import. + // You can set properties on the Tile objects, such as collision, n-way movement and meta data. + // A Tilemap uses a Tileset to render. The indexes in the map corresponding to the Tileset indexes. + // This way multiple levels can share the same single Tileset without requiring one each. + tileset = game.cache.getTileset('tiles'); + + // Basically this sets EVERY SINGLE tile to fully collide on all faces + tileset.setCollisionRange(0, tileset.total - 1, true, true, true, true); + + // And this turns off collision on the only tile we don't want collision on :) + tileset.setCollision(6, false, false, false, false); + tileset.setCollision(34, false, false, false, false); + tileset.setCollision(35, false, false, false, false); + + // A TilemapLayer consists of an x,y coordinate (position), a width and height, a Tileset and a Tilemap which it uses for map data. + // The x/y coordinates are in World space and you can place the tilemap layer anywhere in the world. + // The width/height is the rendered size of the layer in pixels, not the size of the map data itself. + + // This one gives tileset as a string, the other an object + // layer = new Phaser.TilemapLayer(game, 0, 0, 640, 400, 'tiles', map, 0); + layer = new Phaser.TilemapLayer(game, 0, 0, 800, 400, tileset, map, 0); + + // To set tiles for collision you need to modify the Tileset, which is a property of the layer + + // Task now + // + // 1) Get tiles that will collide with sprites new position (hullX and hullY) + // 2) Separate x/y + + + // Collision is based on the layer.x/y value + + // layer.sprite.anchor.setTo(0.5, 0.5); + + game.world.add(layer.sprite); + + // This is a bit nuts, ought to find a way to automate it, but it looks cool :) + map.debugMap = [ '#000000', + '#e40058', '#e40058', '#e40058', '#80d010', '#bcbcbc', '#e40058', '#000000', '#0070ec', '#bcbcbc', '#bcbcbc', '#bcbcbc', + '#bcbcbc', '#bcbcbc', '#e40058', '#e40058', '#0070ec', '#0070ec', '#80d010', '#80d010', '#80d010', '#bcbcbc', '#bcbcbc', + '#bcbcbc', '#80d010', '#80d010', '#80d010', '#0070ec', '#0070ec', '#80d010', '#80d010', '#80d010', '#80d010', '#0070ec', + '#0070ec', '#24188c', '#24188c', '#80d010', '#80d010', '#80d010', '#bcbcbc', '#80d010', '#80d010', '#80d010', '#e40058', + '#e40058', '#bcbcbc', '#e40058', '#bcbcbc', '#e40058', '#bcbcbc', '#80d010', '#bcbcbc', '#80d010', '#000000', '#80d010', + '#80d010', '#80d010', '#bcbcbc', '#e40058', '#80d010', '#80d010', '#e40058', '#e40058', '#bcbcbc', '#bcbcbc', '#bcbcbc', + '#0070ec', '#0070ec', '#bcbcbc', '#bcbcbc', '#0070ec', '#0070ec', '#bcbcbc', '#bcbcbc', '#bcbcbc', '#bcbcbc', '#bcbcbc', + '#bcbcbc', '#bcbcbc' + ]; + + // map.dump(); + + // layer.sprite.scale.setTo(2, 2); + + // Works a treat :) + // game.add.sprite(320, 0, layer.texture, layer.frame); + // game.add.sprite(0, 200, layer.texture, layer.frame); + // game.add.sprite(320, 200, layer.texture, layer.frame); + + // game.world.setBounds(0, 0, 2000, 2000); + // game.camera.x = 400; + + sprite = game.add.sprite(200, 80, 'phaser'); + + cursors = game.input.keyboard.createCursorKeys(); + +} + +function update() { + + sprite.body.velocity.setTo(0, 0); + + // layer.sprite.angle += 0.5; + + if (cursors.up.isDown) + { + sprite.body.velocity.y = -100; + // layer.y -= 4; + } + else if (cursors.down.isDown) + { + sprite.body.velocity.y = 100; + // layer.y += 4; + } + + if (cursors.left.isDown) + { + sprite.body.velocity.x = -100; + // layer.x -= 4; + } + else if (cursors.right.isDown) + { + sprite.body.velocity.x = 100; + // layer.x += 4; + } + + // getTiles: function (x, y, width, height, collides, layer) { + overlap = layer.getTiles(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height, true); + + if (overlap.length > 1) + { + // console.log('%c ', 'background: #000000') + for (var i = 1; i < overlap.length; i++) + { + game.physics.separateTile(sprite.body, overlap[i]); + } + } + +} + +function render() { + + layer.render(); + + game.debug.renderSpriteInfo(sprite, 32, 450); + // game.debug.renderCameraInfo(game.camera, 32, 32); + + /* + game.context.save(); + game.context.setTransform(1, 0, 0, 1, 0, 0); + + + game.context.fillStyle = 'rgba(255, 0, 0, 0.5)'; + + if (overlap.length > 1) + { + var x = 0; + var y = 0; + + for (var i = 1; i < overlap.length; i++) + { + game.context.drawImage( + overlap[i].tile.tileset.image, + overlap[i].tile.x, + overlap[i].tile.y, + overlap[i].tile.width, + overlap[i].tile.height, + 0 + (x * overlap[i].tile.width), + 420 + (y * overlap[i].tile.height), + overlap[i].tile.width, + overlap[i].tile.height + ); + + if (overlap[i].tile.collideNone == false) + { + game.context.fillRect(0 + (x * overlap[i].tile.width), 420 + (y * overlap[i].tile.height), overlap[i].tile.width, overlap[i].tile.height); + } + + x++; + + if (x == overlap[0].tw) + { + x = 0; + y++; + } + } + } + + game.context.restore(); + */ + + // game.debug.renderRectangle(sprite.body.hullX); + +} diff --git a/examples/wip/wip3.js b/examples/wip/wip3.js new file mode 100644 index 00000000..663964cc --- /dev/null +++ b/examples/wip/wip3.js @@ -0,0 +1,188 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('level3', 'assets/maps/cybernoid.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/maps/cybernoid.png', 16, 16); + // game.load.image('phaser', 'assets/sprites/phaser-dude.png'); + game.load.image('phaser', 'assets/sprites/space-baddie.png'); + +} + +var map; +var tileset; +var layer; +var cursors; +var overlap; +var sprite; + +function create() { + + game.stage.backgroundColor = '#3d3d3d'; + + // A Tilemap object just holds the data needed to describe the map (i.e. the json exported from Tiled, or the CSV exported from elsewhere). + // You can add your own data or manipulate the data (swap tiles around, etc) but in order to display it you need to create a TilemapLayer. + map = new Phaser.Tilemap(game, 'level3'); + + // A Tileset is a single image containing a strip of tiles. Each tile is broken down into its own Phaser.Tile object on import. + // You can set properties on the Tile objects, such as collision, n-way movement and meta data. + // A Tilemap uses a Tileset to render. The indexes in the map corresponding to the Tileset indexes. + // This way multiple levels can share the same single Tileset without requiring one each. + tileset = game.cache.getTileset('tiles'); + + // Basically this sets EVERY SINGLE tile to fully collide on all faces + tileset.setCollisionRange(0, tileset.total - 1, true, true, true, true); + + // And this turns off collision on the only tile we don't want collision on :) + tileset.setCollision(6, false, false, false, false); + tileset.setCollision(34, false, false, false, false); + tileset.setCollision(35, false, false, false, false); + + // A TilemapLayer consists of an x,y coordinate (position), a width and height, a Tileset and a Tilemap which it uses for map data. + // The x/y coordinates are in World space and you can place the tilemap layer anywhere in the world. + // The width/height is the rendered size of the layer in pixels, not the size of the map data itself. + + // This one gives tileset as a string, the other an object + // layer = new Phaser.TilemapLayer(game, 0, 0, 800, 400, tileset, map, 0); + layer = new Phaser.TilemapLayer(game, 0, 0, 400, 200, tileset, map, 0); + layer.sprite.scale.setTo(2, 2); + + // layer.sprite.anchor.setTo(0.5, 0.5); + + game.world.add(layer.sprite); + + // This is a bit nuts, ought to find a way to automate it, but it looks cool :) + map.debugMap = [ '#000000', + '#e40058', '#e40058', '#e40058', '#80d010', '#bcbcbc', '#e40058', '#000000', '#0070ec', '#bcbcbc', '#bcbcbc', '#bcbcbc', + '#bcbcbc', '#bcbcbc', '#e40058', '#e40058', '#0070ec', '#0070ec', '#80d010', '#80d010', '#80d010', '#bcbcbc', '#bcbcbc', + '#bcbcbc', '#80d010', '#80d010', '#80d010', '#0070ec', '#0070ec', '#80d010', '#80d010', '#80d010', '#80d010', '#0070ec', + '#0070ec', '#24188c', '#24188c', '#80d010', '#80d010', '#80d010', '#bcbcbc', '#80d010', '#80d010', '#80d010', '#e40058', + '#e40058', '#bcbcbc', '#e40058', '#bcbcbc', '#e40058', '#bcbcbc', '#80d010', '#bcbcbc', '#80d010', '#000000', '#80d010', + '#80d010', '#80d010', '#bcbcbc', '#e40058', '#80d010', '#80d010', '#e40058', '#e40058', '#bcbcbc', '#bcbcbc', '#bcbcbc', + '#0070ec', '#0070ec', '#bcbcbc', '#bcbcbc', '#0070ec', '#0070ec', '#bcbcbc', '#bcbcbc', '#bcbcbc', '#bcbcbc', '#bcbcbc', + '#bcbcbc', '#bcbcbc' + ]; + + // map.dump(); + + // layer.sprite.scale.setTo(2, 2); + + // Works a treat :) + // game.add.sprite(320, 0, layer.texture, layer.frame); + // game.add.sprite(0, 200, layer.texture, layer.frame); + // game.add.sprite(320, 200, layer.texture, layer.frame); + + // game.world.setBounds(0, 0, 2000, 2000); + // game.camera.x = 400; + + sprite = game.add.sprite(200, 80, 'phaser'); + // sprite.x = 140; + // sprite.y = 40; + + //sprite.scale.setTo(2, 2); + + + + cursors = game.input.keyboard.createCursorKeys(); + +} + +function update() { + + sprite.body.velocity.setTo(0, 0); + + // layer.sprite.angle += 0.5; + + if (cursors.up.isDown) + { + sprite.body.velocity.y = -100; + // layer.y -= 4; + } + else if (cursors.down.isDown) + { + sprite.body.velocity.y = 100; + // layer.y += 4; + } + + if (cursors.left.isDown) + { + sprite.body.velocity.x = -100; + // layer.x -= 4; + } + else if (cursors.right.isDown) + { + sprite.body.velocity.x = 100; + // layer.x += 4; + } + + // getTiles: function (x, y, width, height, collides, layer) { + overlap = layer.getTiles(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height, true); + + if (overlap.length > 1) + { + // console.log('%c ', 'background: #000000') + for (var i = 1; i < overlap.length; i++) + { + game.physics.separateTile(sprite.body, overlap[i]); + } + } + +} + +function render() { + + layer.render(); + + game.debug.renderSpriteBody(sprite); + + game.debug.renderSpriteInfo(sprite, 32, 450); + // game.debug.renderCameraInfo(game.camera, 32, 32); + + /* + game.context.save(); + game.context.setTransform(1, 0, 0, 1, 0, 0); + + + game.context.fillStyle = 'rgba(255, 0, 0, 0.5)'; + + if (overlap.length > 1) + { + var x = 0; + var y = 0; + + for (var i = 1; i < overlap.length; i++) + { + game.context.drawImage( + overlap[i].tile.tileset.image, + overlap[i].tile.x, + overlap[i].tile.y, + overlap[i].tile.width, + overlap[i].tile.height, + 0 + (x * overlap[i].tile.width), + 420 + (y * overlap[i].tile.height), + overlap[i].tile.width, + overlap[i].tile.height + ); + + if (overlap[i].tile.collideNone == false) + { + game.context.fillRect(0 + (x * overlap[i].tile.width), 420 + (y * overlap[i].tile.height), overlap[i].tile.width, overlap[i].tile.height); + } + + x++; + + if (x == overlap[0].tw) + { + x = 0; + y++; + } + } + } + + game.context.restore(); + */ + + // game.debug.renderRectangle(sprite.body.hullX); + +} diff --git a/examples/wip/wip4.js b/examples/wip/wip4.js new file mode 100644 index 00000000..6810c596 --- /dev/null +++ b/examples/wip/wip4.js @@ -0,0 +1,197 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.tilemap('level3', 'assets/maps/cybernoid.json', null, Phaser.Tilemap.TILED_JSON); + game.load.tileset('tiles', 'assets/maps/cybernoid.png', 16, 16); + game.load.image('phaser', 'assets/sprites/phaser-ship.png'); + +} + +var map; +var tileset; +var layer; +var cursors; +var overlap; +var sprite; + +function create() { + + game.stage.backgroundColor = '#3d3d3d'; + + // A Tilemap object just holds the data needed to describe the map (i.e. the json exported from Tiled, or the CSV exported from elsewhere). + // You can add your own data or manipulate the data (swap tiles around, etc) but in order to display it you need to create a TilemapLayer. + map = new Phaser.Tilemap(game, 'level3'); + + // A Tileset is a single image containing a strip of tiles. Each tile is broken down into its own Phaser.Tile object on import. + // You can set properties on the Tile objects, such as collision, n-way movement and meta data. + // A Tilemap uses a Tileset to render. The indexes in the map corresponding to the Tileset indexes. + // This way multiple levels can share the same single Tileset without requiring one each. + tileset = game.cache.getTileset('tiles'); + + // Basically this sets EVERY SINGLE tile to fully collide on all faces + tileset.setCollisionRange(0, tileset.total - 1, true, true, true, true); + + // And this turns off collision on the only tile we don't want collision on :) + tileset.setCollision(6, false, false, false, false); + tileset.setCollision(31, false, false, false, false); + tileset.setCollision(34, false, false, false, false); + tileset.setCollision(35, false, false, false, false); + tileset.setCollision(46, false, false, false, false); + + // A TilemapLayer consists of an x,y coordinate (position), a width and height, a Tileset and a Tilemap which it uses for map data. + // The x/y coordinates are in World space and you can place the tilemap layer anywhere in the world. + // The width/height is the rendered size of the layer in pixels, not the size of the map data itself. + + // This one gives tileset as a string, the other an object + layer = new Phaser.TilemapLayer(game, 0, 0, 800, 600, tileset, map, 0); + // layer = new Phaser.TilemapLayer(game, 0, 0, 400, 200, tileset, map, 0); + // layer.sprite.scale.setTo(2, 2); + + // layer.sprite.anchor.setTo(0.5, 0.5); + + layer.resizeWorld(); + + game.world.add(layer.sprite); + + // This is a bit nuts, ought to find a way to automate it, but it looks cool :) + map.debugMap = [ '#000000', + '#e40058', '#e40058', '#e40058', '#80d010', '#bcbcbc', '#e40058', '#000000', '#0070ec', '#bcbcbc', '#bcbcbc', '#bcbcbc', + '#bcbcbc', '#bcbcbc', '#e40058', '#e40058', '#0070ec', '#0070ec', '#80d010', '#80d010', '#80d010', '#bcbcbc', '#bcbcbc', + '#bcbcbc', '#80d010', '#80d010', '#80d010', '#0070ec', '#0070ec', '#80d010', '#80d010', '#80d010', '#80d010', '#0070ec', + '#0070ec', '#24188c', '#24188c', '#80d010', '#80d010', '#80d010', '#bcbcbc', '#80d010', '#80d010', '#80d010', '#e40058', + '#e40058', '#bcbcbc', '#e40058', '#bcbcbc', '#e40058', '#bcbcbc', '#80d010', '#bcbcbc', '#80d010', '#000000', '#80d010', + '#80d010', '#80d010', '#bcbcbc', '#e40058', '#80d010', '#80d010', '#e40058', '#e40058', '#bcbcbc', '#bcbcbc', '#bcbcbc', + '#0070ec', '#0070ec', '#bcbcbc', '#bcbcbc', '#0070ec', '#0070ec', '#bcbcbc', '#bcbcbc', '#bcbcbc', '#bcbcbc', '#bcbcbc', + '#bcbcbc', '#bcbcbc' + ]; + + // map.dump(); + + // layer.sprite.scale.setTo(2, 2); + + // Works a treat :) + // game.add.sprite(320, 0, layer.texture, layer.frame); + // game.add.sprite(0, 200, layer.texture, layer.frame); + // game.add.sprite(320, 200, layer.texture, layer.frame); + + // game.world.setBounds(0, 0, 2000, 2000); + // game.camera.x = 400; + + sprite = game.add.sprite(450, 80, 'phaser'); + sprite.anchor.setTo(0.5, 0.5); + // sprite.x = 140; + // sprite.y = 40; + + //sprite.scale.setTo(2, 2); + + // sprite.body.gravity.y = 100; + // sprite.body.bounce.x = 0.5; + // sprite.body.bounce.y = 0.2; + + game.camera.follow(sprite); + game.camera.deadzone = new Phaser.Rectangle(160, 160, layer.renderWidth-320, layer.renderHeight-320); + + cursors = game.input.keyboard.createCursorKeys(); + +} + +function update() { + + layer.update(); + + // getTiles: function (x, y, width, height, collides, layer) { + overlap = layer.getTiles(sprite.body.x, sprite.body.y, sprite.body.width, sprite.body.height, true); + + if (overlap.length > 1) + { + for (var i = 1; i < overlap.length; i++) + { + game.physics.separateTile(sprite.body, overlap[i]); + } + } + + sprite.body.velocity.x = 0; + sprite.body.velocity.y = 0; + + if (cursors.up.isDown) + { + sprite.body.velocity.y = -150; + } + else if (cursors.down.isDown) + { + sprite.body.velocity.y = 150; + } + + if (cursors.left.isDown) + { + sprite.body.velocity.x = -150; + sprite.scale.x = -1; + } + else if (cursors.right.isDown) + { + sprite.body.velocity.x = 150; + sprite.scale.x = 1; + } + + +} + +function render() { + + layer.render(); + + // game.debug.renderSpriteBody(sprite); + + // game.debug.renderSpriteInfo(sprite, 32, 450); + + // game.debug.renderCameraInfo(game.camera, 32, 32); + + /* + game.context.save(); + game.context.setTransform(1, 0, 0, 1, 0, 0); + + + game.context.fillStyle = 'rgba(255, 0, 0, 0.5)'; + + if (overlap.length > 1) + { + var x = 0; + var y = 0; + + for (var i = 1; i < overlap.length; i++) + { + game.context.drawImage( + overlap[i].tile.tileset.image, + overlap[i].tile.x, + overlap[i].tile.y, + overlap[i].tile.width, + overlap[i].tile.height, + 0 + (x * overlap[i].tile.width), + 420 + (y * overlap[i].tile.height), + overlap[i].tile.width, + overlap[i].tile.height + ); + + if (overlap[i].tile.collideNone == false) + { + game.context.fillRect(0 + (x * overlap[i].tile.width), 420 + (y * overlap[i].tile.height), overlap[i].tile.width, overlap[i].tile.height); + } + + x++; + + if (x == overlap[0].tw) + { + x = 0; + y++; + } + } + } + + game.context.restore(); + */ + + // game.debug.renderRectangle(game.camera.deadzone, 'rgba(0,200,0,0.5)'); + +} diff --git a/examples/world/fixed to camera.js b/examples/world/fixed to camera.js new file mode 100644 index 00000000..a49b4e7c --- /dev/null +++ b/examples/world/fixed to camera.js @@ -0,0 +1,66 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render : render }); + +function preload() { + + game.stage.backgroundColor = '#007236'; + + game.load.image('mushroom', 'assets/sprites/mushroom2.png'); + game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png'); + game.load.image('phaser', 'assets/sprites/phaser1.png'); + +} + +var cursors; +var logo1; +var logo2; + +function create() { + + // Modify the world and camera bounds + game.world.setBounds(-1000, -1000, 2000, 2000); + + for (var i = 0; i < 200; i++) + { + game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom'); + } + + logo1 = game.add.sprite(100, 100, 'phaser'); + logo1.fixedToCamera = true; + + logo2 = game.add.sprite(500, 100, 'phaser'); + logo2.fixedToCamera = true; + + game.add.tween(logo2).to( { y: 400 }, 2000, Phaser.Easing.Back.InOut, true, 0, 2000, true); + + cursors = game.input.keyboard.createCursorKeys(); + +} + +function update() { + + if (cursors.up.isDown) + { + game.camera.y -= 4; + } + else if (cursors.down.isDown) + { + game.camera.y += 4; + } + + if (cursors.left.isDown) + { + game.camera.x -= 4; + } + else if (cursors.right.isDown) + { + game.camera.x += 4; + } + +} + +function render() { + + game.debug.renderCameraInfo(game.camera, 32, 32); + +} diff --git a/examples/world/move around world.js b/examples/world/move around world.js new file mode 100644 index 00000000..52573551 --- /dev/null +++ b/examples/world/move around world.js @@ -0,0 +1,95 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render : render }); + +function preload() { + + game.stage.backgroundColor = '#007236'; + + game.load.image('mushroom', 'assets/sprites/mushroom2.png'); + game.load.image('phaser', 'assets/sprites/sonic_havok_sanity.png'); + +} + +var cursors; +var d; + +function create() { + + // Modify the world and camera bounds + game.world.setBounds(-1000, -1000, 2000, 2000); + + for (var i = 0; i < 100; i++) + { + game.add.sprite(game.world.randomX, game.world.randomY, 'mushroom'); + } + + game.add.text(600, 800, "- phaser -", { font: "32px Arial", fill: "#330088", align: "center" }); + + d = game.add.sprite(0, 0, 'phaser'); + d.anchor.setTo(0.5, 0.5); + + cursors = game.input.keyboard.createCursorKeys(); + +} + +function update() { + + d.angle += 1; + + if (cursors.up.isDown) + { + if (cursors.up.shiftKey) + { + d.angle++; + } + else + { + game.camera.y -= 4; + } + } + else if (cursors.down.isDown) + { + if (cursors.down.shiftKey) + { + d.angle--; + } + else + { + game.camera.y += 4; + } + } + + if (cursors.left.isDown) + { + if (cursors.left.shiftKey) + { + game.world.rotation -= 0.05; + } + else + { + game.camera.x -= 4; + } + } + else if (cursors.right.isDown) + { + if (cursors.right.shiftKey) + { + game.world.rotation += 0.05; + } + else + { + game.camera.x += 4; + } + } + +} + +function render() { + + game.debug.renderCameraInfo(game.camera, 32, 32); + game.debug.renderSpriteInfo(d, 32, 200); + // game.debug.renderWorldTransformInfo(d, 32, 200); + // game.debug.renderLocalTransformInfo(d, 32, 400); + game.debug.renderSpriteCorners(d, false, true); + +} diff --git a/package.json b/package.json index c7e5d788..27aeecbd 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,7 @@ { "name": "Phaser", - "version": "1.0.0", - "description": "html5 game framework", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, + "version": "1.1.0", + "description": "HTML5 game framework", "repository": { "type": "git", "url": "https://photonstorm@github.com/photonstorm/phaser.git" @@ -18,15 +14,13 @@ ], "author": "Richard Davey", "license": "MIT", - "readmeFilename": "README.md", - "gitHead": "1217bf4722768514fe15ff904dab59f848d146f4", "devDependencies": { "grunt": "~0.4.1", - "typescript": "~0.8.3", - "grunt-typescript": "~0.1.4", - "grunt-contrib-watch": "~0.3.1", - "grunt-contrib-connect": "~0.3.0", - "grunt-open": "~0.2.0", - "grunt-contrib-copy": "~0.4.1" + "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-connect": "~0.5.0", + "grunt-contrib-copy": "~0.4.1", + "grunt-contrib-clean": "~0.5.0", + "grunt-contrib-uglify": "~0.2.4", + "lodash": "~2.2.1" } } diff --git a/Plugins/CSS3Filters.js b/plugins/CSS3Filters.js similarity index 100% rename from Plugins/CSS3Filters.js rename to plugins/CSS3Filters.js diff --git a/Plugins/ColorHarmony.js b/plugins/ColorHarmony.js similarity index 100% rename from Plugins/ColorHarmony.js rename to plugins/ColorHarmony.js diff --git a/Plugins/SamplePlugin.js b/plugins/SamplePlugin.js similarity index 100% rename from Plugins/SamplePlugin.js rename to plugins/SamplePlugin.js diff --git a/resources/Phaser Logo/2D Text/Phaser Logo 2D Vector Outline.fla b/resources/Phaser Logo/2D Text/Phaser Logo 2D Vector Outline.fla new file mode 100644 index 00000000..ddce8c1b Binary files /dev/null and b/resources/Phaser Logo/2D Text/Phaser Logo 2D Vector Outline.fla differ diff --git a/Docs/Phaser Logo/PNG/Phaser Logo Print Quality.png b/resources/Phaser Logo/PNG/Phaser Logo Print Quality.png similarity index 100% rename from Docs/Phaser Logo/PNG/Phaser Logo Print Quality.png rename to resources/Phaser Logo/PNG/Phaser Logo Print Quality.png diff --git a/Docs/Phaser Logo/PNG/Phaser Logo Web Quality.png b/resources/Phaser Logo/PNG/Phaser Logo Web Quality.png similarity index 100% rename from Docs/Phaser Logo/PNG/Phaser Logo Web Quality.png rename to resources/Phaser Logo/PNG/Phaser Logo Web Quality.png diff --git a/Docs/Phaser Logo/PNG/Phaser Logo iPad Resolution.png b/resources/Phaser Logo/PNG/Phaser Logo iPad Resolution.png similarity index 100% rename from Docs/Phaser Logo/PNG/Phaser Logo iPad Resolution.png rename to resources/Phaser Logo/PNG/Phaser Logo iPad Resolution.png diff --git a/Docs/Phaser Logo/PNG/Phaser-Logo-Small.png b/resources/Phaser Logo/PNG/Phaser-Logo-Small.png similarity index 100% rename from Docs/Phaser Logo/PNG/Phaser-Logo-Small.png rename to resources/Phaser Logo/PNG/Phaser-Logo-Small.png diff --git a/Docs/Phaser Logo/Pixel Art/Phaser-Logo-Sizes.png b/resources/Phaser Logo/Pixel Art/Phaser-Logo-Sizes.png similarity index 100% rename from Docs/Phaser Logo/Pixel Art/Phaser-Logo-Sizes.png rename to resources/Phaser Logo/Pixel Art/Phaser-Logo-Sizes.png diff --git a/Docs/Phaser Logo/Pixel Art/Phaser Logo.png b/resources/Phaser Logo/Pixel Art/phaser_pixel_large_shaded.png similarity index 100% rename from Docs/Phaser Logo/Pixel Art/Phaser Logo.png rename to resources/Phaser Logo/Pixel Art/phaser_pixel_large_shaded.png diff --git a/resources/Phaser Logo/Pixel Art/phaser_pixel_medium_flat.png b/resources/Phaser Logo/Pixel Art/phaser_pixel_medium_flat.png new file mode 100644 index 00000000..6c02f4ef Binary files /dev/null and b/resources/Phaser Logo/Pixel Art/phaser_pixel_medium_flat.png differ diff --git a/resources/Phaser Logo/Pixel Art/phaser_pixel_medium_shaded.png b/resources/Phaser Logo/Pixel Art/phaser_pixel_medium_shaded.png new file mode 100644 index 00000000..94e0c812 Binary files /dev/null and b/resources/Phaser Logo/Pixel Art/phaser_pixel_medium_shaded.png differ diff --git a/resources/Phaser Logo/Pixel Art/phaser_pixel_small_flat.png b/resources/Phaser Logo/Pixel Art/phaser_pixel_small_flat.png new file mode 100644 index 00000000..14d49ae8 Binary files /dev/null and b/resources/Phaser Logo/Pixel Art/phaser_pixel_small_flat.png differ diff --git a/Docs/Phaser Logo/Vector/Phaser Logo.eps b/resources/Phaser Logo/Vector/Phaser Logo.eps similarity index 100% rename from Docs/Phaser Logo/Vector/Phaser Logo.eps rename to resources/Phaser Logo/Vector/Phaser Logo.eps diff --git a/Docs/Phaser Logo/Vector/Phaser Logo.fla b/resources/Phaser Logo/Vector/Phaser Logo.fla similarity index 100% rename from Docs/Phaser Logo/Vector/Phaser Logo.fla rename to resources/Phaser Logo/Vector/Phaser Logo.fla diff --git a/resources/Screen Shots/phaser-cybernoid.png b/resources/Screen Shots/phaser-cybernoid.png new file mode 100644 index 00000000..0730dad0 Binary files /dev/null and b/resources/Screen Shots/phaser-cybernoid.png differ diff --git a/Docs/Screen Shots/phaser_balls.png b/resources/Screen Shots/phaser_balls.png similarity index 100% rename from Docs/Screen Shots/phaser_balls.png rename to resources/Screen Shots/phaser_balls.png diff --git a/Docs/Screen Shots/phaser_blaster.png b/resources/Screen Shots/phaser_blaster.png similarity index 100% rename from Docs/Screen Shots/phaser_blaster.png rename to resources/Screen Shots/phaser_blaster.png diff --git a/Docs/Screen Shots/phaser_cams.png b/resources/Screen Shots/phaser_cams.png similarity index 100% rename from Docs/Screen Shots/phaser_cams.png rename to resources/Screen Shots/phaser_cams.png diff --git a/Docs/Screen Shots/phaser_desert.png b/resources/Screen Shots/phaser_desert.png similarity index 100% rename from Docs/Screen Shots/phaser_desert.png rename to resources/Screen Shots/phaser_desert.png diff --git a/resources/Screen Shots/phaser_fixed_camera.png b/resources/Screen Shots/phaser_fixed_camera.png new file mode 100644 index 00000000..28263fa4 Binary files /dev/null and b/resources/Screen Shots/phaser_fixed_camera.png differ diff --git a/Docs/Screen Shots/phaser_fruit.png b/resources/Screen Shots/phaser_fruit.png similarity index 100% rename from Docs/Screen Shots/phaser_fruit.png rename to resources/Screen Shots/phaser_fruit.png diff --git a/Docs/Screen Shots/phaser_fruit_particles.png b/resources/Screen Shots/phaser_fruit_particles.png similarity index 100% rename from Docs/Screen Shots/phaser_fruit_particles.png rename to resources/Screen Shots/phaser_fruit_particles.png diff --git a/Docs/Screen Shots/phaser_mapdraw.png b/resources/Screen Shots/phaser_mapdraw.png similarity index 100% rename from Docs/Screen Shots/phaser_mapdraw.png rename to resources/Screen Shots/phaser_mapdraw.png diff --git a/Docs/Screen Shots/phaser_mario_combo.png b/resources/Screen Shots/phaser_mario_combo.png similarity index 100% rename from Docs/Screen Shots/phaser_mario_combo.png rename to resources/Screen Shots/phaser_mario_combo.png diff --git a/Docs/Screen Shots/phaser_particles.png b/resources/Screen Shots/phaser_particles.png similarity index 100% rename from Docs/Screen Shots/phaser_particles.png rename to resources/Screen Shots/phaser_particles.png diff --git a/Docs/Screen Shots/phaser_platformer.png b/resources/Screen Shots/phaser_platformer.png similarity index 100% rename from Docs/Screen Shots/phaser_platformer.png rename to resources/Screen Shots/phaser_platformer.png diff --git a/Docs/Screen Shots/phaser_quadtree.png b/resources/Screen Shots/phaser_quadtree.png similarity index 100% rename from Docs/Screen Shots/phaser_quadtree.png rename to resources/Screen Shots/phaser_quadtree.png diff --git a/Docs/Screen Shots/phaser_rotate4.png b/resources/Screen Shots/phaser_rotate4.png similarity index 100% rename from Docs/Screen Shots/phaser_rotate4.png rename to resources/Screen Shots/phaser_rotate4.png diff --git a/Docs/Screen Shots/phaser_scrollfactor.png b/resources/Screen Shots/phaser_scrollfactor.png similarity index 100% rename from Docs/Screen Shots/phaser_scrollfactor.png rename to resources/Screen Shots/phaser_scrollfactor.png diff --git a/resources/Screen Shots/phaser_sprite_bounds.png b/resources/Screen Shots/phaser_sprite_bounds.png new file mode 100644 index 00000000..cda91f28 Binary files /dev/null and b/resources/Screen Shots/phaser_sprite_bounds.png differ diff --git a/resources/Screen Shots/phaser_tanks.png b/resources/Screen Shots/phaser_tanks.png new file mode 100644 index 00000000..eaffc0d6 Binary files /dev/null and b/resources/Screen Shots/phaser_tanks.png differ diff --git a/Docs/Screen Shots/phaser_tilemap.png b/resources/Screen Shots/phaser_tilemap.png similarity index 100% rename from Docs/Screen Shots/phaser_tilemap.png rename to resources/Screen Shots/phaser_tilemap.png diff --git a/Docs/Screen Shots/phaser_tilemap_collision.png b/resources/Screen Shots/phaser_tilemap_collision.png similarity index 100% rename from Docs/Screen Shots/phaser_tilemap_collision.png rename to resources/Screen Shots/phaser_tilemap_collision.png diff --git a/resources/Screen Shots/phaser_tilemap_debug.png b/resources/Screen Shots/phaser_tilemap_debug.png new file mode 100644 index 00000000..392022ce Binary files /dev/null and b/resources/Screen Shots/phaser_tilemap_debug.png differ diff --git a/Docs/WIP/01_phaser-arcade.jpg b/resources/wip/01_phaser-arcade.jpg similarity index 100% rename from Docs/WIP/01_phaser-arcade.jpg rename to resources/wip/01_phaser-arcade.jpg diff --git a/Docs/WIP/02_phaser-newsletter.jpg b/resources/wip/02_phaser-newsletter.jpg similarity index 100% rename from Docs/WIP/02_phaser-newsletter.jpg rename to resources/wip/02_phaser-newsletter.jpg diff --git a/Docs/WIP/Physics Comparison.xlsx b/resources/wip/Physics Comparison.xlsx similarity index 100% rename from Docs/WIP/Physics Comparison.xlsx rename to resources/wip/Physics Comparison.xlsx diff --git a/Docs/WIP/phaser-manual_2013-08-27.pdf b/resources/wip/phaser-manual_2013-08-27.pdf similarity index 100% rename from Docs/WIP/phaser-manual_2013-08-27.pdf rename to resources/wip/phaser-manual_2013-08-27.pdf diff --git a/Docs/WIP/phaser_copy.doc b/resources/wip/phaser_copy.doc similarity index 100% rename from Docs/WIP/phaser_copy.doc rename to resources/wip/phaser_copy.doc diff --git a/Docs/WIP/phaser_onscreen-controls_1-arcade.png b/resources/wip/phaser_onscreen-controls_1-arcade.png similarity index 100% rename from Docs/WIP/phaser_onscreen-controls_1-arcade.png rename to resources/wip/phaser_onscreen-controls_1-arcade.png diff --git a/Docs/WIP/phaser_onscreen-controls_2-dpad.png b/resources/wip/phaser_onscreen-controls_2-dpad.png similarity index 100% rename from Docs/WIP/phaser_onscreen-controls_2-dpad.png rename to resources/wip/phaser_onscreen-controls_2-dpad.png diff --git a/Docs/WIP/phaser_onscreen-controls_3-generic.png b/resources/wip/phaser_onscreen-controls_3-generic.png similarity index 100% rename from Docs/WIP/phaser_onscreen-controls_3-generic.png rename to resources/wip/phaser_onscreen-controls_3-generic.png diff --git a/Docs/Resources/avoid-digits.png b/resources/wip/sprites/avoid-digits.png similarity index 100% rename from Docs/Resources/avoid-digits.png rename to resources/wip/sprites/avoid-digits.png diff --git a/Docs/Resources/avoid-panel.png b/resources/wip/sprites/avoid-panel.png similarity index 100% rename from Docs/Resources/avoid-panel.png rename to resources/wip/sprites/avoid-panel.png diff --git a/Docs/Resources/avoid-sheet.png b/resources/wip/sprites/avoid-sheet.png similarity index 100% rename from Docs/Resources/avoid-sheet.png rename to resources/wip/sprites/avoid-sheet.png diff --git a/Docs/Resources/avoidmock4x2.png b/resources/wip/sprites/avoidmock4x2.png similarity index 100% rename from Docs/Resources/avoidmock4x2.png rename to resources/wip/sprites/avoidmock4x2.png diff --git a/Docs/Resources/box-01.png b/resources/wip/sprites/box-01.png similarity index 100% rename from Docs/Resources/box-01.png rename to resources/wip/sprites/box-01.png diff --git a/Docs/Resources/box-02.png b/resources/wip/sprites/box-02.png similarity index 100% rename from Docs/Resources/box-02.png rename to resources/wip/sprites/box-02.png diff --git a/resources/wip/sprites/breakout2c.png b/resources/wip/sprites/breakout2c.png new file mode 100644 index 00000000..2dd498cf Binary files /dev/null and b/resources/wip/sprites/breakout2c.png differ diff --git a/Docs/Resources/phaser checkboxes.gif b/resources/wip/sprites/phaser checkboxes.gif similarity index 100% rename from Docs/Resources/phaser checkboxes.gif rename to resources/wip/sprites/phaser checkboxes.gif diff --git a/Docs/Resources/phaser power tools.gif b/resources/wip/sprites/phaser power tools.gif similarity index 100% rename from Docs/Resources/phaser power tools.gif rename to resources/wip/sprites/phaser power tools.gif diff --git a/resources/wip/sprites/phaser sprites10.gif b/resources/wip/sprites/phaser sprites10.gif new file mode 100644 index 00000000..4d476ca3 Binary files /dev/null and b/resources/wip/sprites/phaser sprites10.gif differ diff --git a/resources/zwoptex-phaser.template b/resources/zwoptex-phaser.template new file mode 100644 index 00000000..23b7f62f --- /dev/null +++ b/resources/zwoptex-phaser.template @@ -0,0 +1,40 @@ +{ + + "frames": + [ + {% for sprite in spritesAndAliases %}{% if currentLoop.currentIndex > 0 %},{% /if %} + { + "filename": "{{ sprite.name }}", + "frame": {"x":{{ sprite.textureRectX }},"y":{{ sprite.textureRectY }},"w":{{ sprite.textureRectWidth }},"h":{{ sprite.textureRectHeight }}}, + "rotated": {% if sprite.isRotated %}true{% else %}false{% /if %}, + "trimmed": {% if sprite.isTrimmed %}true{% else %}false{% /if %}, + "spriteSourceSize": {"x":0,"y":0,"w":{{ sprite.sourceSizeWidth }},"h":{{ sprite.sourceSizeHeight }}}, + "sourceSize": {"w":{{ sprite.sourceSizeWidth }},"h":{{ sprite.sourceSizeHeight }}}, + "spriteColorRect": {"x":{{ sprite.sourceColorRectX }},"y":{{ sprite.sourceColorRectY }},"w":{{ sprite.sourceColorRectWidth }},"h":{{ sprite.sourceColorRectHeight }}}, + "spriteOffset": {"x":{{ sprite.offsetX }}, "y":{{ sprite.offsetY }}}, + "spriteSize": {"w":{{ sprite.sizeWidth }}, "h":{{ sprite.sizeHeight }}} + }{% /for %} + ], + + "meta": + { + + "app": "http://zwoptexapp.com", + "version": "{{ metadata.version }}", + "image": "{{ metadata.target.textureFileName }}{{ metadata.target.textureFileExtension }}", + "size": {"w":{{ metadata.sizeWidth }},"h":{{ metadata.sizeHeight }}}, + "name": "{{ metadata.name }}", + "premultipliedAlpha": {% if metadata.premultipliedAlpha %}true{% else %}false{% /if %}, + "target": { + "name": "{{ metadata.target.name }}", + "textureFileName": "{{ metadata.target.textureFileName }}", + "textureFileExtension": "{{ metadata.target.textureFileExtension }}", + "coordinatesFileName": "{{ metadata.target.coordinatesFileName }}", + "coordinatesFileExtension": "{{ metadata.target.coordinatesFileExtension }}", + "premultipliedAlpha": {% if metadata.target.premultipliedAlpha %}true{% else %}false{% /if %} + }, + "scale": "1" + + } + +} \ No newline at end of file diff --git a/src/Intro.js b/src/Intro.js index 08ea73e7..908be578 100644 --- a/src/Intro.js +++ b/src/Intro.js @@ -1,9 +1,17 @@ /** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* @overview +* * Phaser - http://www.phaser.io * -* v{version} - Built at: {buildDate} +* v<%= version %> - Built at: <%= buildDate %> * -* @author Richard Davey http://www.photonstorm.com @photonstorm +* By Richard Davey http://www.photonstorm.com @photonstorm * * A feature-packed 2D HTML5 game framework born from the smouldering pits of Flixel and * constructed via plenty of blood, sweat, tears and coffee by Richard Davey (@photonstorm). diff --git a/src/IntroDocs.js b/src/IntroDocs.js new file mode 100644 index 00000000..27a04815 --- /dev/null +++ b/src/IntroDocs.js @@ -0,0 +1,29 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* @overview +* +* Phaser - http://www.phaser.io +* +* v1.1 - Released October 25th 2013. +* +* By Richard Davey http://www.photonstorm.com @photonstorm +* +* A feature-packed 2D HTML5 game framework born from the smouldering pits of Flixel and +* constructed via plenty of blood, sweat, tears and coffee by Richard Davey (@photonstorm). +* +* Phaser uses Pixi.js for rendering, created by Mat Groves http://matgroves.com/ @Doormat23. +* +* Follow Phaser development progress at http://www.photonstorm.com +* +* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel, from both which Phaser +* and my love of game development originate. +* +* "If you want your children to be intelligent, read them fairy tales." +* "If you want them to be more intelligent, read them more fairy tales." +* -- Albert Einstein +*/ diff --git a/src/Phaser.js b/src/Phaser.js index eb5a425b..639e1637 100644 --- a/src/Phaser.js +++ b/src/Phaser.js @@ -1,10 +1,16 @@ /** - * @module Phaser - */ -var Phaser = Phaser || { +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ - VERSION: '1.0.6a', - GAMES: [], +/** +* @namespace Phaser +*/ +var Phaser = Phaser || { + + VERSION: '<%= version %>', + GAMES: [], AUTO: 0, CANVAS: 1, WEBGL: 2, @@ -20,11 +26,17 @@ var Phaser = Phaser || { RENDERTEXTURE: 8, TILEMAP: 9, TILEMAPLAYER: 10, - EMITTER: 11 + EMITTER: 11, + + NONE: 0, + LEFT: 1, + RIGHT: 2, + UP: 3, + DOWN: 4 }; PIXI.InteractionManager = function (dummy) { // We don't need this in Pixi, so we've removed it to save space // however the Stage object expects a reference to it, so here is a dummy entry. -}; \ No newline at end of file +}; diff --git a/src/PixiPatch.js b/src/PixiPatch.js new file mode 100644 index 00000000..c1bfe366 --- /dev/null +++ b/src/PixiPatch.js @@ -0,0 +1,230 @@ +/** + * We're replacing a couple of Pixi's methods here to fix or add some vital functionality: + * + * 1) Added support for Trimmed sprite sheets + * 2) Skip display objects with an alpha of zero + * + * Hopefully we can remove this once Pixi has been updated to support these things. + */ + +PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject) +{ + // no loger recurrsive! + var transform; + var context = this.context; + + context.globalCompositeOperation = 'source-over'; + + // one the display object hits this. we can break the loop + var testObject = displayObject.last._iNext; + displayObject = displayObject.first; + + do + { + transform = displayObject.worldTransform; + + if(!displayObject.visible) + { + displayObject = displayObject.last._iNext; + continue; + } + + if(!displayObject.renderable || displayObject.alpha == 0) + { + displayObject = displayObject._iNext; + continue; + } + + if(displayObject instanceof PIXI.Sprite) + { + var frame = displayObject.texture.frame; + + if(frame) + { + context.globalAlpha = displayObject.worldAlpha; + + if (displayObject.texture.trimmed) + { + context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2] + displayObject.texture.trim.x, transform[5] + displayObject.texture.trim.y); + } + else + { + context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]); + } + + context.drawImage(displayObject.texture.baseTexture.source, + frame.x, + frame.y, + frame.width, + frame.height, + (displayObject.anchor.x) * -frame.width, + (displayObject.anchor.y) * -frame.height, + frame.width, + frame.height); + } + } + else if(displayObject instanceof PIXI.Strip) + { + context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]) + this.renderStrip(displayObject); + } + else if(displayObject instanceof PIXI.TilingSprite) + { + context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]) + this.renderTilingSprite(displayObject); + } + else if(displayObject instanceof PIXI.CustomRenderable) + { + displayObject.renderCanvas(this); + } + else if(displayObject instanceof PIXI.Graphics) + { + context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]) + PIXI.CanvasGraphics.renderGraphics(displayObject, context); + } + else if(displayObject instanceof PIXI.FilterBlock) + { + if(displayObject.open) + { + context.save(); + + var cacheAlpha = displayObject.mask.alpha; + var maskTransform = displayObject.mask.worldTransform; + + context.setTransform(maskTransform[0], maskTransform[3], maskTransform[1], maskTransform[4], maskTransform[2], maskTransform[5]) + + displayObject.mask.worldAlpha = 0.5; + + context.worldAlpha = 0; + + PIXI.CanvasGraphics.renderGraphicsMask(displayObject.mask, context); + context.clip(); + + displayObject.mask.worldAlpha = cacheAlpha; + } + else + { + context.restore(); + } + } + // count++ + displayObject = displayObject._iNext; + + + } + while(displayObject != testObject) + +} + +PIXI.WebGLBatch.prototype.update = function() +{ + var gl = this.gl; + var worldTransform, width, height, aX, aY, w0, w1, h0, h1, index, index2, index3 + + var a, b, c, d, tx, ty; + + var indexRun = 0; + + var displayObject = this.head; + + while(displayObject) + { + if(displayObject.vcount === PIXI.visibleCount) + { + width = displayObject.texture.frame.width; + height = displayObject.texture.frame.height; + + // TODO trim?? + aX = displayObject.anchor.x;// - displayObject.texture.trim.x + aY = displayObject.anchor.y; //- displayObject.texture.trim.y + w0 = width * (1-aX); + w1 = width * -aX; + + h0 = height * (1-aY); + h1 = height * -aY; + + index = indexRun * 8; + + worldTransform = displayObject.worldTransform; + + a = worldTransform[0]; + b = worldTransform[3]; + c = worldTransform[1]; + d = worldTransform[4]; + tx = worldTransform[2]; + ty = worldTransform[5]; + + if (displayObject.texture.trimmed) + { + tx += displayObject.texture.trim.x; + ty += displayObject.texture.trim.y; + } + + this.verticies[index + 0 ] = a * w1 + c * h1 + tx; + this.verticies[index + 1 ] = d * h1 + b * w1 + ty; + + this.verticies[index + 2 ] = a * w0 + c * h1 + tx; + this.verticies[index + 3 ] = d * h1 + b * w0 + ty; + + this.verticies[index + 4 ] = a * w0 + c * h0 + tx; + this.verticies[index + 5 ] = d * h0 + b * w0 + ty; + + this.verticies[index + 6] = a * w1 + c * h0 + tx; + this.verticies[index + 7] = d * h0 + b * w1 + ty; + + if(displayObject.updateFrame || displayObject.texture.updateFrame) + { + this.dirtyUVS = true; + + var texture = displayObject.texture; + + var frame = texture.frame; + var tw = texture.baseTexture.width; + var th = texture.baseTexture.height; + + this.uvs[index + 0] = frame.x / tw; + this.uvs[index +1] = frame.y / th; + + this.uvs[index +2] = (frame.x + frame.width) / tw; + this.uvs[index +3] = frame.y / th; + + this.uvs[index +4] = (frame.x + frame.width) / tw; + this.uvs[index +5] = (frame.y + frame.height) / th; + + this.uvs[index +6] = frame.x / tw; + this.uvs[index +7] = (frame.y + frame.height) / th; + + displayObject.updateFrame = false; + } + + // TODO this probably could do with some optimisation.... + if(displayObject.cacheAlpha != displayObject.worldAlpha) + { + displayObject.cacheAlpha = displayObject.worldAlpha; + + var colorIndex = indexRun * 4; + this.colors[colorIndex] = this.colors[colorIndex + 1] = this.colors[colorIndex + 2] = this.colors[colorIndex + 3] = displayObject.worldAlpha; + this.dirtyColors = true; + } + } + else + { + index = indexRun * 8; + + this.verticies[index + 0 ] = 0; + this.verticies[index + 1 ] = 0; + + this.verticies[index + 2 ] = 0; + this.verticies[index + 3 ] = 0; + + this.verticies[index + 4 ] = 0; + this.verticies[index + 5 ] = 0; + + this.verticies[index + 6] = 0; + this.verticies[index + 7] = 0; + } + + indexRun++; + displayObject = displayObject.__next; + } +} diff --git a/src/animation/Animation.js b/src/animation/Animation.js index 64c72b9b..ff95fd72 100644 --- a/src/animation/Animation.js +++ b/src/animation/Animation.js @@ -1,8 +1,7 @@ /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Animation +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** @@ -14,7 +13,7 @@ * @param {Phaser.Game} game - A reference to the currently running game. * @param {Phaser.Sprite} parent - A reference to the owner of this Animation. * @param {string} name - The unique name for this animation, used in playback commands. -* @param {Phaser.Animation.FrameData} frameData - The FrameData object that contains all frames used by this Animation. +* @param {Phaser.FrameData} frameData - The FrameData object that contains all frames used by this Animation. * @param {(Array.|Array.)} frames - An array of numbers or strings indicating which frames to play in which order. * @param {number} delay - The time between each frame of the animation, given in ms. * @param {boolean} looped - Should this animation loop or play through once. @@ -60,6 +59,11 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope */ this.looped = looped; + /** + * @property {boolean} looped - The loop state of the Animation. + */ + this.killOnComplete = false; + /** * @property {boolean} isFinished - The finished state of the Animation. Set to true once playback completes, false during playback. * @default @@ -72,6 +76,19 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope */ this.isPlaying = false; + /** + * @property {boolean} isPaused - The paused state of the Animation. + * @default + */ + this.isPaused = false; + + /** + * @property {boolean} _pauseStartTime - The time the animation paused. + * @private + * @default + */ + this._pauseStartTime = 0; + /** * @property {number} _frameIndex * @private @@ -80,7 +97,21 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope this._frameIndex = 0; /** - * @property {Phaser.Animation.Frame} currentFrame - The currently displayed frame of the Animation. + * @property {number} _frameDiff + * @private + * @default + */ + this._frameDiff = 0; + + /** + * @property {number} _frameSkip + * @private + * @default + */ + this._frameSkip = 1; + + /** + * @property {Phaser.Frame} currentFrame - The currently displayed frame of the Animation. */ this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); @@ -91,28 +122,33 @@ Phaser.Animation.prototype = { /** * Plays this animation. * - * @method play - * @param {Number} [frameRate=null] The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. - * @param {Boolean} [loop=null] Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. - * @return {Phaser.Animation} A reference to this Animation instance. + * @method Phaser.Animation#play + * @memberof Phaser.Animation + * @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. + * @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. + * @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. + * @return {Phaser.Animation} - A reference to this Animation instance. */ - play: function (frameRate, loop) { + play: function (frameRate, loop, killOnComplete) { - frameRate = frameRate || null; - loop = loop || null; - - if (frameRate !== null) + if (typeof frameRate === 'number') { + // If they set a new frame rate then use it, otherwise use the one set on creation this.delay = 1000 / frameRate; - // this.delay = frameRate; } - if (loop !== null) + if (typeof loop === 'boolean') { - // If they set a new loop value then use it, otherwise use the default set on creation + // If they set a new loop value then use it, otherwise use the one set on creation this.looped = loop; } + if (typeof killOnComplete !== 'undefined') + { + // Remove the parent sprite once the animation has finished? + this.killOnComplete = killOnComplete; + } + this.isPlaying = true; this.isFinished = false; @@ -136,7 +172,8 @@ Phaser.Animation.prototype = { /** * Sets this animation back to the first frame and restarts the animation. * - * @method restart + * @method Phaser.Animation#restart + * @memberof Phaser.Animation */ restart: function () { @@ -155,8 +192,9 @@ Phaser.Animation.prototype = { /** * Stops playback of this animation and set it to a finished state. If a resetFrame is provided it will stop playback and set frame to the first in the animation. * - * @method stop - * @param {Boolean} [resetFrame=false] If true after the animation stops the currentFrame value will be set to the first frame in this animation. + * @method Phaser.Animation#stop + * @memberof Phaser.Animation + * @param {boolean} [resetFrame=false] - If true after the animation stops the currentFrame value will be set to the first frame in this animation. */ stop: function (resetFrame) { @@ -175,21 +213,50 @@ Phaser.Animation.prototype = { /** * Updates this animation. Called automatically by the AnimationManager. * - * @method update + * @method Phaser.Animation#update + * @memberof Phaser.Animation */ update: function () { + if (this.isPaused) + { + return false; + } + if (this.isPlaying == true && this.game.time.now >= this._timeNextFrame) { - this._frameIndex++; + this._frameSkip = 1; - if (this._frameIndex == this._frames.length) + // Lagging? + this._frameDiff = this.game.time.now - this._timeNextFrame; + + this._timeLastFrame = this.game.time.now; + + if (this._frameDiff > this.delay) + { + // We need to skip a frame, work out how many + this._frameSkip = Math.floor(this._frameDiff / this.delay); + + this._frameDiff -= (this._frameSkip * this.delay); + } + + // And what's left now? + this._timeNextFrame = this.game.time.now + (this.delay - this._frameDiff); + + this._frameIndex += this._frameSkip; + + if (this._frameIndex >= this._frames.length) { if (this.looped) { - this._frameIndex = 0; + this._frameIndex %= this._frames.length; this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); - this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + + if (this.currentFrame) + { + this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + } + this._parent.events.onAnimationLoop.dispatch(this._parent, this); } else @@ -203,9 +270,6 @@ Phaser.Animation.prototype = { this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); } - this._timeLastFrame = this.game.time.now; - this._timeNextFrame = this.game.time.now + this.delay; - return true; } @@ -216,7 +280,8 @@ Phaser.Animation.prototype = { /** * Cleans up this animation ready for deletion. Nulls all values and references. * - * @method destroy + * @method Phaser.Animation#destroy + * @memberof Phaser.Animation */ destroy: function () { @@ -232,7 +297,8 @@ Phaser.Animation.prototype = { /** * Called internally when the animation finishes playback. Sets the isPlaying and isFinished states and dispatches the onAnimationComplete event if it exists on the parent. * - * @method onComplete + * @method Phaser.Animation#onComplete + * @memberof Phaser.Animation */ onComplete: function () { @@ -244,28 +310,68 @@ Phaser.Animation.prototype = { this._parent.events.onAnimationComplete.dispatch(this._parent, this); } + if (this.killOnComplete) + { + this._parent.kill(); + } + } }; +/** +* @name Phaser.Animation#paused +* @property {boolean} paused - Gets and sets the paused state of this Animation. +*/ +Object.defineProperty(Phaser.Animation.prototype, "paused", { + + get: function () { + + return this.isPaused; + + }, + + set: function (value) { + + this.isPaused = value; + + if (value) + { + // Paused + this._pauseStartTime = this.game.time.now; + } + else + { + // Un-paused + if (this.isPlaying) + { + this._timeNextFrame = this.game.time.now + this.delay; + } + } + + } + +}); + +/** +* @name Phaser.Animation#frameTotal +* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded. +* @readonly +*/ Object.defineProperty(Phaser.Animation.prototype, "frameTotal", { - /** - * @method frameTotal - * @return {Number} The total number of frames in this animation. - */ get: function () { return this._frames.length; } }); +/** +* @name Phaser.Animation#frame +* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display. +*/ Object.defineProperty(Phaser.Animation.prototype, "frame", { - /** - * @method frame - * @return {Animation.Frame} Returns the current frame, or if not set the index of the most recent frame. - */ get: function () { if (this.currentFrame !== null) @@ -279,10 +385,6 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", { }, - /** - * @method frame - * @return {Number} Sets the current frame to the given frame index and updates the texture cache. - */ set: function (value) { this.currentFrame = this._frameData.getFrame(value); @@ -296,3 +398,65 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", { } }); + +/** +* Really handy function for when you are creating arrays of animation data but it's using frame names and not numbers. +* For example imagine you've got 30 frames named: 'explosion_0001-large' to 'explosion_0030-large' +* You could use this function to generate those by doing: Phaser.Animation.generateFrameNames('explosion_', 1, 30, '-large', 4); +* +* @method Phaser.Animation.generateFrameNames +* @param {string} prefix - The start of the filename. If the filename was 'explosion_0001-large' the prefix would be 'explosion_'. +* @param {number} start - The number to start sequentially counting from. If your frames are named 'explosion_0001' to 'explosion_0034' the start is 1. +* @param {number} stop - The number to count to. If your frames are named 'explosion_0001' to 'explosion_0034' the stop value is 34. +* @param {string} [suffix=''] - The end of the filename. If the filename was 'explosion_0001-large' the prefix would be '-large'. +* @param {number} [zeroPad=0] - The number of zeroes to pad the min and max values with. If your frames are named 'explosion_0001' to 'explosion_0034' then the zeroPad is 4. +*/ +Phaser.Animation.generateFrameNames = function (prefix, start, stop, suffix, zeroPad) { + + if (typeof suffix == 'undefined') { suffix = ''; } + + var output = []; + var frame = ''; + + if (start < stop) + { + for (var i = start; i <= stop; i++) + { + if (typeof zeroPad == 'number') + { + // str, len, pad, dir + frame = Phaser.Utils.pad(i.toString(), zeroPad, '0', 1); + } + else + { + frame = i.toString(); + } + + frame = prefix + frame + suffix; + + output.push(frame); + } + } + else + { + for (var i = start; i >= stop; i--) + { + if (typeof zeroPad == 'number') + { + // str, len, pad, dir + frame = Phaser.Utils.pad(i.toString(), zeroPad, '0', 1); + } + else + { + frame = i.toString(); + } + + frame = prefix + frame + suffix; + + output.push(frame); + } + } + + return output; + +} diff --git a/src/animation/AnimationManager.js b/src/animation/AnimationManager.js index f6e40ea3..992a33ec 100644 --- a/src/animation/AnimationManager.js +++ b/src/animation/AnimationManager.js @@ -1,75 +1,64 @@ /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Animation +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** -* The AnimationManager is used to add, play and update Phaser Animations. +* The Animation Manager is used to add, play and update Phaser Animations. * Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance. * -* @class AnimationManager +* @class Phaser.AnimationManager * @constructor -* @param {Phaser.Sprite} sprite A reference to the Game Object that owns this AnimationManager. +* @param {Phaser.Sprite} sprite - A reference to the Game Object that owns this AnimationManager. */ Phaser.AnimationManager = function (sprite) { /** - * A reference to the parent Sprite that owns this AnimationManager. - * @property sprite - * @public - * @type {Phaser.Sprite} + * @property {Phaser.Sprite} sprite - A reference to the parent Sprite that owns this AnimationManager. */ this.sprite = sprite; /** - * A reference to the currently running Game. - * @property game - * @public - * @type {Phaser.Game} + * @property {Phaser.Game} game - A reference to the currently running Game. */ this.game = sprite.game; - /** - * The currently displayed Frame of animation, if any. - * @property currentFrame - * @public - * @type {Phaser.Animation.Frame} - */ + /** + * @property {Phaser.Frame} currentFrame - The currently displayed Frame of animation, if any. + * @default + */ this.currentFrame = null; - - /** - * Should the animation data continue to update even if the Sprite.visible is set to false. - * @property updateIfVisible - * @public - * @type {Boolean} - * @default true - */ + + /** + * @property {boolean} updateIfVisible - Should the animation data continue to update even if the Sprite.visible is set to false. + * @default + */ this.updateIfVisible = true; - /** - * A temp. var for holding the currently playing Animations FrameData. - * @property _frameData - * @private - * @type {Phaser.Animation.FrameData} - */ + /** + * @property {boolean} isLoaded - Set to true once animation data has been loaded. + * @default + */ + this.isLoaded = false; + + /** + * @property {Phaser.FrameData} _frameData - A temp. var for holding the currently playing Animations FrameData. + * @private + * @default + */ this._frameData = null; - /** - * An internal object that stores all of the Animation instances. - * @property _anims - * @private - * @type {Object} - */ + /** + * @property {object} _anims - An internal object that stores all of the Animation instances. + * @private + */ this._anims = {}; - /** - * An internal object to help avoid gc. - * @property _outputFrames - * @private - * @type {Object} - */ + /** + * @property {object} _outputFrames - An internal object to help avoid gc. + * @private + */ this._outputFrames = []; }; @@ -80,14 +69,15 @@ Phaser.AnimationManager.prototype = { * Loads FrameData into the internal temporary vars and resets the frame index to zero. * This is called automatically when a new Sprite is created. * - * @method loadFrameData + * @method Phaser.AnimationManager#loadFrameData * @private - * @param {Phaser.Animation.FrameData} frameData The FrameData set to load. + * @param {Phaser.FrameData} frameData - The FrameData set to load. */ loadFrameData: function (frameData) { this._frameData = frameData; this.frame = 0; + this.isLoaded = true; }, @@ -95,12 +85,12 @@ Phaser.AnimationManager.prototype = { * Adds a new animation under the given key. Optionally set the frames, frame rate and loop. * Animations added in this way are played back with the play function. * - * @method add - * @param {String} name The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk". - * @param {Array} [frames=null] An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used. - * @param {Number} [frameRate=60] The speed at which the animation should play. The speed is given in frames per second. - * @param {Boolean} [loop=false] {bool} Whether or not the animation is looped or just plays once. - * @param {Boolean} [useNumericIndex=true] Are the given frames using numeric indexes (default) or strings? (false) + * @method Phaser.AnimationManager#add + * @param {string} name - The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk". + * @param {Array} [frames=null] - An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used. + * @param {number} [frameRate=60] - The speed at which the animation should play. The speed is given in frames per second. + * @param {boolean} [loop=false] - Whether or not the animation is looped or just plays once. + * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? * @return {Phaser.Animation} The Animation object that was created. */ add: function (name, frames, frameRate, loop, useNumericIndex) { @@ -114,7 +104,19 @@ Phaser.AnimationManager.prototype = { frameRate = frameRate || 60; if (typeof loop === 'undefined') { loop = false; } - if (typeof useNumericIndex === 'undefined') { useNumericIndex = true; } + + // If they didn't set the useNumericIndex then let's at least try and guess it + if (typeof useNumericIndex === 'undefined') + { + if (frames && typeof frames[0] === 'number') + { + useNumericIndex = true; + } + else + { + useNumericIndex = false; + } + } // Create the signals the AnimationManager will emit if (this.sprite.events.onAnimationStart == null) @@ -140,10 +142,10 @@ Phaser.AnimationManager.prototype = { /** * Check whether the frames in the given array are valid and exist. * - * @method validateFrames - * @param {Array} frames An array of frames to be validated. - * @param {Boolean} [useNumericIndex=true] Validate the frames based on their numeric index (true) or string index (false) - * @return {Boolean} True if all given Frames are valid, otherwise false. + * @method Phaser.AnimationManager#validateFrames + * @param {Array} frames - An array of frames to be validated. + * @param {boolean} [useNumericIndex=true] - Validate the frames based on their numeric index (true) or string index (false) + * @return {boolean} True if all given Frames are valid, otherwise false. */ validateFrames: function (frames, useNumericIndex) { @@ -175,13 +177,14 @@ Phaser.AnimationManager.prototype = { * Play an animation based on the given key. The animation should previously have been added via sprite.animations.add() * If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself. * - * @method play - * @param {String} name The name of the animation to be played, e.g. "fire", "walk", "jump". - * @param {Number} [frameRate=null] The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. - * @param {Boolean} [loop=null] Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. + * @method Phaser.AnimationManager#play + * @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump". + * @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. + * @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. + * @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. * @return {Phaser.Animation} A reference to playing Animation instance. */ - play: function (name, frameRate, loop) { + play: function (name, frameRate, loop, killOnComplete) { if (this._anims[name]) { @@ -189,13 +192,13 @@ Phaser.AnimationManager.prototype = { { if (this.currentAnim.isPlaying == false) { - return this.currentAnim.play(frameRate, loop); + return this.currentAnim.play(frameRate, loop, killOnComplete); } } else { this.currentAnim = this._anims[name]; - return this.currentAnim.play(frameRate, loop); + return this.currentAnim.play(frameRate, loop, killOnComplete); } } @@ -205,9 +208,9 @@ Phaser.AnimationManager.prototype = { * Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the current animation is stopped. * The currentAnim property of the AnimationManager is automatically set to the animation given. * - * @method stop - * @param {String} [name=null] The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped. - * @param {Boolean} [resetFrame=false] When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false) + * @method Phaser.AnimationManager#stop + * @param {string} [name=null] - The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped. + * @param {boolean} [resetFrame=false] - When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false) */ stop: function (name, resetFrame) { @@ -234,9 +237,9 @@ Phaser.AnimationManager.prototype = { /** * The main update function is called by the Sprites update loop. It's responsible for updating animation frames and firing related events. * - * @method update + * @method Phaser.AnimationManager#update * @protected - * @return {Boolean} True if a new animation frame has been set, otherwise false. + * @return {boolean} True if a new animation frame has been set, otherwise false. */ update: function () { @@ -256,10 +259,22 @@ Phaser.AnimationManager.prototype = { }, + /** + * Refreshes the current frame data back to the parent Sprite and also resets the texture data. + * + * @method Phaser.AnimationManager#refreshFrame + */ + refreshFrame: function () { + + this.sprite.currentFrame = this.currentFrame; + this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); + + }, + /** * Destroys all references this AnimationManager contains. Sets the _anims to a new object and nulls the current animation. * - * @method destroy + * @method Phaser.AnimationManager#destroy */ destroy: function () { @@ -273,24 +288,26 @@ Phaser.AnimationManager.prototype = { }; +/** +* @name Phaser.AnimationManager#frameData +* @property {Phaser.FrameData} frameData - The current animations FrameData. +* @readonly +*/ Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", { - /** - * @method frameData - * @return {Phaser.Animation.FrameData} Returns the FrameData of the current animation. - */ get: function () { return this._frameData; } }); +/** +* @name Phaser.AnimationManager#frameTotal +* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded. +* @readonly +*/ Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", { - - /** - * @method frameTotal - * @return {Number} Returns the total number of frames in the loaded FrameData, or -1 if no FrameData is loaded. - */ + get: function () { if (this._frameData) @@ -305,12 +322,32 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", { }); +/** +* @name Phaser.AnimationManager#paused +* @property {boolean} paused - Gets and sets the paused state of the current animation. +*/ +Object.defineProperty(Phaser.AnimationManager.prototype, "paused", { + + get: function () { + + return this.currentAnim.isPaused; + + }, + + set: function (value) { + + this.currentAnim.paused = value; + + } + +}); + +/** +* @name Phaser.AnimationManager#frame +* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display. +*/ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", { - /** - * @method frame - * @return {Number} Returns the index of the current frame. - */ get: function () { if (this.currentFrame) @@ -320,13 +357,9 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", { }, - /** - * @method frame - * @param {Number} value Sets the current frame on the Sprite and updates the texture cache for display. - */ set: function (value) { - if (this._frameData && this._frameData.getFrame(value) !== null) + if (typeof value === 'number' && this._frameData && this._frameData.getFrame(value) !== null) { this.currentFrame = this._frameData.getFrame(value); this._frameIndex = value; @@ -338,12 +371,12 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", { }); +/** +* @name Phaser.AnimationManager#frameName +* @property {string} frameName - Gets or sets the current frame name and updates the Texture Cache for display. +*/ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", { - /** - * @method frameName - * @return {String} Returns the name of the current frame if it has one. - */ get: function () { if (this.currentFrame) @@ -353,13 +386,9 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", { }, - /** - * @method frameName - * @param {String} value Sets the current frame on the Sprite and updates the texture cache for display. - */ set: function (value) { - if (this._frameData && this._frameData.getFrameByName(value) !== null) + if (typeof value === 'string' && this._frameData && this._frameData.getFrameByName(value) !== null) { this.currentFrame = this._frameData.getFrameByName(value); this._frameIndex = this.currentFrame.index; diff --git a/src/animation/Parser.js b/src/animation/AnimationParser.js similarity index 63% rename from src/animation/Parser.js rename to src/animation/AnimationParser.js index 0c420392..e4006eba 100644 --- a/src/animation/Parser.js +++ b/src/animation/AnimationParser.js @@ -1,24 +1,26 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + /** * Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations. * -* @author Richard Davey -* @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Animation +* @class Phaser.AnimationParser */ - -Phaser.Animation.Parser = { +Phaser.AnimationParser = { /** * Parse a Sprite Sheet and extract the animation frame data from it. * - * @method spriteSheet - * @param {Phaser.Game} game A reference to the currently running game. - * @param {String} key The Game.Cache asset key of the Sprite Sheet image. - * @param {Number} frameWidth The fixed width of each frame of the animation. If negative, indicates how many columns there are. - * @param {Number} frameHeight The fixed height of each frame of the animation. If negative, indicates how many rows there are. - * @param {Number} [frameMax=-1] The total number of animation frames to extact from the Sprite Sheet. The default value of -1 means "extract all frames". - * @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames. + * @method Phaser.AnimationParser.spriteSheet + * @param {Phaser.Game} game - A reference to the currently running game. + * @param {string} key - The Game.Cache asset key of the Sprite Sheet image. + * @param {number} frameWidth - The fixed width of each frame of the animation. + * @param {number} frameHeight - The fixed height of each frame of the animation. + * @param {number} [frameMax=-1] - The total number of animation frames to extact from the Sprite Sheet. The default value of -1 means "extract all frames". + * @return {Phaser.FrameData} A FrameData object containing the parsed frames. */ spriteSheet: function (game, key, frameWidth, frameHeight, frameMax) { @@ -32,14 +34,17 @@ Phaser.Animation.Parser = { var width = img.width; var height = img.height; + if (frameWidth <= 0) { - frameWidth = Math.floor(-width/Math.min(-1, frameWidth)); + frameWidth = Math.floor(-width / Math.min(-1, frameWidth)); } + if (frameHeight <= 0) { - frameHeight = Math.floor(-height/Math.min(-1, frameHeight)); + frameHeight = Math.floor(-height / Math.min(-1, frameHeight)); } + var row = Math.round(width / frameWidth); var column = Math.round(height / frameHeight); var total = row * column; @@ -52,12 +57,12 @@ Phaser.Animation.Parser = { // Zero or smaller than frame sizes? if (width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0) { - console.warn("Phaser.Animation.Parser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight"); + console.warn("Phaser.AnimationParser.spriteSheet: width/height zero or width/height < given frameWidth/frameHeight"); return null; } // Let's create some frames then - var data = new Phaser.Animation.FrameData(); + var data = new Phaser.FrameData(); var x = 0; var y = 0; @@ -65,7 +70,7 @@ Phaser.Animation.Parser = { { var uuid = game.rnd.uuid(); - data.addFrame(new Phaser.Animation.Frame(i, x, y, frameWidth, frameHeight, '', uuid)); + data.addFrame(new Phaser.Frame(i, x, y, frameWidth, frameHeight, '', uuid)); PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[key], { x: x, @@ -90,24 +95,24 @@ Phaser.Animation.Parser = { /** * Parse the JSON data and extract the animation frame data from it. * - * @method JSONData - * @param {Phaser.Game} game A reference to the currently running game. - * @param {Object} json The JSON data from the Texture Atlas. Must be in Array format. - * @param {String} cacheKey The Game.Cache asset key of the texture image. - * @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames. + * @method Phaser.AnimationParser.JSONData + * @param {Phaser.Game} game - A reference to the currently running game. + * @param {Object} json - The JSON data from the Texture Atlas. Must be in Array format. + * @param {string} cacheKey - The Game.Cache asset key of the texture image. + * @return {Phaser.FrameData} A FrameData object containing the parsed frames. */ JSONData: function (game, json, cacheKey) { // Malformed? if (!json['frames']) { - console.warn("Phaser.Animation.Parser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"); + console.warn("Phaser.AnimationParser.JSONData: Invalid Texture Atlas JSON given, missing 'frames' array"); console.log(json); return; } // Let's create some frames then - var data = new Phaser.Animation.FrameData(); + var data = new Phaser.FrameData(); // By this stage frames is a fully parsed array var frames = json['frames']; @@ -117,7 +122,7 @@ Phaser.Animation.Parser = { { var uuid = game.rnd.uuid(); - newFrame = data.addFrame(new Phaser.Animation.Frame( + newFrame = data.addFrame(new Phaser.Frame( i, frames[i].frame.x, frames[i].frame.y, @@ -146,9 +151,11 @@ Phaser.Animation.Parser = { frames[i].spriteSourceSize.h ); - PIXI.TextureCache[uuid].realSize = frames[i].spriteSourceSize; - // PIXI.TextureCache[uuid].realSize = frames[i].sourceSize; - PIXI.TextureCache[uuid].trim.x = 0; + // We had to hack Pixi to get this to work :( + PIXI.TextureCache[uuid].trimmed = true; + PIXI.TextureCache[uuid].trim.x = frames[i].spriteSourceSize.x; + PIXI.TextureCache[uuid].trim.y = frames[i].spriteSourceSize.y; + } } @@ -159,24 +166,24 @@ Phaser.Animation.Parser = { /** * Parse the JSON data and extract the animation frame data from it. * - * @method JSONDataHash - * @param {Phaser.Game} game A reference to the currently running game. - * @param {Object} json The JSON data from the Texture Atlas. Must be in JSON Hash format. - * @param {String} cacheKey The Game.Cache asset key of the texture image. - * @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames. + * @method Phaser.AnimationParser.JSONDataHash + * @param {Phaser.Game} game - A reference to the currently running game. + * @param {Object} json - The JSON data from the Texture Atlas. Must be in JSON Hash format. + * @param {string} cacheKey - The Game.Cache asset key of the texture image. + * @return {Phaser.FrameData} A FrameData object containing the parsed frames. */ JSONDataHash: function (game, json, cacheKey) { // Malformed? if (!json['frames']) { - console.warn("Phaser.Animation.Parser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"); + console.warn("Phaser.AnimationParser.JSONDataHash: Invalid Texture Atlas JSON given, missing 'frames' object"); console.log(json); return; } // Let's create some frames then - var data = new Phaser.Animation.FrameData(); + var data = new Phaser.FrameData(); // By this stage frames is a fully parsed array var frames = json['frames']; @@ -187,7 +194,7 @@ Phaser.Animation.Parser = { { var uuid = game.rnd.uuid(); - newFrame = data.addFrame(new Phaser.Animation.Frame( + newFrame = data.addFrame(new Phaser.Frame( i, frames[key].frame.x, frames[key].frame.y, @@ -216,9 +223,11 @@ Phaser.Animation.Parser = { frames[key].spriteSourceSize.h ); - PIXI.TextureCache[uuid].realSize = frames[key].spriteSourceSize; - // PIXI.TextureCache[uuid].realSize = frames[key].sourceSize; - PIXI.TextureCache[uuid].trim.x = 0; + // We had to hack Pixi to get this to work :( + PIXI.TextureCache[uuid].trimmed = true; + PIXI.TextureCache[uuid].trim.x = frames[key].spriteSourceSize.x; + PIXI.TextureCache[uuid].trim.y = frames[key].spriteSourceSize.y; + } i++; @@ -231,23 +240,23 @@ Phaser.Animation.Parser = { /** * Parse the XML data and extract the animation frame data from it. * - * @method XMLData - * @param {Phaser.Game} game A reference to the currently running game. - * @param {Object} xml The XML data from the Texture Atlas. Must be in Starling XML format. - * @param {String} cacheKey The Game.Cache asset key of the texture image. - * @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames. + * @method Phaser.AnimationParser.XMLData + * @param {Phaser.Game} game - A reference to the currently running game. + * @param {Object} xml - The XML data from the Texture Atlas. Must be in Starling XML format. + * @param {string} cacheKey - The Game.Cache asset key of the texture image. + * @return {Phaser.FrameData} A FrameData object containing the parsed frames. */ XMLData: function (game, xml, cacheKey) { // Malformed? if (!xml.getElementsByTagName('TextureAtlas')) { - console.warn("Phaser.Animation.Parser.XMLData: Invalid Texture Atlas XML given, missing tag"); + console.warn("Phaser.AnimationParser.XMLData: Invalid Texture Atlas XML given, missing tag"); return; } // Let's create some frames then - var data = new Phaser.Animation.FrameData(); + var data = new Phaser.FrameData(); var frames = xml.getElementsByTagName('SubTexture'); var newFrame; @@ -257,7 +266,7 @@ Phaser.Animation.Parser = { var frame = frames[i].attributes; - newFrame = data.addFrame(new Phaser.Animation.Frame( + newFrame = data.addFrame(new Phaser.Frame( i, frame.x.nodeValue, frame.y.nodeValue, @@ -275,7 +284,8 @@ Phaser.Animation.Parser = { }); // Trimmed? - if (frame.frameX.nodeValue != '-0' || frame.frameY.nodeValue != '-0') { + if (frame.frameX.nodeValue != '-0' || frame.frameY.nodeValue != '-0') + { newFrame.setTrim( true, frame.width.nodeValue, @@ -293,7 +303,10 @@ Phaser.Animation.Parser = { h: frame.frameHeight.nodeValue }; - PIXI.TextureCache[uuid].trim.x = 0; + // We had to hack Pixi to get this to work :( + PIXI.TextureCache[uuid].trimmed = true; + PIXI.TextureCache[uuid].trim.x = Math.abs(frame.frameX.nodeValue); + PIXI.TextureCache[uuid].trim.y = Math.abs(frame.frameY.nodeValue); } } diff --git a/src/animation/Frame.js b/src/animation/Frame.js index 35132c13..bba87347 100644 --- a/src/animation/Frame.js +++ b/src/animation/Frame.js @@ -1,198 +1,141 @@ /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Animation +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** * A Frame is a single frame of an animation and is part of a FrameData collection. * -* @class Frame +* @class Phaser.Frame * @constructor -* @param {Number} index The index of this Frame within the FrameData set it is being added to. -* @param {Number} x X position of the frame within the texture image. -* @param {Number} y Y position of the frame within the texture image. -* @param {Number} width Width of the frame within the texture image. -* @param {Number} height Height of the frame within the texture image. -* @param {String} name The name of the frame. In Texture Atlas data this is usually set to the filename. -* @param {String} uuid Internal UUID key. +* @param {number} index - The index of this Frame within the FrameData set it is being added to. +* @param {number} x - X position of the frame within the texture image. +* @param {number} y - Y position of the frame within the texture image. +* @param {number} width - Width of the frame within the texture image. +* @param {number} height - Height of the frame within the texture image. +* @param {string} name - The name of the frame. In Texture Atlas data this is usually set to the filename. +* @param {string} uuid - Internal UUID key. */ -Phaser.Animation.Frame = function (index, x, y, width, height, name, uuid) { +Phaser.Frame = function (index, x, y, width, height, name, uuid) { /** - * The index of this Frame within the FrameData set it is being added to. - * @property index - * @public - * @type {Number} + * @property {number} index - The index of this Frame within the FrameData set it is being added to. */ this.index = index; - + /** - * X position within the image to cut from. - * @property x - * @public - * @type {Number} + * @property {number} x - X position within the image to cut from. */ this.x = x; /** - * Y position within the image to cut from. - * @property y - * @public - * @type {Number} + * @property {number} y - Y position within the image to cut from. */ this.y = y; /** - * Width of the frame. - * @property width - * @public - * @type {Number} + * @property {number} width - Width of the frame. */ this.width = width; /** - * Height of the frame. - * @property height - * @public - * @type {Number} + * @property {number} height - Height of the frame. */ this.height = height; /** - * Useful for Texture Atlas files. (is set to the filename value) - * @property name - * @public - * @type {String} + * @property {string} name - Useful for Texture Atlas files (is set to the filename value). */ this.name = name; /** - * A link to the PIXI.TextureCache entry - * @property uuid - * @public - * @type {String} + * @property {string} uuid - A link to the PIXI.TextureCache entry. */ this.uuid = uuid; /** - * center X position within the image to cut from. - * @property centerX - * @public - * @type {Number} + * @property {number} centerX - Center X position within the image to cut from. */ this.centerX = Math.floor(width / 2); /** - * center Y position within the image to cut from. - * @property centerY - * @public - * @type {Number} + * @property {number} centerY - Center Y position within the image to cut from. */ this.centerY = Math.floor(height / 2); /** - * The distance from the top left to the bottom-right of this Frame. - * @property distance - * @public - * @type {Number} + * @property {number} distance - The distance from the top left to the bottom-right of this Frame. */ this.distance = Phaser.Math.distance(0, 0, width, height); /** - * Rotated? (not yet implemented) - * @property rotated - * @public - * @type {Boolean} - * @default false + * @property {boolean} rotated - Rotated? (not yet implemented) + * @default */ this.rotated = false; /** - * Either cw or ccw, rotation is always 90 degrees. - * @property rotationDirection - * @public - * @type {String} - * @default "cw" + * @property {string} rotationDirection - Either 'cw' or 'ccw', rotation is always 90 degrees. + * @default 'cw' */ this.rotationDirection = 'cw'; /** - * Was it trimmed when packed? - * @property trimmed - * @public - * @type {Boolean} + * @property {boolean} trimmed - Was it trimmed when packed? + * @default */ this.trimmed = false; /** - * Width of the original sprite. - * @property sourceSizeW - * @public - * @type {Number} + * @property {number} sourceSizeW - Width of the original sprite. */ this.sourceSizeW = width; /** - * Height of the original sprite. - * @property sourceSizeH - * @public - * @type {Number} + * @property {number} sourceSizeH - Height of the original sprite. */ this.sourceSizeH = height; /** - * X position of the trimmed sprite inside original sprite. - * @property spriteSourceSizeX - * @public - * @type {Number} - * @default 0 + * @property {number} spriteSourceSizeX - X position of the trimmed sprite inside original sprite. + * @default */ this.spriteSourceSizeX = 0; /** - * Y position of the trimmed sprite inside original sprite. - * @property spriteSourceSizeY - * @public - * @type {Number} - * @default 0 + * @property {number} spriteSourceSizeY - Y position of the trimmed sprite inside original sprite. + * @default */ this.spriteSourceSizeY = 0; /** - * Width of the trimmed sprite. - * @property spriteSourceSizeW - * @public - * @type {Number} - * @default 0 + * @property {number} spriteSourceSizeW - Width of the trimmed sprite. + * @default */ this.spriteSourceSizeW = 0; /** - * Height of the trimmed sprite. - * @property spriteSourceSizeH - * @public - * @type {Number} - * @default 0 + * @property {number} spriteSourceSizeH - Height of the trimmed sprite. + * @default */ this.spriteSourceSizeH = 0; }; -Phaser.Animation.Frame.prototype = { +Phaser.Frame.prototype = { /** * If the frame was trimmed when added to the Texture Atlas this records the trim and source data. * - * @method setTrim - * @param {Boolean} trimmed If this frame was trimmed or not. - * @param {Number} actualWidth The width of the frame before being trimmed. - * @param {Number} actualHeight The height of the frame before being trimmed. - * @param {Number} destX The destination X position of the trimmed frame for display. - * @param {Number} destY The destination Y position of the trimmed frame for display. - * @param {Number} destWidth The destination width of the trimmed frame for display. - * @param {Number} destHeight The destination height of the trimmed frame for display. + * @method Phaser.Frame#setTrim + * @param {boolean} trimmed - If this frame was trimmed or not. + * @param {number} actualWidth - The width of the frame before being trimmed. + * @param {number} actualHeight - The height of the frame before being trimmed. + * @param {number} destX - The destination X position of the trimmed frame for display. + * @param {number} destY - The destination Y position of the trimmed frame for display. + * @param {number} destWidth - The destination width of the trimmed frame for display. + * @param {number} destHeight - The destination height of the trimmed frame for display. */ setTrim: function (trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) { diff --git a/src/animation/FrameData.js b/src/animation/FrameData.js index b4f5d407..59a7b549 100644 --- a/src/animation/FrameData.js +++ b/src/animation/FrameData.js @@ -1,44 +1,40 @@ /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Animation.FrameData +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** * FrameData is a container for Frame objects, which are the internal representation of animation data in Phaser. * -* @class FrameData +* @class Phaser.FrameData * @constructor */ -Phaser.Animation.FrameData = function () { +Phaser.FrameData = function () { - /** - * Local array of frames. - * @property _frames - * @private - * @type {Array} - */ + /** + * @property {Array} _frames - Local array of frames. + * @private + */ this._frames = []; - /** - * Local array of frame names for name to index conversions. - * @property _frameNames - * @private - * @type {Array} - */ + + /** + * @property {Array} _frameNames - Local array of frame names for name to index conversions. + * @private + */ this._frameNames = []; }; -Phaser.Animation.FrameData.prototype = { +Phaser.FrameData.prototype = { /** * Adds a new Frame to this FrameData collection. Typically called by the Animation.Parser and not directly. * - * @method addFrame - * @param {Phaser.Animation.Frame} frame The frame to add to this FrameData set. - * @return {Phaser.Animation.Frame} The frame that was just added. + * @method Phaser.FrameData#addFrame + * @param {Phaser.Frame} frame - The frame to add to this FrameData set. + * @return {Phaser.Frame} The frame that was just added. */ addFrame: function (frame) { @@ -58,13 +54,13 @@ Phaser.Animation.FrameData.prototype = { /** * Get a Frame by its numerical index. * - * @method getFrame - * @param {Number} index The index of the frame you want to get. - * @return {Phaser.Animation.Frame} The frame, if found. + * @method Phaser.FrameData#getFrame + * @param {number} index - The index of the frame you want to get. + * @return {Phaser.Frame} The frame, if found. */ getFrame: function (index) { - if (this._frames[index]) + if (this._frames.length > index) { return this._frames[index]; } @@ -76,9 +72,9 @@ Phaser.Animation.FrameData.prototype = { /** * Get a Frame by its frame name. * - * @method getFrameByName - * @param {String} name The name of the frame you want to get. - * @return {Phaser.Animation.Frame} The frame, if found. + * @method Phaser.FrameData#getFrameByName + * @param {string} name - The name of the frame you want to get. + * @return {Phaser.Frame} The frame, if found. */ getFrameByName: function (name) { @@ -94,9 +90,9 @@ Phaser.Animation.FrameData.prototype = { /** * Check if there is a Frame with the given name. * - * @method checkFrameName - * @param {String} name The name of the frame you want to check. - * @return {Boolean} True if the frame is found, otherwise false. + * @method Phaser.FrameData#checkFrameName + * @param {string} name - The name of the frame you want to check. + * @return {boolean} True if the frame is found, otherwise false. */ checkFrameName: function (name) { @@ -112,10 +108,10 @@ Phaser.Animation.FrameData.prototype = { /** * Returns a range of frames based on the given start and end frame indexes and returns them in an Array. * - * @method getFrameRange - * @param {Number} start The starting frame index. - * @param {Number} end The ending frame index. - * @param {Array} [output] Optional array. If given the results will be appended to the end of this Array. + * @method Phaser.FrameData#getFrameRange + * @param {number} start - The starting frame index. + * @param {number} end - The ending frame index. + * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created. * @return {Array} An array of Frames between the start and end index values, or an empty array if none were found. */ getFrameRange: function (start, end, output) { @@ -135,10 +131,10 @@ Phaser.Animation.FrameData.prototype = { * Returns all of the Frames in this FrameData set where the frame index is found in the input array. * The frames are returned in the output array, or if none is provided in a new Array object. * - * @method getFrames - * @param {Array} frames An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned. - * @param {Boolean} [useNumericIndex=true] Are the given frames using numeric indexes (default) or strings? (false) - * @param {Array} [output] Optional array. If given the results will be appended to the end of this Array, otherwise a new array is created. + * @method Phaser.FrameData#getFrames + * @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned. + * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false) + * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created. * @return {Array} An array of all Frames in this FrameData set matching the given names or IDs. */ getFrames: function (frames, useNumericIndex, output) { @@ -182,10 +178,10 @@ Phaser.Animation.FrameData.prototype = { * Returns all of the Frame indexes in this FrameData set. * The frames indexes are returned in the output array, or if none is provided in a new Array object. * - * @method getFrameIndexes - * @param {Array} frames An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned. - * @param {Boolean} [useNumericIndex=true] Are the given frames using numeric indexes (default) or strings? (false) - * @param {Array} [output] Optional array. If given the results will be appended to the end of this Array, otherwise a new array is created. + * @method Phaser.FrameData#getFrameIndexes + * @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned. + * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false) + * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created. * @return {Array} An array of all Frame indexes matching the given names or IDs. */ getFrameIndexes: function (frames, useNumericIndex, output) { @@ -213,7 +209,10 @@ Phaser.Animation.FrameData.prototype = { } else { - output.push(this.getFrameByName(frames[i]).index); + if (this.getFrameByName(frames[i])) + { + output.push(this.getFrameByName(frames[i]).index); + } } } } @@ -224,17 +223,15 @@ Phaser.Animation.FrameData.prototype = { }; -Object.defineProperty(Phaser.Animation.FrameData.prototype, "total", { +/** +* @name Phaser.FrameData#total +* @property {number} total - The total number of frames in this FrameData set. +* @readonly +*/ +Object.defineProperty(Phaser.FrameData.prototype, "total", { - /** - * Returns the total number of frames in this FrameData set. - * - * @method total - * @return {Number} The total number of frames in this FrameData set. - */ get: function () { return this._frames.length; } }); - diff --git a/src/core/Camera.js b/src/core/Camera.js index e5da9e26..6b9b40bb 100644 --- a/src/core/Camera.js +++ b/src/core/Camera.js @@ -1,123 +1,125 @@ /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Camera +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** -* * A Camera is your view into the game world. It has a position and size and renders only those objects within its field of view. * The game automatically creates a single Stage sized camera on boot. Move the camera around the world with Phaser.Camera.x/y * -* @class Camera +* @class Phaser.Camera * @constructor -* @param {Phaser.Game} game game reference to the currently running game. -* @param {number} id not being used at the moment, will be when Phaser supports multiple camera -* @param {number} x position of the camera on the X axis -* @param {number} y position of the camera on the Y axis -* @param {number} width the width of the view rectangle -* @param {number} height the height of the view rectangle +* @param {Phaser.Game} game - Game reference to the currently running game. +* @param {number} id - Not being used at the moment, will be when Phaser supports multiple camera +* @param {number} x - Position of the camera on the X axis +* @param {number} y - Position of the camera on the Y axis +* @param {number} width - The width of the view rectangle +* @param {number} height - The height of the view rectangle */ - Phaser.Camera = function (game, id, x, y, width, height) { - - /** - * A reference to the currently running Game. - * @property game - * @public - * @type {Phaser.Game} - */ + + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; - /** - * A reference to the game world - * @property world - * @public - * @type {Phaser.World} - */ + /** + * @property {Phaser.World} world - A reference to the game world. + */ this.world = game.world; - /** - * reserved for future multiple camera set-ups - * @property id - * @public - * @type {number} - */ + /** + * @property {number} id - Reserved for future multiple camera set-ups. + * @default + */ this.id = 0; - /** - * Camera view. - * The view into the world we wish to render (by default the game dimensions) - * The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render - * Objects outside of this view are not rendered (unless set to ignore the Camera, i.e. UI?) - * @property view - * @public - * @type {Phaser.Rectangle} - */ + /** + * Camera view. + * The view into the world we wish to render (by default the game dimensions). + * The x/y values are in world coordinates, not screen coordinates, the width/height is how many pixels to render. + * Objects outside of this view are not rendered (unless set to ignore the Camera, i.e. UI?). + * @property {Phaser.Rectangle} view + */ this.view = new Phaser.Rectangle(x, y, width, height); /** - * Used by Sprites to work out Camera culling. - * @property screenView - * @public - * @type {Phaser.Rectangle} - */ + * @property {Phaser.Rectangle} screenView - Used by Sprites to work out Camera culling. + */ this.screenView = new Phaser.Rectangle(x, y, width, height); /** - * Sprite moving inside this Rectangle will not cause camera moving. - * @property deadzone - * @type {Phaser.Rectangle} + * The Camera is bound to this Rectangle and cannot move outside of it. By default it is enabled and set to the size of the World. + * The Rectangle can be located anywhere in the world and updated as often as you like. If you don't wish the Camera to be bound + * at all then set this to null. The values can be anything and are in World coordinates, with 0,0 being the center of the world. + * @property {Phaser.Rectangle} bounds - The Rectangle in which the Camera is bounded. Set to null to allow for movement anywhere. */ + this.bounds = new Phaser.Rectangle(x, y, width, height); + + /** + * @property {Phaser.Rectangle} deadzone - Moving inside this Rectangle will not cause camera moving. + */ this.deadzone = null; - /** - * Whether this camera is visible or not. (default is true) - * @property visible - * @public - * @default true - * @type {bool} - */ + /** + * @property {boolean} visible - Whether this camera is visible or not. + * @default + */ this.visible = true; - /** - * Whether this camera is flush with the World Bounds or not. - * @property atLimit - * @type {bool} + /** + * @property {boolean} atLimit - Whether this camera is flush with the World Bounds or not. */ this.atLimit = { x: false, y: false }; - /** - * If the camera is tracking a Sprite, this is a reference to it, otherwise null - * @property target - * @public - * @type {Phaser.Sprite} + /** + * @property {Phaser.Sprite} target - If the camera is tracking a Sprite, this is a reference to it, otherwise null. + * @default */ this.target = null; - /** - * Edge property - * @property edge + /** + * @property {number} edge - Edge property. * @private - * @type {number} + * @default */ this._edge = 0; + + this.displayObject = null; }; -// Consts +/** +* @constant +* @type {number} +*/ Phaser.Camera.FOLLOW_LOCKON = 0; + +/** +* @constant +* @type {number} +*/ Phaser.Camera.FOLLOW_PLATFORMER = 1; + +/** +* @constant +* @type {number} +*/ Phaser.Camera.FOLLOW_TOPDOWN = 2; + +/** +* @constant +* @type {number} +*/ Phaser.Camera.FOLLOW_TOPDOWN_TIGHT = 3; Phaser.Camera.prototype = { /** * Tells this camera which sprite to follow. - * @method follow - * @param {Phaser.Sprite} target The object you want the camera to track. Set to null to not follow anything. + * @method Phaser.Camera#follow + * @param {Phaser.Sprite} target - The object you want the camera to track. Set to null to not follow anything. * @param {number} [style] Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow(). */ follow: function (target, style) { @@ -152,103 +154,136 @@ Phaser.Camera.prototype = { break; } + }, + + /** + * Move the camera focus on a display object instantly. + * @method Phaser.Camera#focusOn + * @param {any} displayObject - The display object to focus the camera on. Must have visible x/y properties. + */ + focusOn: function (displayObject) { + + this.setPosition(Math.round(displayObject.x - this.view.halfWidth), Math.round(displayObject.y - this.view.halfHeight)); + }, /** - * Move the camera focus to a location instantly. - * @method focusOnXY - * @param {number} x X position. - * @param {number} y Y position. + * Move the camera focus on a location instantly. + * @method Phaser.Camera#focusOnXY + * @param {number} x - X position. + * @param {number} y - Y position. */ focusOnXY: function (x, y) { - this.view.x = Math.round(x - this.view.halfWidth); - this.view.y = Math.round(y - this.view.halfHeight); + this.setPosition(Math.round(x - this.view.halfWidth), Math.round(y - this.view.halfHeight)); }, /** * Update focusing and scrolling. - * @method update + * @method Phaser.Camera#update */ update: function () { - // Add dirty flag - - if (this.target !== null) + if (this.target) { - if (this.deadzone) - { - this._edge = this.target.x - this.deadzone.x; - - if (this.view.x > this._edge) - { - this.view.x = this._edge; - } - - this._edge = this.target.x + this.target.width - this.deadzone.x - this.deadzone.width; - - if (this.view.x < this._edge) - { - this.view.x = this._edge; - } - - this._edge = this.target.y - this.deadzone.y; - - if (this.view.y > this._edge) - { - this.view.y = this._edge; - } - - this._edge = this.target.y + this.target.height - this.deadzone.y - this.deadzone.height; - - if (this.view.y < this._edge) - { - this.view.y = this._edge; - } - } - else - { - this.focusOnXY(this.target.x, this.target.y); - } + this.updateTarget(); } - this.checkWorldBounds(); + if (this.bounds) + { + this.checkBounds(); + } + + if (this.view.x !== -this.displayObject.position.x) + { + this.displayObject.position.x = -this.view.x; + } + + if (this.view.y !== -this.displayObject.position.y) + { + this.displayObject.position.y = -this.view.y; + } + + }, + + updateTarget: function () { + + if (this.deadzone) + { + this._edge = this.target.x - this.deadzone.x; + + if (this.view.x > this._edge) + { + this.view.x = this._edge; + } + + this._edge = this.target.x + this.target.width - this.deadzone.x - this.deadzone.width; + + if (this.view.x < this._edge) + { + this.view.x = this._edge; + } + + this._edge = this.target.y - this.deadzone.y; + + if (this.view.y > this._edge) + { + this.view.y = this._edge; + } + + this._edge = this.target.y + this.target.height - this.deadzone.y - this.deadzone.height; + + if (this.view.y < this._edge) + { + this.view.y = this._edge; + } + } + else + { + this.focusOnXY(this.target.x, this.target.y); + } + + }, + + setBoundsToWorld: function () { + + this.bounds.setTo(this.game.world.x, this.game.world.y, this.game.world.width, this.game.world.height); }, /** - * Method called to ensure the camera doesn't venture outside of the game world - * @method checkWorldBounds + * Method called to ensure the camera doesn't venture outside of the game world. + * @method Phaser.Camera#checkWorldBounds */ - checkWorldBounds: function () { + checkBounds: function () { this.atLimit.x = false; this.atLimit.y = false; - // Make sure we didn't go outside the cameras worldBounds - if (this.view.x < this.world.bounds.left) + // Make sure we didn't go outside the cameras bounds + if (this.view.x < this.bounds.x) { this.atLimit.x = true; - this.view.x = this.world.bounds.left; + this.view.x = this.bounds.x; } - if (this.view.x > this.world.bounds.right - this.width) + if (this.view.x > this.bounds.right - this.width) { this.atLimit.x = true; - this.view.x = (this.world.bounds.right - this.width) + 1; + this.view.x = (this.bounds.right - this.width) + 1; } - if (this.view.y < this.world.bounds.top) + if (this.view.y < this.bounds.top) { this.atLimit.y = true; - this.view.y = this.world.bounds.top; + this.view.y = this.bounds.top; } - if (this.view.y > this.world.bounds.bottom - this.height) + if (this.view.y > this.bounds.bottom - this.height) { this.atLimit.y = true; - this.view.y = (this.world.bounds.bottom - this.height) + 1; + this.view.y = (this.bounds.bottom - this.height) + 1; } this.view.floor(); @@ -257,26 +292,30 @@ Phaser.Camera.prototype = { /** * A helper function to set both the X and Y properties of the camera at once - * without having to use game.camera.x and game.camera.y + * without having to use game.camera.x and game.camera.y. * - * @method setPosition - * @param {number} x X position. - * @param {number} y Y position. + * @method Phaser.Camera#setPosition + * @param {number} x - X position. + * @param {number} y - Y position. */ setPosition: function (x, y) { this.view.x = x; this.view.y = y; - this.checkWorldBounds(); + + if (this.bounds) + { + this.checkBounds(); + } }, /** - * Sets the size of the view rectangle given the width and height in parameters + * Sets the size of the view rectangle given the width and height in parameters. * - * @method setSize - * @param {number} width The desired width. - * @param {number} height The desired height. + * @method Phaser.Camera#setSize + * @param {number} width - The desired width. + * @param {number} height - The desired height. */ setSize: function (width, height) { @@ -287,81 +326,80 @@ Phaser.Camera.prototype = { }; +/** +* The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds. +* @name Phaser.Camera#x +* @property {number} x - Gets or sets the cameras x position. +*/ Object.defineProperty(Phaser.Camera.prototype, "x", { - /** - * @method x - * @return {Number} The x position - */ get: function () { return this.view.x; }, - /** - * @method x - * @return {Number} Sets the camera's x position and clamp it if it's outside the world bounds - */ + set: function (value) { + this.view.x = value; - this.checkWorldBounds(); + + if (this.bounds) + { + this.checkBounds(); + } } }); +/** +* The Cameras y coordinate. This value is automatically clamped if it falls outside of the World bounds. +* @name Phaser.Camera#y +* @property {number} y - Gets or sets the cameras y position. +*/ Object.defineProperty(Phaser.Camera.prototype, "y", { - - /** - * @method y - * @return {Number} The y position - */ + get: function () { return this.view.y; }, - /** - * @method y - * @return {Number} Sets the camera's y position and clamp it if it's outside the world bounds - */ set: function (value) { + this.view.y = value; - this.checkWorldBounds(); + + if (this.bounds) + { + this.checkBounds(); + } } }); +/** +* The Cameras width. By default this is the same as the Game size and should not be adjusted for now. +* @name Phaser.Camera#width +* @property {number} width - Gets or sets the cameras width. +*/ Object.defineProperty(Phaser.Camera.prototype, "width", { - /** - * @method width - * @return {Number} The width of the view rectangle, in pixels - */ get: function () { return this.view.width; }, - /** - * @method width - * @return {Number} Sets the width of the view rectangle - */ set: function (value) { this.view.width = value; } }); +/** +* The Cameras height. By default this is the same as the Game size and should not be adjusted for now. +* @name Phaser.Camera#height +* @property {number} height - Gets or sets the cameras height. +*/ Object.defineProperty(Phaser.Camera.prototype, "height", { - /** - * @method height - * @return {Number} The height of the view rectangle, in pixels - */ get: function () { return this.view.height; }, - /** - * @method height - * @return {Number} Sets the height of the view rectangle - */ set: function (value) { this.view.height = value; } diff --git a/src/core/Game.js b/src/core/Game.js index 41c63da7..73fd060a 100644 --- a/src/core/Game.js +++ b/src/core/Game.js @@ -1,28 +1,26 @@ /** -* Phaser.Game -* -* This is where the magic happens. The Game object is the heart of your game, -* providing quick access to common functions and handling the boot process. -* -* "Hell, there are no rules here - we're trying to accomplish something." -* Thomas A. Edison -* -* @package Phaser.Game -* @author Richard Davey -* @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** * Game constructor * * Instantiate a new Phaser.Game object. -* +* @class Phaser.Game +* @classdesc This is where the magic happens. The Game object is the heart of your game, +* providing quick access to common functions and handling the boot process. +*

    "Hell, there are no rules here - we're trying to accomplish something."


    +* Thomas A. Edison * @constructor -* @param width {number} The width of your game in game pixels. -* @param height {number} The height of your game in game pixels. -* @param renderer {number} Which renderer to use (canvas or webgl) -* @param parent {string} ID of its parent DOM element. +* @param {number} width - The width of your game in game pixels. +* @param {number} height - The height of your game in game pixels. +* @param {number} renderer -Which renderer to use (canvas or webgl) +* @param {HTMLElement} parent -The Games DOM parent. +* @param {Description} state - Description. +* @param {boolean} transparent - Use a transparent canvas background or not. +* @param {boolean} antialias - Anti-alias graphics. */ Phaser.Game = function (width, height, renderer, parent, state, transparent, antialias) { @@ -31,206 +29,201 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant renderer = renderer || Phaser.AUTO; parent = parent || ''; state = state || null; - transparent = transparent || false; - antialias = typeof antialias === 'undefined' ? true : antialias; + + if (typeof transparent == 'undefined') { transparent = false; } + if (typeof antialias == 'undefined') { antialias = true; } /** - * Phaser Game ID (for when Pixi supports multiple instances) - * @type {number} + * @property {number} id - Phaser Game ID (for when Pixi supports multiple instances). */ this.id = Phaser.GAMES.push(this) - 1; /** - * The Games DOM parent. - * @type {HTMLElement} + * @property {HTMLElement} parent - The Games DOM parent. */ this.parent = parent; // Do some more intelligent size parsing here, so they can set "100%" for example, maybe pass the scale mode in here too? /** - * The Game width (in pixels). - * @type {number} + * @property {number} width - The Game width (in pixels). */ this.width = width; /** - * The Game height (in pixels). - * @type {number} + * @property {number} height - The Game height (in pixels). */ this.height = height; /** - * Use a transparent canvas background or not. - * @type {boolean} + * @property {boolean} transparent - Use a transparent canvas background or not. */ this.transparent = transparent; /** - * Anti-alias graphics (in WebGL this helps with edges, in Canvas2D it retains pixel-art quality) - * @type {boolean} + * @property {boolean} antialias - Anti-alias graphics (in WebGL this helps with edges, in Canvas2D it retains pixel-art quality). */ this.antialias = antialias; /** - * The Pixi Renderer - * @type {number} + * @property {number} renderer - The Pixi Renderer + * @default */ this.renderer = null; - /** - * The StateManager. - * @type {Phaser.StateManager} - */ + /** + * @property {number} state - The StateManager. + */ this.state = new Phaser.StateManager(this, state); /** - * Is game paused? - * @type {bool} + * @property {boolean} _paused - Is game paused? + * @private + * @default */ this._paused = false; /** - * The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL - * @type {number} + * @property {number} renderType - The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL. */ this.renderType = renderer; /** - * Whether load complete loading or not. - * @type {bool} + * @property {boolean} _loadComplete - Whether load complete loading or not. + * @private + * @default */ this._loadComplete = false; /** - * Whether the game engine is booted, aka available. - * @type {bool} + * @property {boolean} isBooted - Whether the game engine is booted, aka available. + * @default */ this.isBooted = false; /** - * Is game running or paused? - * @type {bool} + * @property {boolean} id -Is game running or paused? + * @default */ this.isRunning = false; /** - * Automatically handles the core game loop via requestAnimationFrame or setTimeout - * @type {Phaser.RequestAnimationFrame} + * @property {Phaser.RequestAnimationFrame} raf - Automatically handles the core game loop via requestAnimationFrame or setTimeout + * @default */ this.raf = null; - /** - * Reference to the GameObject Factory. - * @type {Phaser.GameObjectFactory} - */ + /** + * @property {Phaser.GameObjectFactory} add - Reference to the GameObject Factory. + * @default + */ this.add = null; /** - * Reference to the assets cache. - * @type {Phaser.Cache} - */ + * @property {Phaser.Cache} cache - Reference to the assets cache. + * @default + */ this.cache = null; /** - * Reference to the input manager - * @type {Phaser.Input} - */ + * @property {Phaser.Input} input - Reference to the input manager + * @default + */ this.input = null; /** - * Reference to the assets loader. - * @type {Phaser.Loader} - */ + * @property {Phaser.Loader} load - Reference to the assets loader. + * @default + */ this.load = null; /** - * Reference to the math helper. - * @type {Phaser.GameMath} - */ + * @property {Phaser.GameMath} math - Reference to the math helper. + * @default + */ this.math = null; /** - * Reference to the network class. - * @type {Phaser.Net} - */ + * @property {Phaser.Net} net - Reference to the network class. + * @default + */ this.net = null; /** - * Reference to the sound manager. - * @type {Phaser.SoundManager} - */ + * @property {Phaser.SoundManager} sound - Reference to the sound manager. + * @default + */ this.sound = null; /** - * Reference to the stage. - * @type {Phaser.Stage} - */ + * @property {Phaser.Stage} stage - Reference to the stage. + * @default + */ this.stage = null; /** - * Reference to game clock. - * @type {Phaser.TimeManager} - */ + * @property {Phaser.TimeManager} time - Reference to game clock. + * @default + */ this.time = null; /** - * Reference to the tween manager. - * @type {Phaser.TweenManager} - */ + * @property {Phaser.TweenManager} tweens - Reference to the tween manager. + * @default + */ this.tweens = null; /** - * Reference to the world. - * @type {Phaser.World} - */ + * @property {Phaser.World} world - Reference to the world. + * @default + */ this.world = null; /** - * Reference to the physics manager. - * @type {Phaser.Physics.PhysicsManager} - */ + * @property {Phaser.Physics.PhysicsManager} physics - Reference to the physics manager. + * @default + */ this.physics = null; /** - * Instance of repeatable random data generator helper. - * @type {Phaser.RandomDataGenerator} - */ + * @property {Phaser.RandomDataGenerator} rnd - Instance of repeatable random data generator helper. + * @default + */ this.rnd = null; /** - * Contains device information and capabilities. - * @type {Phaser.Device} - */ + * @property {Phaser.Device} device - Contains device information and capabilities. + * @default + */ this.device = null; - /** - * A handy reference to world.camera - * @type {Phaser.Camera} + /** + * @property {Phaser.Physics.PhysicsManager} camera - A handy reference to world.camera. + * @default */ this.camera = null; - /** - * A handy reference to renderer.view - * @type {HTMLCanvasElement} + /** + * @property {HTMLCanvasElement} canvas - A handy reference to renderer.view. + * @default */ this.canvas = null; /** - * A handy reference to renderer.context (only set for CANVAS games) - * @type {Context} + * @property {Context} context - A handy reference to renderer.context (only set for CANVAS games) + * @default */ this.context = null; - /** - * A set of useful debug utilities - * @type {Phaser.Utils.Debug} + /** + * @property {Phaser.Utils.Debug} debug - A set of useful debug utilitie. + * @default */ this.debug = null; /** - * The Particle Manager - * @type {Phaser.Particles} + * @property {Phaser.Particles} particles - The Particle Manager. + * @default */ this.particles = null; @@ -258,9 +251,9 @@ Phaser.Game.prototype = { /** * Initialize engine sub modules and start the game. - * @param parent {string} ID of parent Dom element. - * @param width {number} Width of the game screen. - * @param height {number} Height of the game screen. + * + * @method Phaser.Game#boot + * @protected */ boot: function () { @@ -305,14 +298,14 @@ Phaser.Game.prototype = { this.net = new Phaser.Net(this); this.debug = new Phaser.Utils.Debug(this); - this.load.onLoadComplete.add(this.loadComplete, this); - this.stage.boot(); this.world.boot(); this.input.boot(); this.sound.boot(); this.state.boot(); + this.load.onLoadComplete.add(this.loadComplete, this); + if (this.renderType == Phaser.CANVAS) { console.log('%cPhaser ' + Phaser.VERSION + ' initialized. Rendering to Canvas', 'color: #ffff33; background: #000000'); @@ -322,6 +315,14 @@ Phaser.Game.prototype = { console.log('%cPhaser ' + Phaser.VERSION + ' initialized. Rendering to WebGL', 'color: #ffff33; background: #000000'); } + var pos = Phaser.VERSION.indexOf('-'); + var versionQualifier = (pos >= 0) ? Phaser.VERSION.substr(pos + 1) : null; + if (versionQualifier) + { + var article = ['a', 'e', 'i', 'o', 'u', 'y'].indexOf(versionQualifier.charAt(0)) >= 0 ? 'an' : 'a'; + console.warn('You are using %s %s version of Phaser. Some things may not work.', article, versionQualifier); + } + this.isRunning = true; this._loadComplete = false; @@ -332,6 +333,12 @@ Phaser.Game.prototype = { }, + /** + * Checks if the device is capable of using the requested renderer and sets it up or an alternative if not. + * + * @method Phaser.Game#setUpRenderer + * @protected + */ setUpRenderer: function () { if (this.renderType === Phaser.CANVAS || (this.renderType === Phaser.AUTO && this.device.webGL == false)) @@ -365,6 +372,9 @@ Phaser.Game.prototype = { /** * Called when the load has finished, after preload was run. + * + * @method Phaser.Game#loadComplete + * @protected */ loadComplete: function () { @@ -374,6 +384,13 @@ Phaser.Game.prototype = { }, + /** + * The core game loop. + * + * @method Phaser.Game#update + * @protected + * @param {number} time - The current time as provided by RequestAnimationFrame. + */ update: function (time) { this.time.update(time); @@ -383,6 +400,7 @@ Phaser.Game.prototype = { this.plugins.preUpdate(); this.physics.preUpdate(); + this.stage.update(); this.input.update(); this.tweens.update(); this.sound.update(); @@ -391,6 +409,8 @@ Phaser.Game.prototype = { this.state.update(); this.plugins.update(); + this.world.postUpdate(); + this.renderer.render(this.stage._stage); this.plugins.render(); this.state.render(); @@ -402,9 +422,15 @@ Phaser.Game.prototype = { /** * Nuke the entire game from orbit + * + * @method Phaser.Game#destroy */ destroy: function () { + this.raf.stop(); + + this.input.destroy(); + this.state.destroy(); this.state = null; @@ -421,6 +447,12 @@ Phaser.Game.prototype = { }; +/** +* The paused state of the Game. A paused game doesn't update any of its subsystems. +* When a game is paused the onPause event is dispatched. When it is resumed the onResume event is dispatched. +* @name Phaser.Game#paused +* @property {boolean} paused - Gets and sets the paused state of the Game. +*/ Object.defineProperty(Phaser.Game.prototype, "paused", { get: function () { @@ -450,3 +482,6 @@ Object.defineProperty(Phaser.Game.prototype, "paused", { }); +/** +* "Deleted code is debugged code." - Jeff Sickel +*/ diff --git a/src/core/Group.js b/src/core/Group.js index 8b1dfcee..8ebf5bcc 100644 --- a/src/core/Group.js +++ b/src/core/Group.js @@ -1,13 +1,39 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser Group constructor. +* @class Phaser.Group +* @classdesc A Group is a container for display objects that allows for fast pooling, recycling and collision checks. +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {*} parent - The parent Group or DisplayObjectContainer that will hold this group, if any. +* @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging. +* @param {boolean} [useStage=false] - Should the DisplayObjectContainer this Group creates be added to the World (default, false) or direct to the Stage (true). +*/ Phaser.Group = function (game, parent, name, useStage) { - parent = parent || null; + if (typeof parent === 'undefined') + { + parent = game.world; + } - if (typeof useStage == 'undefined') + if (typeof useStage === 'undefined') { useStage = false; } + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; + + /** + * @property {string} name - A name for this Group. Not used internally but useful for debugging. + */ this.name = name || 'group'; if (useStage) @@ -24,31 +50,53 @@ Phaser.Group = function (game, parent, name, useStage) { if (parent instanceof Phaser.Group) { parent._container.addChild(this._container); + parent._container.updateTransform(); } else { parent.addChild(this._container); + parent.updateTransform(); } } else { this.game.stage._stage.addChild(this._container); + this.game.stage._stage.updateTransform(); } } + /** + * @property {number} type - Internal Phaser Type value. + * @protected + */ this.type = Phaser.GROUP; + /** + * @property {boolean} exists - If exists is true the the Group is updated, otherwise it is skipped. + * @default + */ this.exists = true; /** - * Helper for sort. - */ - this._sortIndex = 'y'; - + * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one. + */ + this.scale = new Phaser.Point(1, 1); + }; Phaser.Group.prototype = { + /** + * Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object. + * The child is automatically added to the top of the Group, so renders on-top of everything else within the Group. If you need to control + * that then see the addAt method. + * + * @see Phaser.Group#create + * @see Phaser.Group#addAt + * @method Phaser.Group#add + * @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object.. + * @return {*} The child that was added to the Group. + */ add: function (child) { if (child.group !== this) @@ -61,12 +109,23 @@ Phaser.Group.prototype = { } this._container.addChild(child); + + child.updateTransform(); } return child; }, + /** + * Adds an existing object to this Group. The object can be an instance of Phaser.Sprite, Phaser.Button or any other display object. + * The child is added to the Group at the location specified by the index value, this allows you to control child ordering. + * + * @method Phaser.Group#addAt + * @param {*} child - An instance of Phaser.Sprite, Phaser.Button or any other display object.. + * @param {number} index - The index within the Group to insert the child to. + * @return {*} The child that was added to the Group. + */ addAt: function (child, index) { if (child.group !== this) @@ -79,18 +138,40 @@ Phaser.Group.prototype = { } this._container.addChildAt(child, index); + + child.updateTransform(); } return child; }, + /** + * Returns the child found at the given index within this Group. + * + * @method Phaser.Group#getAt + * @memberof Phaser.Group + * @param {number} index - The index to return the child from. + * @return {*} The child that was found at the given index. + */ getAt: function (index) { return this._container.getChildAt(index); }, + /** + * Automatically creates a new Phaser.Sprite object and adds it to the top of this Group. + * Useful if you don't need to create the Sprite instances before-hand. + * + * @method Phaser.Group#create + * @param {number} x - The x coordinate to display the newly created Sprite at. The value is in relation to the Group.x point. + * @param {number} y - The y coordinate to display the newly created Sprite at. The value is in relation to the Group.y point. + * @param {string} key - The Game.cache key of the image that this Sprite will use. + * @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here. + * @param {boolean} [exists=true] - The default exists state of the Sprite. + * @return {Phaser.Sprite} The child that was created. + */ create: function (x, y, key, frame, exists) { if (typeof exists == 'undefined') { exists = true; } @@ -99,6 +180,8 @@ Phaser.Group.prototype = { child.group = this; child.exists = exists; + child.visible = exists; + child.alive = exists; if (child.events) { @@ -106,11 +189,57 @@ Phaser.Group.prototype = { } this._container.addChild(child); + + child.updateTransform(); return child; }, + /** + * Automatically creates multiple Phaser.Sprite objects and adds them to the top of this Group. + * Useful if you need to quickly generate a pool of identical sprites, such as bullets. By default the sprites will be set to not exist + * and will be positioned at 0, 0 (relative to the Group.x/y) + * + * @method Phaser.Group#createMultiple + * @param {number} quantity - The number of Sprites to create. + * @param {string} key - The Game.cache key of the image that this Sprite will use. + * @param {number|string} [frame] - If the Sprite image contains multiple frames you can specify which one to use here. + * @param {boolean} [exists=false] - The default exists state of the Sprite. + */ + createMultiple: function (quantity, key, frame, exists) { + + if (typeof exists == 'undefined') { exists = false; } + + for (var i = 0; i < quantity; i++) + { + var child = new Phaser.Sprite(this.game, 0, 0, key, frame); + + child.group = this; + child.exists = exists; + child.visible = exists; + child.alive = exists; + + if (child.events) + { + child.events.onAddedToGroup.dispatch(child, this); + } + + this._container.addChild(child); + child.updateTransform(); + + } + + }, + + /** + * Swaps the position of two children in this Group. + * + * @method Phaser.Group#swap + * @param {*} child1 - The first child to swap. + * @param {*} child2 - The second child to swap. + * @return {boolean} True if the swap was successful, otherwise false. + */ swap: function (child1, child2) { if (child1 === child2 || !child1.parent || !child2.parent) @@ -231,6 +360,13 @@ Phaser.Group.prototype = { }, + /** + * Brings the given child to the top of this Group so it renders above all other children. + * + * @method Phaser.Group#bringToTop + * @param {*} child - The child to bring to the top of this Group. + * @return {*} The child that was moved. + */ bringToTop: function (child) { if (child.group === this) @@ -243,12 +379,26 @@ Phaser.Group.prototype = { }, + /** + * Get the index position of the given child in this Group. + * + * @method Phaser.Group#getIndex + * @param {*} child - The child to get the index for. + * @return {number} The index of the child or -1 if it's not a member of this Group. + */ getIndex: function (child) { return this._container.children.indexOf(child); }, + /** + * Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group. + * + * @method Phaser.Group#replace + * @param {*} oldChild - The child in this Group that will be replaced. + * @param {*} newChild - The child to be inserted into this group. + */ replace: function (oldChild, newChild) { if (!this._container.first._iNext) @@ -269,11 +419,20 @@ Phaser.Group.prototype = { this._container.removeChild(oldChild); this._container.addChildAt(newChild, index); newChild.events.onAddedToGroup.dispatch(newChild, this); + newChild.updateTransform(); } }, - // key is an ARRAY of values. + /** + * Sets the given property to the given value on the child. The operation controls the assignment of the value. + * + * @method Phaser.Group#setProperty + * @param {*} child - The child to set the property value on. + * @param {array} key - An array of strings that make up the property that will be set. + * @param {*} value - The value that will be set. + * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. + */ setProperty: function (child, key, value, operation) { operation = operation || 0; @@ -327,11 +486,24 @@ Phaser.Group.prototype = { }, + /** + * This function allows you to quickly set the same property across all children of this Group to a new value. + * The operation parameter controls how the new value is assigned to the property, from simple replacement to addition and multiplication. + * + * @method Phaser.Group#setAll + * @param {string} key - The property, as a string, to be set. For example: 'body.velocity.x' + * @param {*} value - The value that will be set. + * @param {boolean} [checkAlive=false] - If set then only children with alive=true will be updated. + * @param {boolean} [checkVisible=false] - If set then only children with visible=true will be updated. + * @param {number} [operation=0] - Controls how the value is assigned. A value of 0 replaces the value with the new one. A value of 1 adds it, 2 subtracts it, 3 multiplies it and 4 divides it. + */ setAll: function (key, value, checkAlive, checkVisible, operation) { key = key.split('.'); - checkAlive = checkAlive || false; - checkVisible = checkVisible || false; + + if (typeof checkAlive === 'undefined') { checkAlive = false; } + if (typeof checkVisible === 'undefined') { checkVisible = false; } + operation = operation || 0; if (this._container.children.length > 0 && this._container.first._iNext) @@ -352,33 +524,82 @@ Phaser.Group.prototype = { }, - addAll: function (key, value, checkAlive, checkVisible) { + /** + * Adds the amount to the given property on all children in this Group. + * Group.addAll('x', 10) will add 10 to the child.x value. + * + * @method Phaser.Group#addAll + * @param {string} property - The property to increment, for example 'body.velocity.x' or 'angle'. + * @param {number} amount - The amount to increment the property by. If child.x = 10 then addAll('x', 40) would make child.x = 50. + * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. + * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. + */ + addAll: function (property, amount, checkAlive, checkVisible) { - this.setAll(key, value, checkAlive, checkVisible, 1); + this.setAll(property, amount, checkAlive, checkVisible, 1); }, - subAll: function (key, value, checkAlive, checkVisible) { + /** + * Subtracts the amount from the given property on all children in this Group. + * Group.subAll('x', 10) will minus 10 from the child.x value. + * + * @method Phaser.Group#subAll + * @param {string} property - The property to decrement, for example 'body.velocity.x' or 'angle'. + * @param {number} amount - The amount to subtract from the property. If child.x = 50 then subAll('x', 40) would make child.x = 10. + * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. + * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. + */ + subAll: function (property, amount, checkAlive, checkVisible) { - this.setAll(key, value, checkAlive, checkVisible, 2); + this.setAll(property, amount, checkAlive, checkVisible, 2); }, - multiplyAll: function (key, value, checkAlive, checkVisible) { + /** + * Multiplies the given property by the amount on all children in this Group. + * Group.multiplyAll('x', 2) will x2 the child.x value. + * + * @method Phaser.Group#multiplyAll + * @param {string} property - The property to multiply, for example 'body.velocity.x' or 'angle'. + * @param {number} amount - The amount to multiply the property by. If child.x = 10 then multiplyAll('x', 2) would make child.x = 20. + * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. + * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. + */ + multiplyAll: function (property, amount, checkAlive, checkVisible) { - this.setAll(key, value, checkAlive, checkVisible, 3); + this.setAll(property, amount, checkAlive, checkVisible, 3); }, - divideAll: function (key, value, checkAlive, checkVisible) { + /** + * Divides the given property by the amount on all children in this Group. + * Group.divideAll('x', 2) will half the child.x value. + * + * @method Phaser.Group#divideAll + * @param {string} property - The property to divide, for example 'body.velocity.x' or 'angle'. + * @param {number} amount - The amount to divide the property by. If child.x = 100 then divideAll('x', 2) would make child.x = 50. + * @param {boolean} checkAlive - If true the property will only be changed if the child is alive. + * @param {boolean} checkVisible - If true the property will only be changed if the child is visible. + */ + divideAll: function (property, amount, checkAlive, checkVisible) { - this.setAll(key, value, checkAlive, checkVisible, 4); + this.setAll(property, amount, checkAlive, checkVisible, 4); }, - callAllExists: function (callback, callbackContext, existsValue) { + /** + * Calls a function on all of the children that have exists=true in this Group. + * After the existsValue parameter you can add as many parameters as you like, which will all be passed to the child callback. + * + * @method Phaser.Group#callAllExists + * @param {function} callback - The function that exists on the children that will be called. + * @param {boolean} existsValue - Only children with exists=existsValue will be called. + * @param {...*} parameter - Additional parameters that will be passed to the callback. + */ + callAllExists: function (callback, existsValue) { - var args = Array.prototype.splice.call(arguments, 3); + var args = Array.prototype.splice.call(arguments, 2); if (this._container.children.length > 0 && this._container.first._iNext) { @@ -401,12 +622,15 @@ Phaser.Group.prototype = { /** * Calls a function on all of the children regardless if they are dead or alive (see callAllExists if you need control over that) - * You must pass the context in which the callback is applied. - * After the context you can add as many parameters as you like, which will all be passed to the child. + * After the callback parameter you can add as many extra parameters as you like, which will all be passed to the child. + * + * @method Phaser.Group#callAll + * @param {function} callback - The function that exists on the children that will be called. + * @param {...*} parameter - Additional parameters that will be passed to the callback. */ - callAll: function (callback, callbackContext) { + callAll: function (callback) { - var args = Array.prototype.splice.call(arguments, 2); + var args = Array.prototype.splice.call(arguments, 1); if (this._container.children.length > 0 && this._container.first._iNext) { @@ -427,9 +651,25 @@ Phaser.Group.prototype = { }, + /** + * Allows you to call your own function on each member of this Group. You must pass the callback and context in which it will run. + * After the checkExists parameter you can add as many parameters as you like, which will all be passed to the callback along with the child. + * For example: Group.forEach(awardBonusGold, this, true, 100, 500) + * + * @method Phaser.Group#forEach + * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter. + * @param {Object} callbackContext - The context in which the function should be called (usually 'this'). + * @param {boolean} checkExists - If set only children with exists=true will be passed to the callback, otherwise all children will be passed. + */ forEach: function (callback, callbackContext, checkExists) { - if (typeof checkExists == 'undefined') { checkExists = false; } + if (typeof checkExists === 'undefined') + { + checkExists = false; + } + + var args = Array.prototype.splice.call(arguments, 3); + args.unshift(null); if (this._container.children.length > 0 && this._container.first._iNext) { @@ -439,7 +679,8 @@ Phaser.Group.prototype = { { if (checkExists == false || (checkExists && currentNode.exists)) { - callback.call(callbackContext, currentNode); + args[0] = currentNode; + callback.apply(callbackContext, args); } currentNode = currentNode._iNext; @@ -450,8 +691,20 @@ Phaser.Group.prototype = { }, + /** + * Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run. + * You can add as many parameters as you like, which will all be passed to the callback along with the child. + * For example: Group.forEachAlive(causeDamage, this, 500) + * + * @method Phaser.Group#forEachAlive + * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter. + * @param {Object} callbackContext - The context in which the function should be called (usually 'this'). + */ forEachAlive: function (callback, callbackContext) { + var args = Array.prototype.splice.call(arguments, 2); + args.unshift(null); + if (this._container.children.length > 0 && this._container.first._iNext) { var currentNode = this._container.first._iNext; @@ -460,7 +713,8 @@ Phaser.Group.prototype = { { if (currentNode.alive) { - callback.call(callbackContext, currentNode); + args[0] = currentNode; + callback.apply(callbackContext, args); } currentNode = currentNode._iNext; @@ -471,8 +725,20 @@ Phaser.Group.prototype = { }, + /** + * Allows you to call your own function on each dead member of this Group (where alive=false). You must pass the callback and context in which it will run. + * You can add as many parameters as you like, which will all be passed to the callback along with the child. + * For example: Group.forEachDead(bringToLife, this) + * + * @method Phaser.Group#forEachDead + * @param {function} callback - The function that will be called. Each child of the Group will be passed to it as its first parameter. + * @param {Object} callbackContext - The context in which the function should be called (usually 'this'). + */ forEachDead: function (callback, callbackContext) { + var args = Array.prototype.splice.call(arguments, 2); + args.unshift(null); + if (this._container.children.length > 0 && this._container.first._iNext) { var currentNode = this._container.first._iNext; @@ -481,7 +747,8 @@ Phaser.Group.prototype = { { if (currentNode.alive == false) { - callback.call(callbackContext, currentNode); + args[0] = currentNode; + callback.apply(callbackContext, args); } currentNode = currentNode._iNext; @@ -492,8 +759,10 @@ Phaser.Group.prototype = { }, /** - * Call this function to retrieve the first object with exists == (the given state) in the group. + * Call this function to retrieve the first object with exists == (the given state) in the Group. * + * @method Phaser.Group#getFirstExists + * @param {boolean} state - True or false. * @return {Any} The first child, or null if none found. */ getFirstExists: function (state) { @@ -525,8 +794,9 @@ Phaser.Group.prototype = { /** * Call this function to retrieve the first object with alive == true in the group. - * This is handy for checking if everything's wiped out, or choosing a squad leader, etc. + * This is handy for checking if everything has been wiped out, or choosing a squad leader, etc. * + * @method Phaser.Group#getFirstAlive * @return {Any} The first alive child, or null if none found. */ getFirstAlive: function () { @@ -553,8 +823,9 @@ Phaser.Group.prototype = { /** * Call this function to retrieve the first object with alive == false in the group. - * This is handy for checking if everything's wiped out, or choosing a squad leader, etc. + * This is handy for checking if everything has been wiped out, or choosing a squad leader, etc. * + * @method Phaser.Group#getFirstDead * @return {Any} The first dead child, or null if none found. */ getFirstDead: function () { @@ -582,11 +853,12 @@ Phaser.Group.prototype = { /** * Call this function to find out how many members of the group are alive. * + * @method Phaser.Group#countLiving * @return {number} The number of children flagged as alive. Returns -1 if Group is empty. */ countLiving: function () { - var total = -1; + var total = 0; if (this._container.children.length > 0 && this._container.first._iNext) { @@ -603,6 +875,10 @@ Phaser.Group.prototype = { } while (currentNode != this._container.last._iNext); } + else + { + total = -1; + } return total; @@ -611,11 +887,12 @@ Phaser.Group.prototype = { /** * Call this function to find out how many members of the group are dead. * + * @method Phaser.Group#countDead * @return {number} The number of children flagged as dead. Returns -1 if Group is empty. */ countDead: function () { - var total = -1; + var total = 0; if (this._container.children.length > 0 && this._container.first._iNext) { @@ -632,6 +909,10 @@ Phaser.Group.prototype = { } while (currentNode != this._container.last._iNext); } + else + { + total = -1; + } return total; @@ -640,9 +921,9 @@ Phaser.Group.prototype = { /** * Returns a member at random from the group. * - * @param {number} startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array. - * @param {number} length Optional restriction on the number of values you want to randomly select from. - * + * @method Phaser.Group#getRandom + * @param {number} startIndex - Optional offset off the front of the array. Default value is 0, or the beginning of the array. + * @param {number} length - Optional restriction on the number of values you want to randomly select from. * @return {Any} A random child of this Group. */ getRandom: function (startIndex, length) { @@ -659,14 +940,31 @@ Phaser.Group.prototype = { }, + /** + * Removes the given child from this Group and sets its group property to null. + * + * @method Phaser.Group#remove + * @param {Any} child - The child to remove. + */ remove: function (child) { - child.events.onRemovedFromGroup.dispatch(child, this); + if (child.events) + { + child.events.onRemovedFromGroup.dispatch(child, this); + } + this._container.removeChild(child); + child.group = null; }, + /** + * Removes all children from this Group, setting all group properties to null. + * The Group container remains on the display list. + * + * @method Phaser.Group#removeAll + */ removeAll: function () { if (this._container.children.length == 0) @@ -686,6 +984,13 @@ Phaser.Group.prototype = { }, + /** + * Removes all children from this Group whos index falls beteen the given startIndex and endIndex values. + * + * @method Phaser.Group#removeBetween + * @param {number} startIndex - The index to start removing children from. + * @param {number} endIndex - The index to stop removing children from. Must be higher than startIndex and less than the length of the Group. + */ removeBetween: function (startIndex, endIndex) { if (this._container.children.length == 0) @@ -707,6 +1012,11 @@ Phaser.Group.prototype = { }, + /** + * Destroys this Group. Removes all children, then removes the container from the display list and nulls references. + * + * @method Phaser.Group#destroy + */ destroy: function () { this.removeAll(); @@ -721,6 +1031,12 @@ Phaser.Group.prototype = { }, + /** + * Dumps out a list of Group children and their index positions to the browser console. Useful for group debugging. + * + * @method Phaser.Group#dump + * @param {boolean} [full=false] - If full the dump will include the entire display list, start from the Stage. Otherwise it will only include this container. + */ dump: function (full) { if (typeof full == 'undefined') @@ -807,6 +1123,24 @@ Phaser.Group.prototype = { }; +/** +* @name Phaser.Group#total +* @property {number} total - The total number of children in this Group, regardless of their alive state. +* @readonly +*/ +Object.defineProperty(Phaser.Group.prototype, "total", { + + get: function () { + return this._container.children.length; + } + +}); + +/** +* @name Phaser.Group#length +* @property {number} length - The number of children in this Group. +* @readonly +*/ Object.defineProperty(Phaser.Group.prototype, "length", { get: function () { @@ -815,6 +1149,12 @@ Object.defineProperty(Phaser.Group.prototype, "length", { }); +/** +* The x coordinate of the Group container. You can adjust the Group container itself by modifying its coordinates. +* This will have no impact on the x/y coordinates of its children, but it will update their worldTransform and on-screen position. +* @name Phaser.Group#x +* @property {number} x - The x coordinate of the Group container. +*/ Object.defineProperty(Phaser.Group.prototype, "x", { get: function () { @@ -827,6 +1167,12 @@ Object.defineProperty(Phaser.Group.prototype, "x", { }); +/** +* The y coordinate of the Group container. You can adjust the Group container itself by modifying its coordinates. +* This will have no impact on the x/y coordinates of its children, but it will update their worldTransform and on-screen position. +* @name Phaser.Group#y +* @property {number} y - The y coordinate of the Group container. +*/ Object.defineProperty(Phaser.Group.prototype, "y", { get: function () { @@ -839,6 +1185,12 @@ Object.defineProperty(Phaser.Group.prototype, "y", { }); +/** +* The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation. +* This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position. +* @name Phaser.Group#angle +* @property {number} angle - The angle of rotation given in degrees, where 0 degrees = to the right. +*/ Object.defineProperty(Phaser.Group.prototype, "angle", { get: function() { @@ -851,6 +1203,12 @@ Object.defineProperty(Phaser.Group.prototype, "angle", { }); +/** +* The angle of rotation of the Group container. This will adjust the Group container itself by modifying its rotation. +* This will have no impact on the rotation value of its children, but it will update their worldTransform and on-screen position. +* @name Phaser.Group#rotation +* @property {number} rotation - The angle of rotation given in radians. +*/ Object.defineProperty(Phaser.Group.prototype, "rotation", { get: function () { @@ -863,6 +1221,10 @@ Object.defineProperty(Phaser.Group.prototype, "rotation", { }); +/** +* @name Phaser.Group#visible +* @property {boolean} visible - The visible state of the Group. Non-visible Groups and all of their children are not rendered. +*/ Object.defineProperty(Phaser.Group.prototype, "visible", { get: function () { @@ -874,3 +1236,19 @@ Object.defineProperty(Phaser.Group.prototype, "visible", { } }); + +/** +* @name Phaser.Group#alpha +* @property {number} alpha - The alpha value of the Group container. +*/ +Object.defineProperty(Phaser.Group.prototype, "alpha", { + + get: function () { + return this._container.alpha; + }, + + set: function (value) { + this._container.alpha = value; + } + +}); diff --git a/src/core/LinkedList.js b/src/core/LinkedList.js index 1cf214ce..4e3abeb0 100644 --- a/src/core/LinkedList.js +++ b/src/core/LinkedList.js @@ -1,16 +1,58 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* A basic linked list data structure. +* +* @class Phaser.LinkedList +* @constructor +*/ Phaser.LinkedList = function () { + /** + * @property {object} next - Next element in the list. + * @default + */ this.next = null; + + /** + * @property {object} prev - Previous element in the list. + * @default + */ this.prev = null; + + /** + * @property {object} first - First element in the list. + * @default + */ this.first = null; + + /** + * @property {object} last - Last element in the list. + * @default + */ this.last = null; + + /** + * @property {object} game - Number of elements in the list. + * @default + */ this.total = 0; }; Phaser.LinkedList.prototype = { - + /** + * Adds a new element to this linked list. + * + * @method Phaser.LinkedList#add + * @param {object} child - The element to add to this list. Can be a Phaser.Sprite or any other object you need to quickly iterate through. + * @return {object} The child that was added. + */ add: function (child) { // If the list is empty @@ -21,7 +63,7 @@ Phaser.LinkedList.prototype = { this.next = child; child.prev = this; this.total++; - return; + return child; } // Get gets appended to the end of the list, regardless of anything, and it won't have any children of its own (non-nested list) @@ -37,40 +79,55 @@ Phaser.LinkedList.prototype = { }, + /** + * Removes the given element from this linked list if it exists. + * + * @method Phaser.LinkedList#remove + * @param {object} child - The child to be removed from the list. + */ remove: function (child) { - // If the list is empty - if (this.first == null && this.last == null) + if (child == this.first) { - return; - } + // It was 'first', make 'first' point to first.next + this.first = this.first.next; + } + else if (child == this.last) + { + // It was 'last', make 'last' point to last.prev + this.last = this.last.prev; + } + + if (child.prev) + { + // make child.prev.next point to childs.next instead of child + child.prev.next = child.next; + } + + if (child.next) + { + // make child.next.prev point to child.prev instead of child + child.next.prev = child.prev; + } + + child.next = child.prev = null; + + if (this.first == null ) + { + this.last = null; + } this.total--; - // The only node? - if (this.first == child && this.last == child) - { - this.first = null; - this.last = null; - this.next = null; - child.next = null; - child.prev = null; - return; - } - - var childPrev = child.prev; - - // Tail node? - if (child.next) - { - // Has another node after it? - child.next.prev = child.prev; - } - - childPrev.next = child.next; - }, + /** + * Calls a function on all members of this list, using the member as the context for the callback. + * The function must exist on the member. + * + * @method Phaser.LinkedList#callAll + * @param {function} callback - The function to call. + */ callAll: function (callback) { if (!this.first || !this.last) @@ -92,79 +149,6 @@ Phaser.LinkedList.prototype = { } while(entity != this.last.next) - }, - - dump: function () { - - var spacing = 20; - - var output = "\n" + Phaser.Utils.pad('Node', spacing) + "|" + Phaser.Utils.pad('Next', spacing) + "|" + Phaser.Utils.pad('Previous', spacing) + "|" + Phaser.Utils.pad('First', spacing) + "|" + Phaser.Utils.pad('Last', spacing); - console.log(output); - - var output = Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing) + "|" + Phaser.Utils.pad('----------', spacing); - console.log(output); - - var entity = this; - - var testObject = entity.last.next; - entity = entity.first; - - do - { - var name = entity.sprite.name || '*'; - var nameNext = '-'; - var namePrev = '-'; - var nameFirst = '-'; - var nameLast = '-'; - - if (entity.next) - { - nameNext = entity.next.sprite.name; - } - - if (entity.prev) - { - namePrev = entity.prev.sprite.name; - } - - if (entity.first) - { - nameFirst = entity.first.sprite.name; - } - - if (entity.last) - { - nameLast = entity.last.sprite.name; - } - - if (typeof nameNext === 'undefined') - { - nameNext = '-'; - } - - if (typeof namePrev === 'undefined') - { - namePrev = '-'; - } - - if (typeof nameFirst === 'undefined') - { - nameFirst = '-'; - } - - if (typeof nameLast === 'undefined') - { - nameLast = '-'; - } - - var output = Phaser.Utils.pad(name, spacing) + "|" + Phaser.Utils.pad(nameNext, spacing) + "|" + Phaser.Utils.pad(namePrev, spacing) + "|" + Phaser.Utils.pad(nameFirst, spacing) + "|" + Phaser.Utils.pad(nameLast, spacing); - console.log(output); - - entity = entity.next; - - } - while(entity != testObject) - - } + } }; \ No newline at end of file diff --git a/src/core/Plugin.js b/src/core/Plugin.js index ef1a967a..14cfc3d8 100644 --- a/src/core/Plugin.js +++ b/src/core/Plugin.js @@ -1,19 +1,66 @@ /** -* Phaser - Plugin -* -* This is a base Plugin template to use for any Phaser plugin development +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* This is a base Plugin template to use for any Phaser plugin development. +* +* @class Phaser.Plugin +* @classdesc Phaser - Plugin +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {Any} parent - The object that owns this plugin, usually Phaser.PluginManager. */ Phaser.Plugin = function (game, parent) { + if (typeof parent === 'undefined') { parent = null; } + + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; + + /** + * @property {Any} parent - The parent of this plugin. If added to the PluginManager the parent will be set to that, otherwise it will be null. + */ this.parent = parent; + /** + * @property {boolean} active - A Plugin with active=true has its preUpdate and update methods called by the parent, otherwise they are skipped. + * @default + */ this.active = false; + + /** + * @property {boolean} visible - A Plugin with visible=true has its render and postRender methods called by the parent, otherwise they are skipped. + * @default + */ this.visible = false; + /** + * @property {boolean} hasPreUpdate - A flag to indicate if this plugin has a preUpdate method. + * @default + */ this.hasPreUpdate = false; + + /** + * @property {boolean} hasUpdate - A flag to indicate if this plugin has an update method. + * @default + */ this.hasUpdate = false; + + /** + * @property {boolean} hasRender - A flag to indicate if this plugin has a render method. + * @default + */ this.hasRender = false; + + /** + * @property {boolean} hasPostRender - A flag to indicate if this plugin has a postRender method. + * @default + */ this.hasPostRender = false; }; @@ -21,8 +68,9 @@ Phaser.Plugin = function (game, parent) { Phaser.Plugin.prototype = { /** - * Pre-update is called at the start of the update cycle, before any other updates have taken place (including Physics). + * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). * It is only called if active is set to true. + * @method Phaser.Plugin#preUpdate */ preUpdate: function () { }, @@ -30,6 +78,7 @@ Phaser.Plugin.prototype = { /** * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. * It is only called if active is set to true. + * @method Phaser.Plugin#update */ update: function () { }, @@ -37,6 +86,7 @@ Phaser.Plugin.prototype = { /** * Render is called right after the Game Renderer completes, but before the State.render. * It is only called if visible is set to true. + * @method Phaser.Plugin#render */ render: function () { }, @@ -44,12 +94,14 @@ Phaser.Plugin.prototype = { /** * Post-render is called after the Game Renderer and State.render have run. * It is only called if visible is set to true. + * @method Phaser.Plugin#postRender */ postRender: function () { }, /** * Clear down this Plugin and null out references + * @method Phaser.Plugin#destroy */ destroy: function () { diff --git a/src/core/PluginManager.js b/src/core/PluginManager.js index a4074f7a..29e49fd6 100644 --- a/src/core/PluginManager.js +++ b/src/core/PluginManager.js @@ -1,14 +1,41 @@ /** -* Phaser - PluginManager -* -* TODO: We can optimise this a lot by using separate hashes per function (update, render, etc) +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ +/** +* Description. +* +* @class Phaser.PluginManager +* @classdesc Phaser - PluginManager +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {Description} parent - Description. +*/ Phaser.PluginManager = function(game, parent) { + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; + + /** + * @property {Description} _parent - Description. + * @private + */ this._parent = parent; + + /** + * @property {array} plugins - Description. + */ this.plugins = []; + + /** + * @property {array} _pluginsLength - Description. + * @private + * @default + */ this._pluginsLength = 0; }; @@ -17,8 +44,10 @@ Phaser.PluginManager.prototype = { /** * Add a new Plugin to the PluginManager. - * The plugins game and parent reference are set to this game and pluginmanager parent. - * @type {Phaser.Plugin} + * The plugin's game and parent reference are set to this game and pluginmanager parent. + * @method Phaser.PluginManager#add + * @param {Phaser.Plugin} plugin - Description. + * @return {Phaser.Plugin} Description. */ add: function (plugin) { @@ -82,6 +111,11 @@ Phaser.PluginManager.prototype = { } }, + /** + * Remove a Plugin from the PluginManager. + * @method Phaser.PluginManager#remove + * @param {Phaser.Plugin} plugin - The plugin to be removed. + */ remove: function (plugin) { // TODO @@ -89,6 +123,12 @@ Phaser.PluginManager.prototype = { }, + /** + * Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics). + * It only calls plugins who have active=true. + * + * @method Phaser.PluginManager#preUpdate + */ preUpdate: function () { if (this._pluginsLength == 0) @@ -106,6 +146,12 @@ Phaser.PluginManager.prototype = { }, + /** + * Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render. + * It only calls plugins who have active=true. + * + * @method Phaser.PluginManager#update + */ update: function () { if (this._pluginsLength == 0) @@ -123,6 +169,12 @@ Phaser.PluginManager.prototype = { }, + /** + * Render is called right after the Game Renderer completes, but before the State.render. + * It only calls plugins who have visible=true. + * + * @method Phaser.PluginManager#render + */ render: function () { if (this._pluginsLength == 0) @@ -140,6 +192,12 @@ Phaser.PluginManager.prototype = { }, + /** + * Post-render is called after the Game Renderer and State.render have run. + * It only calls plugins who have visible=true. + * + * @method Phaser.PluginManager#postRender + */ postRender: function () { if (this._pluginsLength == 0) @@ -157,6 +215,11 @@ Phaser.PluginManager.prototype = { }, + /** + * Clear down this PluginManager and null out references + * + * @method Phaser.PluginManager#destroy + */ destroy: function () { this.plugins.length = 0; diff --git a/src/core/Signal.js b/src/core/Signal.js index cc5f4383..08aa10f6 100644 --- a/src/core/Signal.js +++ b/src/core/Signal.js @@ -1,23 +1,35 @@ /** -* Phaser.Signal -* -* A Signal is used for object communication via a custom broadcaster instead of Events. -* +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* @class Phaser.Signal +* @classdesc A Signal is used for object communication via a custom broadcaster instead of Events. * @author Miller Medeiros http://millermedeiros.github.com/js-signals/ * @constructor */ Phaser.Signal = function () { /** - * @type Array. - * @private - */ + * @property {Array.} _bindings - Description. + * @private + */ this._bindings = []; + + /** + * @property {Description} _prevParams - Description. + * @private + */ this._prevParams = null; // enforce dispatch to aways work on same context (#47) var self = this; + /** + * @property {Description} dispatch - Description. + */ this.dispatch = function(){ Phaser.Signal.prototype.dispatch.apply(self, arguments); }; @@ -27,26 +39,33 @@ Phaser.Signal = function () { Phaser.Signal.prototype = { /** - * If Signal should keep record of previously dispatched parameters and - * automatically execute listener during `add()`/`addOnce()` if Signal was - * already dispatched before. - * @type boolean - */ + * If Signal should keep record of previously dispatched parameters and + * automatically execute listener during `add()`/`addOnce()` if Signal was + * already dispatched before. + * @property {boolean} memorize + */ memorize: false, /** - * @type boolean - * @private - */ + * @property {boolean} _shouldPropagate + * @private + */ _shouldPropagate: true, /** - * If Signal is active and should broadcast events. - *

    IMPORTANT: Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.

    - * @type boolean - */ + * If Signal is active and should broadcast events. + *

    IMPORTANT: Setting this property during a dispatch will only affect the next dispatch, if you want to stop the propagation of a signal use `halt()` instead.

    + * @property {boolean} active + * @default + */ active: true, + /** + * @method Phaser.Signal#validateListener + * @param {function} listener - Signal handler function. + * @param {Description} fnName - Description. + * @private + */ validateListener: function (listener, fnName) { if (typeof listener !== 'function') { throw new Error( 'listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName) ); @@ -54,11 +73,12 @@ Phaser.Signal.prototype = { }, /** - * @param {Function} listener - * @param {boolean} isOnce - * @param {Object} [listenerContext] - * @param {Number} [priority] - * @return {Phaser.SignalBinding} + * @method Phaser.Signal#_registerListener + * @param {function} listener - Signal handler function. + * @param {boolean} isOnce - Description. + * @param {object} [listenerContext] - Description. + * @param {number} [priority] - The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0). + * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener. * @private */ _registerListener: function (listener, isOnce, listenerContext, priority) { @@ -84,7 +104,8 @@ Phaser.Signal.prototype = { }, /** - * @param {Phaser.SignalBinding} binding + * @method Phaser.Signal#_addBinding + * @param {Phaser.SignalBinding} binding - An Object representing the binding between the Signal and listener. * @private */ _addBinding: function (binding) { @@ -95,8 +116,9 @@ Phaser.Signal.prototype = { }, /** - * @param {Function} listener - * @return {number} + * @method Phaser.Signal#_indexOfListener + * @param {function} listener - Signal handler function. + * @return {number} Description. * @private */ _indexOfListener: function (listener, context) { @@ -113,9 +135,11 @@ Phaser.Signal.prototype = { /** * Check if listener was attached to Signal. - * @param {Function} listener - * @param {Object} [context] - * @return {boolean} if Signal has the specified listener. + * + * @method Phaser.Signal#has + * @param {Function} listener - Signal handler function. + * @param {Object} [context] - Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @return {boolean} If Signal has the specified listener. */ has: function (listener, context) { return this._indexOfListener(listener, context) !== -1; @@ -123,9 +147,11 @@ Phaser.Signal.prototype = { /** * Add a listener to the signal. - * @param {Function} listener Signal handler function. - * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) + * + * @method Phaser.Signal#add + * @param {function} listener - Signal handler function. + * @param {object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @param {number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0). * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener. */ add: function (listener, listenerContext, priority) { @@ -134,37 +160,48 @@ Phaser.Signal.prototype = { }, /** - * Add listener to the signal that should be removed after first execution (will be executed only once). - * @param {Function} listener Signal handler function. - * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) - * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener. - */ + * Add listener to the signal that should be removed after first execution (will be executed only once). + * + * @method Phaser.Signal#addOnce + * @param {function} listener Signal handler function. + * @param {object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @param {number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0) + * @return {Phaser.SignalBinding} An Object representing the binding between the Signal and listener. + */ addOnce: function (listener, listenerContext, priority) { this.validateListener(listener, 'addOnce'); return this._registerListener(listener, true, listenerContext, priority); }, /** - * Remove a single listener from the dispatch queue. - * @param {Function} listener Handler function that should be removed. - * @param {Object} [context] Execution context (since you can add the same handler multiple times if executing in a different context). - * @return {Function} Listener handler function. - */ + * Remove a single listener from the dispatch queue. + * + * @method Phaser.Signal#remove + * @param {function} listener Handler function that should be removed. + * @param {object} [context] Execution context (since you can add the same handler multiple times if executing in a different context). + * @return {function} Listener handler function. + */ remove: function (listener, context) { + this.validateListener(listener, 'remove'); var i = this._indexOfListener(listener, context); - if (i !== -1) { + + if (i !== -1) + { this._bindings[i]._destroy(); //no reason to a Phaser.SignalBinding exist if it isn't attached to a signal this._bindings.splice(i, 1); } + return listener; + }, /** - * Remove all listeners from the Signal. - */ + * Remove all listeners from the Signal. + * + * @method Phaser.Signal#removeAll + */ removeAll: function () { var n = this._bindings.length; while (n--) { @@ -174,25 +211,32 @@ Phaser.Signal.prototype = { }, /** - * @return {number} Number of listeners attached to the Signal. - */ + * Gets the total number of listeneres attached to ths Signal. + * + * @method Phaser.Signal#getNumListeners + * @return {number} Number of listeners attached to the Signal. + */ getNumListeners: function () { return this._bindings.length; }, /** - * Stop propagation of the event, blocking the dispatch to next listeners on the queue. - *

    IMPORTANT: should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.

    - * @see Signal.prototype.disable - */ + * Stop propagation of the event, blocking the dispatch to next listeners on the queue. + *

    IMPORTANT: should be called only during signal dispatch, calling it before/after dispatch won't affect signal broadcast.

    + * @see Signal.prototype.disable + * + * @method Phaser.Signal#halt + */ halt: function () { this._shouldPropagate = false; }, /** - * Dispatch/Broadcast Signal to all listeners added to the queue. - * @param {...*} [params] Parameters that should be passed to each handler. - */ + * Dispatch/Broadcast Signal to all listeners added to the queue. + * + * @method Phaser.Signal#dispatch + * @param {any} [params] - Parameters that should be passed to each handler. + */ dispatch: function (params) { if (! this.active) { return; @@ -220,17 +264,21 @@ Phaser.Signal.prototype = { }, /** - * Forget memorized arguments. - * @see Signal.memorize - */ + * Forget memorized arguments. + * @see Signal.memorize + * + * @method Phaser.Signal#forget + */ forget: function(){ this._prevParams = null; }, /** - * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object). - *

    IMPORTANT: calling any method on the signal instance after calling dispose will throw errors.

    - */ + * Remove all bindings from signal and destroy any reference to external objects (destroy Signal object). + *

    IMPORTANT: calling any method on the signal instance after calling dispose will throw errors.

    + * + * @method Phaser.Signal#dispose + */ dispose: function () { this.removeAll(); delete this._bindings; @@ -238,8 +286,10 @@ Phaser.Signal.prototype = { }, /** - * @return {string} String representation of the object. - */ + * + * @method Phaser.Signal#toString + * @return {string} String representation of the object. + */ toString: function () { return '[Phaser.Signal active:'+ this.active +' numListeners:'+ this.getNumListeners() +']'; } diff --git a/src/core/SignalBinding.js b/src/core/SignalBinding.js index 3617838d..58d9903b 100644 --- a/src/core/SignalBinding.js +++ b/src/core/SignalBinding.js @@ -1,3 +1,9 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + /** * Phaser.SignalBinding * @@ -5,52 +11,47 @@ *
    - This is an internal constructor and shouldn't be called by regular users. *
    - inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes. * +* @class Phaser.SignalBinding +* @name SignalBinding * @author Miller Medeiros http://millermedeiros.github.com/js-signals/ * @constructor -* @internal -* @name SignalBinding -* @param {Signal} signal Reference to Signal object that listener is currently bound to. -* @param {Function} listener Handler function bound to the signal. -* @param {boolean} isOnce If binding should be executed just once. -* @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function). -* @param {Number} [priority] The priority level of the event listener. (default = 0). +* @inner +* @param {Signal} signal - Reference to Signal object that listener is currently bound to. +* @param {function} listener - Handler function bound to the signal. +* @param {boolean} isOnce - If binding should be executed just once. +* @param {object} [listenerContext] - Context on which listener will be executed (object that should represent the `this` variable inside listener function). +* @param {number} [priority] - The priority level of the event listener. (default = 0). */ Phaser.SignalBinding = function (signal, listener, isOnce, listenerContext, priority) { /** - * Handler function bound to the signal. - * @type Function - * @private - */ + * @property {Phaser.Game} _listener - Handler function bound to the signal. + * @private + */ this._listener = listener; /** - * If binding should be executed just once. - * @type boolean - * @private - */ + * @property {boolean} _isOnce - If binding should be executed just once. + * @private + */ this._isOnce = isOnce; /** - * Context on which listener will be executed (object that should represent the `this` variable inside listener function). - * @memberOf SignalBinding.prototype - * @name context - * @type Object|undefined|null - */ + * @property {object|undefined|null} context - Context on which listener will be executed (object that should represent the `this` variable inside listener function). + * @memberof SignalBinding.prototype + */ this.context = listenerContext; /** - * Reference to Signal object that listener is currently bound to. - * @type Signal - * @private - */ + * @property {Signal} _signal - Reference to Signal object that listener is currently bound to. + * @private + */ this._signal = signal; /** - * Listener priority - * @type Number - * @private - */ + * @property {number} _priority - Listener priority. + * @private + */ this._priority = priority || 0; }; @@ -58,23 +59,26 @@ Phaser.SignalBinding = function (signal, listener, isOnce, listenerContext, prio Phaser.SignalBinding.prototype = { /** - * If binding is active and should be executed. - * @type boolean - */ + * If binding is active and should be executed. + * @property {boolean} active + * @default + */ active: true, /** - * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters) - * @type Array|null - */ + * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute` (curried parameters). + * @property {array|null} params + * @default + */ params: null, /** - * Call listener passing arbitrary parameters. - *

    If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.

    - * @param {Array} [paramsArr] Array of parameters that should be passed to the listener - * @return {*} Value returned by the listener. - */ + * Call listener passing arbitrary parameters. + *

    If binding was added using `Signal.addOnce()` it will be automatically removed from signal dispatch queue, this method is used internally for the signal dispatch.

    + * @method Phaser.SignalBinding#execute + * @param {array} [paramsArr] - Array of parameters that should be passed to the listener. + * @return {Description} Value returned by the listener. + */ execute: function (paramsArr) { var handlerReturn, params; @@ -95,46 +99,52 @@ Phaser.SignalBinding.prototype = { }, /** - * Detach binding from signal. - * - alias to: mySignal.remove(myBinding.getListener()); - * @return {Function|null} Handler function bound to the signal or `null` if binding was previously detached. - */ + * Detach binding from signal. + *

    alias to: @see mySignal.remove(myBinding.getListener()); + * @method Phaser.SignalBinding#detach + * @return {function|null} Handler function bound to the signal or `null` if binding was previously detached. + */ detach: function () { return this.isBound() ? this._signal.remove(this._listener, this.context) : null; }, /** - * @return {Boolean} `true` if binding is still bound to the signal and have a listener. - */ + * @method Phaser.SignalBinding#isBound + * @return {boolean} True if binding is still bound to the signal and has a listener. + */ isBound: function () { return (!!this._signal && !!this._listener); }, /** - * @return {boolean} If SignalBinding will only be executed once. - */ + * @method Phaser.SignalBinding#isOnce + * @return {boolean} If SignalBinding will only be executed once. + */ isOnce: function () { return this._isOnce; }, /** - * @return {Function} Handler function bound to the signal. - */ + * @method Phaser.SignalBinding#getListener + * @return {Function} Handler function bound to the signal. + */ getListener: function () { return this._listener; }, /** - * @return {Signal} Signal that listener is currently bound to. - */ + * @method Phaser.SignalBinding#getSignal + * @return {Signal} Signal that listener is currently bound to. + */ getSignal: function () { return this._signal; }, /** - * Delete instance properties - * @private - */ + * @method Phaser.SignalBinding#_destroy + * Delete instance properties + * @private + */ _destroy: function () { delete this._signal; delete this._listener; @@ -142,8 +152,9 @@ Phaser.SignalBinding.prototype = { }, /** - * @return {string} String representation of the object. - */ + * @method Phaser.SignalBinding#toString + * @return {string} String representation of the object. + */ toString: function () { return '[Phaser.SignalBinding isOnce:' + this._isOnce +', isBound:'+ this.isBound() +', active:' + this.active + ']'; } diff --git a/src/core/Stage.js b/src/core/Stage.js index 73ea9392..50499321 100644 --- a/src/core/Stage.js +++ b/src/core/Stage.js @@ -1,96 +1,86 @@ /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Stage +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** -* * The Stage controls the canvas on which everything is displayed. It handles display within the browser, * focus handling, game resizing, scaling and the pause, boot and orientation screens. * -* @class Stage +* @class Phaser.Stage * @constructor -* @param {Phaser.Game} game Game reference to the currently running game. -* @param {number} width Width of the canvas element -* @param {number} height Height of the canvas element +* @param {Phaser.Game} game - Game reference to the currently running game. +* @param {number} width - Width of the canvas element. +* @param {number} height - Height of the canvas element. */ Phaser.Stage = function (game, width, height) { - /** - * A reference to the currently running Game. - * @property game - * @public - * @type {Phaser.Game} - */ + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; /** - * Background color of the stage (defaults to black). Set via the public backgroundColor property. - * @property _backgroundColor - * @private - * @type {string} - */ + * @property {string} game - Background color of the stage (defaults to black). Set via the public backgroundColor property. + * @private + * @default 'rgb(0,0,0)' + */ this._backgroundColor = 'rgb(0,0,0)'; /** - * Get the offset values (for input and other things) - * @property offset - * @public - * @type {Phaser.Point} - */ + * @property {Phaser.Point} offset - Get the offset values (for input and other things). + */ this.offset = new Phaser.Point; /** - * reference to the newly created element - * @property canvas - * @public - * @type {HTMLCanvasElement} + * @property {HTMLCanvasElement} canvas - Reference to the newly created <canvas> element. */ - this.canvas = Phaser.Canvas.create(width, height); + this.canvas = Phaser.Canvas.create(width, height); this.canvas.style['-webkit-full-screen'] = 'width: 100%; height: 100%'; /** - * The Pixi Stage which is hooked to the renderer - * @property _stage + * @property {PIXI.Stage} _stage - The Pixi Stage which is hooked to the renderer. * @private - * @type {PIXI.Stage} */ this._stage = new PIXI.Stage(0x000000, false); this._stage.name = '_stage_root'; /** - * The current scaleMode - * @property scaleMode - * @public - * @type {number} - */ + * @property {number} scaleMode - The current scaleMode. + */ this.scaleMode = Phaser.StageScaleMode.NO_SCALE; /** - * The scale of the current running game - * @property scale - * @public - * @type {Phaser.StageScaleMode} + * @property {Phaser.StageScaleMode} scale - The scale of the current running game. */ this.scale = new Phaser.StageScaleMode(this.game, width, height); /** - * aspect ratio - * @property aspectRatio - * @public - * @type {number} - */ + * @property {number} aspectRatio - Aspect ratio. + */ this.aspectRatio = width / height; + /** + * @property {number} _nextOffsetCheck - The time to run the next offset check. + * @private + */ + this._nextOffsetCheck = 0; + + /** + * @property {number|false} checkOffsetInterval - The time (in ms) between which the stage should check to see if it has moved. + * @default + */ + this.checkOffsetInterval = 2500; + }; Phaser.Stage.prototype = { /** - * Initialises the stage and adds the event listeners - * @method boot + * Initialises the stage and adds the event listeners. + * @method Phaser.Stage#boot + * @private */ boot: function () { @@ -104,6 +94,9 @@ Phaser.Stage.prototype = { return _this.visibilityChange(event); } + Phaser.Canvas.setUserSelect(this.canvas, 'none'); + Phaser.Canvas.setTouchAction(this.canvas, 'none'); + document.addEventListener('visibilitychange', this._onChange, false); document.addEventListener('webkitvisibilitychange', this._onChange, false); document.addEventListener('pagehide', this._onChange, false); @@ -112,12 +105,30 @@ Phaser.Stage.prototype = { window.onblur = this._onChange; window.onfocus = this._onChange; + }, + + /** + * Runs Stage processes that need periodic updates, such as the offset checks. + * @method Phaser.Stage#update + */ + update: function () { + + if (this.checkOffsetInterval !== false) + { + if (this.game.time.now > this._nextOffsetCheck) + { + Phaser.Canvas.getOffset(this.canvas, this.offset); + this._nextOffsetCheck = this.game.time.now + this.checkOffsetInterval; + } + + } + }, /** * This method is called when the document visibility is changed. - * @method visibilityChange - * @param {Event} event Its type will be used to decide whether the game should be paused or not + * @method Phaser.Stage#visibilityChange + * @param {Event} event - Its type will be used to decide whether the game should be paused or not. */ visibilityChange: function (event) { @@ -128,12 +139,10 @@ Phaser.Stage.prototype = { if (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] == true || document['webkitHidden'] == true) { - // console.log('visibilityChange - hidden', event); this.game.paused = true; } else { - // console.log('visibilityChange - shown', event); this.game.paused = false; } @@ -141,21 +150,16 @@ Phaser.Stage.prototype = { }; +/** +* @name Phaser.Stage#backgroundColor +* @property {number|string} paused - Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000' +*/ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", { - /** - * @method backgroundColor - * @return {string} returns the background color of the stage - */ get: function () { return this._backgroundColor; }, - /** - * @method backgroundColor - * @param {string} the background color you want the stage to have - * @return {string} returns the background color of the stage - */ set: function (color) { this._backgroundColor = color; diff --git a/src/core/State.js b/src/core/State.js index 42fb59e6..e202c949 100644 --- a/src/core/State.js +++ b/src/core/State.js @@ -1,30 +1,100 @@ /** -* State -* +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** * This is a base State class which can be extended if you are creating your own game. * It provides quick access to common functions such as the camera, cache, input, match, sound and more. * -* @package Phaser.State -* @author Richard Davey -* @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License +* @class Phaser.State +* @constructor */ Phaser.State = function () { + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = null; + + /** + * @property {Phaser.GameObjectFactory} add - Reference to the GameObjectFactory. + * @default + */ this.add = null; + + /** + * @property {Phaser.Physics.PhysicsManager} camera - A handy reference to world.camera. + * @default + */ this.camera = null; + + /** + * @property {Phaser.Cache} cache - Reference to the assets cache. + * @default + */ this.cache = null; + + /** + * @property {Phaser.Input} input - Reference to the input manager + * @default + */ this.input = null; + + /** + * @property {Phaser.Loader} load - Reference to the assets loader. + * @default + */ this.load = null; + + /** + * @property {Phaser.GameMath} math - Reference to the math helper. + * @default + */ this.math = null; + + /** + * @property {Phaser.SoundManager} sound - Reference to the sound manager. + * @default + */ this.sound = null; + + /** + * @property {Phaser.Stage} stage - Reference to the stage. + * @default + */ this.stage = null; + + /** + * @property {Phaser.TimeManager} time - Reference to game clock. + * @default + */ this.time = null; + + /** + * @property {Phaser.TweenManager} tweens - Reference to the tween manager. + * @default + */ this.tweens = null; + + /** + * @property {Phaser.World} world - Reference to the world. + * @default + */ this.world = null; + + /** + * @property {Description} add - Description. + * @default + */ this.particles = null; + + /** + * @property {Phaser.Physics.PhysicsManager} physics - Reference to the physics manager. + * @default + */ this.physics = null; }; @@ -34,37 +104,64 @@ Phaser.State.prototype = { /** * Override this method to add some load operations. * If you need to use the loader, you may need to use them here. + * + * @method Phaser.State#preload */ preload: function () { }, + /** + * Put update logic here. + * + * @method Phaser.State#loadUpdate + */ + loadUpdate: function () { + }, + + /** + * Put render operations here. + * + * @method Phaser.State#loadRender + */ + loadRender: function () { + }, + /** * This method is called after the game engine successfully switches states. - * Feel free to add any setup code here.(Do not load anything here, override preload() instead) + * Feel free to add any setup code here (do not load anything here, override preload() instead). + * + * @method Phaser.State#create */ create: function () { }, /** * Put update logic here. + * + * @method Phaser.State#update */ update: function () { }, /** * Put render operations here. + * + * @method Phaser.State#render */ render: function () { }, /** * This method will be called when game paused. + * + * @method Phaser.State#paused */ paused: function () { }, /** - * This method will be called when the state is destroyed + * This method will be called when the state is destroyed. + * @method Phaser.State#destroy */ destroy: function () { } diff --git a/src/core/StateManager.js b/src/core/StateManager.js index 86a2b8c6..d589d6b8 100644 --- a/src/core/StateManager.js +++ b/src/core/StateManager.js @@ -1,7 +1,29 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* The State Manager is responsible for loading, setting up and switching game states. +* +* @class Phaser.StateManager +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {Phaser.State|Object} [pendingState=null] - A State object to seed the manager with. +*/ Phaser.StateManager = function (game, pendingState) { + /** + * A reference to the currently running game. + * @property {Phaser.Game} game. + */ this.game = game; + /** + * Description. + * @property {Description} states. + */ this.states = {}; if (pendingState !== null) @@ -14,94 +36,102 @@ Phaser.StateManager = function (game, pendingState) { Phaser.StateManager.prototype = { /** - * @type {Phaser.Game} + * A reference to the currently running game. + * @property {Phaser.Game} game. */ game: null, /** * The state to be switched to in the next frame. - * @type {State} + * @property {State} _pendingState + * @private */ _pendingState: null, /** * Flag that sets if the State has been created or not. - * @type {Boolean} + * @property {boolean}_created + * @private */ _created: false, /** * The state to be switched to in the next frame. - * @type {Object} + * @property {Description} states */ states: {}, /** - * The current active State object (defaults to null) - * @type {String} + * The current active State object (defaults to null). + * @property {string} current */ current: '', /** - * This will be called when the state is started (i.e. set as the current active state) - * @type {function} + * This will be called when the state is started (i.e. set as the current active state). + * @property {function} onInitCallback */ onInitCallback: null, /** - * This will be called when init states. (loading assets...) - * @type {function} + * This will be called when init states (loading assets...). + * @property {function} onPreloadCallback */ onPreloadCallback: null, /** - * This will be called when create states. (setup states...) - * @type {function} + * This will be called when create states (setup states...). + * @property {function} onCreateCallback */ onCreateCallback: null, /** - * This will be called when State is updated, this doesn't happen during load (see onLoadUpdateCallback) - * @type {function} + * This will be called when State is updated, this doesn't happen during load (@see onLoadUpdateCallback). + * @property {function} onUpdateCallback */ onUpdateCallback: null, /** - * This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback) - * @type {function} + * This will be called when the State is rendered, this doesn't happen during load (see onLoadRenderCallback). + * @property {function} onRenderCallback */ onRenderCallback: null, /** - * This will be called before the State is rendered and before the stage is cleared - * @type {function} + * This will be called before the State is rendered and before the stage is cleared. + * @property {function} onPreRenderCallback */ onPreRenderCallback: null, /** - * This will be called when the State is updated but only during the load process - * @type {function} + * This will be called when the State is updated but only during the load process. + * @property {function} onLoadUpdateCallback */ onLoadUpdateCallback: null, /** - * This will be called when the State is rendered but only during the load process - * @type {function} + * This will be called when the State is rendered but only during the load process. + * @property {function} onLoadRenderCallback */ onLoadRenderCallback: null, /** * This will be called when states paused. - * @type {function} + * @property {function} onPausedCallback */ onPausedCallback: null, /** - * This will be called when the state is shut down (i.e. swapped to another state) - * @type {function} + * This will be called when the state is shut down (i.e. swapped to another state). + * @property {function} onShutDownCallback */ onShutDownCallback: null, + /** + * Description. + * @method Phaser.StateManager#boot + * @private + */ boot: function () { // console.log('Phaser.StateManager.boot'); @@ -127,9 +157,10 @@ Phaser.StateManager.prototype = { /** * Add a new State. - * @param key {String} A unique key you use to reference this state, i.e. "MainMenu", "Level1". - * @param state {State} The state you want to switch to. - * @param autoStart {Boolean} Start the state immediately after creating it? (default true) + * @method Phaser.StateManager#add + * @param key {string} - A unique key you use to reference this state, i.e. "MainMenu", "Level1". + * @param state {State} - The state you want to switch to. + * @param autoStart {boolean} - Start the state immediately after creating it? (default true) */ add: function (key, state, autoStart) { @@ -178,6 +209,11 @@ Phaser.StateManager.prototype = { }, + /** + * Delete the given state. + * @method Phaser.StateManager#remove + * @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1". + */ remove: function (key) { if (this.current == key) @@ -203,9 +239,10 @@ Phaser.StateManager.prototype = { /** * Start the given state - * @param key {String} The key of the state you want to start. - * @param [clearWorld] {bool} clear everything in the world? (Default to true) - * @param [clearCache] {bool} clear asset cache? (Default to false and ONLY available when clearWorld=true) + * @method Phaser.StateManager#start + * @param {string} key - The key of the state you want to start. + * @param {boolean} [clearWorld] - clear everything in the world? (Default to true) + * @param {boolean} [clearCache] - clear asset cache? (Default to false and ONLY available when clearWorld=true) */ start: function (key, clearWorld, clearCache) { @@ -235,7 +272,9 @@ Phaser.StateManager.prototype = { this.onShutDownCallback.call(this.callbackContext); } - if (clearWorld) { + if (clearWorld) + { + this.game.tweens.removeAll(); this.game.world.destroy(); @@ -275,11 +314,21 @@ Phaser.StateManager.prototype = { } }, - - // Used by onInit and onShutdown when those functions don't exist on the state + + /** + * Used by onInit and onShutdown when those functions don't exist on the state + * @method Phaser.StateManager#dummy + * @private + */ dummy: function () { }, + /** + * Description. + * @method Phaser.StateManager#checkState + * @param {string} key - The key of the state you want to check. + * @return {boolean} Description. + */ checkState: function (key) { if (this.states[key]) @@ -312,6 +361,12 @@ Phaser.StateManager.prototype = { }, + /** + * Links game properties to the State given by the key. + * @method Phaser.StateManager#link + * @param {string} key - State key. + * @protected + */ link: function (key) { // console.log('linked'); @@ -333,6 +388,12 @@ Phaser.StateManager.prototype = { }, + /** + * Sets the current State. Should not be called directly (use StateManager.start) + * @method Phaser.StateManager#setCurrentState + * @param {string} key - State key. + * @protected + */ setCurrentState: function (key) { this.callbackContext = this.states[key]; @@ -361,6 +422,10 @@ Phaser.StateManager.prototype = { }, + /** + * @method Phaser.StateManager#loadComplete + * @protected + */ loadComplete: function () { // console.log('Phaser.StateManager.loadComplete'); @@ -378,6 +443,10 @@ Phaser.StateManager.prototype = { }, + /** + * @method Phaser.StateManager#update + * @protected + */ update: function () { if (this._created && this.onUpdateCallback) @@ -394,6 +463,10 @@ Phaser.StateManager.prototype = { }, + /** + * @method Phaser.StateManager#preRender + * @protected + */ preRender: function () { if (this.onPreRenderCallback) @@ -403,6 +476,10 @@ Phaser.StateManager.prototype = { }, + /** + * @method Phaser.StateManager#render + * @protected + */ render: function () { if (this._created && this.onRenderCallback) @@ -421,6 +498,7 @@ Phaser.StateManager.prototype = { /** * Nuke the entire game from orbit + * @method Phaser.StateManager#destroy */ destroy: function () { diff --git a/src/core/World.js b/src/core/World.js index 4fbbd8c6..61bc6692 100644 --- a/src/core/World.js +++ b/src/core/World.js @@ -1,240 +1,260 @@ /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.World +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** - * - * "This world is but a canvas to our imagination." - Henry David Thoreau - * - * A game has only one world. The world is an abstract place in which all game objects live. It is not bound - * by stage limits and can be any size. You look into the world via cameras. All game objects live within - * the world at world-based coordinates. By default a world is created the same size as your Stage. - * - * @class World - * @constructor - * @param {Phaser.Game} game Reference to the current game instance. - */ +* "This world is but a canvas to our imagination." - Henry David Thoreau +* +* A game has only one world. The world is an abstract place in which all game objects live. It is not bound +* by stage limits and can be any size. You look into the world via cameras. All game objects live within +* the world at world-based coordinates. By default a world is created the same size as your Stage. +* +* @class Phaser.World +* @constructor +* @param {Phaser.Game} game - Reference to the current game instance. +*/ Phaser.World = function (game) { - /** - * A reference to the currently running Game. - * @property game - * @public - * @type {Phaser.Game} - */ - this.game = game; + Phaser.Group.call(this, game, null, '__world', false); /** - * Bound of this world that objects can not escape from. - * @property bounds - * @public - * @type {Phaser.Rectangle} - */ + * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one. + */ + this.scale = new Phaser.Point(1, 1); + + /** + * The World has no fixed size, but it does have a bounds outside of which objects are no longer considered as being "in world" and you should use this to clean-up the display list and purge dead objects. + * By default we set the Bounds to be from 0,0 to Game.width,Game.height. I.e. it will match the size given to the game constructor with 0,0 representing the top-left of the display. + * However 0,0 is actually the center of the world, and if you rotate or scale the world all of that will happen from 0,0. + * So if you want to make a game in which the world itself will rotate you should adjust the bounds so that 0,0 is the center point, i.e. set them to -1000,-1000,2000,2000 for a 2000x2000 sized world centered around 0,0. + * @property {Phaser.Rectangle} bounds - Bound of this world that objects can not escape from. + */ this.bounds = new Phaser.Rectangle(0, 0, game.width, game.height); /** - * Camera instance. - * @property camera - * @public - * @type {Phaser.Camera} - */ + * @property {Phaser.Camera} camera - Camera instance. + */ this.camera = null; /** - * Reset each frame, keeps a count of the total number of objects updated. - * @property currentRenderOrderID - * @public - * @type {Number} - */ + * @property {number} currentRenderOrderID - Reset each frame, keeps a count of the total number of objects updated. + */ + this.currentRenderOrderID = 0; + +}; + +Phaser.World.prototype = Object.create(Phaser.Group.prototype); +Phaser.World.prototype.constructor = Phaser.World; + +/** +* Initialises the game world. +* +* @method Phaser.World#boot +* @protected +*/ +Phaser.World.prototype.boot = function () { + + this.camera = new Phaser.Camera(this.game, 0, 0, 0, this.game.width, this.game.height); + + this.camera.displayObject = this._container; + + this.game.camera = this.camera; + +} + +/** +* This is called automatically every frame, and is where main logic happens. +* +* @method Phaser.World#update +*/ +Phaser.World.prototype.update = function () { + this.currentRenderOrderID = 0; - /** - * Object container stores every object created with `create*` methods. - * @property group - * @public - * @type {Phaser.Group} - */ - this.group = null; - -}; - -Phaser.World.prototype = { - - - /** - * Initialises the game world - * - * @method boot - */ - boot: function () { - - this.camera = new Phaser.Camera(this.game, 0, 0, 0, this.game.width, this.game.height); - - this.game.camera = this.camera; - - this.group = new Phaser.Group(this.game, null, '__world', true); - - }, - - /** - * This is called automatically every frame, and is where main logic happens. - * @method update - */ - update: function () { - - this.camera.update(); - - this.currentRenderOrderID = 0; - - if (this.game.stage._stage.first._iNext) + if (this.game.stage._stage.first._iNext) + { + var currentNode = this.game.stage._stage.first._iNext; + + do { - var currentNode = this.game.stage._stage.first._iNext; - - do + if (currentNode['preUpdate']) { - if (currentNode['preUpdate']) - { - currentNode.preUpdate(); - } - - if (currentNode['update']) - { - currentNode.update(); - } - - currentNode = currentNode._iNext; + currentNode.preUpdate(); } - while (currentNode != this.game.stage._stage.last._iNext) + + if (currentNode['update']) + { + currentNode.update(); + } + + currentNode = currentNode._iNext; } + while (currentNode != this.game.stage._stage.last._iNext) + } - }, +} - /** - * Updates the size of this world. - * @method setSize - * @param {number} width New width of the world. - * @param {number} height New height of the world. - */ - setSize: function (width, height) { +/** +* This is called automatically every frame, and is where main logic happens. +* @method Phaser.World#postUpdate +*/ +Phaser.World.prototype.postUpdate = function () { - if (width >= this.game.width) + this.camera.update(); + + if (this.game.stage._stage.first._iNext) + { + var currentNode = this.game.stage._stage.first._iNext; + + do { - this.bounds.width = width; + if (currentNode['postUpdate']) + { + currentNode.postUpdate(); + } + + currentNode = currentNode._iNext; } - - if (height >= this.game.height) - { - this.bounds.height = height; - } - - }, - - /** - * Destroyer of worlds. - * @method destroy - */ - destroy: function () { - - this.camera.x = 0; - this.camera.y = 0; - - this.game.input.reset(true); - - this.group.removeAll(); - + while (currentNode != this.game.stage._stage.last._iNext) } - -}; -// Getters / Setters +} +/** +* Updates the size of this world. Note that this doesn't modify the world x/y coordinates, just the width and height. +* If you need to adjust the bounds of the world +* @method Phaser.World#setBounds +* @param {number} x - Top left most corner of the world. +* @param {number} y - Top left most corner of the world. +* @param {number} width - New width of the world. +* @param {number} height - New height of the world. +*/ +Phaser.World.prototype.setBounds = function (x, y, width, height) { + + this.bounds.setTo(x, y, width, height); + + if (this.camera.bounds) + { + this.camera.bounds.setTo(x, y, width, height); + } + +} + +/** +* Destroyer of worlds. +* @method Phaser.World#destroy +*/ +Phaser.World.prototype.destroy = function () { + + this.camera.x = 0; + this.camera.y = 0; + + this.game.input.reset(true); + + this.removeAll(); + +} + +/** +* @name Phaser.World#width +* @property {number} width - Gets or sets the current width of the game world. +*/ Object.defineProperty(Phaser.World.prototype, "width", { - /** - * @method width - * @return {Number} The current width of the game world - */ get: function () { return this.bounds.width; }, - /** - * @method width - * @return {Number} Sets the width of the game world - */ set: function (value) { this.bounds.width = value; } }); +/** +* @name Phaser.World#height +* @property {number} height - Gets or sets the current height of the game world. +*/ Object.defineProperty(Phaser.World.prototype, "height", { - /** - * @method height - * @return {Number} The current height of the game world - */ get: function () { return this.bounds.height; }, - /** - * @method height - * @return {Number} Sets the width of the game world - */ set: function (value) { this.bounds.height = value; } }); +/** +* @name Phaser.World#centerX +* @property {number} centerX - Gets the X position corresponding to the center point of the world. +* @readonly +*/ Object.defineProperty(Phaser.World.prototype, "centerX", { - /** - * @method centerX - * @return {Number} return the X position of the center point of the world - */ get: function () { return this.bounds.halfWidth; } }); +/** +* @name Phaser.World#centerY +* @property {number} centerY - Gets the Y position corresponding to the center point of the world. +* @readonly +*/ Object.defineProperty(Phaser.World.prototype, "centerY", { - /** - * @method centerY - * @return {Number} return the Y position of the center point of the world - */ get: function () { return this.bounds.halfHeight; } }); +/** +* @name Phaser.World#randomX +* @property {number} randomX - Gets a random integer which is lesser than or equal to the current width of the game world. +* @readonly +*/ Object.defineProperty(Phaser.World.prototype, "randomX", { - /** - * @method randomX - * @return {Number} a random integer which is lesser or equal to the current width of the game world - */ get: function () { - return Math.round(Math.random() * this.bounds.width); + + if (this.bounds.x < 0) + { + return this.game.rnd.integerInRange(this.bounds.x, (this.bounds.width - Math.abs(this.bounds.x))); + } + else + { + return this.game.rnd.integerInRange(this.bounds.x, this.bounds.width); + } + } }); +/** +* @name Phaser.World#randomY +* @property {number} randomY - Gets a random integer which is lesser than or equal to the current height of the game world. +* @readonly +*/ Object.defineProperty(Phaser.World.prototype, "randomY", { - /** - * @method randomY - * @return {Number} a random integer which is lesser or equal to the current height of the game world - */ get: function () { - return Math.round(Math.random() * this.bounds.height); + + if (this.bounds.y < 0) + { + return this.game.rnd.integerInRange(this.bounds.y, (this.bounds.height - Math.abs(this.bounds.y))); + } + else + { + return this.game.rnd.integerInRange(this.bounds.y, this.bounds.height); + } + } }); diff --git a/src/gameobjects/BitmapText.js b/src/gameobjects/BitmapText.js index 42dfaf11..8090d8f8 100644 --- a/src/gameobjects/BitmapText.js +++ b/src/gameobjects/BitmapText.js @@ -1,37 +1,89 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Creates a new BitmapText. +* @class Phaser.BitmapText +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {number} x - X position of the new bitmapText object. +* @param {number} y - Y position of the new bitmapText object. +* @param {string} text - The actual text that will be written. +* @param {object} style - The style object containing style attributes like font, font size , etc. +*/ Phaser.BitmapText = function (game, x, y, text, style) { x = x || 0; y = y || 0; + text = text || ''; style = style || ''; - // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all + /** + * @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all. + * @default + */ this.exists = true; - // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering + /** + * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering. + * @default + */ this.alive = true; + /** + * @property {Description} group - Description. + * @default + */ this.group = null; + /** + * @property {string} name - Description. + * @default + */ this.name = ''; + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; PIXI.BitmapText.call(this, text, style); + /** + * @property {Description} type - Description. + */ this.type = Phaser.BITMAPTEXT; + /** + * @property {number} position.x - Description. + */ this.position.x = x; + + /** + * @property {number} position.y - Description. + */ this.position.y = y; // Replaces the PIXI.Point with a slightly more flexible one + /** + * @property {Phaser.Point} anchor - Description. + */ this.anchor = new Phaser.Point(); + + /** + * @property {Phaser.Point} scale - Description. + */ this.scale = new Phaser.Point(1, 1); - // Influence of camera movement upon the position - this.scrollFactor = new Phaser.Point(1, 1); - // A mini cache for storing all of the calculated values + /** + * @property {function} _cache - Description. + * @private + */ this._cache = { dirty: false, @@ -39,7 +91,7 @@ Phaser.BitmapText = function (game, x, y, text, style) { // Transform cache a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, - // The previous calculated position inc. camera x/y and scrollFactor + // The previous calculated position x: -1, y: -1, // The actual scale values based on the worldTransform @@ -47,9 +99,13 @@ Phaser.BitmapText = function (game, x, y, text, style) { }; - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + this._cache.x = this.x; + this._cache.y = this.y; + /** + * @property {boolean} renderable - Description. + * @private + */ this.renderable = true; }; @@ -59,8 +115,9 @@ Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype); Phaser.BitmapText.prototype.constructor = Phaser.BitmapText; /** - * Automatically called by World.update - */ +* Automatically called by World.update +* @method Phaser.BitmapText.prototype.update +*/ Phaser.BitmapText.prototype.update = function() { if (!this.exists) @@ -70,8 +127,8 @@ Phaser.BitmapText.prototype.update = function() { this._cache.dirty = false; - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + this._cache.x = this.x; + this._cache.y = this.y; if (this.position.x != this._cache.x || this.position.y != this._cache.y) { @@ -85,6 +142,39 @@ Phaser.BitmapText.prototype.update = function() { } +/** +* @method Phaser.Text.prototype.destroy +*/ +Phaser.BitmapText.prototype.destroy = function() { + + if (this.group) + { + this.group.remove(this); + } + + if (this.canvas.parentNode) + { + this.canvas.parentNode.removeChild(this.canvas); + } + else + { + this.canvas = null; + this.context = null; + } + + this.exists = false; + + this.group = null; + +} + +/** +* Get +* @returns {Description} +*//** +* Set +* @param {Description} value - Description +*/ Object.defineProperty(Phaser.BitmapText.prototype, 'angle', { get: function() { @@ -97,6 +187,13 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'angle', { }); +/** +* Get +* @returns {Description} +*//** +* Set +* @param {Description} value - Description +*/ Object.defineProperty(Phaser.BitmapText.prototype, 'x', { get: function() { @@ -109,6 +206,13 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'x', { }); +/** +* Get +* @returns {Description} +*//** +* Set +* @param {Description} value - Description +*/ Object.defineProperty(Phaser.BitmapText.prototype, 'y', { get: function() { diff --git a/src/gameobjects/Bullet.js b/src/gameobjects/Bullet.js index 0d1d96be..4da6912e 100644 --- a/src/gameobjects/Bullet.js +++ b/src/gameobjects/Bullet.js @@ -1,28 +1,89 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Warning: Bullet is an experimental object that we don't advise using for now. +* +* A Bullet is like a stripped-down Sprite, useful for when you just need to get something moving around the screen quickly with little of the extra +* features that a Sprite supports. +* Bullet is MISSING the following: +* +* animation, all input events, crop support, health/damage, loadTexture +* +* @class Phaser.Bullet +* @constructor +* @param {Phaser.Game} game - Current game instance. +* @param {number} x - X position of the new bullet. +* @param {number} y - Y position of the new bullet. +* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. +* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. +*/ Phaser.Bullet = function (game, x, y, key, frame) { x = x || 0; y = y || 0; key = key || null; frame = frame || null; - + + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; - - // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all + + /** + * @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all. + * @default + */ this.exists = true; - // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering + /** + * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering. + * @default + */ this.alive = true; + /** + * @property {Description} group - Description. + * @default + */ this.group = null; + /** + * @property {string} name - The user defined name given to this Sprite. + * @default + */ this.name = ''; + /** + * @property {Description} type - Description. + */ + this.type = Phaser.BULLET; + + /** + * @property {number} renderOrderID - Description. + * @default + */ this.renderOrderID = -1; - // If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc. - // The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called. + /** + * If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc. + * The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called. + * @property {number} lifespan + * @default + */ this.lifespan = 0; + /** + * @property {Events} events - The Signals you can subscribe to that are dispatched when certain things happen on this Sprite or its components + */ + this.events = new Phaser.Events(this); + + /** + * @property {Description} key - Description. + */ this.key = key; if (key instanceof Phaser.RenderTexture) @@ -31,6 +92,12 @@ Phaser.Bullet = function (game, x, y, key, frame) { this.currentFrame = this.game.cache.getTextureFrame(key.name); } + else if (key instanceof PIXI.Texture) + { + PIXI.Sprite.call(this, key); + + this.currentFrame = frame; + } else { if (key == null || this.game.cache.checkImageKey(key) == false) @@ -42,17 +109,21 @@ Phaser.Bullet = function (game, x, y, key, frame) { if (this.game.cache.isSpriteSheet(key)) { + /* + this.animations.loadFrameData(this.game.cache.getFrameData(key)); + if (frame !== null) { if (typeof frame === 'string') { - this.currentFrame = this.game.cache.getFrameByName(key, frame); + this.frameName = frame; } else { - this.currentFrame = this.game.cache.getFrameByIndex(key, frame); + this.frame = frame; } } + */ } else { @@ -61,54 +132,65 @@ Phaser.Bullet = function (game, x, y, key, frame) { } /** - * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right - * - * @property anchor - * @type Point - */ + * The anchor sets the origin point of the texture. + * The default is 0,0 this means the textures origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centered + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * + * @property {Phaser.Point} anchor + */ this.anchor = new Phaser.Point(); + /** + * @property {number} x - Description. + */ this.x = x; + + /** + * @property {number} y - Description. + */ this.y = y; + /** + * @property {Description} position - Description. + */ this.position.x = x; this.position.y = y; /** - * Should this Sprite be automatically culled if out of range of the camera? - * A culled sprite has its visible property set to 'false'. - * Note that this check doesn't look at this Sprites children, which may still be in camera range. - * So you should set autoCull to false if the Sprite will have children likely to still be in camera range. - * - * @property autoCull - * @type Boolean - */ + * Should this Sprite be automatically culled if out of range of the camera? + * A culled sprite has its visible property set to 'false'. + * Note that this check doesn't look at this Sprites children, which may still be in camera range. + * So you should set autoCull to false if the Sprite will have children likely to still be in camera range. + * + * @property {boolean} autoCull + * @default + */ this.autoCull = false; - // Replaces the PIXI.Point with a slightly more flexible one + /** + * @property {Phaser.Point} scale - Replaces the PIXI.Point with a slightly more flexible one. + */ this.scale = new Phaser.Point(1, 1); - // Influence of camera movement upon the position - this.scrollFactor = new Phaser.Point(1, 1); - - // A mini cache for storing all of the calculated values + /** + * @property {Phaser.Point} _cache - A mini cache for storing all of the calculated values. + * @private + */ this._cache = { dirty: false, // Transform cache - a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, + a00: -1, a01: -1, a02: -1, a10: -1, a11: -1, a12: -1, id: -1, // Input specific transform cache - i01: 0, i10: 0, idi: 1, + i01: -1, i10: -1, idi: -1, // Bounds check left: null, right: null, top: null, bottom: null, - // The previous calculated position inc. camera x/y and scrollFactor + // The previous calculated position x: -1, y: -1, // The actual scale values based on the worldTransform @@ -120,35 +202,93 @@ Phaser.Bullet = function (game, x, y, key, frame) { // The actual width/height of the image if from a trimmed atlas, multiplied by the final calculated scale size halfWidth: Math.floor(this.currentFrame.sourceSizeW / 2), halfHeight: Math.floor(this.currentFrame.sourceSizeH / 2), - // The current frame details - frameID: this.currentFrame.uuid, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height, - boundsX: 0, boundsY: 0, // If this sprite visible to the camera (regardless of being set to visible or not) cameraVisible: true }; + + /** + * @property {Phaser.Point} offset - Corner point defaults. + */ + this.offset = new Phaser.Point; + + /** + * @property {Phaser.Point} center - Description. + */ + this.center = new Phaser.Point(x + Math.floor(this._cache.width / 2), y + Math.floor(this._cache.height / 2)); + + /** + * @property {Phaser.Point} topLeft - Description. + */ + this.topLeft = new Phaser.Point(x, y); + + /** + * @property {Phaser.Point} topRight - Description. + */ + this.topRight = new Phaser.Point(x + this._cache.width, y); + + /** + * @property {Phaser.Point} bottomRight - Description. + */ + this.bottomRight = new Phaser.Point(x + this._cache.width, y + this._cache.height); + + /** + * @property {Phaser.Point} bottomLeft - Description. + */ + this.bottomLeft = new Phaser.Point(x, y + this._cache.height); + + /** + * @property {Phaser.Rectangle} bounds - Description. + */ + this.bounds = new Phaser.Rectangle(x, y, this._cache.width, this._cache.height); - this.bounds = new Phaser.Rectangle(x, y, this.currentFrame.sourceSizeW, this.currentFrame.sourceSizeH); - - // Set-up the physics body + /** + * @property {Phaser.Physics.Arcade.Body} body - Set-up the physics body. + */ this.body = new Phaser.Physics.Arcade.Body(this); - // World bounds check + /** + * @property {Description} inWorld - World bounds check. + */ this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds); + + /** + * @property {number} inWorldThreshold - World bounds check. + * @default + */ this.inWorldThreshold = 0; + + /** + * @property {boolean} outOfBoundsKill - Kills this sprite as soon as it goes outside of the World bounds. + * @default + */ + this.outOfBoundsKill = false; + + /** + * @property {boolean} _outOfBoundsFired - Description. + * @private + * @default + */ this._outOfBoundsFired = false; + /** + * A Sprite that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera. + * @property {boolean} fixedToCamera - Fixes this Sprite to the Camera. + * @default + */ + this.fixedToCamera = false; + }; -// Needed to keep the PIXI.Sprite constructor in the prototype chain (as the core pixi renderer uses an instanceof check sadly) Phaser.Bullet.prototype = Object.create(PIXI.Sprite.prototype); Phaser.Bullet.prototype.constructor = Phaser.Bullet; /** - * Automatically called by World.update. You can create your own update in Objects that extend Phaser.Bullet. - */ +* Automatically called by World.preUpdate. You can create your own update in Objects that extend Phaser.Sprite. +* @method Phaser.Sprite.prototype.preUpdate +*/ Phaser.Bullet.prototype.preUpdate = function() { if (!this.exists) @@ -168,142 +308,226 @@ Phaser.Bullet.prototype.preUpdate = function() { } } - // this._cache.dirty = false; - - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); - - // If this sprite or the camera have moved then let's update everything - if (this.position.x != this._cache.x || this.position.y != this._cache.y) - { - this.position.x = this._cache.x; - this.position.y = this._cache.y; - // this._cache.dirty = true; - } + this._cache.dirty = false; if (this.visible) { this.renderOrderID = this.game.world.currentRenderOrderID++; - - /* - - // Only update the values we need - if (this.worldTransform[0] != this._cache.a00 || this.worldTransform[1] != this._cache.a01) - { - this._cache.a00 = this.worldTransform[0]; // scaleX a - this._cache.a01 = this.worldTransform[1]; // skewY c - this._cache.i01 = this.worldTransform[1]; // skewY c - this._cache.scaleX = Math.sqrt((this._cache.a00 * this._cache.a00) + (this._cache.a01 * this._cache.a01)); // round this off a bit? - this._cache.a01 *= -1; - this._cache.dirty = true; - } - - // Need to test, but probably highly unlikely that a scaleX would happen without effecting the Y skew - if (this.worldTransform[3] != this._cache.a10 || this.worldTransform[4] != this._cache.a11) - { - this._cache.a10 = this.worldTransform[3]; // skewX b - this._cache.i10 = this.worldTransform[3]; // skewX b - this._cache.a11 = this.worldTransform[4]; // scaleY d - this._cache.scaleY = Math.sqrt((this._cache.a10 * this._cache.a10) + (this._cache.a11 * this._cache.a11)); // round this off a bit? - this._cache.a10 *= -1; - this._cache.dirty = true; - } - - if (this.worldTransform[2] != this._cache.a02 || this.worldTransform[5] != this._cache.a12) - { - this._cache.a02 = this.worldTransform[2]; // translateX tx - this._cache.a12 = this.worldTransform[5]; // translateY ty - this._cache.dirty = true; - } - - if (this._cache.dirty) - { - this._cache.width = Math.floor(this.currentFrame.sourceSizeW * this._cache.scaleX); - this._cache.height = Math.floor(this.currentFrame.sourceSizeH * this._cache.scaleY); - this._cache.halfWidth = Math.floor(this._cache.width / 2); - this._cache.halfHeight = Math.floor(this._cache.height / 2); - - this._cache.id = 1 / (this._cache.a00 * this._cache.a11 + this._cache.a01 * -this._cache.a10); - this._cache.idi = 1 / (this._cache.a00 * this._cache.a11 + this._cache.i01 * -this._cache.i10); - - this.updateBounds(); - } - */ } - else - { - // We still need to work out the bounds in case the camera has moved - // but we can't use the local or worldTransform to do it, as Pixi resets that if a Sprite is invisible. - // So we'll compare against the cached state + new position. - if (this._cache.dirty && this.visible == false) - { - this.bounds.x -= this._cache.boundsX - this._cache.x; - this._cache.boundsX = this._cache.x; - this.bounds.y -= this._cache.boundsy - this._cache.y; - this._cache.boundsY = this._cache.y; - } + this.prevX = this.x; + this.prevY = this.y; + + // |a c tx| + // |b d ty| + // |0 0 1| + + if (this.worldTransform[1] != this._cache.i01 || this.worldTransform[3] != this._cache.i10) + { + this._cache.a00 = this.worldTransform[0]; // scaleX a + this._cache.a01 = this.worldTransform[1]; // skewY c + this._cache.a10 = this.worldTransform[3]; // skewX b + this._cache.a11 = this.worldTransform[4]; // scaleY d + + this._cache.i01 = this.worldTransform[1]; // skewY c (remains non-modified for input checks) + this._cache.i10 = this.worldTransform[3]; // skewX b (remains non-modified for input checks) + + this._cache.scaleX = Math.sqrt((this._cache.a00 * this._cache.a00) + (this._cache.a01 * this._cache.a01)); // round this off a bit? + this._cache.scaleY = Math.sqrt((this._cache.a10 * this._cache.a10) + (this._cache.a11 * this._cache.a11)); // round this off a bit? + + this._cache.a01 *= -1; + this._cache.a10 *= -1; + + this._cache.dirty = true; + } + + if (this.worldTransform[2] != this._cache.a02 || this.worldTransform[5] != this._cache.a12) + { + this._cache.a02 = this.worldTransform[2]; // translateX tx + this._cache.a12 = this.worldTransform[5]; // translateY ty + this._cache.dirty = true; } // Re-run the camera visibility check - // if (this._cache.dirty) - // { + if (this._cache.dirty) + { this._cache.cameraVisible = Phaser.Rectangle.intersects(this.game.world.camera.screenView, this.bounds, 0); if (this.autoCull == true) { - this.visible = this._cache.cameraVisible; + // Won't get rendered but will still get its transform updated + this.renderable = this._cache.cameraVisible; } // Update our physics bounds - this.body.updateBounds(this.center.x, this.center.y, this._cache.scaleX, this._cache.scaleY); - // } + if (this.body) + { + this.body.updateBounds(this.center.x, this.center.y, this._cache.scaleX, this._cache.scaleY); + } + } - this.body.update(); + if (this.body) + { + this.body.preUpdate(); + } } -Phaser.Bullet.prototype.revive = function() { +Phaser.Bullet.prototype.postUpdate = function() { + + if (this.exists) + { + // The sprite is positioned in this call, after taking into consideration motion updates and collision + if (this.body) + { + this.body.postUpdate(); + } + + if (this.fixedToCamera) + { + this._cache.x = this.game.camera.view.x + this.x; + this._cache.y = this.game.camera.view.y + this.y; + } + else + { + this._cache.x = this.x; + this._cache.y = this.y; + } + + if (this.position.x != this._cache.x || this.position.y != this._cache.y) + { + this.position.x = this._cache.x; + this.position.y = this._cache.y; + } + } + +} + +Phaser.Bullet.prototype.deltaAbsX = function () { + return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX()); +} + +Phaser.Bullet.prototype.deltaAbsY = function () { + return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY()); +} + +Phaser.Bullet.prototype.deltaX = function () { + return this.x - this.prevX; +} + +Phaser.Bullet.prototype.deltaY = function () { + return this.y - this.prevY; +} + +/** +* Description. +* +* @method Phaser.Bullet.prototype.revive +*/ +Phaser.Bullet.prototype.revive = function(health) { + + if (typeof health === 'undefined') { health = 1; } this.alive = true; this.exists = true; this.visible = true; - // this.events.onRevived.dispatch(this); + this.health = health; + + this.events.onRevived.dispatch(this); } +/** +* Description. +* +* @method Phaser.Bullet.prototype.kill +*/ Phaser.Bullet.prototype.kill = function() { this.alive = false; this.exists = false; this.visible = false; - // this.events.onKilled.dispatch(this); + this.events.onKilled.dispatch(this); } +/** +* Description. +* +* @method Phaser.Bullet.prototype.destroy +*/ +Phaser.Bullet.prototype.destroy = function() { + + if (this.group) + { + this.group.remove(this); + } + + this.events.destroy(); + + this.alive = false; + this.exists = false; + this.visible = false; + + this.game = null; + +} + +/** +* Description. +* +* @method Phaser.Sprite.prototype.reset +*/ Phaser.Bullet.prototype.reset = function(x, y) { this.x = x; this.y = y; - this.position.x = x; - this.position.y = y; + this.position.x = this.x; + this.position.y = this.y; this.alive = true; this.exists = true; this.visible = true; + this.renderable = true; this._outOfBoundsFired = false; - this.body.reset(); + + if (this.body) + { + this.body.reset(); + } } +/** +* Description. +* +* @method Phaser.Sprite.prototype.updateBounds +*/ Phaser.Bullet.prototype.updateBounds = function() { // Update the edge points - // this.bounds.setTo(this._cache.left, this._cache.top, this._cache.right - this._cache.left, this._cache.bottom - this._cache.top); + this.offset.setTo(this._cache.a02 - (this.anchor.x * this._cache.width), this._cache.a12 - (this.anchor.y * this._cache.height)); + + this.getLocalPosition(this.center, this.offset.x + this._cache.halfWidth, this.offset.y + this._cache.halfHeight); + this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y); + this.getLocalPosition(this.topRight, this.offset.x + this._cache.width, this.offset.y); + this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this._cache.height); + this.getLocalPosition(this.bottomRight, this.offset.x + this._cache.width, this.offset.y + this._cache.height); + + this._cache.left = Phaser.Math.min(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x); + this._cache.right = Phaser.Math.max(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x); + this._cache.top = Phaser.Math.min(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y); + this._cache.bottom = Phaser.Math.max(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y); + + this.bounds.setTo(this._cache.left, this._cache.top, this._cache.right - this._cache.left, this._cache.bottom - this._cache.top); + + // This is the coordinate the Bullet was at when the last bounds was created + this._cache.boundsX = this._cache.x; + this._cache.boundsY = this._cache.y; if (this.inWorld == false) { - // Sprite WAS out of the screen, is it still? + // Bullet WAS out of the screen, is it still? this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold); if (this.inWorld) @@ -314,18 +538,46 @@ Phaser.Bullet.prototype.updateBounds = function() { } else { - // Sprite WAS in the screen, has it now left? + // Bullet WAS in the screen, has it now left? this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold); if (this.inWorld == false) { this.events.onOutOfBounds.dispatch(this); this._outOfBoundsFired = true; + + if (this.outOfBoundsKill) + { + this.kill(); + } } } } +/** +* Description. +* +* @method Phaser.Bullet.prototype.getLocalPosition +* @param {Description} p - Description. +* @param {number} x - Description. +* @param {number} y - Description. +* @return {Description} Description. +*/ +Phaser.Bullet.prototype.getLocalPosition = function(p, x, y) { + + p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * this._cache.scaleX) + this._cache.a02; + p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * this._cache.scaleY) + this._cache.a12; + + return p; + +} + +/** +* Description. +* +* @method Phaser.Bullet.prototype.bringToTop +*/ Phaser.Bullet.prototype.bringToTop = function() { if (this.group) @@ -339,26 +591,33 @@ Phaser.Bullet.prototype.bringToTop = function() { } +/** +* Indicates the rotation of the Bullet, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. +* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90. +* If you wish to work in radians instead of degrees use the property Bullet.rotation instead. +* @name Phaser.Bullet#angle +* @property {number} angle - Gets or sets the Bullets angle of rotation in degrees. +*/ Object.defineProperty(Phaser.Bullet.prototype, 'angle', { get: function() { - return Phaser.Math.radToDeg(this.rotation); + return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation)); }, set: function(value) { - this.rotation = Phaser.Math.degToRad(value); + this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value)); } }); +/** +* Is this sprite visible to the camera or not? +* @returns {boolean} +*/ Object.defineProperty(Phaser.Bullet.prototype, "inCamera", { - /** - * Is this sprite visible to the camera or not? - */ get: function () { return this._cache.cameraVisible; } }); - diff --git a/src/gameobjects/Button.js b/src/gameobjects/Button.js index 325fee20..63bceb82 100644 --- a/src/gameobjects/Button.js +++ b/src/gameobjects/Button.js @@ -1,13 +1,13 @@ /** * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser.Button +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ + /** * Create a new Button object. -* @class Button +* @class Phaser.Button * @constructor * * @param {Phaser.Game} game Current game instance. @@ -22,7 +22,6 @@ */ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) { - x = x || 0; y = y || 0; key = key || null; @@ -31,21 +30,86 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, Phaser.Sprite.call(this, game, x, y, key, outFrame); + /** + * @property {Description} type - Description. + */ this.type = Phaser.BUTTON; + /** + * @property {Description} _onOverFrameName - Description. + * @private + * @default + */ this._onOverFrameName = null; + + /** + * @property {Description} _onOutFrameName - Description. + * @private + * @default + */ this._onOutFrameName = null; + + /** + * @property {Description} _onDownFrameName - Description. + * @private + * @default + */ this._onDownFrameName = null; + + /** + * @property {Description} _onUpFrameName - Description. + * @private + * @default + */ this._onUpFrameName = null; + + /** + * @property {Description} _onOverFrameID - Description. + * @private + * @default + */ this._onOverFrameID = null; + + /** + * @property {Description} _onOutFrameID - Description. + * @private + * @default + */ this._onOutFrameID = null; + + /** + * @property {Description} _onDownFrameID - Description. + * @private + * @default + */ this._onDownFrameID = null; + + /** + * @property {Description} _onUpFrameID - Description. + * @private + * @default + */ this._onUpFrameID = null; // These are the signals the game will subscribe to + /** + * @property {Phaser.Signal} onInputOver - Description. + */ this.onInputOver = new Phaser.Signal; + + /** + * @property {Phaser.Signal} onInputOut - Description. + */ this.onInputOut = new Phaser.Signal; + + /** + * @property {Phaser.Signal} onInputDown - Description. + */ this.onInputDown = new Phaser.Signal; + + /** + * @property {Phaser.Signal} onInputUp - Description. + */ this.onInputUp = new Phaser.Signal; this.setFrames(overFrame, outFrame, downFrame); @@ -55,7 +119,9 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame, this.onInputUp.add(callback, callbackContext); } - this.input.start(0, false, true); + this.freezeFrames = false; + + this.input.start(0, true); // Redirect the input events to here so we can handle animation updates, etc this.events.onInputOver.add(this.onInputOverHandler, this); @@ -70,12 +136,12 @@ Phaser.Button.prototype.constructor = Phaser.Button; /** * Used to manually set the frames that will be used for the different states of the button -* exactly like setting them in the constructor +* exactly like setting them in the constructor. * -* @method setFrames -* @param {string|number} [overFrame] This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name. -* @param {string|number} [outFrame] This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name. -* @param {string|number} [downFrame] This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name. +* @method Phaser.Button.prototype.setFrames +* @param {string|number} [overFrame] - This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name. +* @param {string|number} [outFrame] - This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name. +* @param {string|number} [downFrame] - This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name. */ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { @@ -84,10 +150,20 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { if (typeof overFrame === 'string') { this._onOverFrameName = overFrame; + + if (this.input.pointerOver()) + { + this.frameName = overFrame; + } } else { this._onOverFrameID = overFrame; + + if (this.input.pointerOver()) + { + this.frame = overFrame; + } } } @@ -97,11 +173,21 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { { this._onOutFrameName = outFrame; this._onUpFrameName = outFrame; + + if (this.input.pointerOver() == false) + { + this.frameName = outFrame; + } } else { this._onOutFrameID = outFrame; this._onUpFrameID = outFrame; + + if (this.input.pointerOver() == false) + { + this.frame = outFrame; + } } } @@ -110,24 +196,43 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) { if (typeof downFrame === 'string') { this._onDownFrameName = downFrame; + + if (this.input.pointerOver()) + { + this.frameName = downFrame; + } } else { this._onDownFrameID = downFrame; + + if (this.input.pointerOver()) + { + this.frame = downFrame; + } } } }; +/** +* Description. +* +* @method Phaser.Button.prototype.onInputOverHandler +* @param {Description} pointer - Description. +*/ Phaser.Button.prototype.onInputOverHandler = function (pointer) { - if (this._onOverFrameName != null) + if (this.freezeFrames == false) { - this.frameName = this._onOverFrameName; - } - else if (this._onOverFrameID != null) - { - this.frame = this._onOverFrameID; + if (this._onOverFrameName != null) + { + this.frameName = this._onOverFrameName; + } + else if (this._onOverFrameID != null) + { + this.frame = this._onOverFrameID; + } } if (this.onInputOver) @@ -136,15 +241,24 @@ Phaser.Button.prototype.onInputOverHandler = function (pointer) { } }; +/** +* Description. +* +* @method Phaser.Button.prototype.onInputOutHandler +* @param {Description} pointer - Description. +*/ Phaser.Button.prototype.onInputOutHandler = function (pointer) { - if (this._onOutFrameName != null) + if (this.freezeFrames == false) { - this.frameName = this._onOutFrameName; - } - else if (this._onOutFrameID != null) - { - this.frame = this._onOutFrameID; + if (this._onOutFrameName != null) + { + this.frameName = this._onOutFrameName; + } + else if (this._onOutFrameID != null) + { + this.frame = this._onOutFrameID; + } } if (this.onInputOut) @@ -153,15 +267,24 @@ Phaser.Button.prototype.onInputOutHandler = function (pointer) { } }; +/** +* Description. +* +* @method Phaser.Button.prototype.onInputDownHandler +* @param {Description} pointer - Description. +*/ Phaser.Button.prototype.onInputDownHandler = function (pointer) { - if (this._onDownFrameName != null) + if (this.freezeFrames == false) { - this.frameName = this._onDownFrameName; - } - else if (this._onDownFrameID != null) - { - this.frame = this._onDownFrameID; + if (this._onDownFrameName != null) + { + this.frameName = this._onDownFrameName; + } + else if (this._onDownFrameID != null) + { + this.frame = this._onDownFrameID; + } } if (this.onInputDown) @@ -170,15 +293,24 @@ Phaser.Button.prototype.onInputDownHandler = function (pointer) { } }; +/** +* Description. +* +* @method Phaser.Button.prototype.onInputUpHandler +* @param {Description} pointer - Description. +*/ Phaser.Button.prototype.onInputUpHandler = function (pointer) { - if (this._onUpFrameName != null) + if (this.freezeFrames == false) { - this.frameName = this._onUpFrameName; - } - else if (this._onUpFrameID != null) - { - this.frame = this._onUpFrameID; + if (this._onUpFrameName != null) + { + this.frameName = this._onUpFrameName; + } + else if (this._onUpFrameID != null) + { + this.frame = this._onUpFrameID; + } } if (this.onInputUp) diff --git a/src/gameobjects/Events.js b/src/gameobjects/Events.js index 09329ef9..73fe1abd 100644 --- a/src/gameobjects/Events.js +++ b/src/gameobjects/Events.js @@ -1,6 +1,17 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + + /** * The Events component is a collection of events fired by the parent game object and its components. -* @param parent The game object using this Input component +* +* @class Phaser.Events +* @constructor +* +* @param {Phaser.Sprite} sprite - A reference to Description. */ Phaser.Events = function (sprite) { @@ -22,4 +33,36 @@ Phaser.Events = function (sprite) { this.onAnimationComplete = null; this.onAnimationLoop = null; +}; + +Phaser.Events.prototype = { + + destroy: function () { + + this.parent = null; + this.onAddedToGroup.dispose(); + this.onRemovedFromGroup.dispose(); + this.onKilled.dispose(); + this.onRevived.dispose(); + this.onOutOfBounds.dispose(); + + if (this.onInputOver) + { + this.onInputOver.dispose(); + this.onInputOut.dispose(); + this.onInputDown.dispose(); + this.onInputUp.dispose(); + this.onDragStart.dispose(); + this.onDragStop.dispose(); + } + + if (this.onAnimationStart) + { + this.onAnimationStart.dispose(); + this.onAnimationComplete.dispose(); + this.onAnimationLoop.dispose(); + } + + } + }; \ No newline at end of file diff --git a/src/gameobjects/GameObjectFactory.js b/src/gameobjects/GameObjectFactory.js index 7ce7cf5b..9f1fd101 100644 --- a/src/gameobjects/GameObjectFactory.js +++ b/src/gameobjects/GameObjectFactory.js @@ -1,58 +1,83 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* The Game Object Factory is a quick way to create all of the different sorts of core objects that Phaser uses. +* +* @class Phaser.GameObjectFactory +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +*/ Phaser.GameObjectFactory = function (game) { + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; + + /** + * @property {Phaser.World} world - A reference to the game world. + */ this.world = this.game.world; }; Phaser.GameObjectFactory.prototype = { - game: null, - world: null, - + /** + * Adds an existing object to the game world. + * @method Phaser.GameObjectFactory#existing + * @param {*} object - An instance of Phaser.Sprite, Phaser.Button or any other display object.. + * @return {*} The child that was added to the Group. + */ existing: function (object) { - return this.world.group.add(object); + return this.world.add(object); }, /** * Create a new Sprite with specific position and sprite sheet key. * - * @param x {number} X position of the new sprite. - * @param y {number} Y position of the new sprite. - * @param [key] {string|RenderTexture} The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture - * @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. - * @returns {Sprite} The newly created sprite object. + * @method Phaser.GameObjectFactory#sprite + * @param {number} x - X position of the new sprite. + * @param {number} y - Y position of the new sprite. + * @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + * @param {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. + * @returns {Phaser.Sprite} the newly created sprite object. */ sprite: function (x, y, key, frame) { - return this.world.group.add(new Phaser.Sprite(this.game, x, y, key, frame)); + return this.world.create(x, y, key, frame); }, /** * Create a new Sprite with specific position and sprite sheet key that will automatically be added as a child of the given parent. * - * @param x {number} X position of the new sprite. - * @param y {number} Y position of the new sprite. - * @param [key] {string|RenderTexture} The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture - * @param [frame] {string|number} If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. - * @returns {Sprite} The newly created sprite object. + * @method Phaser.GameObjectFactory#child + * @param {Phaser.Group} group - The Group to add this child to. + * @param {number} x - X position of the new sprite. + * @param {number} y - Y position of the new sprite. + * @param {string|RenderTexture} [key] - The image key as defined in the Game.Cache to use as the texture for this sprite OR a RenderTexture. + * @param {string|number} [frame] - If the sprite uses an image from a texture atlas or sprite sheet you can pass the frame here. Either a number for a frame ID or a string for a frame name. + * @returns {Phaser.Sprite} the newly created sprite object. */ - child: function (parent, x, y, key, frame) { + child: function (group, x, y, key, frame) { - var child = this.world.group.add(new Phaser.Sprite(this.game, x, y, key, frame)); - parent.addChild(child); - return child; + return group.create(x, y, key, frame); }, /** * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. * - * @param obj {object} Object the tween will be run on. - * @return {Phaser.Tween} The newly created tween object. + * @method Phaser.GameObjectFactory#tween + * @param {object} obj - Object the tween will be run on. + * @return {Phaser.Tween} Description. */ tween: function (obj) { @@ -60,60 +85,187 @@ Phaser.GameObjectFactory.prototype = { }, + /** + * A Group is a container for display objects that allows for fast pooling, recycling and collision checks. + * + * @method Phaser.GameObjectFactory#group + * @param {*} parent - The parent Group or DisplayObjectContainer that will hold this group, if any. + * @param {string} [name=group] - A name for this Group. Not used internally but useful for debugging. + * @return {Phaser.Group} The newly created group. + */ group: function (parent, name) { return new Phaser.Group(this.game, parent, name); }, + /** + * Creates a new instance of the Sound class. + * + * @method Phaser.GameObjectFactory#audio + * @param {string} key - The Game.cache key of the sound that this object will use. + * @param {number} volume - The volume at which the sound will be played. + * @param {boolean} loop - Whether or not the sound will loop. + * @return {Phaser.Sound} The newly created text object. + */ audio: function (key, volume, loop) { return this.game.sound.add(key, volume, loop); }, + /** + * Creates a new TileSprite. + * + * @method Phaser.GameObjectFactory#tileSprite + * @param {number} x - X position of the new tileSprite. + * @param {number} y - Y position of the new tileSprite. + * @param {number} width - the width of the tilesprite. + * @param {number} height - the height of the tilesprite. + * @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + * @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. + * @return {Phaser.TileSprite} The newly created tileSprite object. + */ tileSprite: function (x, y, width, height, key, frame) { - return this.world.group.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame)); + return this.world.add(new Phaser.TileSprite(this.game, x, y, width, height, key, frame)); }, + /** + * Creates a new Text. + * + * @method Phaser.GameObjectFactory#text + * @param {number} x - X position of the new text object. + * @param {number} y - Y position of the new text object. + * @param {string} text - The actual text that will be written. + * @param {object} style - The style object containing style attributes like font, font size , etc. + * @return {Phaser.Text} The newly created text object. + */ text: function (x, y, text, style) { - return this.world.group.add(new Phaser.Text(this.game, x, y, text, style)); + return this.world.add(new Phaser.Text(this.game, x, y, text, style)); }, + /** + * Creates a new Button object. + * + * @method Phaser.GameObjectFactory#button + * @param {number} [x] X position of the new button object. + * @param {number} [y] Y position of the new button object. + * @param {string} [key] The image key as defined in the Game.Cache to use as the texture for this button. + * @param {function} [callback] The function to call when this button is pressed + * @param {object} [callbackContext] The context in which the callback will be called (usually 'this') + * @param {string|number} [overFrame] This is the frame or frameName that will be set when this button is in an over state. Give either a number to use a frame ID or a string for a frame name. + * @param {string|number} [outFrame] This is the frame or frameName that will be set when this button is in an out state. Give either a number to use a frame ID or a string for a frame name. + * @param {string|number} [downFrame] This is the frame or frameName that will be set when this button is in a down state. Give either a number to use a frame ID or a string for a frame name. + * @return {Phaser.Button} The newly created button object. + */ button: function (x, y, key, callback, callbackContext, overFrame, outFrame, downFrame) { - return this.world.group.add(new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame)); + return this.world.add(new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame)); }, + /** + * Creates a new Graphics object. + * + * @method Phaser.GameObjectFactory#graphics + * @param {number} x - X position of the new graphics object. + * @param {number} y - Y position of the new graphics object. + * @return {Phaser.Graphics} The newly created graphics object. + */ graphics: function (x, y) { - return this.world.group.add(new Phaser.Graphics(this.game, x, y)); + return this.world.add(new Phaser.Graphics(this.game, x, y)); }, + /** + * Emitter is a lightweight particle emitter. It can be used for one-time explosions or for + * continuous effects like rain and fire. All it really does is launch Particle objects out + * at set intervals, and fixes their positions and velocities accorindgly. + * + * @method Phaser.GameObjectFactory#emitter + * @param {number} [x=0] - The x coordinate within the Emitter that the particles are emitted from. + * @param {number} [y=0] - The y coordinate within the Emitter that the particles are emitted from. + * @param {number} [maxParticles=50] - The total number of particles in this emitter. + * @return {Phaser.Emitter} The newly created emitter object. + */ emitter: function (x, y, maxParticles) { return this.game.particles.add(new Phaser.Particles.Arcade.Emitter(this.game, x, y, maxParticles)); }, + /** + * * Create a new BitmapText. + * + * @method Phaser.GameObjectFactory#bitmapText + * @param {number} x - X position of the new bitmapText object. + * @param {number} y - Y position of the new bitmapText object. + * @param {string} text - The actual text that will be written. + * @param {object} style - The style object containing style attributes like font, font size , etc. + * @return {Phaser.BitmapText} The newly created bitmapText object. + */ bitmapText: function (x, y, text, style) { - return this.world.group.add(new Phaser.BitmapText(this.game, x, y, text, style)); + return this.world.add(new Phaser.BitmapText(this.game, x, y, text, style)); }, - tilemap: function (x, y, key, resizeWorld, tileWidth, tileHeight) { + /** + * Creates a new Tilemap object. + * + * @method Phaser.GameObjectFactory#tilemap + * @param {string} key - Asset key for the JSON file. + * @return {Phaser.Tilemap} The newly created tilemap object. + */ + tilemap: function (key) { - return this.world.group.add(new Phaser.Tilemap(this.game, key, x, y, resizeWorld, tileWidth, tileHeight)); + return new Phaser.Tilemap(this.game, key); }, + /** + * Creates a new Tileset object. + * + * @method Phaser.GameObjectFactory#tileset + * @param {string} key - The image key as defined in the Game.Cache to use as the tileset. + * @return {Phaser.Tileset} The newly created tileset object. + */ + tileset: function (key) { + + return this.game.cache.getTileset(key); + + }, + + /** + * Creates a new Tilemap Layer object. + * + * @method Phaser.GameObjectFactory#tilemapLayer + * @param {number} x - X position of the new tilemapLayer. + * @param {number} y - Y position of the new tilemapLayer. + * @param {number} width - the width of the tilemapLayer. + * @param {number} height - the height of the tilemapLayer. + * @return {Phaser.TilemapLayer} The newly created tilemaplayer object. + */ + tilemapLayer: function (x, y, width, height, tileset, tilemap, layer) { + + return this.world.add(new Phaser.TilemapLayer(this.game, x, y, width, height, tileset, tilemap, layer)); + + }, + + /** + * A dynamic initially blank canvas to which images can be drawn. + * + * @method Phaser.GameObjectFactory#renderTexture + * @param {string} key - Asset key for the render texture. + * @param {number} width - the width of the render texture. + * @param {number} height - the height of the render texture. + * @return {Phaser.RenderTexture} The newly created renderTexture object. + */ renderTexture: function (key, width, height) { var texture = new Phaser.RenderTexture(this.game, key, width, height); @@ -122,6 +274,6 @@ Phaser.GameObjectFactory.prototype = { return texture; - }, + } }; \ No newline at end of file diff --git a/src/gameobjects/Graphics.js b/src/gameobjects/Graphics.js index 9bafc76b..e2303e9f 100644 --- a/src/gameobjects/Graphics.js +++ b/src/gameobjects/Graphics.js @@ -1,27 +1,87 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Creates a new Graphics object. +* +* @class Phaser.Graphics +* @constructor +* +* @param {Phaser.Game} game Current game instance. +* @param {number} x - X position of the new graphics object. +* @param {number} y - Y position of the new graphics object. +*/ Phaser.Graphics = function (game, x, y) { + this.game = game; + PIXI.Graphics.call(this); - Phaser.Sprite.call(this, game, x, y); - + /** + * @property {Description} type - Description. + */ this.type = Phaser.GRAPHICS; }; Phaser.Graphics.prototype = Object.create(PIXI.Graphics.prototype); Phaser.Graphics.prototype.constructor = Phaser.Graphics; -Phaser.Graphics.prototype = Phaser.Utils.extend(true, Phaser.Graphics.prototype, Phaser.Sprite.prototype); // Add our own custom methods +/** +* Description. +* +* @method Phaser.Sprite.prototype.destroy +*/ +Phaser.Graphics.prototype.destroy = function() { + + this.clear(); + + if (this.group) + { + this.group.remove(this); + } + + this.game = null; + +} + Object.defineProperty(Phaser.Graphics.prototype, 'angle', { get: function() { - return Phaser.Math.radToDeg(this.rotation); + return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation)); }, set: function(value) { - this.rotation = Phaser.Math.degToRad(value); + this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value)); + } + +}); + +Object.defineProperty(Phaser.Graphics.prototype, 'x', { + + get: function() { + return this.position.x; + }, + + set: function(value) { + this.position.x = value; + } + +}); + +Object.defineProperty(Phaser.Graphics.prototype, 'y', { + + get: function() { + return this.position.y; + }, + + set: function(value) { + this.position.y = value; } }); diff --git a/src/gameobjects/RenderTexture.js b/src/gameobjects/RenderTexture.js index 10d8560a..597fd700 100644 --- a/src/gameobjects/RenderTexture.js +++ b/src/gameobjects/RenderTexture.js @@ -1,20 +1,57 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* A dynamic initially blank canvas to which images can be drawn +* @class Phaser.RenderTexture +* @constructor +* @param {Phaser.Game} game - Current game instance. +* @param {string} key - Asset key for the render texture. +* @param {number} width - the width of the render texture. +* @param {number} height - the height of the render texture. +*/ Phaser.RenderTexture = function (game, key, width, height) { + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; + /** + * @property {string} name - the name of the object. + */ this.name = key; PIXI.EventTarget.call( this ); + /** + * @property {number} width - the width. + */ this.width = width || 100; + + /** + * @property {number} height - the height. + */ this.height = height || 100; - // I know this has a typo in it, but it's because the PIXI.RenderTexture does and we need to pair-up with it - // once they update pixi to fix the typo, we'll fix it here too :) + /** + * I know this has a typo in it, but it's because the PIXI.RenderTexture does and we need to pair-up with it + * once they update pixi to fix the typo, we'll fix it here too :) + * @property {Description} indetityMatrix - Description. + */ this.indetityMatrix = PIXI.mat3.create(); + /** + * @property {Description} frame - Description. + */ this.frame = new PIXI.Rectangle(0, 0, this.width, this.height); + /** + * @property {Description} type - Description. + */ this.type = Phaser.RENDERTEXTURE; if (PIXI.gl) diff --git a/src/gameobjects/Sprite.js b/src/gameobjects/Sprite.js index d3fdb6df..3384cb73 100644 --- a/src/gameobjects/Sprite.js +++ b/src/gameobjects/Sprite.js @@ -1,61 +1,121 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Create a new `Sprite` object. Sprites are the lifeblood of your game, used for nearly everything visual. +* At its most basic a Sprite consists of a set of coordinates and a texture that is rendered to the canvas. +* They also contain additional properties allowing for physics motion (via Sprite.body), input handling (via Sprite.input), +* events (via Sprite.events), animation (via Sprite.animations), camera culling and more. Please see the Examples for use cases. +* +* @class Phaser.Sprite +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {number} x - The x coordinate (in world space) to position the Sprite at. +* @param {number} y - The y coordinate (in world space) to position the Sprite at. +* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. +* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. +*/ Phaser.Sprite = function (game, x, y, key, frame) { x = x || 0; y = y || 0; key = key || null; frame = frame || null; - + + /** + * @property {Phaser.Game} game - A reference to the currently running Game. + */ this.game = game; - - // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all + + /** + * @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all. + * @default + */ this.exists = true; - // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering + /** + * @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering. + * @default + */ this.alive = true; + /** + * @property {Phaser.Group} group - The parent Group of this Sprite. This is usually set after Sprite instantiation by the parent. + */ this.group = null; + /** + * @property {string} name - The user defined name given to this Sprite. + * @default + */ this.name = ''; + /** + * @property {number} type - The const type of this object. + * @default + */ this.type = Phaser.SPRITE; + /** + * @property {number} renderOrderID - Used by the Renderer and Input Manager to control picking order. + * @default + */ this.renderOrderID = -1; - // If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc. - // The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called. + /** + * If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc. + * The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called. + * @property {number} lifespan - The lifespan of the Sprite (in ms) before it will be killed. + * @default + */ this.lifespan = 0; /** - * The Signals you can subscribe to that are dispatched when certain things happen on this Sprite or its components - * @type Events - */ + * @property {Events} events - The Events you can subscribe to that are dispatched when certain things happen on this Sprite or its components. + */ this.events = new Phaser.Events(this); /** - * This manages animations of the sprite. You can modify animations through it. (see AnimationManager) - * @type AnimationManager - */ + * @property {Phaser.AnimationManager} animations - This manages animations of the sprite. You can modify animations through it (see Phaser.AnimationManager) + */ this.animations = new Phaser.AnimationManager(this); /** - * The Input Handler Component - * @type InputHandler - */ + * @property {InputHandler} input - The Input Handler Component. + */ this.input = new Phaser.InputHandler(this); + /** + * @property {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. + */ this.key = key; + /** + * @property {Phaser.Frame} currentFrame - A reference to the currently displayed frame. + */ + this.currentFrame = null; + if (key instanceof Phaser.RenderTexture) { PIXI.Sprite.call(this, key); this.currentFrame = this.game.cache.getTextureFrame(key.name); } + else if (key instanceof PIXI.Texture) + { + PIXI.Sprite.call(this, key); + + this.currentFrame = frame; + } else { if (key == null || this.game.cache.checkImageKey(key) == false) { key = '__default'; + this.key = key; } PIXI.Sprite.call(this, PIXI.TextureCache[key]); @@ -83,98 +143,184 @@ Phaser.Sprite = function (game, x, y, key, frame) { } /** - * The anchor sets the origin point of the texture. - * The default is 0,0 this means the textures origin is the top left - * Setting than anchor to 0.5,0.5 means the textures origin is centered - * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right - * - * @property anchor - * @type Point - */ + * The anchor sets the origin point of the texture. + * The default is 0,0 this means the textures origin is the top left + * Setting than anchor to 0.5,0.5 means the textures origin is centered + * Setting the anchor to 1,1 would mean the textures origin points will be the bottom right + * + * @property {Phaser.Point} anchor - The anchor around with Sprite rotation and scaling takes place. + */ this.anchor = new Phaser.Point(); - this._cropUUID = null; - this._cropRect = null; - + /** + * @property {number} x - The x coordinate (in world space) of this Sprite. + */ this.x = x; + + /** + * @property {number} y - The y coordinate (in world space) of this Sprite. + */ this.y = y; this.position.x = x; this.position.y = y; /** - * Should this Sprite be automatically culled if out of range of the camera? - * A culled sprite has its visible property set to 'false'. - * Note that this check doesn't look at this Sprites children, which may still be in camera range. - * So you should set autoCull to false if the Sprite will have children likely to still be in camera range. - * - * @property autoCull - * @type Boolean - */ + * Should this Sprite be automatically culled if out of range of the camera? + * A culled sprite has its renderable property set to 'false'. + * + * @property {boolean} autoCull - A flag indicating if the Sprite should be automatically camera culled or not. + * @default + */ this.autoCull = false; - // Replaces the PIXI.Point with a slightly more flexible one + /** + * @property {Phaser.Point} scale - The scale of the Sprite when rendered. By default it's set to 1 (no scale). You can modify it via scale.x or scale.y or scale.setTo(x, y). A value of 1 means no change to the scale, 0.5 means "half the size", 2 means "twice the size", etc. + */ this.scale = new Phaser.Point(1, 1); - // Influence of camera movement upon the position - this.scrollFactor = new Phaser.Point(1, 1); - - // A mini cache for storing all of the calculated values + /** + * @property {Phaser.Point} _cache - A mini cache for storing all of the calculated values. + * @private + */ this._cache = { dirty: false, // Transform cache - a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, + a00: -1, a01: -1, a02: -1, a10: -1, a11: -1, a12: -1, id: -1, // Input specific transform cache - i01: 0, i10: 0, idi: 1, + i01: -1, i10: -1, idi: -1, // Bounds check left: null, right: null, top: null, bottom: null, - // The previous calculated position inc. camera x/y and scrollFactor + // The previous calculated position x: -1, y: -1, // The actual scale values based on the worldTransform scaleX: 1, scaleY: 1, + // cache scale check + realScaleX: 1, realScaleY: 1, + // The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size width: this.currentFrame.sourceSizeW, height: this.currentFrame.sourceSizeH, // The actual width/height of the image if from a trimmed atlas, multiplied by the final calculated scale size halfWidth: Math.floor(this.currentFrame.sourceSizeW / 2), halfHeight: Math.floor(this.currentFrame.sourceSizeH / 2), + // The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size + calcWidth: -1, calcHeight: -1, + // The current frame details - frameID: this.currentFrame.uuid, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height, + // frameID: this.currentFrame.uuid, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height, + frameID: -1, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height, boundsX: 0, boundsY: 0, // If this sprite visible to the camera (regardless of being set to visible or not) - cameraVisible: true + cameraVisible: true, + + // Crop cache + cropX: 0, cropY: 0, cropWidth: this.currentFrame.sourceSizeW, cropHeight: this.currentFrame.sourceSizeH }; - - // Corner point defaults + + /** + * @property {Phaser.Point} offset - Corner point defaults. Should not typically be modified. + */ this.offset = new Phaser.Point; + + /** + * @property {Phaser.Point} center - A Point containing the center coordinate of the Sprite. Takes rotation and scale into account. + */ this.center = new Phaser.Point(x + Math.floor(this._cache.width / 2), y + Math.floor(this._cache.height / 2)); + + /** + * @property {Phaser.Point} topLeft - A Point containing the top left coordinate of the Sprite. Takes rotation and scale into account. + */ this.topLeft = new Phaser.Point(x, y); + + /** + * @property {Phaser.Point} topRight - A Point containing the top right coordinate of the Sprite. Takes rotation and scale into account. + */ this.topRight = new Phaser.Point(x + this._cache.width, y); + + /** + * @property {Phaser.Point} bottomRight - A Point containing the bottom right coordinate of the Sprite. Takes rotation and scale into account. + */ this.bottomRight = new Phaser.Point(x + this._cache.width, y + this._cache.height); + + /** + * @property {Phaser.Point} bottomLeft - A Point containing the bottom left coordinate of the Sprite. Takes rotation and scale into account. + */ this.bottomLeft = new Phaser.Point(x, y + this._cache.height); + + /** + * This Rectangle object fully encompasses the Sprite and is updated in real-time. + * The bounds is the full bounding area after rotation and scale have been taken into account. It should not be modified directly. + * It's used for Camera culling and physics body alignment. + * @property {Phaser.Rectangle} bounds + */ this.bounds = new Phaser.Rectangle(x, y, this._cache.width, this._cache.height); - - // Set-up the physics body + + /** + * @property {Phaser.Physics.Arcade.Body} body - By default Sprites have a Phaser.Physics Body attached to them. You can operate physics actions via this property, or null it to skip all physics updates. + */ this.body = new Phaser.Physics.Arcade.Body(this); - this.velocity = this.body.velocity; - this.acceleration = this.body.acceleration; + /** + * @property {number} health - Health value. Used in combination with damage() to allow for quick killing of Sprites. + */ + this.health = 1; - // World bounds check + /** + * @property {boolean} inWorld - This value is set to true if the Sprite is positioned within the World, otherwise false. + */ this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds); + + /** + * @property {number} inWorldThreshold - A threshold value applied to the inWorld check. If you don't want a Sprite to be considered "out of the world" until at least 100px away for example then set it to 100. + * @default + */ this.inWorldThreshold = 0; + + /** + * @property {boolean} outOfBoundsKill - If true the Sprite is killed as soon as Sprite.inWorld is false. + * @default + */ + this.outOfBoundsKill = false; + + /** + * @property {boolean} _outOfBoundsFired - Internal flag. + * @private + * @default + */ this._outOfBoundsFired = false; + /** + * A Sprite that is fixed to the camera ignores the position of any ancestors in the display list and uses its x/y coordinates as offsets from the top left of the camera. + * @property {boolean} fixedToCamera - Fixes this Sprite to the Camera. + * @default + */ + this.fixedToCamera = false; + + /** + * You can crop the Sprites texture by modifying the crop properties. For example crop.width = 50 would set the Sprite to only render 50px wide. + * The crop is only applied if you have set Sprite.cropEnabled to true. + * @property {Phaser.Rectangle} crop - The crop Rectangle applied to the Sprite texture before rendering. + * @default + */ + this.crop = new Phaser.Rectangle(0, 0, this._cache.width, this._cache.height); + + /** + * @property {boolean} cropEnabled - If true the Sprite.crop property is used to crop the texture before render. Set to false to disable. + * @default + */ + this.cropEnabled = false; + }; // Needed to keep the PIXI.Sprite constructor in the prototype chain (as the core pixi renderer uses an instanceof check sadly) @@ -182,8 +328,11 @@ Phaser.Sprite.prototype = Object.create(PIXI.Sprite.prototype); Phaser.Sprite.prototype.constructor = Phaser.Sprite; /** - * Automatically called by World.update. You can create your own update in Objects that extend Phaser.Sprite. - */ +* Automatically called by World.preUpdate. Handles cache updates, lifespan checks, animation updates and physics updates. +* +* @method Phaser.Sprite#preUpdate +* @memberof Phaser.Sprite +*/ Phaser.Sprite.prototype.preUpdate = function() { if (!this.exists) @@ -210,46 +359,77 @@ Phaser.Sprite.prototype.preUpdate = function() { this._cache.dirty = true; } - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); - - // If this sprite or the camera have moved then let's update everything - // Note: The actual position shouldn't be changed if this item is inside a Group? - if (this.position.x != this._cache.x || this.position.y != this._cache.y) - { - this.position.x = this._cache.x; - this.position.y = this._cache.y; - this._cache.dirty = true; - } - if (this.visible) { this.renderOrderID = this.game.world.currentRenderOrderID++; } + this.prevX = this.x; + this.prevY = this.y; + + this.updateCache(); + this.updateAnimation(); + + if (this.cropEnabled) + { + this.updateCrop(); + } + + // Re-run the camera visibility check + if (this._cache.dirty) + { + this.updateBounds(); + + this._cache.cameraVisible = Phaser.Rectangle.intersects(this.game.world.camera.screenView, this.bounds, 0); + + if (this.autoCull == true) + { + // Won't get rendered but will still get its transform updated + this.renderable = this._cache.cameraVisible; + } + + // Update our physics bounds + if (this.body) + { + this.body.updateBounds(this.center.x, this.center.y, this._cache.scaleX, this._cache.scaleY); + } + } + + if (this.body) + { + this.body.preUpdate(); + } + +} + +/** +* Internal function called by preUpdate. +* +* @method Phaser.Sprite#updateCache +* @memberof Phaser.Sprite +*/ +Phaser.Sprite.prototype.updateCache = function() { + // |a c tx| // |b d ty| // |0 0 1| - // Only update the values we need - if (this.worldTransform[0] != this._cache.a00 || this.worldTransform[1] != this._cache.a01) + if (this.worldTransform[1] != this._cache.i01 || this.worldTransform[3] != this._cache.i10) { this._cache.a00 = this.worldTransform[0]; // scaleX a this._cache.a01 = this.worldTransform[1]; // skewY c - this._cache.i01 = this.worldTransform[1]; // skewY c - this._cache.scaleX = Math.sqrt((this._cache.a00 * this._cache.a00) + (this._cache.a01 * this._cache.a01)); // round this off a bit? - this._cache.a01 *= -1; - this._cache.dirty = true; - } - - // Need to test, but probably highly unlikely that a scaleX would happen without effecting the Y skew - if (this.worldTransform[3] != this._cache.a10 || this.worldTransform[4] != this._cache.a11) - { this._cache.a10 = this.worldTransform[3]; // skewX b - this._cache.i10 = this.worldTransform[3]; // skewX b this._cache.a11 = this.worldTransform[4]; // scaleY d + + this._cache.i01 = this.worldTransform[1]; // skewY c (remains non-modified for input checks) + this._cache.i10 = this.worldTransform[3]; // skewX b (remains non-modified for input checks) + + this._cache.scaleX = Math.sqrt((this._cache.a00 * this._cache.a00) + (this._cache.a01 * this._cache.a01)); // round this off a bit? this._cache.scaleY = Math.sqrt((this._cache.a10 * this._cache.a10) + (this._cache.a11 * this._cache.a11)); // round this off a bit? + + this._cache.a01 *= -1; this._cache.a10 *= -1; + this._cache.dirty = true; } @@ -260,8 +440,17 @@ Phaser.Sprite.prototype.preUpdate = function() { this._cache.dirty = true; } - // Frame updated? - if (this.currentFrame.uuid != this._cache.frameID) +} + +/** +* Internal function called by preUpdate. +* +* @method Phaser.Sprite#updateAnimation +* @memberof Phaser.Sprite +*/ +Phaser.Sprite.prototype.updateAnimation = function() { + + if (this.currentFrame && this.currentFrame.uuid != this._cache.frameID) { this._cache.frameWidth = this.texture.frame.width; this._cache.frameHeight = this.texture.frame.height; @@ -269,116 +458,43 @@ Phaser.Sprite.prototype.preUpdate = function() { this._cache.dirty = true; } - if (this._cache.dirty) + if (this._cache.dirty && this.currentFrame) { - this._cache.width = Math.floor(this.currentFrame.sourceSizeW * this._cache.scaleX); - this._cache.height = Math.floor(this.currentFrame.sourceSizeH * this._cache.scaleY); + this._cache.width = this.currentFrame.width; + this._cache.height = this.currentFrame.height; this._cache.halfWidth = Math.floor(this._cache.width / 2); this._cache.halfHeight = Math.floor(this._cache.height / 2); this._cache.id = 1 / (this._cache.a00 * this._cache.a11 + this._cache.a01 * -this._cache.a10); this._cache.idi = 1 / (this._cache.a00 * this._cache.a11 + this._cache.i01 * -this._cache.i10); - - this.updateBounds(); - } - // } - // else - // { - // We still need to work out the bounds in case the camera has moved - // but we can't use the local or worldTransform to do it, as Pixi resets that if a Sprite is invisible. - // So we'll compare against the cached state + new position. - // if (this._cache.dirty && this.visible == false) - // { - // this.bounds.x -= this._cache.boundsX - this._cache.x; - // this._cache.boundsX = this._cache.x; - - // this.bounds.y -= this._cache.boundsY - this._cache.y; - // this._cache.boundsY = this._cache.y; - // } - // } - - // Re-run the camera visibility check - if (this._cache.dirty) - { - this._cache.cameraVisible = Phaser.Rectangle.intersects(this.game.world.camera.screenView, this.bounds, 0); - - if (this.autoCull == true) - { - // Won't get rendered but will still get its transform updated - this.renderable = this._cache.cameraVisible; - } - - // Update our physics bounds - this.body.updateBounds(this.center.x, this.center.y, this._cache.scaleX, this._cache.scaleY); - } - - this.body.update(); - -} - -Phaser.Sprite.prototype.postUpdate = function() { - - if (this.exists) - { - this.body.postUpdate(); } } /** - * Moves the sprite so its center is located on the given x and y coordinates. - * Doesn't change the origin of the sprite. - */ -Phaser.Sprite.prototype.centerOn = function(x, y) { - - this.x = x + (this.x - this.center.x); - this.y = y + (this.y - this.center.y); - -} - -Phaser.Sprite.prototype.revive = function() { - - this.alive = true; - this.exists = true; - this.visible = true; - this.events.onRevived.dispatch(this); - -} - -Phaser.Sprite.prototype.kill = function() { - - this.alive = false; - this.exists = false; - this.visible = false; - this.events.onKilled.dispatch(this); - -} - -Phaser.Sprite.prototype.reset = function(x, y) { - - this.x = x; - this.y = y; - this.position.x = x; - this.position.y = y; - this.alive = true; - this.exists = true; - this.visible = true; - this._outOfBoundsFired = false; - this.body.reset(); - -} - +* Internal function called by preUpdate. +* +* @method Phaser.Sprite#updateBounds +* @memberof Phaser.Sprite +*/ Phaser.Sprite.prototype.updateBounds = function() { - // Update the edge points + var sx = 1; + var sy = 1; - this.offset.setTo(this._cache.a02 - (this.anchor.x * this._cache.width), this._cache.a12 - (this.anchor.y * this._cache.height)); + if (this.worldTransform[3] !== 0 || this.worldTransform[1] !== 0) + { + sx = this.scale.x; + sy = this.scale.y; + } - this.getLocalPosition(this.center, this.offset.x + this._cache.halfWidth, this.offset.y + this._cache.halfHeight); - this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y); - this.getLocalPosition(this.topRight, this.offset.x + this._cache.width, this.offset.y); - this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this._cache.height); - this.getLocalPosition(this.bottomRight, this.offset.x + this._cache.width, this.offset.y + this._cache.height); + this.offset.setTo(this._cache.a02 - (this.anchor.x * this.width), this._cache.a12 - (this.anchor.y * this.height)); + + this.getLocalPosition(this.center, this.offset.x + (this.width / 2), this.offset.y + (this.height / 2), sx, sy); + this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y, sx, sy); + this.getLocalPosition(this.topRight, this.offset.x + this.width, this.offset.y, sx, sy); + this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this.height, sx, sy); + this.getLocalPosition(this.bottomRight, this.offset.x + this.width, this.offset.y + this.height, sx, sy); this._cache.left = Phaser.Math.min(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x); this._cache.right = Phaser.Math.max(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x); @@ -390,6 +506,8 @@ Phaser.Sprite.prototype.updateBounds = function() { // This is the coordinate the Sprite was at when the last bounds was created this._cache.boundsX = this._cache.x; this._cache.boundsY = this._cache.y; + + this.updateFrame = true; if (this.inWorld == false) { @@ -411,29 +529,419 @@ Phaser.Sprite.prototype.updateBounds = function() { { this.events.onOutOfBounds.dispatch(this); this._outOfBoundsFired = true; + + if (this.outOfBoundsKill) + { + this.kill(); + } } } } -Phaser.Sprite.prototype.getLocalPosition = function(p, x, y) { +/** +* Gets the local position of a coordinate relative to the Sprite, factoring in rotation and scale. +* Mostly only used internally. +* +* @method Phaser.Sprite#getLocalPosition +* @memberof Phaser.Sprite +* @param {Phaser.Point} p - The Point object to store the results in. +* @param {number} x - x coordinate within the Sprite to translate. +* @param {number} y - x coordinate within the Sprite to translate. +* @param {number} sx - Scale factor to be applied. +* @param {number} sy - Scale factor to be applied. +* @return {Phaser.Point} The translated point. +*/ +Phaser.Sprite.prototype.getLocalPosition = function(p, x, y, sx, sy) { - p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * this._cache.scaleX) + this._cache.a02; - p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * this._cache.scaleY) + this._cache.a12; + p.x = ((this._cache.a11 * this._cache.id * x + -this._cache.a01 * this._cache.id * y + (this._cache.a12 * this._cache.a01 - this._cache.a02 * this._cache.a11) * this._cache.id) * sx) + this._cache.a02; + p.y = ((this._cache.a00 * this._cache.id * y + -this._cache.a10 * this._cache.id * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.a10) * this._cache.id) * sy) + this._cache.a12; return p; } -Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, x, y) { +/** +* Gets the local unmodified position of a coordinate relative to the Sprite, factoring in rotation and scale. +* Mostly only used internally by the Input Manager, but also useful for custom hit detection. +* +* @method Phaser.Sprite#getLocalUnmodifiedPosition +* @memberof Phaser.Sprite +* @param {Phaser.Point} p - The Point object to store the results in. +* @param {number} x - x coordinate within the Sprite to translate. +* @param {number} y - x coordinate within the Sprite to translate. +* @return {Phaser.Point} The translated point. +*/ +Phaser.Sprite.prototype.getLocalUnmodifiedPosition = function(p, gx, gy) { - p.x = this._cache.a11 * this._cache.idi * x + -this._cache.i01 * this._cache.idi * y + (this._cache.a12 * this._cache.i01 - this._cache.a02 * this._cache.a11) * this._cache.idi; - p.y = this._cache.a00 * this._cache.idi * y + -this._cache.i10 * this._cache.idi * x + (-this._cache.a12 * this._cache.a00 + this._cache.a02 * this._cache.i10) * this._cache.idi; + var a00 = this.worldTransform[0], a01 = this.worldTransform[1], a02 = this.worldTransform[2], + a10 = this.worldTransform[3], a11 = this.worldTransform[4], a12 = this.worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10), + x = a11 * id * gx + -a01 * id * gy + (a12 * a01 - a02 * a11) * id, + y = a00 * id * gy + -a10 * id * gx + (-a12 * a00 + a02 * a10) * id; + + p.x = x + (this.anchor.x * this._cache.width); + p.y = y + (this.anchor.y * this._cache.height); return p; } +/** +* Internal function called by preUpdate. +* +* @method Phaser.Sprite#updateCrop +* @memberof Phaser.Sprite +*/ +Phaser.Sprite.prototype.updateCrop = function() { + + // This only runs if crop is enabled + if (this.crop.width != this._cache.cropWidth || this.crop.height != this._cache.cropHeight || this.crop.x != this._cache.cropX || this.crop.y != this._cache.cropY) + { + this.crop.floorAll(); + + this._cache.cropX = this.crop.x; + this._cache.cropY = this.crop.y; + this._cache.cropWidth = this.crop.width; + this._cache.cropHeight = this.crop.height; + + this.texture.frame = this.crop; + this.texture.width = this.crop.width; + this.texture.height = this.crop.height; + + this.texture.updateFrame = true; + + PIXI.Texture.frameUpdates.push(this.texture); + } + +} + +/** +* Resets the Sprite.crop value back to the frame dimensions. +* +* @method Phaser.Sprite#resetCrop +* @memberof Phaser.Sprite +*/ +Phaser.Sprite.prototype.resetCrop = function() { + + this.crop = new Phaser.Rectangle(0, 0, this._cache.width, this._cache.height); + this.texture.setFrame(this.crop); + this.cropEnabled = false; + +} + +/** +* Internal function called by the World postUpdate cycle. +* +* @method Phaser.Sprite#postUpdate +* @memberof Phaser.Sprite +*/ +Phaser.Sprite.prototype.postUpdate = function() { + + if (this.exists) + { + // The sprite is positioned in this call, after taking into consideration motion updates and collision + if (this.body) + { + this.body.postUpdate(); + } + + if (this.fixedToCamera) + { + this._cache.x = this.game.camera.view.x + this.x; + this._cache.y = this.game.camera.view.y + this.y; + } + else + { + this._cache.x = this.x; + this._cache.y = this.y; + } + + if (this.position.x != this._cache.x || this.position.y != this._cache.y) + { + this.position.x = this._cache.x; + this.position.y = this._cache.y; + } + } + +} + +/** +* Changes the Texture the Sprite is using entirely. The old texture is removed and the new one is referenced or fetched from the Cache. +* This causes a WebGL texture update, so use sparingly or in low-intensity portions of your game. +* +* @method Phaser.Sprite#loadTexture +* @memberof Phaser.Sprite +* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. +* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. +*/ +Phaser.Sprite.prototype.loadTexture = function (key, frame) { + + this.key = key; + + if (key instanceof Phaser.RenderTexture) + { + this.currentFrame = this.game.cache.getTextureFrame(key.name); + } + else if (key instanceof PIXI.Texture) + { + this.currentFrame = frame; + } + else + { + if (typeof key === 'undefined' || this.game.cache.checkImageKey(key) === false) + { + key = '__default'; + this.key = key; + } + + if (this.game.cache.isSpriteSheet(key)) + { + this.animations.loadFrameData(this.game.cache.getFrameData(key)); + + if (typeof frame !== 'undefined') + { + if (typeof frame === 'string') + { + this.frameName = frame; + } + else + { + this.frame = frame; + } + } + } + else + { + this.currentFrame = this.game.cache.getFrame(key); + this.setTexture(PIXI.TextureCache[key]); + } + } + +} + +/** +* Returns the absolute delta x value. +* +* @method Phaser.Sprite#deltaAbsX +* @memberof Phaser.Sprite +* @return {number} The absolute delta value. +*/ +Phaser.Sprite.prototype.deltaAbsX = function () { + return (this.deltaX() > 0 ? this.deltaX() : -this.deltaX()); +} + +/** +* Returns the absolute delta y value. +* +* @method Phaser.Sprite#deltaAbsY +* @memberof Phaser.Sprite +* @return {number} The absolute delta value. +*/ +Phaser.Sprite.prototype.deltaAbsY = function () { + return (this.deltaY() > 0 ? this.deltaY() : -this.deltaY()); +} + +/** +* Returns the delta x value. +* +* @method Phaser.Sprite#deltaX +* @memberof Phaser.Sprite +* @return {number} The delta value. +*/ +Phaser.Sprite.prototype.deltaX = function () { + return this.x - this.prevX; +} + +/** +* Returns the delta y value. +* +* @method Phaser.Sprite#deltaY +* @memberof Phaser.Sprite +* @return {number} The delta value. +*/ +Phaser.Sprite.prototype.deltaY = function () { + return this.y - this.prevY; +} + +/** +* Moves the sprite so its center is located on the given x and y coordinates. +* Doesn't change the anchor point of the sprite. +* +* @method Phaser.Sprite#centerOn +* @memberof Phaser.Sprite +* @param {number} x - The x coordinate (in world space) to position the Sprite at. +* @param {number} y - The y coordinate (in world space) to position the Sprite at. +* @return (Phaser.Sprite) This instance. +*/ +Phaser.Sprite.prototype.centerOn = function(x, y) { + + this.x = x + (this.x - this.center.x); + this.y = y + (this.y - this.center.y); + return this; + +} + +/** +* Brings a 'dead' Sprite back to life, optionally giving it the health value specified. +* A resurrected Sprite has its alive, exists and visible properties all set to true. +* It will dispatch the onRevived event, you can listen to Sprite.events.onRevived for the signal. +* +* @method Phaser.Sprite#revive +* @memberof Phaser.Sprite +* @param {number} [health=1] - The health to give the Sprite. +* @return (Phaser.Sprite) This instance. +*/ +Phaser.Sprite.prototype.revive = function(health) { + + if (typeof health === 'undefined') { health = 1; } + + this.alive = true; + this.exists = true; + this.visible = true; + this.health = health; + + if (this.events) + { + this.events.onRevived.dispatch(this); + } + + return this; + +} + +/** +* Kills a Sprite. A killed Sprite has its alive, exists and visible properties all set to false. +* It will dispatch the onKilled event, you can listen to Sprite.events.onKilled for the signal. +* Note that killing a Sprite is a way for you to quickly recycle it in a Sprite pool, it doesn't free it up from memory. +* If you don't need this Sprite any more you should call Sprite.destroy instead. +* +* @method Phaser.Sprite#kill +* @memberof Phaser.Sprite +* @return (Phaser.Sprite) This instance. +*/ +Phaser.Sprite.prototype.kill = function() { + + this.alive = false; + this.exists = false; + this.visible = false; + + if (this.events) + { + this.events.onKilled.dispatch(this); + } + + return this; + +} + +/** +* Destroys the Sprite. This removes it from its parent group, destroys the input, event and animation handlers if present +* and nulls its reference to game, freeing it up for garbage collection. +* +* @method Phaser.Sprite#destroy +* @memberof Phaser.Sprite +*/ +Phaser.Sprite.prototype.destroy = function() { + + if (this.group) + { + this.group.remove(this); + } + + if (this.input) + { + this.input.destroy(); + } + + if (this.events) + { + this.events.destroy(); + } + + if (this.animations) + { + this.animations.destroy(); + } + + this.alive = false; + this.exists = false; + this.visible = false; + + this.game = null; + +} + +/** +* Damages the Sprite, this removes the given amount from the Sprites health property. +* If health is then taken below zero Sprite.kill is called. +* +* @method Phaser.Sprite#damage +* @memberof Phaser.Sprite +* @param {number} amount - The amount to subtract from the Sprite.health value. +* @return (Phaser.Sprite) This instance. +*/ +Phaser.Sprite.prototype.damage = function(amount) { + + if (this.alive) + { + this.health -= amount; + + if (this.health < 0) + { + this.kill(); + } + } + + return this; + +} + +/** +* Resets the Sprite. This places the Sprite at the given x/y world coordinates and then +* sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state and health values. +* If the Sprite has a physics body that too is reset. +* +* @method Phaser.Sprite#reset +* @memberof Phaser.Sprite +* @param {number} x - The x coordinate (in world space) to position the Sprite at. +* @param {number} y - The y coordinate (in world space) to position the Sprite at. +* @param {number} [health=1] - The health to give the Sprite. +* @return (Phaser.Sprite) This instance. +*/ +Phaser.Sprite.prototype.reset = function(x, y, health) { + + if (typeof health === 'undefined') { health = 1; } + + this.x = x; + this.y = y; + this.position.x = this.x; + this.position.y = this.y; + this.alive = true; + this.exists = true; + this.visible = true; + this.renderable = true; + this._outOfBoundsFired = false; + + this.health = health; + + if (this.body) + { + this.body.reset(); + } + + return this; + +} + +/** +* Brings the Sprite to the top of the display list it is a child of. Sprites that are members of a Phaser.Group are only +* bought to the top of that Group, not the entire display list. +* +* @method Phaser.Sprite#bringToTop +* @memberof Phaser.Sprite +* @return (Phaser.Sprite) This instance. +*/ Phaser.Sprite.prototype.bringToTop = function() { if (this.group) @@ -445,141 +953,156 @@ Phaser.Sprite.prototype.bringToTop = function() { this.game.world.bringToTop(this); } -} - -Phaser.Sprite.prototype.getBounds = function(rect) { - - rect = rect || new Phaser.Rectangle; - - var left = Phaser.Math.min(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x); - var right = Phaser.Math.max(this.topLeft.x, this.topRight.x, this.bottomLeft.x, this.bottomRight.x); - var top = Phaser.Math.min(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y); - var bottom = Phaser.Math.max(this.topLeft.y, this.topRight.y, this.bottomLeft.y, this.bottomRight.y); - - rect.x = left; - rect.y = top; - rect.width = right - left; - rect.height = bottom - top; - - return rect; + return this; } +/** +* Play an animation based on the given key. The animation should previously have been added via sprite.animations.add() +* If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself. +* +* @method Phaser.Sprite#play +* @memberof Phaser.Sprite +* @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump". +* @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used. +* @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used. +* @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed. +* @return {Phaser.Animation} A reference to playing Animation instance. +*/ +Phaser.Sprite.prototype.play = function (name, frameRate, loop, killOnComplete) { + + if (this.animations) + { + return this.animations.play(name, frameRate, loop, killOnComplete); + } + +} + +/** +* Indicates the rotation of the Sprite, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. +* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90. +* If you wish to work in radians instead of degrees use the property Sprite.rotation instead. +* @name Phaser.Sprite#angle +* @property {number} angle - Gets or sets the Sprites angle of rotation in degrees. +*/ Object.defineProperty(Phaser.Sprite.prototype, 'angle', { get: function() { - return Phaser.Math.radToDeg(this.rotation); + return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation)); }, set: function(value) { - this.rotation = Phaser.Math.degToRad(value); + this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value)); } }); +/** +* @name Phaser.Sprite#frame +* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display. +*/ Object.defineProperty(Phaser.Sprite.prototype, "frame", { - /** - * Get the animation frame number. - */ get: function () { return this.animations.frame; }, - /** - * Set the animation frame by frame number. - */ set: function (value) { this.animations.frame = value; } }); +/** +* @name Phaser.Sprite#frameName +* @property {string} frameName - Gets or sets the current frame name and updates the Texture Cache for display. +*/ Object.defineProperty(Phaser.Sprite.prototype, "frameName", { - /** - * Get the animation frame name. - */ get: function () { return this.animations.frameName; }, - /** - * Set the animation frame by frame name. - */ set: function (value) { this.animations.frameName = value; } }); +/** +* @name Phaser.Sprite#inCamera +* @property {boolean} inCamera - Is this sprite visible to the camera or not? +* @readonly +*/ Object.defineProperty(Phaser.Sprite.prototype, "inCamera", { - /** - * Is this sprite visible to the camera or not? - */ get: function () { return this._cache.cameraVisible; } }); -Object.defineProperty(Phaser.Sprite.prototype, "crop", { - - /** - * Get the input enabled state of this Sprite. - */ - get: function () { - - return this._cropRect; +/** +* The width of the sprite in pixels, setting this will actually modify the scale to acheive the value desired. +* If you wish to crop the Sprite instead see the Sprite.crop value. +* +* @name Phaser.Sprite#width +* @property {number} width - The width of the Sprite in pixels. +*/ +Object.defineProperty(Phaser.Sprite.prototype, 'width', { + get: function() { + return this.scale.x * this.currentFrame.width; }, - /** - * Set the ability for this sprite to receive input events. - */ - set: function (value) { + set: function(value) { - if (value instanceof Phaser.Rectangle) - { - if (this._cropUUID == null) - { - this._cropUUID = this.game.rnd.uuid(); - - PIXI.TextureCache[this._cropUUID] = new PIXI.Texture(PIXI.BaseTextureCache[this.key], { - x: value.x, - y: value.y, - width: value.width, - height: value.height - }); - } - else - { - PIXI.TextureCache[this._cropUUID].frame = value; - } - - this._cropRect = value; - this.setTexture(PIXI.TextureCache[this._cropUUID]); - } + this.scale.x = value / this.currentFrame.width; + this._cache.scaleX = value / this.currentFrame.width; + this._width = value; } }); +/** +* The height of the sprite in pixels, setting this will actually modify the scale to acheive the value desired. +* If you wish to crop the Sprite instead see the Sprite.crop value. +* +* @name Phaser.Sprite#height +* @property {number} height - The height of the Sprite in pixels. +*/ +Object.defineProperty(Phaser.Sprite.prototype, 'height', { + + get: function() { + return this.scale.y * this.currentFrame.height; + }, + + set: function(value) { + + this.scale.y = value / this.currentFrame.height; + this._cache.scaleY = value / this.currentFrame.height; + this._height = value; + + } + +}); + +/** +* By default a Sprite won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is +* activated for this Sprite instance and it will then start to process click/touch events and more. +* +* @name Phaser.Sprite#inputEnabled +* @property {boolean} inputEnabled - Set to true to allow this Sprite to receive input events, otherwise false. +*/ Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", { - /** - * Get the input enabled state of this Sprite. - */ get: function () { return (this.input.enabled); }, - /** - * Set the ability for this sprite to receive input events. - */ set: function (value) { if (value) diff --git a/src/gameobjects/Text.js b/src/gameobjects/Text.js index 092143eb..762477f3 100644 --- a/src/gameobjects/Text.js +++ b/src/gameobjects/Text.js @@ -1,3 +1,19 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Create a new Text. +* @class Phaser.Text +* @constructor +* @param {Phaser.Game} game - Current game instance. +* @param {number} x - X position of the new text object. +* @param {number} y - Y position of the new text object. +* @param {string} text - The actual text that will be written. +* @param {object} style - The style object containing style attributes like font, font size , +*/ Phaser.Text = function (game, x, y, text, style) { x = x || 0; @@ -6,15 +22,34 @@ Phaser.Text = function (game, x, y, text, style) { style = style || ''; // If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all + /** + * @property {boolean} exists - Description. + * @default + */ this.exists = true; // This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering + /** + * @property {boolean} alive - Description. + * @default + */ this.alive = true; + /** + * @property {Description} group - Description. + * @default + */ this.group = null; + /** + * @property {string} name - Description. + * @default + */ this.name = ''; + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; this._text = text; @@ -22,19 +57,33 @@ Phaser.Text = function (game, x, y, text, style) { PIXI.Text.call(this, text, style); + /** + * @property {Description} type - Description. + */ this.type = Phaser.TEXT; + /** + * @property {Description} position - Description. + */ this.position.x = this.x = x; this.position.y = this.y = y; // Replaces the PIXI.Point with a slightly more flexible one + /** + * @property {Phaser.Point} anchor - Description. + */ this.anchor = new Phaser.Point(); + + /** + * @property {Phaser.Point} scale - Description. + */ this.scale = new Phaser.Point(1, 1); - // Influence of camera movement upon the position - this.scrollFactor = new Phaser.Point(1, 1); - // A mini cache for storing all of the calculated values + /** + * @property {Description} _cache - Description. + * @private + */ this._cache = { dirty: false, @@ -42,7 +91,7 @@ Phaser.Text = function (game, x, y, text, style) { // Transform cache a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, - // The previous calculated position inc. camera x/y and scrollFactor + // The previous calculated position x: -1, y: -1, // The actual scale values based on the worldTransform @@ -50,9 +99,12 @@ Phaser.Text = function (game, x, y, text, style) { }; - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + this._cache.x = this.x; + this._cache.y = this.y; + /** + * @property {boolean} renderable - Description. + */ this.renderable = true; }; @@ -60,7 +112,10 @@ Phaser.Text = function (game, x, y, text, style) { Phaser.Text.prototype = Object.create(PIXI.Text.prototype); Phaser.Text.prototype.constructor = Phaser.Text; -// Automatically called by World.update +/** +* Automatically called by World.update. +* @method Phaser.Text.prototype.update +*/ Phaser.Text.prototype.update = function() { if (!this.exists) @@ -70,8 +125,8 @@ Phaser.Text.prototype.update = function() { this._cache.dirty = false; - this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); - this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); + this._cache.x = this.x; + this._cache.y = this.y; if (this.position.x != this._cache.x || this.position.y != this._cache.y) { @@ -82,6 +137,39 @@ Phaser.Text.prototype.update = function() { } +/** +* @method Phaser.Text.prototype.destroy +*/ +Phaser.Text.prototype.destroy = function() { + + if (this.group) + { + this.group.remove(this); + } + + if (this.canvas.parentNode) + { + this.canvas.parentNode.removeChild(this.canvas); + } + else + { + this.canvas = null; + this.context = null; + } + + this.exists = false; + + this.group = null; + +} + +/** +* Get +* @returns {Description} +*//** +* Set +* @param {Description} value - Description +*/ Object.defineProperty(Phaser.Text.prototype, 'angle', { get: function() { @@ -94,7 +182,7 @@ Object.defineProperty(Phaser.Text.prototype, 'angle', { }); -Object.defineProperty(Phaser.Text.prototype, 'text', { +Object.defineProperty(Phaser.Text.prototype, 'content', { get: function() { return this._text; @@ -106,14 +194,14 @@ Object.defineProperty(Phaser.Text.prototype, 'text', { if (value !== this._text) { this._text = value; - this.dirty = true; + this.setText(value); } } }); -Object.defineProperty(Phaser.Text.prototype, 'style', { +Object.defineProperty(Phaser.Text.prototype, 'font', { get: function() { return this._style; @@ -125,7 +213,7 @@ Object.defineProperty(Phaser.Text.prototype, 'style', { if (value !== this._style) { this._style = value; - this.dirty = true; + this.setStyle(value); } } diff --git a/src/gameobjects/TileSprite.js b/src/gameobjects/TileSprite.js index d578f736..c9ee3dda 100644 --- a/src/gameobjects/TileSprite.js +++ b/src/gameobjects/TileSprite.js @@ -1,3 +1,21 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Create a new TileSprite. +* @class Phaser.Tilemap +* @constructor +* @param {Phaser.Game} game - Current game instance. +* @param {number} x - X position of the new tileSprite. +* @param {number} y - Y position of the new tileSprite. +* @param {number} width - the width of the tilesprite. +* @param {number} height - the height of the tilesprite. +* @param {string|Phaser.RenderTexture|PIXI.Texture} key - This is the image or texture used by the Sprite during rendering. It can be a string which is a reference to the Cache entry, or an instance of a RenderTexture or PIXI.Texture. +* @param {string|number} frame - If this Sprite is using part of a sprite sheet or texture atlas you can specify the exact frame to use by giving a string or numeric index. +*/ Phaser.TileSprite = function (game, x, y, width, height, key, frame) { x = x || 0; @@ -9,26 +27,26 @@ Phaser.TileSprite = function (game, x, y, width, height, key, frame) { Phaser.Sprite.call(this, game, x, y, key, frame); + /** + * @property {Description} texture - Description. + */ this.texture = PIXI.TextureCache[key]; PIXI.TilingSprite.call(this, this.texture, width, height); + /** + * @property {Description} type - Description. + */ this.type = Phaser.TILESPRITE; /** - * The scaling of the image that is being tiled - * - * @property tileScale - * @type Point - */ + * @property {Point} tileScale - The scaling of the image that is being tiled. + */ this.tileScale = new Phaser.Point(1, 1); /** - * The offset position of the image that is being tiled - * - * @property tilePosition - * @type Point - */ + * @property {Point} tilePosition - The offset position of the image that is being tiled. + */ this.tilePosition = new Phaser.Point(0, 0); }; diff --git a/src/geom/Circle.js b/src/geom/Circle.js index ada013d1..cbb736f1 100644 --- a/src/geom/Circle.js +++ b/src/geom/Circle.js @@ -1,13 +1,18 @@ /** -* Phaser - Circle -* +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** * Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created. * @class Circle +* @classdesc Phaser - Circle * @constructor -* @param {Number} [x] The x coordinate of the center of the circle. -* @param {Number} [y] The y coordinate of the center of the circle. -* @param {Number} [diameter] The diameter of the circle. -* @return {Circle} This circle object +* @param {number} [x] The x coordinate of the center of the circle. +* @param {number} [y] The y coordinate of the center of the circle. +* @param {number} [diameter] The diameter of the circle. +* @return {Phaser.Circle} This circle object **/ Phaser.Circle = function (x, y, diameter) { @@ -16,23 +21,27 @@ Phaser.Circle = function (x, y, diameter) { diameter = diameter || 0; /** - * The x coordinate of the center of the circle - * @property x - * @type Number + * @property {number} x - The x coordinate of the center of the circle. **/ this.x = x; /** - * The y coordinate of the center of the circle - * @property y - * @type Number + * @property {number} y - The y coordinate of the center of the circle. **/ this.y = y; + /** + * @property {number} _diameter - The diameter of the circle. + * @private + **/ this._diameter = diameter; if (diameter > 0) { + /** + * @property {number} _radius - The radius of the circle. + * @private + **/ this._radius = diameter * 0.5; } else @@ -46,8 +55,8 @@ Phaser.Circle.prototype = { /** * The circumference of the circle. - * @method circumference - * @return {Number} + * @method Phaser.Circle#circumference + * @return {number} **/ circumference: function () { return 2 * (Math.PI * this._radius); @@ -55,11 +64,11 @@ Phaser.Circle.prototype = { /** * Sets the members of Circle to the specified values. - * @method setTo - * @param {Number} x The x coordinate of the center of the circle. - * @param {Number} y The y coordinate of the center of the circle. - * @param {Number} diameter The diameter of the circle in pixels. - * @return {Circle} This circle object + * @method Phaser.Circle#setTo + * @param {number} x - The x coordinate of the center of the circle. + * @param {number} y - The y coordinate of the center of the circle. + * @param {number} diameter - The diameter of the circle in pixels. + * @return {Circle} This circle object. **/ setTo: function (x, y, diameter) { this.x = x; @@ -71,7 +80,7 @@ Phaser.Circle.prototype = { /** * Copies the x, y and diameter properties from any given object to this Circle. - * @method copyFrom + * @method Phaser.Circle#copyFrom * @param {any} source - The object to copy from. * @return {Circle} This Circle object. **/ @@ -81,7 +90,7 @@ Phaser.Circle.prototype = { /** * Copies the x, y and diameter properties from this Circle to any given object. - * @method copyTo + * @method Phaser.Circle#copyTo * @param {any} dest - The object to copy to. * @return {Object} This dest object. **/ @@ -95,10 +104,10 @@ Phaser.Circle.prototype = { /** * Returns the distance from the center of the Circle object to the given object * (can be Circle, Point or anything with x/y properties) - * @method distance - * @param {object} dest The target object. Must have visible x and y properties that represent the center of the object. - * @param {bool} [optional] round Round the distance to the nearest integer (default false) - * @return {Number} The distance between this Point object and the destination Point object. + * @method Phaser.Circle#distance + * @param {object} dest - The target object. Must have visible x and y properties that represent the center of the object. + * @param {boolean} [round] - Round the distance to the nearest integer (default false). + * @return {number} The distance between this Point object and the destination Point object. */ distance: function (dest, round) { @@ -117,8 +126,8 @@ Phaser.Circle.prototype = { /** * Returns a new Circle object with the same values for the x, y, width, and height properties as this Circle object. - * @method clone - * @param {Phaser.Circle} out Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned. + * @method Phaser.Circle#clone + * @param {Phaser.Circle} out - Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned. * @return {Phaser.Circle} The cloned Circle object. */ clone: function(out) { @@ -131,10 +140,10 @@ Phaser.Circle.prototype = { /** * Return true if the given x/y coordinates are within this Circle object. - * @method contains - * @param {Number} x The X value of the coordinate to test. - * @param {Number} y The Y value of the coordinate to test. - * @return {bool} True if the coordinates are within this circle, otherwise false. + * @method Phaser.Circle#contains + * @param {number} x - The X value of the coordinate to test. + * @param {number} y - The Y value of the coordinate to test. + * @return {boolean} True if the coordinates are within this circle, otherwise false. */ contains: function (x, y) { return Phaser.Circle.contains(this, x, y); @@ -142,10 +151,10 @@ Phaser.Circle.prototype = { /** * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. - * @method circumferencePoint - * @param {Number} angle The angle in radians (unless asDegrees is true) to return the point from. - * @param {bool} asDegrees Is the given angle in radians (false) or degrees (true)? - * @param {Phaser.Point} [optional] output An optional Point object to put the result in to. If none specified a new Point object will be created. + * @method Phaser.Circle#circumferencePoint + * @param {number} angle - The angle in radians (unless asDegrees is true) to return the point from. + * @param {boolean} asDegrees - Is the given angle in radians (false) or degrees (true)? + * @param {Phaser.Point} [out] - An optional Point object to put the result in to. If none specified a new Point object will be created. * @return {Phaser.Point} The Point object holding the result. */ circumferencePoint: function (angle, asDegrees, out) { @@ -154,9 +163,9 @@ Phaser.Circle.prototype = { /** * Adjusts the location of the Circle object, as determined by its center coordinate, by the specified amounts. - * @method offset - * @param {Number} dx Moves the x value of the Circle object by this amount. - * @param {Number} dy Moves the y value of the Circle object by this amount. + * @method Phaser.Circle#offset + * @param {number} dx - Moves the x value of the Circle object by this amount. + * @param {number} dy - Moves the y value of the Circle object by this amount. * @return {Circle} This Circle object. **/ offset: function (dx, dy) { @@ -167,7 +176,7 @@ Phaser.Circle.prototype = { /** * Adjusts the location of the Circle object using a Point object as a parameter. This method is similar to the Circle.offset() method, except that it takes a Point object as a parameter. - * @method offsetPoint + * @method Phaser.Circle#offsetPoint * @param {Point} point A Point object to use to offset this Circle object (or any valid object with exposed x and y properties). * @return {Circle} This Circle object. **/ @@ -177,7 +186,7 @@ Phaser.Circle.prototype = { /** * Returns a string representation of this object. - * @method toString + * @method Phaser.Circle#toString * @return {string} a string representation of the instance. **/ toString: function () { @@ -186,24 +195,17 @@ Phaser.Circle.prototype = { }; -// Getters / Setters - +/** +* The largest distance between any two points on the circle. The same as the radius * 2. +* @name Phaser.Circle#diameter +* @property {number} diameter - Gets or sets the diameter of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "diameter", { - /** - * The diameter of the circle. The largest distance between any two points on the circle. The same as the radius * 2. - * @method diameter - * @return {Number} - **/ get: function () { return this._diameter; }, - /** - * The diameter of the circle. The largest distance between any two points on the circle. The same as the radius * 2. - * @method diameter - * @param {Number} The diameter of the circle. - **/ set: function (value) { if (value > 0) { this._diameter = value; @@ -213,22 +215,17 @@ Object.defineProperty(Phaser.Circle.prototype, "diameter", { }); +/** +* The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter. +* @name Phaser.Circle#radius +* @property {number} radius - Gets or sets the radius of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "radius", { - /** - * The radius of the circle. The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter. - * @method radius - * @return {Number} - **/ get: function () { return this._radius; }, - /** - * The radius of the circle. The length of a line extending from the center of the circle to any point on the circle itself. The same as half the diameter. - * @method radius - * @param {Number} The radius of the circle. - **/ set: function (value) { if (value > 0) { this._radius = value; @@ -238,22 +235,17 @@ Object.defineProperty(Phaser.Circle.prototype, "radius", { }); +/** +* The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. +* @name Phaser.Circle#left +* @propety {number} left - Gets or sets the value of the leftmost point of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "left", { - /** - * The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - * @method left - * @return {Number} The x coordinate of the leftmost point of the circle. - **/ get: function () { return this.x - this._radius; }, - /** - * The x coordinate of the leftmost point of the circle. Changing the left property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - * @method left - * @param {Number} The value to adjust the position of the leftmost point of the circle by. - **/ set: function (value) { if (value > this.x) { this._radius = 0; @@ -265,22 +257,17 @@ Object.defineProperty(Phaser.Circle.prototype, "left", { }); +/** +* The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. +* @name Phaser.Circle#right +* @property {number} right - Gets or sets the value of the rightmost point of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "right", { - /** - * The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - * @method right - * @return {Number} - **/ get: function () { return this.x + this._radius; }, - /** - * The x coordinate of the rightmost point of the circle. Changing the right property of a Circle object has no effect on the x and y properties. However it does affect the diameter, whereas changing the x value does not affect the diameter property. - * @method right - * @param {Number} The amount to adjust the diameter of the circle by. - **/ set: function (value) { if (value < this.x) { this._radius = 0; @@ -292,22 +279,17 @@ Object.defineProperty(Phaser.Circle.prototype, "right", { }); +/** +* The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter. +* @name Phaser.Circle#top +* @property {number} top - Gets or sets the top of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "top", { - /** - * The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter. - * @method bottom - * @return {Number} - **/ get: function () { return this.y - this._radius; }, - /** - * The sum of the y minus the radius property. Changing the top property of a Circle object has no effect on the x and y properties, but does change the diameter. - * @method bottom - * @param {Number} The amount to adjust the height of the circle by. - **/ set: function (value) { if (value > this.y) { this._radius = 0; @@ -319,22 +301,17 @@ Object.defineProperty(Phaser.Circle.prototype, "top", { }); +/** +* The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter. +* @name Phaser.Circle#bottom +* @property {number} bottom - Gets or sets the bottom of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "bottom", { - /** - * The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter. - * @method bottom - * @return {Number} - **/ get: function () { return this.y + this._radius; }, - /** - * The sum of the y and radius properties. Changing the bottom property of a Circle object has no effect on the x and y properties, but does change the diameter. - * @method bottom - * @param {Number} The value to adjust the height of the circle by. - **/ set: function (value) { if (value < this.y) { @@ -347,13 +324,14 @@ Object.defineProperty(Phaser.Circle.prototype, "bottom", { }); +/** +* The area of this Circle. +* @name Phaser.Circle#area +* @property {number} area - The area of this circle. +* @readonly +*/ Object.defineProperty(Phaser.Circle.prototype, "area", { - /** - * Gets the area of this Circle. - * @method area - * @return {Number} This area of this circle. - **/ get: function () { if (this._radius > 0) { return Math.PI * this._radius * this._radius; @@ -364,37 +342,31 @@ Object.defineProperty(Phaser.Circle.prototype, "area", { }); +/** +* Determines whether or not this Circle object is empty. Will return a value of true if the Circle objects diameter is less than or equal to 0; otherwise false. +* If set to true it will reset all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0. +* @name Phaser.Circle#empty +* @property {boolean} empty - Gets or sets the empty state of the circle. +*/ Object.defineProperty(Phaser.Circle.prototype, "empty", { - /** - * Determines whether or not this Circle object is empty. - * @method empty - * @return {bool} A value of true if the Circle objects diameter is less than or equal to 0; otherwise false. - **/ get: function () { return (this._diameter == 0); }, - /** - * Sets all of the Circle objects properties to 0. A Circle object is empty if its diameter is less than or equal to 0. - * @method setEmpty - * @return {Circle} This Circle object - **/ set: function (value) { this.setTo(0, 0, 0); } }); -// Statics - /** * Return true if the given x/y coordinates are within the Circle object. -* @method contains -* @param {Phaser.Circle} a The Circle to be checked. -* @param {Number} x The X value of the coordinate to test. -* @param {Number} y The Y value of the coordinate to test. -* @return {bool} True if the coordinates are within this circle, otherwise false. +* @method Phaser.Circle.contains +* @param {Phaser.Circle} a - The Circle to be checked. +* @param {number} x - The X value of the coordinate to test. +* @param {number} y - The Y value of the coordinate to test. +* @return {boolean} True if the coordinates are within this circle, otherwise false. */ Phaser.Circle.contains = function (a, x, y) { @@ -414,10 +386,10 @@ Phaser.Circle.contains = function (a, x, y) { /** * Determines whether the two Circle objects match. This method compares the x, y and diameter properties. -* @method equals -* @param {Phaser.Circle} a The first Circle object. -* @param {Phaser.Circle} b The second Circle object. -* @return {bool} A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false. +* @method Phaser.Circle.equals +* @param {Phaser.Circle} a - The first Circle object. +* @param {Phaser.Circle} b - The second Circle object. +* @return {boolean} A value of true if the object has exactly the same values for the x, y and diameter properties as this Circle object; otherwise false. */ Phaser.Circle.equals = function (a, b) { return (a.x == b.x && a.y == b.y && a.diameter == b.diameter); @@ -426,10 +398,10 @@ Phaser.Circle.equals = function (a, b) { /** * Determines whether the two Circle objects intersect. * This method checks the radius distances between the two Circle objects to see if they intersect. -* @method intersects -* @param {Phaser.Circle} a The first Circle object. -* @param {Phaser.Circle} b The second Circle object. -* @return {bool} A value of true if the specified object intersects with this Circle object; otherwise false. +* @method Phaser.Circle.intersects +* @param {Phaser.Circle} a - The first Circle object. +* @param {Phaser.Circle} b - The second Circle object. +* @return {boolean} A value of true if the specified object intersects with this Circle object; otherwise false. */ Phaser.Circle.intersects = function (a, b) { return (Phaser.Math.distance(a.x, a.y, b.x, b.y) <= (a.radius + b.radius)); @@ -437,11 +409,11 @@ Phaser.Circle.intersects = function (a, b) { /** * Returns a Point object containing the coordinates of a point on the circumference of the Circle based on the given angle. -* @method circumferencePoint -* @param {Phaser.Circle} a The first Circle object. -* @param {Number} angle The angle in radians (unless asDegrees is true) to return the point from. -* @param {bool} asDegrees Is the given angle in radians (false) or degrees (true)? -* @param {Phaser.Point} [optional] output An optional Point object to put the result in to. If none specified a new Point object will be created. +* @method Phaser.Circle.circumferencePoint +* @param {Phaser.Circle} a - The first Circle object. +* @param {number} angle - The angle in radians (unless asDegrees is true) to return the point from. +* @param {boolean} asDegrees - Is the given angle in radians (false) or degrees (true)? +* @param {Phaser.Point} [out] - An optional Point object to put the result in to. If none specified a new Point object will be created. * @return {Phaser.Point} The Point object holding the result. */ Phaser.Circle.circumferencePoint = function (a, angle, asDegrees, out) { @@ -462,10 +434,10 @@ Phaser.Circle.circumferencePoint = function (a, angle, asDegrees, out) { /** * Checks if the given Circle and Rectangle objects intersect. -* @method intersectsRectangle -* @param {Phaser.Circle} c The Circle object to test. -* @param {Phaser.Rectangle} r The Rectangle object to test. -* @return {bool} True if the two objects intersect, otherwise false. +* @method Phaser.Circle.intersectsRectangle +* @param {Phaser.Circle} c - The Circle object to test. +* @param {Phaser.Rectangle} r - The Rectangle object to test. +* @return {boolean} True if the two objects intersect, otherwise false. */ Phaser.Circle.intersectsRectangle = function (c, r) { diff --git a/src/geom/Point.js b/src/geom/Point.js index d6adb21a..ef8799f6 100644 --- a/src/geom/Point.js +++ b/src/geom/Point.js @@ -1,27 +1,30 @@ /** -* Phaser - Point -* -* The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis. -* * @author Richard Davey * @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License -* @module Phaser +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** * Creates a new Point. If you pass no parameters a Point is created set to (0,0). -* @class Point +* @class Phaser.Point +* @classdesc The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis. * @constructor -* @param {Number} x The horizontal position of this Point (default 0) -* @param {Number} y The vertical position of this Point (default 0) +* @param {number} x The horizontal position of this Point (default 0) +* @param {number} y The vertical position of this Point (default 0) **/ Phaser.Point = function (x, y) { x = x || 0; y = y || 0; + /** + * @property {number} x - The x coordinate of the point. + **/ this.x = x; + + /** + * @property {number} y - The y coordinate of the point. + **/ this.y = y; }; @@ -30,7 +33,7 @@ Phaser.Point.prototype = { /** * Copies the x and y properties from any given object to this Point. - * @method copyFrom + * @method Phaser.Point#copyFrom * @param {any} source - The object to copy from. * @return {Point} This Point object. **/ @@ -40,7 +43,7 @@ Phaser.Point.prototype = { /** * Inverts the x and y values of this Point - * @method invert + * @method Phaser.Point#invert * @return {Point} This Point object. **/ invert: function () { @@ -49,17 +52,26 @@ Phaser.Point.prototype = { /** * Sets the x and y values of this Point object to the given coordinates. - * @method setTo - * @param {Number} x - The horizontal position of this point. - * @param {Number} y - The vertical position of this point. + * @method Phaser.Point#setTo + * @param {number} x - The horizontal position of this point. + * @param {number} y - The vertical position of this point. * @return {Point} This Point object. Useful for chaining method calls. **/ setTo: function (x, y) { + this.x = x; this.y = y; return this; + }, + /** + * Adds the given x and y values to this Point. + * @method Phaser.Point#add + * @param {number} x - The value to add to Point.x. + * @param {number} y - The value to add to Point.y. + * @return {Phaser.Point} This Point object. Useful for chaining method calls. + **/ add: function (x, y) { this.x += x; @@ -68,6 +80,13 @@ Phaser.Point.prototype = { }, + /** + * Subtracts the given x and y values from this Point. + * @method Phaser.Point#subtract + * @param {number} x - The value to subtract from Point.x. + * @param {number} y - The value to subtract from Point.y. + * @return {Phaser.Point} This Point object. Useful for chaining method calls. + **/ subtract: function (x, y) { this.x -= x; @@ -76,6 +95,13 @@ Phaser.Point.prototype = { }, + /** + * Multiplies Point.x and Point.y by the given x and y values. + * @method Phaser.Point#multiply + * @param {number} x - The value to multiply Point.x by. + * @param {number} y - The value to multiply Point.x by. + * @return {Phaser.Point} This Point object. Useful for chaining method calls. + **/ multiply: function (x, y) { this.x *= x; @@ -84,6 +110,13 @@ Phaser.Point.prototype = { }, + /** + * Divides Point.x and Point.y by the given x and y values. + * @method Phaser.Point#divide + * @param {number} x - The value to divide Point.x by. + * @param {number} y - The value to divide Point.x by. + * @return {Phaser.Point} This Point object. Useful for chaining method calls. + **/ divide: function (x, y) { this.x /= x; @@ -93,10 +126,10 @@ Phaser.Point.prototype = { }, /** - * Clamps the x value of this Point to be between the given min and max - * @method clampX - * @param {Number} min The minimum value to clamp this Point to - * @param {Number} max The maximum value to clamp this Point to + * Clamps the x value of this Point to be between the given min and max. + * @method Phaser.Point#clampX + * @param {number} min - The minimum value to clamp this Point to. + * @param {number} max - The maximum value to clamp this Point to. * @return {Phaser.Point} This Point object. */ clampX: function (min, max) { @@ -108,9 +141,9 @@ Phaser.Point.prototype = { /** * Clamps the y value of this Point to be between the given min and max - * @method clampY - * @param {Number} min The minimum value to clamp this Point to - * @param {Number} max The maximum value to clamp this Point to + * @method Phaser.Point#clampY + * @param {number} min - The minimum value to clamp this Point to. + * @param {number} max - The maximum value to clamp this Point to. * @return {Phaser.Point} This Point object. */ clampY: function (min, max) { @@ -121,10 +154,10 @@ Phaser.Point.prototype = { }, /** - * Clamps this Point object values to be between the given min and max - * @method clamp - * @param {Number} min The minimum value to clamp this Point to - * @param {Number} max The maximum value to clamp this Point to + * Clamps this Point object values to be between the given min and max. + * @method Phaser.Point#clamp + * @param {number} min - The minimum value to clamp this Point to. + * @param {number} max - The maximum value to clamp this Point to. * @return {Phaser.Point} This Point object. */ clamp: function (min, max) { @@ -137,8 +170,8 @@ Phaser.Point.prototype = { /** * Creates a copy of the given Point. - * @method clone - * @param {Phaser.Point} output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned. + * @method Phaser.Point#clone + * @param {Phaser.Point} [output] Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned. * @return {Phaser.Point} The new Point object. */ clone: function (output) { @@ -151,7 +184,7 @@ Phaser.Point.prototype = { /** * Copies the x and y properties from any given object to this Point. - * @method copyFrom + * @method Phaser.Point#copyFrom * @param {any} source - The object to copy from. * @return {Point} This Point object. **/ @@ -161,7 +194,7 @@ Phaser.Point.prototype = { /** * Copies the x and y properties from this Point to any given object. - * @method copyTo + * @method Phaser.Point#copyTo * @param {any} dest - The object to copy to. * @return {Object} The dest object. **/ @@ -176,10 +209,10 @@ Phaser.Point.prototype = { /** * Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties) - * @method distance - * @param {object} dest The target object. Must have visible x and y properties that represent the center of the object. - * @param {bool} [optional] round Round the distance to the nearest integer (default false) - * @return {Number} The distance between this Point object and the destination Point object. + * @method Phaser.Point#distance + * @param {object} dest - The target object. Must have visible x and y properties that represent the center of the object. + * @param {boolean} [round] - Round the distance to the nearest integer (default false). + * @return {number} The distance between this Point object and the destination Point object. */ distance: function (dest, round) { @@ -189,9 +222,9 @@ Phaser.Point.prototype = { /** * Determines whether the given objects x/y values are equal to this Point object. - * @method equals - * @param {Phaser.Point} a The first object to compare. - * @return {bool} A value of true if the Points are equal, otherwise false. + * @method Phaser.Point#equals + * @param {Phaser.Point} a - The first object to compare. + * @return {boolean} A value of true if the Points are equal, otherwise false. */ equals: function (a) { return (a.x == this.x && a.y == this.y); @@ -199,13 +232,13 @@ Phaser.Point.prototype = { /** * Rotates this Point around the x/y coordinates given to the desired angle. - * @method rotate - * @param {Number} x The x coordinate of the anchor point - * @param {Number} y The y coordinate of the anchor point - * @param {Number} angle The angle in radians (unless asDegrees is true) to rotate the Point to. - * @param {bool} asDegrees Is the given rotation in radians (false) or degrees (true)? - * @param {Number} distance An optional distance constraint between the Point and the anchor. - * @return {Phaser.Point} The modified point object + * @method Phaser.Point#rotate + * @param {number} x - The x coordinate of the anchor point + * @param {number} y - The y coordinate of the anchor point + * @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the Point to. + * @param {boolean} asDegrees - Is the given rotation in radians (false) or degrees (true)? + * @param {number} [distance] - An optional distance constraint between the Point and the anchor. + * @return {Phaser.Point} The modified point object. */ rotate: function (x, y, angle, asDegrees, distance) { return Phaser.Point.rotate(this, x, y, angle, asDegrees, distance); @@ -213,8 +246,8 @@ Phaser.Point.prototype = { /** * Returns a string representation of this object. - * @method toString - * @return {string} a string representation of the instance. + * @method Phaser.Point#toString + * @return {string} A string representation of the instance. **/ toString: function () { return '[{Point (x=' + this.x + ' y=' + this.y + ')}]'; @@ -222,14 +255,12 @@ Phaser.Point.prototype = { }; -// Statics - /** * Adds the coordinates of two points together to create a new point. -* @method add -* @param {Phaser.Point} a The first Point object. -* @param {Phaser.Point} b The second Point object. -* @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created. +* @method Phaser.Point.add +* @param {Phaser.Point} a - The first Point object. +* @param {Phaser.Point} b - The second Point object. +* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created. * @return {Phaser.Point} The new Point object. */ Phaser.Point.add = function (a, b, out) { @@ -245,10 +276,10 @@ Phaser.Point.add = function (a, b, out) { /** * Subtracts the coordinates of two points to create a new point. -* @method subtract -* @param {Phaser.Point} a The first Point object. -* @param {Phaser.Point} b The second Point object. -* @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created. +* @method Phaser.Point.subtract +* @param {Phaser.Point} a - The first Point object. +* @param {Phaser.Point} b - The second Point object. +* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created. * @return {Phaser.Point} The new Point object. */ Phaser.Point.subtract = function (a, b, out) { @@ -264,10 +295,10 @@ Phaser.Point.subtract = function (a, b, out) { /** * Multiplies the coordinates of two points to create a new point. -* @method subtract -* @param {Phaser.Point} a The first Point object. -* @param {Phaser.Point} b The second Point object. -* @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created. +* @method Phaser.Point.multiply +* @param {Phaser.Point} a - The first Point object. +* @param {Phaser.Point} b - The second Point object. +* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created. * @return {Phaser.Point} The new Point object. */ Phaser.Point.multiply = function (a, b, out) { @@ -283,10 +314,10 @@ Phaser.Point.multiply = function (a, b, out) { /** * Divides the coordinates of two points to create a new point. -* @method subtract -* @param {Phaser.Point} a The first Point object. -* @param {Phaser.Point} b The second Point object. -* @param {Phaser.Point} out Optional Point to store the value in, if not supplied a new Point object will be created. +* @method Phaser.Point.divide +* @param {Phaser.Point} a - The first Point object. +* @param {Phaser.Point} b - The second Point object. +* @param {Phaser.Point} [out] - Optional Point to store the value in, if not supplied a new Point object will be created. * @return {Phaser.Point} The new Point object. */ Phaser.Point.divide = function (a, b, out) { @@ -302,22 +333,22 @@ Phaser.Point.divide = function (a, b, out) { /** * Determines whether the two given Point objects are equal. They are considered equal if they have the same x and y values. -* @method equals -* @param {Phaser.Point} a The first Point object. -* @param {Phaser.Point} b The second Point object. -* @return {bool} A value of true if the Points are equal, otherwise false. +* @method Phaser.Point.equals +* @param {Phaser.Point} a - The first Point object. +* @param {Phaser.Point} b - The second Point object. +* @return {boolean} A value of true if the Points are equal, otherwise false. */ Phaser.Point.equals = function (a, b) { return (a.x == b.x && a.y == b.y); }; /** -* Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties) -* @method distance -* @param {object} a The target object. Must have visible x and y properties that represent the center of the object. -* @param {object} b The target object. Must have visible x and y properties that represent the center of the object. -* @param {bool} [optional] round Round the distance to the nearest integer (default false) -* @return {Number} The distance between this Point object and the destination Point object. +* Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties). +* @method Phaser.Point.distance +* @param {object} a - The target object. Must have visible x and y properties that represent the center of the object. +* @param {object} b - The target object. Must have visible x and y properties that represent the center of the object. +* @param {boolean} [round] - Round the distance to the nearest integer (default false). +* @return {number} The distance between this Point object and the destination Point object. */ Phaser.Point.distance = function (a, b, round) { @@ -336,14 +367,14 @@ Phaser.Point.distance = function (a, b, round) { /** * Rotates a Point around the x/y coordinates given to the desired angle. -* @method rotate -* @param {Phaser.Point} a The Point object to rotate. -* @param {Number} x The x coordinate of the anchor point -* @param {Number} y The y coordinate of the anchor point -* @param {Number} angle The angle in radians (unless asDegrees is true) to rotate the Point to. -* @param {bool} asDegrees Is the given rotation in radians (false) or degrees (true)? -* @param {Number} distance An optional distance constraint between the Point and the anchor. -* @return {Phaser.Point} The modified point object +* @method Phaser.Point.rotate +* @param {Phaser.Point} a - The Point object to rotate. +* @param {number} x - The x coordinate of the anchor point +* @param {number} y - The y coordinate of the anchor point +* @param {number} angle - The angle in radians (unless asDegrees is true) to rotate the Point to. +* @param {boolean} asDegrees - Is the given rotation in radians (false) or degrees (true)? +* @param {number} distance - An optional distance constraint between the Point and the anchor. +* @return {Phaser.Point} The modified point object. */ Phaser.Point.rotate = function (a, x, y, angle, asDegrees, distance) { @@ -364,5 +395,3 @@ Phaser.Point.rotate = function (a, x, y, angle, asDegrees, distance) { return a.setTo(x + distance * Math.cos(angle), y + distance * Math.sin(angle)); }; - - diff --git a/src/geom/Rectangle.js b/src/geom/Rectangle.js index 54a279eb..f851fa03 100644 --- a/src/geom/Rectangle.js +++ b/src/geom/Rectangle.js @@ -1,13 +1,19 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + /** * Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. If you call this function without parameters, a Rectangle with x, y, width, and height properties set to 0 is created. * -* @class Rectangle +* @class Phaser.Rectangle * @constructor -* @param {Number} x The x coordinate of the top-left corner of the Rectangle. -* @param {Number} y The y coordinate of the top-left corner of the Rectangle. -* @param {Number} width The width of the Rectangle in pixels. -* @param {Number} height The height of the Rectangle in pixels. -* @return {Rectangle} This Rectangle object +* @param {number} x - The x coordinate of the top-left corner of the Rectangle. +* @param {number} y - The y coordinate of the top-left corner of the Rectangle. +* @param {number} width - The width of the Rectangle in pixels. +* @param {number} height - The height of the Rectangle in pixels. +* @return {Rectangle} This Rectangle object. **/ Phaser.Rectangle = function (x, y, width, height) { @@ -17,31 +23,23 @@ Phaser.Rectangle = function (x, y, width, height) { height = height || 0; /** - * @property x - * @type Number - * @default 0 - */ + * @property {number} x - Description. + */ this.x = x; /** - * @property y - * @type Number - * @default 0 - */ + * @property {number} y - Description. + */ this.y = y; /** - * @property width - * @type Number - * @default 0 - */ + * @property {number} width - Description. + */ this.width = width; /** - * @property height - * @type Number - * @default 0 - */ + * @property {number} height - Description. + */ this.height = height; }; @@ -50,9 +48,9 @@ Phaser.Rectangle.prototype = { /** * Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts. - * @method offset - * @param {Number} dx Moves the x value of the Rectangle object by this amount. - * @param {Number} dy Moves the y value of the Rectangle object by this amount. + * @method Phaser.Rectangle#offset + * @param {number} dx - Moves the x value of the Rectangle object by this amount. + * @param {number} dy - Moves the y value of the Rectangle object by this amount. * @return {Rectangle} This Rectangle object. **/ offset: function (dx, dy) { @@ -66,8 +64,8 @@ Phaser.Rectangle.prototype = { /** * Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter. - * @method offsetPoint - * @param {Point} point A Point object to use to offset this Rectangle object. + * @method Phaser.Rectangle#offsetPoint + * @param {Point} point - A Point object to use to offset this Rectangle object. * @return {Rectangle} This Rectangle object. **/ offsetPoint: function (point) { @@ -76,11 +74,11 @@ Phaser.Rectangle.prototype = { /** * Sets the members of Rectangle to the specified values. - * @method setTo - * @param {Number} x The x coordinate of the top-left corner of the Rectangle. - * @param {Number} y The y coordinate of the top-left corner of the Rectangle. - * @param {Number} width The width of the Rectangle in pixels. - * @param {Number} height The height of the Rectangle in pixels. + * @method Phaser.Rectangle#setTo + * @param {number} x - The x coordinate of the top-left corner of the Rectangle. + * @param {number} y - The y coordinate of the top-left corner of the Rectangle. + * @param {number} width - The width of the Rectangle in pixels. + * @param {number} height - The height of the Rectangle in pixels. * @return {Rectangle} This Rectangle object **/ setTo: function (x, y, width, height) { @@ -96,7 +94,7 @@ Phaser.Rectangle.prototype = { /** * Runs Math.floor() on both the x and y values of this Rectangle. - * @method floor + * @method Phaser.Rectangle#floor **/ floor: function () { @@ -105,9 +103,22 @@ Phaser.Rectangle.prototype = { }, + /** + * Runs Math.floor() on the x, y, width and height values of this Rectangle. + * @method Phaser.Rectangle#floorAll + **/ + floorAll: function () { + + this.x = Math.floor(this.x); + this.y = Math.floor(this.y); + this.width = Math.floor(this.width); + this.height = Math.floor(this.height); + + }, + /** * Copies the x, y, width and height properties from any given object to this Rectangle. - * @method copyFrom + * @method Phaser.Rectangle#copyFrom * @param {any} source - The object to copy from. * @return {Rectangle} This Rectangle object. **/ @@ -117,7 +128,7 @@ Phaser.Rectangle.prototype = { /** * Copies the x, y, width and height properties from this Rectangle to any given object. - * @method copyTo + * @method Phaser.Rectangle#copyTo * @param {any} source - The object to copy to. * @return {object} This object. **/ @@ -134,9 +145,9 @@ Phaser.Rectangle.prototype = { /** * Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. - * @method inflate - * @param {Number} dx The amount to be added to the left side of the Rectangle. - * @param {Number} dy The amount to be added to the bottom side of the Rectangle. + * @method Phaser.Rectangle#inflate + * @param {number} dx - The amount to be added to the left side of the Rectangle. + * @param {number} dy - The amount to be added to the bottom side of the Rectangle. * @return {Phaser.Rectangle} This Rectangle object. */ inflate: function (dx, dy) { @@ -145,9 +156,9 @@ Phaser.Rectangle.prototype = { /** * The size of the Rectangle object, expressed as a Point object with the values of the width and height properties. - * @method size - * @param {Phaser.Point} output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. - * @return {Phaser.Point} The size of the Rectangle object + * @method Phaser.Rectangle#size + * @param {Phaser.Point} [output] - Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. + * @return {Phaser.Point} The size of the Rectangle object. */ size: function (output) { return Phaser.Rectangle.size(this, output); @@ -155,9 +166,9 @@ Phaser.Rectangle.prototype = { /** * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. - * @method clone - * @param {Phaser.Rectangle} output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. - * @return {Phaser.Rectangle} + * @method Phaser.Rectangle#clone + * @param {Phaser.Rectangle} [output] - Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. + * @return {Phaser.Rectangle} */ clone: function (output) { return Phaser.Rectangle.clone(this, output); @@ -165,10 +176,10 @@ Phaser.Rectangle.prototype = { /** * Determines whether the specified coordinates are contained within the region defined by this Rectangle object. - * @method contains - * @param {Number} x The x coordinate of the point to test. - * @param {Number} y The y coordinate of the point to test. - * @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false. + * @method Phaser.Rectangle#contains + * @param {number} x - The x coordinate of the point to test. + * @param {number} y - The y coordinate of the point to test. + * @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false. */ contains: function (x, y) { return Phaser.Rectangle.contains(this, x, y); @@ -177,9 +188,9 @@ Phaser.Rectangle.prototype = { /** * Determines whether the first Rectangle object is fully contained within the second Rectangle object. * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. - * @method containsRect - * @param {Phaser.Rectangle} b The second Rectangle object. - * @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false. + * @method Phaser.Rectangle#containsRect + * @param {Phaser.Rectangle} b - The second Rectangle object. + * @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false. */ containsRect: function (b) { return Phaser.Rectangle.containsRect(this, b); @@ -188,9 +199,9 @@ Phaser.Rectangle.prototype = { /** * Determines whether the two Rectangles are equal. * This method compares the x, y, width and height properties of each Rectangle. - * @method equals - * @param {Phaser.Rectangle} b The second Rectangle object. - * @return {bool} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false. + * @method Phaser.Rectangle#equals + * @param {Phaser.Rectangle} b - The second Rectangle object. + * @return {boolean} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false. */ equals: function (b) { return Phaser.Rectangle.equals(this, b); @@ -198,9 +209,9 @@ Phaser.Rectangle.prototype = { /** * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0. - * @method intersection - * @param {Phaser.Rectangle} b The second Rectangle object. - * @param {Phaser.Rectangle} output Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. + * @method Phaser.Rectangle#intersection + * @param {Phaser.Rectangle} b - The second Rectangle object. + * @param {Phaser.Rectangle} out - Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. * @return {Phaser.Rectangle} A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0. */ intersection: function (b, out) { @@ -210,10 +221,10 @@ Phaser.Rectangle.prototype = { /** * Determines whether the two Rectangles intersect with each other. * This method checks the x, y, width, and height properties of the Rectangles. - * @method intersects - * @param {Phaser.Rectangle} b The second Rectangle object. - * @param {Number} tolerance A tolerance value to allow for an intersection test with padding, default to 0 - * @return {bool} A value of true if the specified object intersects with this Rectangle object; otherwise false. + * @method Phaser.Rectangle#intersects + * @param {Phaser.Rectangle} b - The second Rectangle object. + * @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0. + * @return {boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false. */ intersects: function (b, tolerance) { return Phaser.Rectangle.intersects(this, b, tolerance); @@ -221,13 +232,13 @@ Phaser.Rectangle.prototype = { /** * Determines whether the object specified intersects (overlaps) with the given values. - * @method intersectsRaw - * @param {Number} left - * @param {Number} right - * @param {Number} top - * @param {Number} bottomt - * @param {Number} tolerance A tolerance value to allow for an intersection test with padding, default to 0 - * @return {bool} A value of true if the specified object intersects with the Rectangle; otherwise false. + * @method Phaser.Rectangle#intersectsRaw + * @param {number} left - Description. + * @param {number} right - Description. + * @param {number} top - Description. + * @param {number} bottomt - Description. + * @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0 + * @return {boolean} A value of true if the specified object intersects with the Rectangle; otherwise false. */ intersectsRaw: function (left, right, top, bottom, tolerance) { return Phaser.Rectangle.intersectsRaw(this, left, right, top, bottom, tolerance); @@ -235,9 +246,9 @@ Phaser.Rectangle.prototype = { /** * Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles. - * @method union - * @param {Phaser.Rectangle} b The second Rectangle object. - * @param {Phaser.Rectangle} output Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. + * @method Phaser.Rectangle#union + * @param {Phaser.Rectangle} b - The second Rectangle object. + * @param {Phaser.Rectangle} [out] - Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. * @return {Phaser.Rectangle} A Rectangle object that is the union of the two Rectangles. */ union: function (b, out) { @@ -246,8 +257,8 @@ Phaser.Rectangle.prototype = { /** * Returns a string representation of this object. - * @method toString - * @return {string} a string representation of the instance. + * @method Phaser.Rectangle#toString + * @return {string} A string representation of the instance. **/ toString: function () { return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.empty + ")}]"; @@ -255,50 +266,43 @@ Phaser.Rectangle.prototype = { }; -// Getters / Setters - +/** +* @name Phaser.Rectangle#halfWidth +* @property {number} halfWidth - Half of the width of the Rectangle. +* @readonly +*/ Object.defineProperty(Phaser.Rectangle.prototype, "halfWidth", { - /** - * Half of the width of the Rectangle - * @property halfWidth - * @type Number - **/ get: function () { return Math.round(this.width / 2); } }); +/** +* @name Phaser.Rectangle#halfHeight +* @property {number} halfHeight - Half of the height of the Rectangle. +* @readonly +*/ Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", { - /** - * Half of the height of the Rectangle - * @property halfHeight - * @type Number - **/ get: function () { return Math.round(this.height / 2); } }); +/** +* 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. +* @name Phaser.Rectangle#bottom +* @property {number} bottom - The sum of the y and height properties. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "bottom", { - /** - * 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. - * @method bottom - * @return {Number} - **/ get: function () { return this.y + this.height; }, - - /** - * 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. - * @method bottom - * @param {Number} value - **/ + set: function (value) { if (value <= this.y) { this.height = 0; @@ -309,21 +313,17 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottom", { }); +/** +* The location of the Rectangles bottom right corner as a Point object. +* @name Phaser.Rectangle#bottom +* @property {Phaser.Point} bottomRight - Gets or sets the location of the Rectangles bottom right corner as a Point object. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", { - /** - * Get the location of the Rectangles bottom right corner as a Point object. - * @return {Phaser.Point} The new Point object. - */ get: function () { return new Phaser.Point(this.right, this.bottom); }, - /** - * Sets the bottom-right corner of the Rectangle, determined by the values of the given Point object. - * @method bottomRight - * @param {Point} value - **/ set: function (value) { this.right = value.x; this.bottom = value.y; @@ -331,23 +331,17 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", { }); +/** +* 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. +* @name Phaser.Rectangle#left +* @property {number} left - The x coordinate of the left of the Rectangle. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "left", { - - /** - * 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. - * @method left - * @ return {number} - **/ + get: function () { return this.x; }, - /** - * 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, whereas changing the x value does not affect the width property. - * @method left - * @param {Number} value - **/ set: function (value) { if (value >= this.right) { this.width = 0; @@ -359,24 +353,17 @@ Object.defineProperty(Phaser.Rectangle.prototype, "left", { }); +/** +* 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. +* @name Phaser.Rectangle#right +* @property {number} right - The sum of the x and width properties. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "right", { - - /** - * 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. - * @method right - * @return {Number} - **/ + get: function () { return this.x + this.width; }, - /** - * 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. - * @method right - * @param {Number} value - **/ set: function (value) { if (value <= this.x) { this.width = 0; @@ -387,94 +374,80 @@ Object.defineProperty(Phaser.Rectangle.prototype, "right", { }); +/** +* The volume of the Rectangle derived from width * height. +* @name Phaser.Rectangle#volume +* @property {number} volume - The volume of the Rectangle derived from width * height. +* @readonly +*/ Object.defineProperty(Phaser.Rectangle.prototype, "volume", { - - /** - * The volume of the Rectangle derived from width * height - * @method volume - * @return {Number} - **/ + get: function () { return this.width * this.height; } }); +/** +* The perimeter size of the Rectangle. This is the sum of all 4 sides. +* @name Phaser.Rectangle#perimeter +* @property {number} perimeter - The perimeter size of the Rectangle. This is the sum of all 4 sides. +* @readonly +*/ Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", { - /** - * The perimeter size of the Rectangle. This is the sum of all 4 sides. - * @method perimeter - * @return {Number} - **/ get: function () { return (this.width * 2) + (this.height * 2); } }); +/** +* The x coordinate of the center of the Rectangle. +* @name Phaser.Rectangle#centerX +* @property {number} centerX - The x coordinate of the center of the Rectangle. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "centerX", { - /** - * The x coordinate of the center of the Rectangle. - * @method centerX - * @return {Number} - **/ get: function () { return this.x + this.halfWidth; }, - /** - * The x coordinate of the center of the Rectangle. - * @method centerX - * @param {Number} value - **/ set: function (value) { this.x = value - this.halfWidth; } }); +/** +* The y coordinate of the center of the Rectangle. +* @name Phaser.Rectangle#centerY +* @property {number} centerY - The y coordinate of the center of the Rectangle. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "centerY", { - /** - * The y coordinate of the center of the Rectangle. - * @method centerY - * @return {Number} - **/ get: function () { return this.y + this.halfHeight; }, - /** - * The y coordinate of the center of the Rectangle. - * @method centerY - * @param {Number} value - **/ set: function (value) { this.y = value - this.halfHeight; } }); +/** +* 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. +* @name Phaser.Rectangle#top +* @property {number} top - The y coordinate of the top of the Rectangle. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "top", { - /** - * 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. - * @method top - * @return {Number} - **/ get: function () { return this.y; }, - /** - * 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. - * @method top - * @param {Number} value - **/ set: function (value) { if (value >= this.bottom) { this.height = 0; @@ -486,21 +459,17 @@ Object.defineProperty(Phaser.Rectangle.prototype, "top", { }); +/** +* The location of the Rectangles top left corner as a Point object. +* @name Phaser.Rectangle#topLeft +* @property {Phaser.Point} topLeft - The location of the Rectangles top left corner as a Point object. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", { - /** - * Get the location of the Rectangles top left corner as a Point object. - * @return {Phaser.Point} The new Point object. - */ get: function () { return new Phaser.Point(this.x, this.y); }, - - /** - * The location of the Rectangles top-left corner, determined by the x and y coordinates of the Point. - * @method topLeft - * @param {Point} value - **/ + set: function (value) { this.x = value.x; this.y = value.y; @@ -508,36 +477,30 @@ Object.defineProperty(Phaser.Rectangle.prototype, "topLeft", { }); +/** +* Determines whether or not this Rectangle object is empty. A Rectangle object is empty if its width or height is less than or equal to 0. +* If set to true then all of the Rectangle properties are set to 0. +* @name Phaser.Rectangle#empty +* @property {boolean} empty - Gets or sets the Rectangles empty state. +*/ Object.defineProperty(Phaser.Rectangle.prototype, "empty", { - /** - * Determines whether or not this Rectangle object is empty. - * @method isEmpty - * @return {bool} A value of true if the Rectangle objects width or height is less than or equal to 0; otherwise false. - **/ get: function () { return (!this.width || !this.height); }, - /** - * Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0. - * @method setEmpty - * @return {Rectangle} This Rectangle object - **/ set: function (value) { this.setTo(0, 0, 0, 0); } }); -// Statics - /** * Increases the size of the Rectangle object by the specified amounts. The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value. -* @method inflate -* @param {Phaser.Rectangle} a The Rectangle object. -* @param {Number} dx The amount to be added to the left side of the Rectangle. -* @param {Number} dy The amount to be added to the bottom side of the Rectangle. +* @method Phaser.Rectangle.inflate +* @param {Phaser.Rectangle} a - The Rectangle object. +* @param {number} dx - The amount to be added to the left side of the Rectangle. +* @param {number} dy - The amount to be added to the bottom side of the Rectangle. * @return {Phaser.Rectangle} This Rectangle object. */ Phaser.Rectangle.inflate = function (a, dx, dy) { @@ -550,20 +513,20 @@ Phaser.Rectangle.inflate = function (a, dx, dy) { /** * Increases the size of the Rectangle object. This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter. -* @method inflatePoint -* @param {Phaser.Rectangle} a The Rectangle object. -* @param {Phaser.Point} point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. +* @method Phaser.Rectangle.inflatePoint +* @param {Phaser.Rectangle} a - The Rectangle object. +* @param {Phaser.Point} point - The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object. * @return {Phaser.Rectangle} The Rectangle object. */ Phaser.Rectangle.inflatePoint = function (a, point) { - return Phaser.Phaser.Rectangle.inflate(a, point.x, point.y); + return Phaser.Rectangle.inflate(a, point.x, point.y); }; /** * The size of the Rectangle object, expressed as a Point object with the values of the width and height properties. -* @method size -* @param {Phaser.Rectangle} a The Rectangle object. -* @param {Phaser.Point} output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. +* @method Phaser.Rectangle.size +* @param {Phaser.Rectangle} a - The Rectangle object. +* @param {Phaser.Point} [output] - Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned. * @return {Phaser.Point} The size of the Rectangle object */ Phaser.Rectangle.size = function (a, output) { @@ -573,9 +536,9 @@ Phaser.Rectangle.size = function (a, output) { /** * Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object. -* @method clone -* @param {Phaser.Rectangle} a The Rectangle object. -* @param {Phaser.Rectangle} output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. +* @method Phaser.Rectangle.clone +* @param {Phaser.Rectangle} a - The Rectangle object. +* @param {Phaser.Rectangle} [output] - Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned. * @return {Phaser.Rectangle} */ Phaser.Rectangle.clone = function (a, output) { @@ -585,34 +548,38 @@ Phaser.Rectangle.clone = function (a, output) { /** * Determines whether the specified coordinates are contained within the region defined by this Rectangle object. -* @method contains -* @param {Phaser.Rectangle} a The Rectangle object. -* @param {Number} x The x coordinate of the point to test. -* @param {Number} y The y coordinate of the point to test. -* @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false. +* @method Phaser.Rectangle.contains +* @param {Phaser.Rectangle} a - The Rectangle object. +* @param {number} x - The x coordinate of the point to test. +* @param {number} y - The y coordinate of the point to test. +* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false. */ Phaser.Rectangle.contains = function (a, x, y) { return (x >= a.x && x <= a.right && y >= a.y && y <= a.bottom); }; +Phaser.Rectangle.containsRaw = function (rx, ry, rw, rh, x, y) { + return (x >= rx && x <= (rx + rw) && y >= ry && y <= (ry + rh)); +}; + /** * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter. -* @method containsPoint -* @param {Phaser.Rectangle} a The Rectangle object. -* @param {Phaser.Point} point The point object being checked. Can be Point or any object with .x and .y values. -* @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false. +* @method Phaser.Rectangle.containsPoint +* @param {Phaser.Rectangle} a - The Rectangle object. +* @param {Phaser.Point} point - The point object being checked. Can be Point or any object with .x and .y values. +* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false. */ Phaser.Rectangle.containsPoint = function (a, point) { - return Phaser.Phaser.Rectangle.contains(a, point.x, point.y); + return Phaser.Rectangle.contains(a, point.x, point.y); }; /** * Determines whether the first Rectangle object is fully contained within the second Rectangle object. * A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first. -* @method containsRect -* @param {Phaser.Rectangle} a The first Rectangle object. -* @param {Phaser.Rectangle} b The second Rectangle object. -* @return {bool} A value of true if the Rectangle object contains the specified point; otherwise false. +* @method Phaser.Rectangle.containsRect +* @param {Phaser.Rectangle} a - The first Rectangle object. +* @param {Phaser.Rectangle} b - The second Rectangle object. +* @return {boolean} A value of true if the Rectangle object contains the specified point; otherwise false. */ Phaser.Rectangle.containsRect = function (a, b) { @@ -629,10 +596,10 @@ Phaser.Rectangle.containsRect = function (a, b) { /** * Determines whether the two Rectangles are equal. * This method compares the x, y, width and height properties of each Rectangle. -* @method equals -* @param {Phaser.Rectangle} a The first Rectangle object. -* @param {Phaser.Rectangle} b The second Rectangle object. -* @return {bool} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false. +* @method Phaser.Rectangle.equals +* @param {Phaser.Rectangle} a - The first Rectangle object. +* @param {Phaser.Rectangle} b - The second Rectangle object. +* @return {boolean} A value of true if the two Rectangles have exactly the same values for the x, y, width and height properties; otherwise false. */ Phaser.Rectangle.equals = function (a, b) { return (a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height); @@ -640,10 +607,10 @@ Phaser.Rectangle.equals = function (a, b) { /** * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, returns the area of intersection as a Rectangle object. If the Rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0. -* @method intersection -* @param {Phaser.Rectangle} a The first Rectangle object. -* @param {Phaser.Rectangle} b The second Rectangle object. -* @param {Phaser.Rectangle} output Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. +* @method Phaser.Rectangle.intersection +* @param {Phaser.Rectangle} a - The first Rectangle object. +* @param {Phaser.Rectangle} b - The second Rectangle object. +* @param {Phaser.Rectangle} [out] - Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned. * @return {Phaser.Rectangle} A Rectangle object that equals the area of intersection. If the Rectangles do not intersect, this method returns an empty Rectangle object; that is, a Rectangle with its x, y, width, and height properties set to 0. */ Phaser.Rectangle.intersection = function (a, b, out) { @@ -665,29 +632,31 @@ Phaser.Rectangle.intersection = function (a, b, out) { /** * Determines whether the two Rectangles intersect with each other. * This method checks the x, y, width, and height properties of the Rectangles. -* @method intersects -* @param {Phaser.Rectangle} a The first Rectangle object. -* @param {Phaser.Rectangle} b The second Rectangle object. -* @param {Number} tolerance A tolerance value to allow for an intersection test with padding, default to 0 -* @return {bool} A value of true if the specified object intersects with this Rectangle object; otherwise false. +* @method Phaser.Rectangle.intersects +* @param {Phaser.Rectangle} a - The first Rectangle object. +* @param {Phaser.Rectangle} b - The second Rectangle object. +* @return {boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false. */ -Phaser.Rectangle.intersects = function (a, b, tolerance) { +Phaser.Rectangle.intersects = function (a, b) { - tolerance = tolerance || 0; + return (a.x < b.right && b.x < a.right && a.y < b.bottom && b.y < a.bottom); - return !(a.x > b.right + tolerance || a.right < b.x - tolerance || a.y > b.bottom + tolerance || a.bottom < b.y - tolerance); + // return (a.x <= b.right && b.x <= a.right && a.y <= b.bottom && b.y <= a.bottom); + + // return (a.left <= b.right && b.left <= a.right && a.top <= b.bottom && b.top <= a.bottom); + // return !(a.x > b.right + tolerance || a.right < b.x - tolerance || a.y > b.bottom + tolerance || a.bottom < b.y - tolerance); }; /** * Determines whether the object specified intersects (overlaps) with the given values. -* @method intersectsRaw -* @param {Number} left -* @param {Number} right -* @param {Number} top -* @param {Number} bottomt -* @param {Number} tolerance A tolerance value to allow for an intersection test with padding, default to 0 -* @return {bool} A value of true if the specified object intersects with the Rectangle; otherwise false. +* @method Phaser.Rectangle.intersectsRaw +* @param {number} left - Description. +* @param {number} right - Description. +* @param {number} top - Description. +* @param {number} bottom - Description. +* @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0 +* @return {boolean} A value of true if the specified object intersects with the Rectangle; otherwise false. */ Phaser.Rectangle.intersectsRaw = function (a, left, right, top, bottom, tolerance) { @@ -699,16 +668,16 @@ Phaser.Rectangle.intersectsRaw = function (a, left, right, top, bottom, toleranc /** * Adds two Rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two Rectangles. -* @method union -* @param {Phaser.Rectangle} a The first Rectangle object. -* @param {Phaser.Rectangle} b The second Rectangle object. -* @param {Phaser.Rectangle} output Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. +* @method Phaser.Rectangle.union +* @param {Phaser.Rectangle} a - The first Rectangle object. +* @param {Phaser.Rectangle} b - The second Rectangle object. +* @param {Phaser.Rectangle} [out] - Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned. * @return {Phaser.Rectangle} A Rectangle object that is the union of the two Rectangles. */ Phaser.Rectangle.union = function (a, b, out) { if (typeof out === "undefined") { out = new Phaser.Rectangle(); } - return out.setTo(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.right, b.right), Math.max(a.bottom, b.bottom)); + return out.setTo(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.max(a.right, b.right) - Math.min(a.left, b.left), Math.max(a.bottom, b.bottom) - Math.min(a.top, b.top)); }; diff --git a/src/input/Input.js b/src/input/Input.js index f9df0d7a..acc9cda9 100644 --- a/src/input/Input.js +++ b/src/input/Input.js @@ -1,265 +1,363 @@ /** -* Phaser.Input -* -* A game specific Input manager that looks after the mouse, keyboard and touch objects. +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Constructor for Phaser Input. +* @class Phaser.Input +* @classdesc A game specific Input manager that looks after the mouse, keyboard and touch objects. * This is updated by the core game loop. +* @constructor +* @param {Phaser.Game} game - Current game instance. */ Phaser.Input = function (game) { + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ this.game = game; + /** + * @property {Description} hitCanvas - Description. + * @default + */ this.hitCanvas = null; + + /** + * @property {Description} hitContext - Description. + * @default + */ this.hitContext = null; }; +/** +* @constant +* @type {number} +*/ Phaser.Input.MOUSE_OVERRIDES_TOUCH = 0; + +/** +* @constant +* @type {number} +*/ Phaser.Input.TOUCH_OVERRIDES_MOUSE = 1; + +/** +* @constant +* @type {number} +*/ Phaser.Input.MOUSE_TOUCH_COMBINE = 2; Phaser.Input.prototype = { + /** + * @property {Phaser.Game} game + */ game: null, /** * How often should the input pointers be checked for updates? * A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on. - * @type {number} + * @property {number} pollRate + * @default */ pollRate: 0, + + /** + * @property {number} _pollCounter - Description. + * @private + * @default + */ _pollCounter: 0, /** * A vector object representing the previous position of the Pointer. - * @property vector - * @type {Vec2} - **/ + * @property {Vec2} vector + * @private + * @default + */ _oldPosition: null, /** * X coordinate of the most recent Pointer event - * @type {Number} + * @property {number} _x * @private + * @default */ _x: 0, /** - * X coordinate of the most recent Pointer event - * @type {Number} + * Y coordinate of the most recent Pointer event + * @property {number} _y * @private + * @default */ _y: 0, /** * You can disable all Input by setting Input.disabled: true. While set all new input related events will be ignored. * If you need to disable just one type of input, for example mouse, use Input.mouse.disabled: true instead - * @type {bool} + * @property {boolean} disabled + * @default */ disabled: false, /** - * Controls the expected behaviour when using a mouse and touch together on a multi-input device + * Controls the expected behaviour when using a mouse and touch together on a multi-input device. + * @property {Description} multiInputOverride */ multiInputOverride: Phaser.Input.MOUSE_TOUCH_COMBINE, /** * A vector object representing the current position of the Pointer. - * @property vector - * @type {Vec2} - **/ + * @property {Phaser.Point} position + * @default + */ position: null, /** * A vector object representing the speed of the Pointer. Only really useful in single Pointer games, * otherwise see the Pointer objects directly. - * @property vector - * @type {Vec2} - **/ + * @property {Phaser.Point} speed + * @default + */ speed: null, /** * A Circle object centered on the x/y screen coordinates of the Input. - * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything - * @property circle - * @type {Circle} - **/ + * Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything. + * @property {Phaser.Circle} circle + * @default + */ circle: null, /** * The scale by which all input coordinates are multiplied, calculated by the StageScaleMode. * In an un-scaled game the values will be x: 1 and y: 1. - * @type {Vec2} + * @property {Phaser.Point} scale + * @default */ scale: null, /** * The maximum number of Pointers allowed to be active at any one time. - * For lots of games it's useful to set this to 1 - * @type {Number} + * For lots of games it's useful to set this to 1. + * @property {number} maxPointers + * @default */ maxPointers: 10, /** * The current number of active Pointers. - * @type {Number} + * @property {number} currentPointers + * @default */ currentPointers: 0, /** - * The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or click - * @property tapRate - * @type {Number} - **/ + * The number of milliseconds that the Pointer has to be pressed down and then released to be considered a tap or clicke + * @property {number} tapRate + * @default + */ tapRate: 200, /** * The number of milliseconds between taps of the same Pointer for it to be considered a double tap / click - * @property doubleTapRate - * @type {Number} - **/ + * @property {number} doubleTapRate + * @default + */ doubleTapRate: 300, /** * The number of milliseconds that the Pointer has to be pressed down for it to fire a onHold event - * @property holdRate - * @type {Number} - **/ + * @property {number} holdRate + * @default + */ holdRate: 2000, /** * The number of milliseconds below which the Pointer is considered justPressed - * @property justPressedRate - * @type {Number} - **/ + * @property {number} justPressedRate + * @default + */ justPressedRate: 200, /** - * The number of milliseconds below which the Pointer is considered justReleased - * @property justReleasedRate - * @type {Number} - **/ + * The number of milliseconds below which the Pointer is considered justReleased + * @property {number} justReleasedRate + * @default + */ justReleasedRate: 200, /** * Sets if the Pointer objects should record a history of x/y coordinates they have passed through. * The history is cleared each time the Pointer is pressed down. * The history is updated at the rate specified in Input.pollRate - * @property recordPointerHistory - * @type {bool} - **/ + * @property {boolean} recordPointerHistory + * @default + */ recordPointerHistory: false, /** * The rate in milliseconds at which the Pointer objects should update their tracking history - * @property recordRate - * @type {Number} + * @property {number} recordRate + * @default */ recordRate: 100, /** * The total number of entries that can be recorded into the Pointer objects tracking history. * If the Pointer is tracking one event every 100ms, then a trackLimit of 100 would store the last 10 seconds worth of history. - * @property recordLimit - * @type {Number} + * @property {number} recordLimit + * @default */ recordLimit: 100, /** * A Pointer object - * @property pointer1 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer1 + */ pointer1: null, /** * A Pointer object - * @property pointer2 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer2 + */ pointer2: null, /** - * A Pointer object - * @property pointer3 - * @type {Pointer} - **/ + * A Pointer object + * @property {Phaser.Pointer} pointer3 + */ pointer3: null, /** * A Pointer object - * @property pointer4 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer4 + */ pointer4: null, /** * A Pointer object - * @property pointer5 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer5 + */ pointer5: null, /** * A Pointer object - * @property pointer6 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer6 + */ pointer6: null, /** - * A Pointer object - * @property pointer7 - * @type {Pointer} - **/ + * A Pointer object + * @property {Phaser.Pointer} pointer7 + */ pointer7: null, /** * A Pointer object - * @property pointer8 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer8 + */ pointer8: null, /** * A Pointer object - * @property pointer9 - * @type {Pointer} - **/ + * @property {Phaser.Pointer} pointer9 + */ pointer9: null, /** - * A Pointer object - * @property pointer10 - * @type {Pointer} - **/ + * A Pointer object. + * @property {Phaser.Pointer} pointer10 + */ pointer10: null, /** * The most recently active Pointer object. * When you've limited max pointers to 1 this will accurately be either the first finger touched or mouse. - * @property activePointer - * @type {Pointer} - **/ + * @property {Phaser.Pointer} activePointer + * @default + */ activePointer: null, + /** + * The mouse has its own unique Phaser.Pointer object which you can use if making a desktop specific game. + * @property {Pointer} mousePointer + * @default + */ mousePointer: null, + + /** + * The Mouse Input manager. + * @property {Phaser.Mouse} mouse - The Mouse Input manager. + * @default + */ mouse: null, + + /** + * The Keyboard Input manager. + * @property {Phaser.Keyboard} keyboard - The Keyboard Input manager. + * @default + */ keyboard: null, + + /** + * The Touch Input manager. + * @property {Phaser.Touch} touch - the Touch Input manager. + * @default + */ touch: null, + + /** + * The MSPointer Input manager. + * @property {Phaser.MSPointer} mspointer - The MSPointer Input manager. + * @default + */ mspointer: null, + /** + * A Signal that is dispatched each time a pointer is pressed down. + * @property {Phaser.Signal} onDown + * @default + */ onDown: null, + + /** + * A Signal that is dispatched each time a pointer is released. + * @property {Phaser.Signal} onUp + * @default + */ onUp: null, + + /** + * A Signal that is dispatched each time a pointer is tapped. + * @property {Phaser.Signal} onTap + * @default + */ onTap: null, + + /** + * A Signal that is dispatched each time a pointer is held down. + * @property {Phaser.Signal} onHold + * @default + */ onHold: null, - // A linked list of interactive objects, the InputHandler components (belong to Sprites) register themselves with this + /** + * A linked list of interactive objects, the InputHandler components (belonging to Sprites) register themselves with this. + * @property {Phaser.LinkedList} interactiveItems + */ interactiveItems: new Phaser.LinkedList(), /** - * Starts the Input Manager running - * @method start - **/ + * Starts the Input Manager running. + * @method Phaser.Input#boot + * @protected + */ boot: function () { this.mousePointer = new Phaser.Pointer(this.game, 0); @@ -297,14 +395,27 @@ Phaser.Input.prototype = { this.mspointer.start(); this.mousePointer.active = true; + }, + + /** + * Stops all of the Input Managers from running. + * @method Phaser.Input#destroy + */ + destroy: function () { + + this.mouse.stop(); + this.keyboard.stop(); + this.touch.stop(); + this.mspointer.stop(); + }, /** - * Add a new Pointer object to the Input Manager. By default Input creates 2 pointer objects for you. If you need more - * use this to create a new one, up to a maximum of 10. - * @method addPointer - * @return {Pointer} A reference to the new Pointer object - **/ + * Add a new Pointer object to the Input Manager. By default Input creates 3 pointer objects: mousePointer, pointer1 and pointer2. + * If you need more then use this to create a new one, up to a maximum of 10. + * @method Phaser.Input#addPointer + * @return {Phaser.Pointer} A reference to the new Pointer object that was created. + */ addPointer: function () { var next = 0; @@ -332,8 +443,9 @@ Phaser.Input.prototype = { /** * Updates the Input Manager. Called by the core Game loop. - * @method update - **/ + * @method Phaser.Input#update + * @protected + */ update: function () { if (this.pollRate > 0 && this._pollCounter < this.pollRate) @@ -365,9 +477,9 @@ Phaser.Input.prototype = { /** * Reset all of the Pointers and Input states - * @method reset - * @param hard {bool} A soft reset (hard = false) won't reset any signals that might be bound. A hard reset will. - **/ + * @method Phaser.Input#reset + * @param {boolean} hard - A soft reset (hard = false) won't reset any Signals that might be bound. A hard reset will. + */ reset: function (hard) { if (this.game.isBooted == false) @@ -409,6 +521,12 @@ Phaser.Input.prototype = { }, + /** + * Resets the speed and old position properties. + * @method Phaser.Input#resetSpeed + * @param {number} x - Sets the oldPosition.x value. + * @param {number} y - Sets the oldPosition.y value. + */ resetSpeed: function (x, y) { this._oldPosition.setTo(x, y); @@ -417,11 +535,11 @@ Phaser.Input.prototype = { }, /** - * Find the first free Pointer object and start it, passing in the event data. - * @method startPointer - * @param {Any} event The event data from the Touch event - * @return {Pointer} The Pointer object that was started or null if no Pointer object is available - **/ + * Find the first free Pointer object and start it, passing in the event data. This is called automatically by Phaser.Touch and Phaser.MSPointer. + * @method Phaser.Input#startPointer + * @param {Any} event - The event data from the Touch event. + * @return {Phaser.Pointer} The Pointer object that was started or null if no Pointer object is available. + */ startPointer: function (event) { if (this.maxPointers < 10 && this.totalActivePointers == this.maxPointers) @@ -453,11 +571,11 @@ Phaser.Input.prototype = { }, /** - * Updates the matching Pointer object, passing in the event data. - * @method updatePointer - * @param {Any} event The event data from the Touch event - * @return {Pointer} The Pointer object that was updated or null if no Pointer object is available - **/ + * Updates the matching Pointer object, passing in the event data. This is called automatically and should not normally need to be invoked. + * @method Phaser.Input#updatePointer + * @param {Any} event - The event data from the Touch event. + * @return {Phaser.Pointer} The Pointer object that was updated or null if no Pointer object is available. + */ updatePointer: function (event) { if (this.pointer1.active && this.pointer1.identifier == event.identifier) @@ -485,10 +603,10 @@ Phaser.Input.prototype = { /** * Stops the matching Pointer object, passing in the event data. - * @method stopPointer - * @param {Any} event The event data from the Touch event - * @return {Pointer} The Pointer object that was stopped or null if no Pointer object is available - **/ + * @method Phaser.Input#stopPointer + * @param {Any} event - The event data from the Touch event. + * @return {Phaser.Pointer} The Pointer object that was stopped or null if no Pointer object is available. + */ stopPointer: function (event) { if (this.pointer1.active && this.pointer1.identifier == event.identifier) @@ -516,10 +634,10 @@ Phaser.Input.prototype = { /** * Get the next Pointer object whos active property matches the given state - * @method getPointer - * @param {bool} state The state the Pointer should be in (false for inactive, true for active) - * @return {Pointer} A Pointer object or null if no Pointer object matches the requested state. - **/ + * @method Phaser.Input#getPointer + * @param {boolean} state - The state the Pointer should be in (false for inactive, true for active). + * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested state. + */ getPointer: function (state) { state = state || false; @@ -548,11 +666,11 @@ Phaser.Input.prototype = { }, /** - * Get the Pointer object whos identified property matches the given identifier value - * @method getPointerFromIdentifier - * @param {Number} identifier The Pointer.identifier value to search for - * @return {Pointer} A Pointer object or null if no Pointer object matches the requested identifier. - **/ + * Get the Pointer object whos identified property matches the given identifier value. + * @method Phaser.Input#getPointerFromIdentifier + * @param {number} identifier - The Pointer.identifier value to search for. + * @return {Phaser.Pointer} A Pointer object or null if no Pointer object matches the requested identifier. + */ getPointerFromIdentifier: function (identifier) { if (this.pointer1.identifier == identifier) @@ -576,40 +694,17 @@ Phaser.Input.prototype = { return null; - }, - - /** - * Get the distance between two Pointer objects - * @method getDistance - * @param {Pointer} pointer1 - * @param {Pointer} pointer2 - **/ - getDistance: function (pointer1, pointer2) { - // return Phaser.Vec2Utils.distance(pointer1.position, pointer2.position); - }, - - /** - * Get the angle between two Pointer objects - * @method getAngle - * @param {Pointer} pointer1 - * @param {Pointer} pointer2 - **/ - getAngle: function (pointer1, pointer2) { - // return Phaser.Vec2Utils.angle(pointer1.position, pointer2.position); } }; -// Getters / Setters - +/** +* The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values. +* @name Phaser.Input#x +* @property {number} x - The X coordinate of the most recently active pointer. +*/ Object.defineProperty(Phaser.Input.prototype, "x", { - /** - * The X coordinate of the most recently active pointer. - * This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values. - * @property x - * @type {Number} - **/ get: function () { return this._x; }, @@ -620,14 +715,13 @@ Object.defineProperty(Phaser.Input.prototype, "x", { }); +/** +* The Y coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values. +* @name Phaser.Input#y +* @property {number} y - The Y coordinate of the most recently active pointer. +*/ Object.defineProperty(Phaser.Input.prototype, "y", { - /** - * The Y coordinate of the most recently active pointer. - * This value takes game scaling into account automatically. See Pointer.screenY/clientY for source values. - * @property y - * @type {Number} - **/ get: function () { return this._y; }, @@ -638,6 +732,11 @@ Object.defineProperty(Phaser.Input.prototype, "y", { }); +/** +* @name Phaser.Input#pollLocked +* @property {boolean} pollLocked - True if the Input is currently poll rate locked. +* @readonly +*/ Object.defineProperty(Phaser.Input.prototype, "pollLocked", { get: function () { @@ -646,26 +745,28 @@ Object.defineProperty(Phaser.Input.prototype, "pollLocked", { }); +/** +* The total number of inactive Pointers +* @name Phaser.Input#totalInactivePointers +* @property {number} totalInactivePointers - The total number of inactive Pointers. +* @readonly +*/ Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", { - /** - * Get the total number of inactive Pointers - * @method totalInactivePointers - * @return {Number} The number of Pointers currently inactive - **/ get: function () { return 10 - this.currentPointers; } }); +/** +* The total number of active Pointers +* @name Phaser.Input#totalActivePointers +* @property {number} totalActivePointers - The total number of active Pointers. +* @readonly +*/ Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", { - /** - * Recalculates the total number of active Pointers - * @method totalActivePointers - * @return {Number} The number of Pointers currently active - **/ get: function () { this.currentPointers = 0; @@ -684,6 +785,11 @@ Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", { }); +/** +* The world X coordinate of the most recently active pointer. +* @name Phaser.Input#worldX +* @property {number} worldX - The world X coordinate of the most recently active pointer. +*/ Object.defineProperty(Phaser.Input.prototype, "worldX", { get: function () { @@ -692,6 +798,11 @@ Object.defineProperty(Phaser.Input.prototype, "worldX", { }); +/** +* The world Y coordinate of the most recently active pointer. +* @name Phaser.Input#worldY +* @property {number} worldY - The world Y coordinate of the most recently active pointer. +*/ Object.defineProperty(Phaser.Input.prototype, "worldY", { get: function () { diff --git a/src/input/InputHandler.js b/src/input/InputHandler.js index 4bcec1bf..38a3d865 100644 --- a/src/input/InputHandler.js +++ b/src/input/InputHandler.js @@ -1,81 +1,208 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Constructor for Phaser InputHandler. +* @class Phaser.InputHandler +* @classdesc Description. +* @constructor +* @param {Phaser.Sprite} game - Description. +*/ Phaser.InputHandler = function (sprite) { - this.game = sprite.game; + /** + * @property {Phaser.Sprite} sprite - Description. + */ this.sprite = sprite; + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = sprite.game; + + /** + * @property {boolean} enabled - Description. + * @default + */ this.enabled = false; // Linked list references + /** + * @property {Description} parent - Description. + * @default + */ this.parent = null; + + /** + * @property {Description} next - Description. + * @default + */ this.next = null; + + /** + * @property {Description} prev - Description. + * @default + */ this.prev = null; + + /** + * @property {Description} last - Description. + * @default + */ this.last = this; + + /** + * @property {Description} first - Description. + * @default + */ this.first = this; - /** - * The PriorityID controls which Sprite receives an Input event first if they should overlap. - */ + /** + * @property {number} priorityID - The PriorityID controls which Sprite receives an Input event first if they should overlap. + * @default + */ this.priorityID = 0; + + /** + * @property {boolean} useHandCursor - Description. + * @default + */ this.useHandCursor = false; + /** + * @property {boolean} isDragged - Description. + * @default + */ this.isDragged = false; + + /** + * @property {boolean} allowHorizontalDrag - Description. + * @default + */ this.allowHorizontalDrag = true; + + /** + * @property {boolean} allowVerticalDrag - Description. + * @default + */ this.allowVerticalDrag = true; + + /** + * @property {boolean} bringToTop - Description. + * @default + */ this.bringToTop = false; + /** + * @property {Description} snapOffset - Description. + * @default + */ this.snapOffset = null; + + /** + * @property {boolean} snapOnDrag - Description. + * @default + */ this.snapOnDrag = false; + + /** + * @property {boolean} snapOnRelease - Description. + * @default + */ this.snapOnRelease = false; + + /** + * @property {number} snapX - Description. + * @default + */ this.snapX = 0; + + /** + * @property {number} snapY - Description. + * @default + */ this.snapY = 0; - /** - * Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it! - * @default false - */ + /** + * @property {number} pixelPerfect - Should we use pixel perfect hit detection? Warning: expensive. Only enable if you really need it! + * @default + */ this.pixelPerfect = false; /** - * The alpha tolerance threshold. If the alpha value of the pixel matches or is above this value, it's considered a hit. - * @default 255 + * @property {number} pixelPerfectAlpha - The alpha tolerance threshold. If the alpha value of the pixel matches or is above this value, it's considered a hit. + * @default */ this.pixelPerfectAlpha = 255; /** - * Is this sprite allowed to be dragged by the mouse? true = yes, false = no - * @default false + * @property {boolean} draggable - Is this sprite allowed to be dragged by the mouse? true = yes, false = no + * @default */ this.draggable = false; /** - * A region of the game world within which the sprite is restricted during drag - * @default null + * @property {Description} boundsRect - A region of the game world within which the sprite is restricted during drag. + * @default */ this.boundsRect = null; /** - * An Sprite the bounds of which this sprite is restricted during drag - * @default null + * @property {Description} boundsSprite - A Sprite the bounds of which this sprite is restricted during drag. + * @default */ this.boundsSprite = null; /** * If this object is set to consume the pointer event then it will stop all propogation from this object on. * For example if you had a stack of 6 sprites with the same priority IDs and one consumed the event, none of the others would receive it. - * @type {bool} + * @property {boolean} consumePointerEvent + * @default */ this.consumePointerEvent = false; + /** + * @property {Phaser.Point} _tempPoint - Description. + * @private + */ this._tempPoint = new Phaser.Point; + this._pointerData = []; + + this._pointerData.push({ + id: 0, + x: 0, + y: 0, + isDown: false, + isUp: false, + isOver: false, + isOut: false, + timeOver: 0, + timeOut: 0, + timeDown: 0, + timeUp: 0, + downDuration: 0, + isDragged: false + }); + }; Phaser.InputHandler.prototype = { + /** + * Description. + * @method Phaser.InputHandler#start + * @param {number} priority - Description. + * @param {boolean} useHandCursor - Description. + * @return {Phaser.Sprite} Description. + */ start: function (priority, useHandCursor) { priority = priority || 0; - useHandCursor = useHandCursor || false; + if (typeof useHandCursor == 'undefined') { useHandCursor = false; } // Turning on if (this.enabled == false) @@ -84,11 +211,10 @@ Phaser.InputHandler.prototype = { this.game.input.interactiveItems.add(this); this.useHandCursor = useHandCursor; this.priorityID = priority; - this._pointerData = []; for (var i = 0; i < 10; i++) { - this._pointerData.push({ + this._pointerData[i] = { id: i, x: 0, y: 0, @@ -102,7 +228,7 @@ Phaser.InputHandler.prototype = { timeUp: 0, downDuration: 0, isDragged: false - }); + }; } this.snapOffset = new Phaser.Point; @@ -124,6 +250,10 @@ Phaser.InputHandler.prototype = { }, + /** + * Description. + * @method Phaser.InputHandler#reset + */ reset: function () { this.enabled = false; @@ -148,6 +278,10 @@ Phaser.InputHandler.prototype = { } }, + /** + * Description. + * @method Phaser.InputHandler#stop + */ stop: function () { // Turning off @@ -165,23 +299,29 @@ Phaser.InputHandler.prototype = { }, /** - * Clean up memory. - */ + * Clean up memory. + * @method Phaser.InputHandler#destroy + */ destroy: function () { if (this.enabled) { + this.enabled = false; + + this.game.input.interactiveItems.remove(this); + this.stop(); - // Null everything + this.sprite = null; - // etc } }, /** * The x coordinate of the Input pointer, relative to the top-left of the parent Sprite. * This value is only set when the pointer is over this Sprite. - * @type {number} + * @method Phaser.InputHandler#pointerX + * @param {Pointer} pointer + * @return {number} The x coordinate of the Input pointer. */ pointerX: function (pointer) { @@ -194,7 +334,9 @@ Phaser.InputHandler.prototype = { /** * The y coordinate of the Input pointer, relative to the top-left of the parent Sprite * This value is only set when the pointer is over this Sprite. - * @type {number} + * @method Phaser.InputHandler#pointerY + * @param {Pointer} pointer + * @return {number} The y coordinate of the Input pointer. */ pointerY: function (pointer) { @@ -205,10 +347,11 @@ Phaser.InputHandler.prototype = { }, /** - * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true - * @property isDown - * @type {bool} - **/ + * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true. + * @method Phaser.InputHandler#pointerDown + * @param {Pointer} pointer + * @return {boolean} + */ pointerDown: function (pointer) { pointer = pointer || 0; @@ -219,9 +362,10 @@ Phaser.InputHandler.prototype = { /** * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true - * @property isUp - * @type {bool} - **/ + * @method Phaser.InputHandler#pointerUp + * @param {Pointer} pointer + * @return {boolean} + */ pointerUp: function (pointer) { pointer = pointer || 0; @@ -232,9 +376,10 @@ Phaser.InputHandler.prototype = { /** * A timestamp representing when the Pointer first touched the touchscreen. - * @property timeDown - * @type {Number} - **/ + * @method Phaser.InputHandler#pointerTimeDown + * @param {Pointer} pointer + * @return {number} + */ pointerTimeDown: function (pointer) { pointer = pointer || 0; @@ -245,9 +390,10 @@ Phaser.InputHandler.prototype = { /** * A timestamp representing when the Pointer left the touchscreen. - * @property timeUp - * @type {Number} - **/ + * @method Phaser.InputHandler#pointerTimeUp + * @param {Pointer} pointer + * @return {number} + */ pointerTimeUp: function (pointer) { pointer = pointer || 0; @@ -257,10 +403,11 @@ Phaser.InputHandler.prototype = { }, /** - * Is the Pointer over this Sprite - * @property isOver - * @type {bool} - **/ + * Is the Pointer over this Sprite? + * @method Phaser.InputHandler#pointerOver + * @param {Pointer} pointer + * @return {bool + */ pointerOver: function (pointer) { pointer = pointer || 0; @@ -270,10 +417,11 @@ Phaser.InputHandler.prototype = { }, /** - * Is the Pointer outside of this Sprite - * @property isOut - * @type {bool} - **/ + * Is the Pointer outside of this Sprite? + * @method Phaser.InputHandler#pointerOut + * @param {Pointer} pointer + * @return {boolean} + */ pointerOut: function (pointer) { pointer = pointer || 0; @@ -284,9 +432,10 @@ Phaser.InputHandler.prototype = { /** * A timestamp representing when the Pointer first touched the touchscreen. - * @property timeDown - * @type {Number} - **/ + * @method Phaser.InputHandler#pointerTimeOver + * @param {Pointer} pointer + * @return {number} + */ pointerTimeOver: function (pointer) { pointer = pointer || 0; @@ -297,9 +446,10 @@ Phaser.InputHandler.prototype = { /** * A timestamp representing when the Pointer left the touchscreen. - * @property timeUp - * @type {Number} - **/ + * @method Phaser.InputHandler#pointerTimeOut + * @param {Pointer} pointer + * @return {number} + */ pointerTimeOut: function (pointer) { pointer = pointer || 0; @@ -310,7 +460,9 @@ Phaser.InputHandler.prototype = { /** * Is this sprite being dragged by the mouse or not? - * @default false + * @method Phaser.InputHandler#pointerTimeOut + * @param {Pointer} pointer + * @return {number} */ pointerDragged: function (pointer) { @@ -322,6 +474,9 @@ Phaser.InputHandler.prototype = { /** * Checks if the given pointer is over this Sprite. + * @method Phaser.InputHandler#checkPointerOver + * @param {Pointer} pointer + * @return {boolean} */ checkPointerOver: function (pointer) { @@ -329,46 +484,42 @@ Phaser.InputHandler.prototype = { { this.sprite.getLocalUnmodifiedPosition(this._tempPoint, pointer.x, pointer.y); - // Check against bounds first (move these to private vars) - var x1 = -(this.sprite.texture.frame.width) * this.sprite.anchor.x; - var y1; - - if (this._tempPoint.x > x1 && this._tempPoint.x < x1 + this.sprite.texture.frame.width) + if (this._tempPoint.x >= 0 && this._tempPoint.x <= this.sprite.currentFrame.width && this._tempPoint.y >= 0 && this._tempPoint.y <= this.sprite.currentFrame.height) { - y1 = -(this.sprite.texture.frame.height) * this.sprite.anchor.y; - - if (this._tempPoint.y > y1 && this._tempPoint.y < y1 + this.sprite.texture.frame.height) + if (this.pixelPerfect) { - if (this.pixelPerfect) - { - return this.checkPixel(this._tempPoint.x, this._tempPoint.y); - } - else - { - return true; - } + return this.checkPixel(this._tempPoint.x, this._tempPoint.y); + } + else + { + return true; } } } - else - { - return false; - } + + return false; }, + /** + * Description. + * @method Phaser.InputHandler#checkPixel + * @param {Description} x - Description. + * @param {Description} y - Description. + * @return {boolean} + */ checkPixel: function (x, y) { - x += (this.sprite.texture.frame.width * this.sprite.anchor.x); - y += (this.sprite.texture.frame.height * this.sprite.anchor.y); - // Grab a pixel from our image into the hitCanvas and then test it - if (this.sprite.texture.baseTexture.source) { this.game.input.hitContext.clearRect(0, 0, 1, 1); // This will fail if the image is part of a texture atlas - need to modify the x/y values here + + x += this.sprite.texture.frame.x; + y += this.sprite.texture.frame.y; + this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source, x, y, 1, 1, 0, 0, 1, 1); var rgb = this.game.input.hitContext.getImageData(0, 0, 1, 1); @@ -384,11 +535,13 @@ Phaser.InputHandler.prototype = { }, /** - * Update + * Update. + * @method Phaser.InputHandler#update + * @param {Pointer} pointer */ update: function (pointer) { - if (this.enabled == false || this.sprite.visible == false) + if (this.enabled == false || this.sprite.visible == false || (this.sprite.group && this.sprite.group.visible == false)) { this._pointerOutHandler(pointer); return false; @@ -414,6 +567,12 @@ Phaser.InputHandler.prototype = { } }, + /** + * Description. + * @method Phaser.InputHandler#_pointerOverHandler + * @private + * @param {Pointer} pointer + */ _pointerOverHandler: function (pointer) { if (this._pointerData[pointer.id].isOver == false) @@ -433,6 +592,12 @@ Phaser.InputHandler.prototype = { } }, + /** + * Description. + * @method Phaser.InputHandler#_pointerOutHandler + * @private + * @param {Pointer} pointer + */ _pointerOutHandler: function (pointer) { this._pointerData[pointer.id].isOver = false; @@ -444,10 +609,19 @@ Phaser.InputHandler.prototype = { this.game.stage.canvas.style.cursor = "default"; } - this.sprite.events.onInputOut.dispatch(this.sprite, pointer); + if (this.sprite && this.sprite.events) + { + this.sprite.events.onInputOut.dispatch(this.sprite, pointer); + } }, + /** + * Description. + * @method Phaser.InputHandler#_touchedHandler + * @private + * @param {Pointer} pointer + */ _touchedHandler: function (pointer) { if (this._pointerData[pointer.id].isDown == false && this._pointerData[pointer.id].isOver == true) @@ -474,6 +648,12 @@ Phaser.InputHandler.prototype = { }, + /** + * Description. + * @method Phaser.InputHandler#_releasedHandler + * @private + * @param {Pointer} pointer + */ _releasedHandler: function (pointer) { // If was previously touched by this Pointer, check if still is AND still over this item @@ -510,6 +690,9 @@ Phaser.InputHandler.prototype = { /** * Updates the Pointer drag on this Sprite. + * @method Phaser.InputHandler#updateDrag + * @param {Pointer} pointer + * @return {boolean} */ updateDrag: function (pointer) { @@ -541,8 +724,8 @@ Phaser.InputHandler.prototype = { if (this.snapOnDrag) { - this.sprite.x = Math.floor(this.sprite.x / this.snapX) * this.snapX; - this.sprite.y = Math.floor(this.sprite.y / this.snapY) * this.snapY; + this.sprite.x = Math.round(this.sprite.x / this.snapX) * this.snapX; + this.sprite.y = Math.round(this.sprite.y / this.snapY) * this.snapY; } return true; @@ -551,8 +734,10 @@ Phaser.InputHandler.prototype = { /** * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second) - * @param delay The time below which the pointer is considered as just over. - * @returns {bool} + * @method Phaser.InputHandler#justOver + * @param {Pointer} pointer + * @param {number} delay - The time below which the pointer is considered as just over. + * @return {boolean} */ justOver: function (pointer, delay) { @@ -565,8 +750,10 @@ Phaser.InputHandler.prototype = { /** * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second) - * @param delay The time below which the pointer is considered as just out. - * @returns {bool} + * @method Phaser.InputHandler#justOut + * @param {Pointer} pointer + * @param {number} delay - The time below which the pointer is considered as just out. + * @return {boolean} */ justOut: function (pointer, delay) { @@ -579,8 +766,10 @@ Phaser.InputHandler.prototype = { /** * Returns true if the pointer has entered the Sprite within the specified delay time (defaults to 500ms, half a second) - * @param delay The time below which the pointer is considered as just over. - * @returns {bool} + * @method Phaser.InputHandler#justPressed + * @param {Pointer} pointer + * @param {number} delay - The time below which the pointer is considered as just over. + * @return {boolean} */ justPressed: function (pointer, delay) { @@ -593,8 +782,10 @@ Phaser.InputHandler.prototype = { /** * Returns true if the pointer has left the Sprite within the specified delay time (defaults to 500ms, half a second) - * @param delay The time below which the pointer is considered as just out. - * @returns {bool} + * @method Phaser.InputHandler#justReleased + * @param {Pointer} pointer + * @param {number} delay - The time below which the pointer is considered as just out. + * @return {boolean} */ justReleased: function (pointer, delay) { @@ -607,7 +798,9 @@ Phaser.InputHandler.prototype = { /** * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds. - * @returns {number} The number of milliseconds the pointer has been over the Sprite, or -1 if not over. + * @method Phaser.InputHandler#overDuration + * @param {Pointer} pointer + * @return {number} The number of milliseconds the pointer has been over the Sprite, or -1 if not over. */ overDuration: function (pointer) { @@ -624,7 +817,9 @@ Phaser.InputHandler.prototype = { /** * If the pointer is currently over this Sprite this returns how long it has been there for in milliseconds. - * @returns {number} The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over. + * @method Phaser.InputHandler#downDuration + * @param {Pointer} pointer + * @return {number} The number of milliseconds the pointer has been pressed down on the Sprite, or -1 if not over. */ downDuration: function (pointer) { @@ -641,7 +836,7 @@ Phaser.InputHandler.prototype = { /** * Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback - * + * @method Phaser.InputHandler#enableDrag * @param lockCenter If false the Sprite will drag from where you click it minus the dragOffset. If true it will center itself to the tip of the mouse pointer. * @param bringToTop If true the Sprite will be bought to the top of the rendering list in its current Group. * @param pixelPerfect If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box. @@ -682,6 +877,7 @@ Phaser.InputHandler.prototype = { /** * Stops this sprite from being able to be dragged. If it is currently the target of an active drag it will be stopped immediately. Also disables any set callbacks. + * @method Phaser.InputHandler#disableDrag */ disableDrag: function () { @@ -701,6 +897,7 @@ Phaser.InputHandler.prototype = { /** * Called by Pointer when drag starts on this Sprite. Should not usually be called directly. + * @method Phaser.InputHandler#startDrag */ startDrag: function (pointer) { @@ -731,6 +928,7 @@ Phaser.InputHandler.prototype = { /** * Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly. + * @method Phaser.InputHandler#stopDrag */ stopDrag: function (pointer) { @@ -740,8 +938,8 @@ Phaser.InputHandler.prototype = { if (this.snapOnRelease) { - this.sprite.x = Math.floor(this.sprite.x / this.snapX) * this.snapX; - this.sprite.y = Math.floor(this.sprite.y / this.snapY) * this.snapY; + this.sprite.x = Math.round(this.sprite.x / this.snapX) * this.snapX; + this.sprite.y = Math.round(this.sprite.y / this.snapY) * this.snapY; } this.sprite.events.onDragStop.dispatch(this.sprite, pointer); @@ -751,7 +949,7 @@ Phaser.InputHandler.prototype = { /** * Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move! - * + * @method Phaser.InputHandler#setDragLock * @param allowHorizontal To enable the sprite to be dragged horizontally set to true, otherwise false * @param allowVertical To enable the sprite to be dragged vertically set to true, otherwise false */ @@ -768,7 +966,7 @@ Phaser.InputHandler.prototype = { /** * Make this Sprite snap to the given grid either during drag or when it's released. * For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels. - * + * @method Phaser.InputHandler#enableSnap * @param snapX The width of the grid cell in pixels * @param snapY The height of the grid cell in pixels * @param onDrag If true the sprite will snap to the grid while being dragged @@ -788,6 +986,7 @@ Phaser.InputHandler.prototype = { /** * Stops the sprite from snapping to a grid during drag or release. + * @method Phaser.InputHandler#disableSnap */ disableSnap: function () { @@ -798,6 +997,7 @@ Phaser.InputHandler.prototype = { /** * Bounds Rect check for the sprite drag + * @method Phaser.InputHandler#checkBoundsRect */ checkBoundsRect: function () { @@ -822,7 +1022,8 @@ Phaser.InputHandler.prototype = { }, /** - * Parent Sprite Bounds check for the sprite drag + * Parent Sprite Bounds check for the sprite drag. + * @method Phaser.InputHandler#checkBoundsSprite */ checkBoundsSprite: function () { diff --git a/src/input/Key.js b/src/input/Key.js new file mode 100644 index 00000000..b8ad2ab4 --- /dev/null +++ b/src/input/Key.js @@ -0,0 +1,171 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* @class Phaser.Key +* @classdesc If you need more fine-grained control over the handling of specific keys you can create and use Phaser.Key objects. +* @constructor +* @param {Phaser.Game} game - Current game instance. +* @param {number} keycode - The key code this Key is responsible for. +*/ +Phaser.Key = function (game, keycode) { + + /** + * @property {Phaser.Game} game - A reference to the currently running game. + */ + this.game = game; + + /** + * @property {boolean} isDown - The "down" state of the key. + * @default + */ + this.isDown = false; + + /** + * @property {boolean} isUp - The "up" state of the key. + * @default + */ + this.isUp = false; + + /** + * @property {boolean} altKey - The down state of the ALT key, if pressed at the same time as this key. + * @default + */ + this.altKey = false; + + /** + * @property {boolean} ctrlKey - The down state of the CTRL key, if pressed at the same time as this key. + * @default + */ + this.ctrlKey = false; + + /** + * @property {boolean} shiftKey - The down state of the SHIFT key, if pressed at the same time as this key. + * @default + */ + this.shiftKey = false; + + /** + * @property {number} timeDown - The timestamp when the key was last pressed down. + * @default + */ + this.timeDown = 0; + + /** + * 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. + * @property {number} duration - The number of milliseconds this key has been held down for. + * @default + */ + this.duration = 0; + + /** + * @property {number} timeUp - The timestamp when the key was last released. + * @default + */ + this.timeUp = 0; + + /** + * @property {number} repeats - If a key is held down this holds down the number of times the key has 'repeated'. + * @default + */ + this.repeats = 0; + + /** + * @property {number} keyCode - The keycode of this key. + */ + this.keyCode = keycode; + + /** + * @property {Phaser.Signal} onDown - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again). + */ + this.onDown = new Phaser.Signal(); + + /** + * @property {Phaser.Signal} onUp - This Signal is dispatched every time this Key is pressed down. It is only dispatched once (until the key is released again). + */ + this.onUp = new Phaser.Signal(); + +}; + +Phaser.Key.prototype = { + + /** + * Called automatically by Phaser.Keyboard. + * @method Phaser.Key#processKeyDown + * @param {KeyboardEvent} event. + * @protected + */ + processKeyDown: function (event) { + + this.altKey = event.altKey; + this.ctrlKey = event.ctrlKey; + this.shiftKey = event.shiftKey; + + if (this.isDown) + { + // Key was already held down, this must be a repeat rate based event + this.duration = event.timeStamp - this.timeDown; + this.repeats++; + } + else + { + this.isDown = true; + this.isUp = false; + this.timeDown = event.timeStamp; + this.duration = 0; + this.repeats = 0; + + this.onDown.dispatch(this); + } + + }, + + /** + * Called automatically by Phaser.Keyboard. + * @method Phaser.Key#processKeyUp + * @param {KeyboardEvent} event. + * @protected + */ + processKeyUp: function (event) { + + this.isDown = false; + this.isUp = true; + this.timeUp = event.timeStamp; + + this.onUp.dispatch(this); + + }, + + /** + * Returns the "just pressed" state of the Key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms) + * @method Phaser.Key#justPressed + * @param {number} [duration=250] - The duration below which the key is considered as being just pressed. + * @return {boolean} True if the key is just pressed otherwise false. + */ + justPressed: function (duration) { + + if (typeof duration === "undefined") { duration = 250; } + + return (this.isDown && this.duration < duration); + + }, + + /** + * Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms) + * @method Phaser.Key#justPressed + * @param {number} [duration=250] - The duration below which the key is considered as being just released. + * @return {boolean} True if the key is just released otherwise false. + */ + justReleased: function (duration) { + + if (typeof duration === "undefined") { duration = 250; } + + return (this.isDown == false && (this.game.time.now - this.timeUp < duration)); + + } + +}; diff --git a/src/input/Keyboard.js b/src/input/Keyboard.js index 1096a9a1..cc1ac1d5 100644 --- a/src/input/Keyboard.js +++ b/src/input/Keyboard.js @@ -1,34 +1,161 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser - Keyboard constructor. +* +* @class Phaser.Keyboard +* @classdesc A Keyboard object Description. +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +*/ Phaser.Keyboard = function (game) { + /** + * @property {Phaser.Game} game - Local reference to game. + */ this.game = game; + + /** + * @property {Description} _keys - Description. + * @private + */ this._keys = {}; + + /** + * @property {Description} _hotkeys - Description. + * @private + */ + this._hotkeys = {}; + + /** + * @property {Description} _capture - Description. + * @private + */ this._capture = {}; + + /** + * You can disable all Keyboard Input by setting disabled to true. While true all new input related events will be ignored. + * @property {boolean} disabled - The disabled state of the Keyboard. + * @default + */ + this.disabled = false; + + /** + * @property {function} _onKeyDown + * @private + * @default + */ + this._onKeyDown = null; + + /** + * @property {function} _onKeyUp + * @private + * @default + */ + this._onKeyUp = null; + + /** + * @property {Object} callbackContext - The context under which the callbacks are run. + */ + this.callbackContext = this; + + /** + * @property {function} onDownCallback - This callback is invoked every time a key is pressed down. + */ + this.onDownCallback = null; + + /** + * @property {function} onUpCallback - This callback is invoked every time a key is released. + */ + this.onUpCallback = null; }; Phaser.Keyboard.prototype = { - game: null, + /** + * Add callbacks to the Keyboard handler so that each time a key is pressed down or releases the callbacks are activated. + * @method Phaser.Keyboard#addCallbacks + * @param {Object} context - The context under which the callbacks are run. + * @param {function} onDown - This callback is invoked every time a key is pressed down. + * @param {function} [onUp=null] - This callback is invoked every time a key is released. + */ + addCallbacks: function (context, onDown, onUp) { + + this.callbackContext = context; + this.onDownCallback = onDown; + + if (typeof onUp !== 'undefined') + { + this.onUpCallback = onUp; + } + + }, /** - * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. - * @type {bool} + * If you need more fine-grained control over a Key you can create a new Phaser.Key object via this method. + * The Key object can then be polled, have events attached to it, etc. + * + * @method Phaser.Keyboard#addKey + * @param {number} keycode - The keycode of the key, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + * @return {Phaser.Key} The Key object which you can store locally and reference directly. */ - disabled: false, + addKey: function (keycode) { - _onKeyDown: null, - _onKeyUp: null, + this._hotkeys[keycode] = new Phaser.Key(this.game, keycode); + return this._hotkeys[keycode]; + }, + + /** + * Removes a Key object from the Keyboard manager. + * + * @method Phaser.Keyboard#removeKey + * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + */ + removeKey: function (keycode) { + + delete (this._hotkeys[keycode]); + + }, + + /** + * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right. + * + * @method Phaser.Keyboard#createCursorKeys + * @return {object} An object containing properties: up, down, left and right. Which can be polled like any other Phaser.Key object. + */ + createCursorKeys: function () { + + return { + up: this.addKey(Phaser.Keyboard.UP), + down: this.addKey(Phaser.Keyboard.DOWN), + left: this.addKey(Phaser.Keyboard.LEFT), + right: this.addKey(Phaser.Keyboard.RIGHT) + } + + }, + + /** + * Starts the Keyboard event listeners running (keydown and keyup). They are attached to the document.body. + * This is called automatically by Phaser.Input and should not normally be invoked directly. + * + * @method Phaser.Keyboard#start + */ start: function () { var _this = this; this._onKeyDown = function (event) { - return _this.onKeyDown(event); + return _this.processKeyDown(event); }; this._onKeyUp = function (event) { - return _this.onKeyUp(event); + return _this.processKeyUp(event); }; document.body.addEventListener('keydown', this._onKeyDown, false); @@ -36,6 +163,11 @@ Phaser.Keyboard.prototype = { }, + /** + * Stops the Keyboard event listeners from running (keydown and keyup). They are removed from the document.body. + * + * @method Phaser.Keyboard#stop + */ stop: function () { document.body.removeEventListener('keydown', this._onKeyDown); @@ -48,6 +180,7 @@ Phaser.Keyboard.prototype = { * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. * You can use addKeyCapture to consume the keyboard event for specific keys so it doesn't bubble up to the the browser. * Pass in either a single keycode or an array/hash of keycodes. + * @method Phaser.Keyboard#addKeyCapture * @param {Any} keycode */ addKeyCapture: function (keycode) { @@ -66,7 +199,9 @@ Phaser.Keyboard.prototype = { }, /** - * @param {Number} keycode + * Removes an existing key capture. + * @method Phaser.Keyboard#removeKeyCapture + * @param {number} keycode */ removeKeyCapture: function (keycode) { @@ -74,6 +209,10 @@ Phaser.Keyboard.prototype = { }, + /** + * Clear all set key captures. + * @method Phaser.Keyboard#clearCaptures + */ clearCaptures: function () { this._capture = {}; @@ -81,9 +220,12 @@ Phaser.Keyboard.prototype = { }, /** + * Process the keydown event. + * @method Phaser.Keyboard#processKeyDown * @param {KeyboardEvent} event + * @protected */ - onKeyDown: function (event) { + processKeyDown: function (event) { if (this.game.input.disabled || this.disabled) { @@ -95,26 +237,51 @@ Phaser.Keyboard.prototype = { event.preventDefault(); } - if (!this._keys[event.keyCode]) + if (this.onDownCallback) { - this._keys[event.keyCode] = { - isDown: true, - timeDown: this.game.time.now, - timeUp: 0 - }; + this.onDownCallback.call(this.callbackContext, event); + } + + if (this._keys[event.keyCode] && this._keys[event.keyCode].isDown) + { + // Key already down and still down, so update + this._keys[event.keyCode].duration = this.game.time.now - this._keys[event.keyCode].timeDown; } else { - this._keys[event.keyCode].isDown = true; - this._keys[event.keyCode].timeDown = this.game.time.now; + if (!this._keys[event.keyCode]) + { + // Not used this key before, so register it + this._keys[event.keyCode] = { + isDown: true, + timeDown: this.game.time.now, + timeUp: 0, + duration: 0 + }; + } + else + { + // Key used before but freshly down + this._keys[event.keyCode].isDown = true; + this._keys[event.keyCode].timeDown = this.game.time.now; + this._keys[event.keyCode].duration = 0; + } + } + + if (this._hotkeys[event.keyCode]) + { + this._hotkeys[event.keyCode].processKeyDown(event); } }, /** + * Process the keyup event. + * @method Phaser.Keyboard#processKeyUp * @param {KeyboardEvent} event + * @protected */ - onKeyUp: function (event) { + processKeyUp: function (event) { if (this.game.input.disabled || this.disabled) { @@ -126,22 +293,38 @@ Phaser.Keyboard.prototype = { event.preventDefault(); } - if (!this._keys[event.keyCode]) + if (this.onUpCallback) { - this._keys[event.keyCode] = { - isDown: false, - timeDown: 0, - timeUp: this.game.time.now - }; + this.onUpCallback.call(this.callbackContext, event); } - else + + if (this._hotkeys[event.keyCode]) + { + this._hotkeys[event.keyCode].processKeyUp(event); + } + + if (this._keys[event.keyCode]) { this._keys[event.keyCode].isDown = false; this._keys[event.keyCode].timeUp = this.game.time.now; } + else + { + // Not used this key before, so register it + this._keys[event.keyCode] = { + isDown: false, + timeDown: this.game.time.now, + timeUp: this.game.time.now, + duration: 0 + }; + } }, + /** + * Reset the "isDown" state of all keys. + * @method Phaser.Keyboard#reset + */ reset: function () { for (var key in this._keys) @@ -151,16 +334,18 @@ Phaser.Keyboard.prototype = { }, - /** - * @param {Number} keycode - * @param {Number} [duration] - * @return {bool} + /** + * Returns the "just pressed" state of the key. Just pressed is considered true if the key was pressed down within the duration given (default 250ms) + * @method Phaser.Keyboard#justPressed + * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + * @param {number} [duration=250] - The duration below which the key is considered as being just pressed. + * @return {boolean} True if the key is just pressed otherwise false. */ justPressed: function (keycode, duration) { if (typeof duration === "undefined") { duration = 250; } - if (this._keys[keycode] && this._keys[keycode].isDown === true && (this.game.time.now - this._keys[keycode].timeDown < duration)) + if (this._keys[keycode] && this._keys[keycode].isDown && this._keys[keycode].duration < duration) { return true; } @@ -169,10 +354,12 @@ Phaser.Keyboard.prototype = { }, - /** - * @param {Number} keycode - * @param {Number} [duration] - * @return {bool} + /** + * Returns the "just released" state of the Key. Just released is considered as being true if the key was released within the duration given (default 250ms) + * @method Phaser.Keyboard#justPressed + * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + * @param {number} [duration=250] - The duration below which the key is considered as being just released. + * @return {boolean} True if the key is just released otherwise false. */ justReleased: function (keycode, duration) { @@ -187,9 +374,11 @@ Phaser.Keyboard.prototype = { }, - /** - * @param {Number} keycode - * @return {bool} + /** + * Returns true of the key is currently pressed down. Note that it can only detect key presses on the web browser. + * @method Phaser.Keyboard#isDown + * @param {number} keycode - The keycode of the key to remove, i.e. Phaser.Keyboard.UP or Phaser.Keyboard.SPACE_BAR + * @return {boolean} True if the key is currently down. */ isDown: function (keycode) { @@ -204,8 +393,6 @@ Phaser.Keyboard.prototype = { }; -// Statics - Phaser.Keyboard.A = "A".charCodeAt(0); Phaser.Keyboard.B = "B".charCodeAt(0); Phaser.Keyboard.C = "C".charCodeAt(0); diff --git a/src/input/MSPointer.js b/src/input/MSPointer.js index d6ffa313..e24399f9 100644 --- a/src/input/MSPointer.js +++ b/src/input/MSPointer.js @@ -1,38 +1,86 @@ /** -* Phaser.MSPointer +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser - MSPointer constructor. * -* The MSPointer class handles touch interactions with the game and the resulting Pointer objects. +* @class Phaser.MSPointer +* @classdesc The MSPointer class handles touch interactions with the game and the resulting Pointer objects. * It will work only in Internet Explorer 10 and Windows Store or Windows Phone 8 apps using JavaScript. * http://msdn.microsoft.com/en-us/library/ie/hh673557(v=vs.85).aspx +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.MSPointer = function (game) { + /** + * @property {Phaser.Game} game - Local reference to game. + */ this.game = game; + + /** + * @property {Phaser.Game} callbackContext - Description. + */ this.callbackContext = this.game; + /** + * @property {Description} mouseDownCallback - Description. + * @default + */ this.mouseDownCallback = null; + + /** + * @property {Description} mouseMoveCallback - Description. + * @default + */ this.mouseMoveCallback = null; + + /** + * @property {Description} mouseUpCallback - Description. + * @default + */ this.mouseUpCallback = null; + /** + * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. + * @property {boolean} disabled + */ + this.disabled = false; + + /** + * Description. + * @property {Description} _onMSPointerDown + * @private + * @default + */ + this._onMSPointerDown = null; + + /** + * Description. + * @property {Description} _onMSPointerMove + * @private + * @default + */ + this._onMSPointerMove = null; + + /** + * Description. + * @property {Description} _onMSPointerUp + * @private + * @default + */ + this._onMSPointerUp = null; + }; Phaser.MSPointer.prototype = { - game: null, - - /** - * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. - * @type {bool} - */ - disabled: false, - - _onMSPointerDown: null, - _onMSPointerMove: null, - _onMSPointerUp: null, - /** - * Starts the event listeners running - * @method start + * Starts the event listeners running. + * @method Phaser.MSPointer#start */ start: function () { @@ -64,7 +112,8 @@ Phaser.MSPointer.prototype = { }, /** - * @method onPointerDown + * Description. + * @method Phaser.MSPointer#onPointerDown * @param {Any} event **/ onPointerDown: function (event) { @@ -82,7 +131,8 @@ Phaser.MSPointer.prototype = { }, /** - * @method onPointerMove + * Description. + * @method Phaser.MSPointer#onPointerMove * @param {Any} event **/ onPointerMove: function (event) { @@ -100,7 +150,8 @@ Phaser.MSPointer.prototype = { }, /** - * @method onPointerUp + * Description. + * @method Phaser.MSPointer#onPointerUp * @param {Any} event **/ onPointerUp: function (event) { @@ -118,8 +169,8 @@ Phaser.MSPointer.prototype = { }, /** - * Stop the event listeners - * @method stop + * Stop the event listeners. + * @method Phaser.MSPointer#stop */ stop: function () { diff --git a/src/input/Mouse.js b/src/input/Mouse.js index 2c762435..cf44e993 100644 --- a/src/input/Mouse.js +++ b/src/input/Mouse.js @@ -1,37 +1,86 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser - Mouse constructor. +* +* @class Phaser.Mouse +* @classdesc The Mouse class +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +*/ Phaser.Mouse = function (game) { + /** + * @property {Phaser.Game} game - Local reference to game. + */ this.game = game; + + /** + * @property {Object} callbackContext - Description. + */ this.callbackContext = this.game; + /** + * @property {Description} mouseDownCallback - Description. + * @default + */ this.mouseDownCallback = null; + + /** + * @property {Description} mouseMoveCallback - Description. + * @default + */ this.mouseMoveCallback = null; + + /** + * @property {Description} mouseUpCallback - Description. + * @default + */ this.mouseUpCallback = null; + /** + * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. + * @property {boolean} disabled + * @default + */ + this.disabled = false; + + /** + * If the mouse has been Pointer Locked successfully this will be set to true. + * @property {boolean} locked + * @default + */ + this.locked = false; + }; +/** +* @constant +* @type {number} +*/ Phaser.Mouse.LEFT_BUTTON = 0; + +/** +* @constant +* @type {number} +*/ Phaser.Mouse.MIDDLE_BUTTON = 1; + +/** +* @constant +* @type {number} +*/ Phaser.Mouse.RIGHT_BUTTON = 2; Phaser.Mouse.prototype = { - game: null, - - /** - * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. - * @type {bool} - */ - disabled: false, - - /** - * If the mouse has been Pointer Locked successfully this will be set to true. - * @type {bool} - */ - locked: false, - /** - * Starts the event listeners running - * @method start + * Starts the event listeners running. + * @method Phaser.Mouse#start */ start: function () { @@ -62,6 +111,8 @@ Phaser.Mouse.prototype = { }, /** + * Description. + * @method Phaser.Mouse#onMouseDown * @param {MouseEvent} event */ onMouseDown: function (event) { @@ -83,6 +134,8 @@ Phaser.Mouse.prototype = { }, /** + * Description + * @method Phaser.Mouse#onMouseMove * @param {MouseEvent} event */ onMouseMove: function (event) { @@ -104,6 +157,8 @@ Phaser.Mouse.prototype = { }, /** + * Description. + * @method Phaser.Mouse#onMouseUp * @param {MouseEvent} event */ onMouseUp: function (event) { @@ -124,6 +179,10 @@ Phaser.Mouse.prototype = { }, + /** + * Description. + * @method Phaser.Mouse#requestPointerLock + */ requestPointerLock: function () { if (this.game.device.pointerLock) @@ -147,6 +206,11 @@ Phaser.Mouse.prototype = { }, + /** + * Description. + * @method Phaser.Mouse#pointerLockChange + * @param {MouseEvent} event + */ pointerLockChange: function (event) { var element = this.game.stage.canvas; @@ -164,6 +228,10 @@ Phaser.Mouse.prototype = { }, + /** + * Description. + * @method Phaser.Mouse#releasePointerLock + */ releasePointerLock: function () { document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock; @@ -177,8 +245,8 @@ Phaser.Mouse.prototype = { }, /** - * Stop the event listeners - * @method stop + * Stop the event listeners. + * @method Phaser.Mouse#stop */ stop: function () { diff --git a/src/input/Pointer.js b/src/input/Pointer.js index 658385fc..2558d1a7 100644 --- a/src/input/Pointer.js +++ b/src/input/Pointer.js @@ -1,193 +1,231 @@ /** -* Phaser - Pointer +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser - Pointer constructor. * -* A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen. +* @class Phaser.Pointer +* @classdesc A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen. +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +* @param {Description} id - Description. */ Phaser.Pointer = function (game, id) { /** - * Local private variable to store the status of dispatching a hold event - * @property _holdSent - * @type {bool} + * @property {Phaser.Game} game - Local reference to game. + */ + this.game = game; + + /** + * @property {Description} id - Description. + */ + this.id = id; + + /** + * Local private variable to store the status of dispatching a hold event. + * @property {boolean} _holdSent * @private + * @default */ this._holdSent = false; /** - * Local private variable storing the short-term history of pointer movements - * @property _history - * @type {Array} + * Local private variable storing the short-term history of pointer movements. + * @property {array} _history * @private */ this._history = []; /** * Local private variable storing the time at which the next history drop should occur - * @property _lastDrop - * @type {Number} + * @property {number} _lastDrop * @private + * @default */ this._nextDrop = 0; - // Monitor events outside of a state reset loop + /** + * Monitor events outside of a state reset loop. + * @property {boolean} _stateReset + * @private + * @default + */ this._stateReset = false; /** * A Vector object containing the initial position when the Pointer was engaged with the screen. - * @property positionDown - * @type {Vec2} + * @property {Vec2} positionDown + * @default **/ this.positionDown = null; /** * A Vector object containing the current position of the Pointer on the screen. - * @property position - * @type {Vec2} + * @property {Vec2} position + * @default **/ this.position = null; /** * A Circle object centered on the x/y screen coordinates of the Pointer. - * Default size of 44px (Apple's recommended "finger tip" size) - * @property circle - * @type {Circle} + * Default size of 44px (Apple's recommended "finger tip" size). + * @property {Circle} circle + * @default **/ this.circle = null; /** - * - * @property withinGame - * @type {bool} + * Description. + * @property {boolean} withinGame */ this.withinGame = false; /** - * The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset - * @property clientX - * @type {Number} + * The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset. + * @property {number} clientX + * @default */ this.clientX = -1; /** - * The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset - * @property clientY - * @type {Number} + * The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset. + * @property {number} clientY + * @default */ this.clientY = -1; /** - * The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset - * @property pageX - * @type {Number} + * The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset. + * @property {number} pageX + * @default */ this.pageX = -1; /** - * The vertical coordinate of point relative to the viewport in pixels, including any scroll offset - * @property pageY - * @type {Number} + * The vertical coordinate of point relative to the viewport in pixels, including any scroll offset. + * @property {number} pageY + * @default */ this.pageY = -1; /** - * The horizontal coordinate of point relative to the screen in pixels - * @property screenX - * @type {Number} + * The horizontal coordinate of point relative to the screen in pixels. + * @property {number} screenX + * @default */ this.screenX = -1; /** - * The vertical coordinate of point relative to the screen in pixels - * @property screenY - * @type {Number} + * The vertical coordinate of point relative to the screen in pixels. + * @property {number} screenY + * @default */ this.screenY = -1; /** * The horizontal coordinate of point relative to the game element. This value is automatically scaled based on game size. - * @property x - * @type {Number} + * @property {number} x + * @default */ this.x = -1; /** * The vertical coordinate of point relative to the game element. This value is automatically scaled based on game size. - * @property y - * @type {Number} + * @property {number} y + * @default */ this.y = -1; /** - * If the Pointer is a mouse this is true, otherwise false - * @property isMouse - * @type {bool} - **/ + * If the Pointer is a mouse this is true, otherwise false. + * @property {boolean} isMouse + * @type {boolean} + */ this.isMouse = false; /** - * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true - * @property isDown - * @type {bool} - **/ + * If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true. + * @property {boolean} isDown + * @default + */ this.isDown = false; /** - * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true - * @property isUp - * @type {bool} - **/ + * If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true. + * @property {boolean} isUp + * @default + */ this.isUp = true; /** * A timestamp representing when the Pointer first touched the touchscreen. - * @property timeDown - * @type {Number} - **/ + * @property {number} timeDown + * @default + */ this.timeDown = 0; /** * A timestamp representing when the Pointer left the touchscreen. - * @property timeUp - * @type {Number} - **/ + * @property {number} timeUp + * @default + */ this.timeUp = 0; /** - * A timestamp representing when the Pointer was last tapped or clicked - * @property previousTapTime - * @type {Number} - **/ + * A timestamp representing when the Pointer was last tapped or clicked. + * @property {number} previousTapTime + * @default + */ this.previousTapTime = 0; /** - * The total number of times this Pointer has been touched to the touchscreen - * @property totalTouches - * @type {Number} - **/ + * The total number of times this Pointer has been touched to the touchscreen. + * @property {number} totalTouches + * @default + */ this.totalTouches = 0; /** - * The number of miliseconds since the last click - * @property msSinceLastClick - * @type {Number} - **/ + * The number of miliseconds since the last click. + * @property {number} msSinceLastClick + * @default + */ this.msSinceLastClick = Number.MAX_VALUE; /** * The Game Object this Pointer is currently over / touching / dragging. - * @property targetObject - * @type {Any} - **/ + * @property {Any} targetObject + * @default + */ this.targetObject = null; - this.game = game; - this.id = id; - + /** + * Description. + * @property {boolean} isDown - Description. + * @default + */ this.active = false; + /** + * Description + * @property {Phaser.Point} position + */ this.position = new Phaser.Point(); + + /** + * Description + * @property {Phaser.Point} positionDown + */ this.positionDown = new Phaser.Point(); + /** + * Description + * @property {Phaser.Circle} circle + */ this.circle = new Phaser.Circle(0, 0, 44); if (id == 0) @@ -200,8 +238,8 @@ Phaser.Pointer = function (game, id) { Phaser.Pointer.prototype = { /** - * Called when the Pointer is pressed onto the touchscreen - * @method start + * Called when the Pointer is pressed onto the touchscreen. + * @method Phaser.Pointer#start * @param {Any} event */ start: function (event) { @@ -209,7 +247,7 @@ Phaser.Pointer.prototype = { this.identifier = event.identifier; this.target = event.target; - if (event.button) + if (typeof event.button !== 'undefined') { this.button = event.button; } @@ -243,7 +281,7 @@ Phaser.Pointer.prototype = { this.game.input.x = this.x * this.game.input.scale.x; this.game.input.y = this.y * this.game.input.scale.y; this.game.input.position.setTo(this.x, this.y); - this.game.input.onDown.dispatch(this); + this.game.input.onDown.dispatch(this, event); this.game.input.resetSpeed(this.x, this.y); } @@ -264,6 +302,10 @@ Phaser.Pointer.prototype = { }, + /** + * Description. + * @method Phaser.Pointer#update + */ update: function () { if (this.active) @@ -299,7 +341,7 @@ Phaser.Pointer.prototype = { /** * Called when the Pointer is moved - * @method move + * @method Phaser.Pointer#move * @param {Any} event */ move: function (event) { @@ -309,7 +351,7 @@ Phaser.Pointer.prototype = { return; } - if (event.button) + if (typeof event.button !== 'undefined') { this.button = event.button; } @@ -388,8 +430,6 @@ Phaser.Pointer.prototype = { if (this._highestRenderObject == null) { - // console.log("HRO null"); - // The pointer isn't currently over anything, check if we've got a lingering previous target if (this.targetObject) { @@ -438,8 +478,8 @@ Phaser.Pointer.prototype = { }, /** - * Called when the Pointer leaves the target area - * @method leave + * Called when the Pointer leaves the target area. + * @method Phaser.Pointer#leave * @param {Any} event */ leave: function (event) { @@ -450,8 +490,8 @@ Phaser.Pointer.prototype = { }, /** - * Called when the Pointer leaves the touchscreen - * @method stop + * Called when the Pointer leaves the touchscreen. + * @method Phaser.Pointer#stop * @param {Any} event */ stop: function (event) { @@ -466,7 +506,7 @@ Phaser.Pointer.prototype = { if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0)) { - this.game.input.onUp.dispatch(this); + this.game.input.onUp.dispatch(this, event); // Was it a tap? if (this.duration >= 0 && this.duration <= this.game.input.tapRate) @@ -529,10 +569,10 @@ Phaser.Pointer.prototype = { }, /** - * The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate - * @method justPressed - * @param {Number} [duration]. - * @return {bool} + * The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate. + * @method Phaser.Pointer#justPressed + * @param {number} [duration] + * @return {boolean} */ justPressed: function (duration) { @@ -543,10 +583,10 @@ Phaser.Pointer.prototype = { }, /** - * The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate - * @method justReleased - * @param {Number} [duration]. - * @return {bool} + * The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate. + * @method Phaser.Pointer#justReleased + * @param {number} [duration] + * @return {boolean} */ justReleased: function (duration) { @@ -558,7 +598,7 @@ Phaser.Pointer.prototype = { /** * Resets the Pointer properties. Called by InputManager.reset when you perform a State change. - * @method reset + * @method Phaser.Pointer#reset */ reset: function () { @@ -586,8 +626,8 @@ Phaser.Pointer.prototype = { /** * Returns a string representation of this object. - * @method toString - * @return {String} a string representation of the instance. + * @method Phaser.Pointer#toString + * @return {string} A string representation of the instance. **/ toString: function () { return "[{Pointer (id=" + this.id + " identifer=" + this.identifier + " active=" + this.active + " duration=" + this.duration + " withinGame=" + this.withinGame + " x=" + this.x + " y=" + this.y + " clientX=" + this.clientX + " clientY=" + this.clientY + " screenX=" + this.screenX + " screenY=" + this.screenY + " pageX=" + this.pageX + " pageY=" + this.pageY + ")}]"; @@ -595,13 +635,14 @@ Phaser.Pointer.prototype = { }; +/** +* How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1. +* @name Phaser.Pointer#duration +* @property {number} duration - How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1. +* @readonly +*/ Object.defineProperty(Phaser.Pointer.prototype, "duration", { - /** - * How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1. - * @property duration - * @type {Number} - **/ get: function () { if (this.isUp) @@ -615,12 +656,14 @@ Object.defineProperty(Phaser.Pointer.prototype, "duration", { }); +/** +* Gets the X value of this Pointer in world coordinates based on the world camera. +* @name Phaser.Pointer#worldX +* @property {number} duration - The X value of this Pointer in world coordinates based on the world camera. +* @readonly +*/ Object.defineProperty(Phaser.Pointer.prototype, "worldX", { - /** - * Gets the X value of this Pointer in world coordinates based on the given camera. - * @param {Camera} [camera] - */ get: function () { return this.game.world.camera.x + this.x; @@ -629,12 +672,14 @@ Object.defineProperty(Phaser.Pointer.prototype, "worldX", { }); +/** +* Gets the Y value of this Pointer in world coordinates based on the world camera. +* @name Phaser.Pointer#worldY +* @property {number} duration - The Y value of this Pointer in world coordinates based on the world camera. +* @readonly +*/ Object.defineProperty(Phaser.Pointer.prototype, "worldY", { - /** - * Gets the Y value of this Pointer in world coordinates based on the given camera. - * @param {Camera} [camera] - */ get: function () { return this.game.world.camera.y + this.y; diff --git a/src/input/Touch.js b/src/input/Touch.js index 155129ab..1cf58659 100644 --- a/src/input/Touch.js +++ b/src/input/Touch.js @@ -1,49 +1,93 @@ /** -* Phaser - Touch +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser.Touch handles touch events with your game. Note: Android 2.x only supports 1 touch event at once, no multi-touch. * -* The Touch class handles touch interactions with the game and the resulting Pointer objects. -* http://www.w3.org/TR/touch-events/ -* https://developer.mozilla.org/en-US/docs/DOM/TouchList -* http://www.html5rocks.com/en/mobile/touchandmouse/ -* Note: Android 2.x only supports 1 touch event at once, no multi-touch +* @class Phaser.Touch +* @classdesc The Touch class handles touch interactions with the game and the resulting Pointer objects. +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.Touch = function (game) { - this.game = game; + /** + * @property {Phaser.Game} game - Local reference to game. + */ + this.game = game; + + /** + * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. + * @method Phaser.Touch#disabled + * @return {boolean} + */ + this.disabled = false; + + /** + * @property {Phaser.Game} callbackContext - Description. + */ this.callbackContext = this.game; + /** + * @property {Phaser.Game} touchStartCallback - Description. + * @default + */ this.touchStartCallback = null; + + /** + * @property {Phaser.Game} touchMoveCallback - Description. + * @default + */ this.touchMoveCallback = null; + + /** + * @property {Phaser.Game} touchEndCallback - Description. + * @default + */ this.touchEndCallback = null; + + /** + * @property {Phaser.Game} touchEnterCallback - Description. + * @default + */ this.touchEnterCallback = null; + + /** + * @property {Phaser.Game} touchLeaveCallback - Description. + * @default + */ this.touchLeaveCallback = null; + + /** + * @property {Description} touchCancelCallback - Description. + * @default + */ this.touchCancelCallback = null; - + + /** + * @property {boolean} preventDefault - Description. + * @default + */ this.preventDefault = true; + this._onTouchStart = null; + this._onTouchMove = null; + this._onTouchEnd = null; + this._onTouchEnter = null; + this._onTouchLeave = null; + this._onTouchCancel = null; + this._onTouchMove = null; + }; Phaser.Touch.prototype = { - game: null, - /** - * You can disable all Input by setting disabled = true. While set all new input related events will be ignored. - * @type {bool} - */ - disabled: false, - - _onTouchStart: null, - _onTouchMove: null, - _onTouchEnd: null, - _onTouchEnter: null, - _onTouchLeave: null, - _onTouchCancel: null, - _onTouchMove: null, - - /** - * Starts the event listeners running - * @method start + * Starts the event listeners running. + * @method Phaser.Touch#start */ start: function () { @@ -86,10 +130,9 @@ Phaser.Touch.prototype = { }, /** - * Consumes all touchmove events on the document (only enable this if you know you need it!) - * @method consumeTouchMove - * @param {Any} event - **/ + * Consumes all touchmove events on the document (only enable this if you know you need it!). + * @method Phaser.Touch#consumeTouchMove + */ consumeDocumentTouches: function () { this._documentTouchMove = function (event) { @@ -100,11 +143,11 @@ Phaser.Touch.prototype = { }, - /** - * - * @method onTouchStart + /** + * Description. + * @method Phaser.Touch#onTouchStart * @param {Any} event - **/ + */ onTouchStart: function (event) { if (this.touchStartCallback) @@ -132,12 +175,12 @@ Phaser.Touch.prototype = { }, - /** - * Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome) - * Occurs for example on iOS when you put down 4 fingers and the app selector UI appears - * @method onTouchCancel + /** + * Touch cancel - touches that were disrupted (perhaps by moving into a plugin or browser chrome). + * Occurs for example on iOS when you put down 4 fingers and the app selector UI appears. + * @method Phaser.Touch#onTouchCancel * @param {Any} event - **/ + */ onTouchCancel: function (event) { if (this.touchCancelCallback) @@ -164,12 +207,12 @@ Phaser.Touch.prototype = { }, - /** - * For touch enter and leave its a list of the touch points that have entered or left the target - * Doesn't appear to be supported by most browsers on a canvas element yet - * @method onTouchEnter + /** + * For touch enter and leave its a list of the touch points that have entered or left the target. + * Doesn't appear to be supported by most browsers on a canvas element yet. + * @method Phaser.Touch#onTouchEnter * @param {Any} event - **/ + */ onTouchEnter: function (event) { if (this.touchEnterCallback) @@ -194,12 +237,12 @@ Phaser.Touch.prototype = { }, - /** - * For touch enter and leave its a list of the touch points that have entered or left the target - * Doesn't appear to be supported by most browsers on a canvas element yet - * @method onTouchLeave + /** + * For touch enter and leave its a list of the touch points that have entered or left the target. + * Doesn't appear to be supported by most browsers on a canvas element yet. + * @method Phaser.Touch#onTouchLeave * @param {Any} event - **/ + */ onTouchLeave: function (event) { if (this.touchLeaveCallback) @@ -219,11 +262,11 @@ Phaser.Touch.prototype = { }, - /** - * - * @method onTouchMove + /** + * Description. + * @method Phaser.Touch#onTouchMove * @param {Any} event - **/ + */ onTouchMove: function (event) { if (this.touchMoveCallback) @@ -243,11 +286,11 @@ Phaser.Touch.prototype = { }, - /** - * - * @method onTouchEnd + /** + * Description. + * @method Phaser.Touch#onTouchEnd * @param {Any} event - **/ + */ onTouchEnd: function (event) { if (this.touchEndCallback) @@ -270,9 +313,9 @@ Phaser.Touch.prototype = { }, - /** - * Stop the event listeners - * @method stop + /** + * Stop the event listeners. + * @method Phaser.Touch#stop */ stop: function () { diff --git a/src/loader/Cache.js b/src/loader/Cache.js index bba57f00..90cb2af2 100644 --- a/src/loader/Cache.js +++ b/src/loader/Cache.js @@ -1,60 +1,72 @@ /** -* Cache +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser.Cache constructor. * -* A game only has one instance of a Cache and it is used to store all externally loaded assets such +* @class Phaser.Cache +* @classdesc A game only has one instance of a Cache and it is used to store all externally loaded assets such * as images, sounds and data files as a result of Loader calls. Cache items use string based keys for look-up. -* -* @package Phaser.Cache -* @author Richard Davey -* @copyright 2013 Photon Storm Ltd. -* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.Cache = function (game) { /** - * Local reference to Game. - */ + * @property {Phaser.Game} game - Local reference to game. + */ this.game = game; - /** - * Canvas key-value container. - * @type {object} - * @private - */ + /** + * @property {object} game - Canvas key-value container. + * @private + */ this._canvases = {}; /** - * Image key-value container. - * @type {object} - */ + * @property {object} _images - Image key-value container. + * @private + */ this._images = {}; /** - * RenderTexture key-value container. - * @type {object} - */ + * @property {object} _textures - RenderTexture key-value container. + * @private + */ this._textures = {}; /** - * Sound key-value container. - * @type {object} - */ + * @property {object} _sounds - Sound key-value container. + * @private + */ this._sounds = {}; /** - * Text key-value container. - * @type {object} - */ + * @property {object} _text - Text key-value container. + * @private + */ this._text = {}; /** - * Tilemap key-value container. - * @type {object} - */ + * @property {object} _tilemaps - Tilemap key-value container. + * @private + */ this._tilemaps = {}; + /** + * @property {object} _tilesets - Tileset key-value container. + * @private + */ + this._tilesets = {}; + this.addDefaultImage(); + /** + * @property {Phaser.Signal} onSoundUnlock - Description. + */ this.onSoundUnlock = new Phaser.Signal; }; @@ -62,11 +74,12 @@ Phaser.Cache = function (game) { Phaser.Cache.prototype = { /** - * Add a new canvas. - * @param key {string} Asset key for this canvas. - * @param canvas {HTMLCanvasElement} Canvas DOM element. - * @param context {CanvasRenderingContext2D} Render context of this canvas. - */ + * Add a new canvas object in to the cache. + * @method Phaser.Cache#addCanvas + * @param {string} key - Asset key for this canvas. + * @param {HTMLCanvasElement} canvas - Canvas DOM element. + * @param {CanvasRenderingContext2D} context - Render context of this canvas. + */ addCanvas: function (key, canvas, context) { this._canvases[key] = { canvas: canvas, context: context }; @@ -74,27 +87,31 @@ Phaser.Cache.prototype = { }, /** - * Add a new canvas. - * @param key {string} Asset key for this canvas. - * @param canvas {RenderTexture} A RenderTexture. - */ + * Add a new Phaser.RenderTexture in to the cache. + * + * @method Phaser.Cache#addRenderTexture + * @param {string} key - The unique key by which you will reference this object. + * @param {Phaser.Texture} textue - The texture to use as the base of the RenderTexture. + */ addRenderTexture: function (key, texture) { - var frame = new Phaser.Animation.Frame(0, 0, 0, texture.width, texture.height, '', ''); + var frame = new Phaser.Frame(0, 0, 0, texture.width, texture.height, '', ''); this._textures[key] = { texture: texture, frame: frame }; }, /** - * Add a new sprite sheet. - * @param key {string} Asset key for the sprite sheet. - * @param url {string} URL of this sprite sheet file. - * @param data {object} Extra sprite sheet data. - * @param frameWidth {number} Width of the sprite sheet. - * @param frameHeight {number} Height of the sprite sheet. - * @param frameMax {number} How many frames stored in the sprite sheet. - */ + * Add a new sprite sheet in to the cache. + * + * @method Phaser.Cache#addSpriteSheet + * @param {string} key - The unique key by which you will reference this object. + * @param {string} url - URL of this sprite sheet file. + * @param {object} data - Extra sprite sheet data. + * @param {number} frameWidth - Width of the sprite sheet. + * @param {number} frameHeight - Height of the sprite sheet. + * @param {number} frameMax - How many frames stored in the sprite sheet. + */ addSpriteSheet: function (key, url, data, frameWidth, frameHeight, frameMax) { this._images[key] = { url: url, data: data, spriteSheet: true, frameWidth: frameWidth, frameHeight: frameHeight }; @@ -102,33 +119,61 @@ Phaser.Cache.prototype = { PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data); PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]); - this._images[key].frameData = Phaser.Animation.Parser.spriteSheet(this.game, key, frameWidth, frameHeight, frameMax); + this._images[key].frameData = Phaser.AnimationParser.spriteSheet(this.game, key, frameWidth, frameHeight, frameMax); }, /** - * Add a new tilemap. - * @param key {string} Asset key for the texture atlas. - * @param url {string} URL of this texture atlas file. - * @param data {object} Extra texture atlas data. - * @param atlasData {object} Texture atlas frames data. - */ - addTilemap: function (key, url, data, mapData, format) { + * Add a new tile set in to the cache. + * + * @method Phaser.Cache#addTileset + * @param {string} key - The unique key by which you will reference this object. + * @param {string} url - URL of this tile set file. + * @param {object} data - Extra tile set data. + * @param {number} tileWidth - Width of the sprite sheet. + * @param {number} tileHeight - Height of the sprite sheet. + * @param {number} tileMax - How many tiles stored in the sprite sheet. + * @param {number} [tileMargin=0] - If the tiles have been drawn with a margin, specify the amount here. + * @param {number} [tileSpacing=0] - If the tiles have been drawn with spacing between them, specify the amount here. + */ + addTileset: function (key, url, data, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing) { - this._tilemaps[key] = { url: url, data: data, spriteSheet: true, mapData: mapData, format: format }; + this._tilesets[key] = { url: url, data: data, tileWidth: tileWidth, tileHeight: tileHeight, tileMargin: tileMargin, tileSpacing: tileSpacing }; PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data); PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]); + this._tilesets[key].tileData = Phaser.TilemapParser.tileset(this.game, key, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing); + }, /** - * Add a new texture atlas. - * @param key {string} Asset key for the texture atlas. - * @param url {string} URL of this texture atlas file. - * @param data {object} Extra texture atlas data. - * @param atlasData {object} Texture atlas frames data. - */ + * Add a new tilemap. + * + * @method Phaser.Cache#addTilemap + * @param {string} key - The unique key by which you will reference this object. + * @param {string} url - URL of the tilemap image. + * @param {object} mapData - The tilemap data object. + * @param {number} format - The format of the tilemap data. + */ + addTilemap: function (key, url, mapData, format) { + + this._tilemaps[key] = { url: url, data: mapData, format: format }; + + this._tilemaps[key].layers = Phaser.TilemapParser.parse(this.game, mapData, format); + + }, + + /** + * Add a new texture atlas. + * + * @method Phaser.Cache#addTextureAtlas + * @param {string} key - The unique key by which you will reference this object. + * @param {string} url - URL of this texture atlas file. + * @param {object} data - Extra texture atlas data. + * @param {object} atlasData - Texture atlas frames data. + * @param {number} format - The format of the texture atlas. + */ addTextureAtlas: function (key, url, data, atlasData, format) { this._images[key] = { url: url, data: data, spriteSheet: true }; @@ -138,26 +183,28 @@ Phaser.Cache.prototype = { if (format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY) { - this._images[key].frameData = Phaser.Animation.Parser.JSONData(this.game, atlasData, key); + this._images[key].frameData = Phaser.AnimationParser.JSONData(this.game, atlasData, key); } else if (format == Phaser.Loader.TEXTURE_ATLAS_JSON_HASH) { - this._images[key].frameData = Phaser.Animation.Parser.JSONDataHash(this.game, atlasData, key); + this._images[key].frameData = Phaser.AnimationParser.JSONDataHash(this.game, atlasData, key); } else if (format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING) { - this._images[key].frameData = Phaser.Animation.Parser.XMLData(this.game, atlasData, key); + this._images[key].frameData = Phaser.AnimationParser.XMLData(this.game, atlasData, key); } }, /** - * Add a new Bitmap Font. - * @param key {string} Asset key for the font texture. - * @param url {string} URL of this font xml file. - * @param data {object} Extra font data. - * @param xmlData {object} Texture atlas frames data. - */ + * Add a new Bitmap Font. + * + * @method Phaser.Cache#addBitmapFont + * @param {string} key - The unique key by which you will reference this object. + * @param {string} url - URL of this font xml file. + * @param {object} data - Extra font data. + * @param xmlData {object} Texture atlas frames data. + */ addBitmapFont: function (key, url, data, xmlData) { this._images[key] = { url: url, data: data, spriteSheet: true }; @@ -165,40 +212,59 @@ Phaser.Cache.prototype = { PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data); PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]); - Phaser.Loader.Parser.bitmapFont(this.game, xmlData, key); - // this._images[key].frameData = Phaser.Animation.Parser.XMLData(this.game, xmlData, key); + Phaser.LoaderParser.bitmapFont(this.game, xmlData, key); + // this._images[key].frameData = Phaser.AnimationParser.XMLData(this.game, xmlData, key); }, /** - * Adds a default image to be used when a key is wrong / missing. - * Is mapped to the key __default - */ + * Adds a default image to be used when a key is wrong / missing. Is mapped to the key __default. + * + * @method Phaser.Cache#addDefaultImage + */ addDefaultImage: function () { - this._images['__default'] = { url: null, data: null, spriteSheet: false }; - this._images['__default'].frame = new Phaser.Animation.Frame(0, 0, 0, 32, 32, '', ''); + var img = new Image(); + img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg=="; - var base = new PIXI.BaseTexture(); - base.width = 32; - base.height = 32; - base.hasLoaded = true; // avoids a hanging event listener + this._images['__default'] = { url: null, data: img, spriteSheet: false }; + this._images['__default'].frame = new Phaser.Frame(0, 0, 0, 32, 32, '', ''); - PIXI.BaseTextureCache['__default'] = base; - PIXI.TextureCache['__default'] = new PIXI.Texture(base); + PIXI.BaseTextureCache['__default'] = new PIXI.BaseTexture(img); + PIXI.TextureCache['__default'] = new PIXI.Texture(PIXI.BaseTextureCache['__default']); }, /** - * Add a new image. - * @param key {string} Asset key for the image. - * @param url {string} URL of this image file. - * @param data {object} Extra image data. - */ + * Add a new text data. + * + * @method Phaser.Cache#addText + * @param {string} key - Asset key for the text data. + * @param {string} url - URL of this text data file. + * @param {object} data - Extra text data. + */ + addText: function (key, url, data) { + + this._text[key] = { + url: url, + data: data + }; + + }, + + /** + * Add a new image. + * + * @method Phaser.Cache#addImage + * @param {string} key - The unique key by which you will reference this object. + * @param {string} url - URL of this image file. + * @param {object} data - Extra image data. + */ addImage: function (key, url, data) { this._images[key] = { url: url, data: data, spriteSheet: false }; - this._images[key].frame = new Phaser.Animation.Frame(0, 0, 0, data.width, data.height, '', ''); + + this._images[key].frame = new Phaser.Frame(0, 0, 0, data.width, data.height, key, this.game.rnd.uuid()); PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data); PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]); @@ -206,11 +272,15 @@ Phaser.Cache.prototype = { }, /** - * Add a new sound. - * @param key {string} Asset key for the sound. - * @param url {string} URL of this sound file. - * @param data {object} Extra sound data. - */ + * Add a new sound. + * + * @method Phaser.Cache#addSound + * @param {string} key - Asset key for the sound. + * @param {string} url - URL of this sound file. + * @param {object} data - Extra sound data. + * @param {boolean} webAudio - True if the file is using web audio. + * @param {boolean} audioTag - True if the file is using legacy HTML audio. + */ addSound: function (key, url, data, webAudio, audioTag) { webAudio = webAudio || true; @@ -228,6 +298,11 @@ Phaser.Cache.prototype = { }, + /** + * Reload a sound. + * @method Phaser.Cache#reloadSound + * @param {string} key - Asset key for the sound. + */ reloadSound: function (key) { var _this = this; @@ -244,6 +319,11 @@ Phaser.Cache.prototype = { } }, + /** + * Description. + * @method Phaser.Cache#reloadSoundComplete + * @param {string} key - Asset key for the sound. + */ reloadSoundComplete: function (key) { if (this._sounds[key]) @@ -254,6 +334,11 @@ Phaser.Cache.prototype = { }, + /** + * Description. + * @method Phaser.Cache#updateSound + * @param {string} key - Asset key for the sound. + */ updateSound: function (key, property, value) { if (this._sounds[key]) @@ -265,8 +350,10 @@ Phaser.Cache.prototype = { /** * Add a new decoded sound. - * @param key {string} Asset key for the sound. - * @param data {object} Extra sound data. + * + * @method Phaser.Cache#decodedSound + * @param {string} key - Asset key for the sound. + * @param {object} data - Extra sound data. */ decodedSound: function (key, data) { @@ -277,23 +364,10 @@ Phaser.Cache.prototype = { }, /** - * Add a new text data. - * @param key {string} Asset key for the text data. - * @param url {string} URL of this text data file. - * @param data {object} Extra text data. - */ - addText: function (key, url, data) { - - this._text[key] = { - url: url, - data: data - }; - - }, - - /** - * Get canvas by key. - * @param key Asset key of the canvas you want. + * Get acanvas object from the cache by its key. + * + * @method Phaser.Cache#getCanvas + * @param {string} key - Asset key of the canvas you want. * @return {object} The canvas you want. */ getCanvas: function (key) { @@ -308,7 +382,9 @@ Phaser.Cache.prototype = { /** * Checks if an image key exists. - * @param key Asset key of the image you want. + * + * @method Phaser.Cache#checkImageKey + * @param {string} key - Asset key of the image you want. * @return {boolean} True if the key exists, otherwise false. */ checkImageKey: function (key) { @@ -324,7 +400,9 @@ Phaser.Cache.prototype = { /** * Get image data by key. - * @param key Asset key of the image you want. + * + * @method Phaser.Cache#getImage + * @param {string} key - Asset key of the image you want. * @return {object} The image data you want. */ getImage: function (key) { @@ -337,12 +415,50 @@ Phaser.Cache.prototype = { return null; }, + /** + * Get tile set image data by key. + * + * @method Phaser.Cache#getTileSetImage + * @param {string} key - Asset key of the image you want. + * @return {object} The image data you want. + */ + getTilesetImage: function (key) { + + if (this._tilesets[key]) + { + return this._tilesets[key].data; + } + + return null; + + }, + + /** + * Get tile set image data by key. + * + * @method Phaser.Cache#getTileset + * @param {string} key - Asset key of the image you want. + * @return {Phaser.Tileset} The tileset data. The tileset image is in the data property, the tile data in tileData. + */ + getTileset: function (key) { + + if (this._tilesets[key]) + { + return this._tilesets[key].tileData; + } + + return null; + + }, + /** * Get tilemap data by key. - * @param key Asset key of the tilemap you want. - * @return {object} The tilemap data. The tileset image is in the data property, the map data in mapData. + * + * @method Phaser.Cache#getTilemap + * @param {string} key - Asset key of the tilemap you want. + * @return {Object} The tilemap data. The tileset image is in the data property, the map data in mapData. */ - getTilemap: function (key) { + getTilemapData: function (key) { if (this._tilemaps[key]) { @@ -354,8 +470,10 @@ Phaser.Cache.prototype = { /** * Get frame data by key. - * @param key Asset key of the frame data you want. - * @return {object} The frame data you want. + * + * @method Phaser.Cache#getFrameData + * @param {string} key - Asset key of the frame data you want. + * @return {Phaser.FrameData} The frame data you want. */ getFrameData: function (key) { @@ -369,8 +487,10 @@ Phaser.Cache.prototype = { /** * Get a single frame out of a frameData set by key. - * @param key Asset key of the frame data you want. - * @return {object} The frame data you want. + * + * @method Phaser.Cache#getFrameByIndex + * @param {string} key - Asset key of the frame data you want. + * @return {Phaser.Frame} The frame data you want. */ getFrameByIndex: function (key, frame) { @@ -384,8 +504,10 @@ Phaser.Cache.prototype = { /** * Get a single frame out of a frameData set by key. - * @param key Asset key of the frame data you want. - * @return {object} The frame data you want. + * + * @method Phaser.Cache#getFrameByName + * @param {string} key - Asset key of the frame data you want. + * @return {Phaser.Frame} The frame data you want. */ getFrameByName: function (key, frame) { @@ -399,8 +521,10 @@ Phaser.Cache.prototype = { /** * Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image. - * @param key Asset key of the frame data you want. - * @return {object} The frame data you want. + * + * @method Phaser.Cache#getFrame + * @param {string} key - Asset key of the frame data you want. + * @return {Phaser.Frame} The frame data you want. */ getFrame: function (key) { @@ -414,8 +538,10 @@ Phaser.Cache.prototype = { /** * Get a single frame by key. You'd only do this to get the default Frame created for a non-atlas/spritesheet image. - * @param key Asset key of the frame data you want. - * @return {object} The frame data you want. + * + * @method Phaser.Cache#getTextureFrame + * @param {string} key - Asset key of the frame data you want. + * @return {Phaser.Frame} The frame data you want. */ getTextureFrame: function (key) { @@ -429,8 +555,10 @@ Phaser.Cache.prototype = { /** * Get a RenderTexture by key. - * @param key Asset key of the RenderTexture you want. - * @return {object} The RenderTexture you want. + * + * @method Phaser.Cache#getTexture + * @param {string} key - Asset key of the RenderTexture you want. + * @return {Phaser.RenderTexture} The RenderTexture you want. */ getTexture: function (key) { @@ -445,8 +573,10 @@ Phaser.Cache.prototype = { /** * Get sound by key. - * @param key Asset key of the sound you want. - * @return {object} The sound you want. + * + * @method Phaser.Cache#getSound + * @param {string} key - Asset key of the sound you want. + * @return {Phaser.Sound} The sound you want. */ getSound: function (key) { @@ -461,7 +591,9 @@ Phaser.Cache.prototype = { /** * Get sound data by key. - * @param key Asset key of the sound you want. + * + * @method Phaser.Cache#getSoundData + * @param {string} key - Asset key of the sound you want. * @return {object} The sound data you want. */ getSoundData: function (key) { @@ -476,9 +608,11 @@ Phaser.Cache.prototype = { }, /** - * Check whether an asset is decoded sound. - * @param key Asset key of the sound you want. - * @return {object} The sound data you want. + * Check if the given sound has finished decoding. + * + * @method Phaser.Cache#isSoundDecoded + * @param {string} key - Asset key of the sound you want. + * @return {boolean} The decoded state of the Sound object. */ isSoundDecoded: function (key) { @@ -490,9 +624,11 @@ Phaser.Cache.prototype = { }, /** - * Check whether an asset is decoded sound. - * @param key Asset key of the sound you want. - * @return {object} The sound data you want. + * Check if the given sound is ready for playback. A sound is considered ready when it has finished decoding and the device is no longer touch locked. + * + * @method Phaser.Cache#isSoundReady + * @param {string} key - Asset key of the sound you want. + * @return {boolean} True if the sound is decoded and the device is not touch locked. */ isSoundReady: function (key) { @@ -501,9 +637,11 @@ Phaser.Cache.prototype = { }, /** - * Check whether an asset is sprite sheet. - * @param key Asset key of the sprite sheet you want. - * @return {object} The sprite sheet data you want. + * Check whether an image asset is sprite sheet or not. + * + * @method Phaser.Cache#isSpriteSheet + * @param {string} key - Asset key of the sprite sheet you want. + * @return {boolean} True if the image is a sprite sheet. */ isSpriteSheet: function (key) { @@ -518,7 +656,9 @@ Phaser.Cache.prototype = { /** * Get text data by key. - * @param key Asset key of the text data you want. + * + * @method Phaser.Cache#getText + * @param {string} key - Asset key of the text data you want. * @return {object} The text data you want. */ getText: function (key) { @@ -532,6 +672,14 @@ Phaser.Cache.prototype = { }, + /** + * Get the cache keys from a given array of objects. + * Normally you don't call this directly but instead use getImageKeys, getSoundKeys, etc. + * + * @method Phaser.Cache#getKeys + * @param {Array} array - An array of items to return the keys for. + * @return {Array} The array of item keys. + */ getKeys: function (array) { var output = []; @@ -550,6 +698,8 @@ Phaser.Cache.prototype = { /** * Returns an array containing all of the keys of Images in the Cache. + * + * @method Phaser.Cache#getImageKeys * @return {Array} The string based keys in the Cache. */ getImageKeys: function () { @@ -558,6 +708,8 @@ Phaser.Cache.prototype = { /** * Returns an array containing all of the keys of Sounds in the Cache. + * + * @method Phaser.Cache#getSoundKeys * @return {Array} The string based keys in the Cache. */ getSoundKeys: function () { @@ -566,30 +718,58 @@ Phaser.Cache.prototype = { /** * Returns an array containing all of the keys of Text Files in the Cache. + * + * @method Phaser.Cache#getTextKeys * @return {Array} The string based keys in the Cache. */ getTextKeys: function () { return this.getKeys(this._text); }, + /** + * Removes a canvas from the cache. + * + * @method Phaser.Cache#removeCanvas + * @param {string} key - Key of the asset you want to remove. + */ removeCanvas: function (key) { delete this._canvases[key]; }, + /** + * Removes an image from the cache. + * + * @method Phaser.Cache#removeImage + * @param {string} key - Key of the asset you want to remove. + */ removeImage: function (key) { delete this._images[key]; }, + /** + * Removes a sound from the cache. + * + * @method Phaser.Cache#removeSound + * @param {string} key - Key of the asset you want to remove. + */ removeSound: function (key) { delete this._sounds[key]; }, + /** + * Removes a text from the cache. + * + * @method Phaser.Cache#removeText + * @param {string} key - Key of the asset you want to remove. + */ removeText: function (key) { delete this._text[key]; }, /** - * Clean up cache memory. + * Clears the cache. Removes every local cache object reference. + * + * @method Phaser.Cache#destroy */ destroy: function () { diff --git a/src/loader/Loader.js b/src/loader/Loader.js index da68a3bd..dabdcb50 100644 --- a/src/loader/Loader.js +++ b/src/loader/Loader.js @@ -1,71 +1,85 @@ /** -* Phaser.Loader -* +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser loader constructor. * The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. * It uses a combination of Image() loading and xhr and provides progress and completion callbacks. +* @class Phaser.Loader +* @classdesc The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files. +* It uses a combination of Image() loading and xhr and provides progress and completion callbacks. +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. */ Phaser.Loader = function (game) { /** - * Local reference to Game. + * @property {Phaser.Game} game - Local reference to game. */ this.game = game; /** - * Array stores assets keys. So you can get that asset by its unique key. - */ + * @property {array} _keys - Array stores assets keys. So you can get that asset by its unique key. + * @private + */ this._keys = []; /** - * Contains all the assets file infos. - */ + * @property {Description} _fileList - Contains all the assets file infos. + * @private + */ this._fileList = {}; /** - * Indicates assets loading progress. (from 0 to 100) - * @type {number} + * @property {number} _progressChunk - Indicates assets loading progress. (from 0 to 100) + * @private + * @default */ this._progressChunk = 0; /** - * An XMLHttpRequest object used for loading text and audio data - * @type {XMLHttpRequest} + * @property {XMLHttpRequest} - An XMLHttpRequest object used for loading text and audio data. + * @private */ this._xhr = new XMLHttpRequest(); - /** - * Length of assets queue. - * @type {number} + /** + * @property {number} - Length of assets queue. + * @default */ this.queueSize = 0; /** - * True if the Loader is in the process of loading the queue. - * @type {bool} + * @property {boolean} isLoading - True if the Loader is in the process of loading the queue. + * @default */ this.isLoading = false; /** - * True if all assets in the queue have finished loading. - * @type {bool} + * @property {boolean} hasLoaded - True if all assets in the queue have finished loading. + * @default */ this.hasLoaded = false; /** - * The Load progress percentage value (from 0 to 100) - * @type {number} + * @property {number} progress - The Load progress percentage value (from 0 to 100) + * @default */ this.progress = 0; /** * You can optionally link a sprite to the preloader. * If you do so the Sprite's width or height will be cropped based on the percentage loaded. + * @property {Description} preloadSprite + * @default */ this.preloadSprite = null; /** - * The crossOrigin value applied to loaded images - * @type {string} + * @property {string} crossOrigin - The crossOrigin value applied to loaded images */ this.crossOrigin = ''; @@ -73,29 +87,62 @@ Phaser.Loader = function (game) { * If you want to append a URL before the path of any asset you can set this here. * Useful if you need to allow an asset url to be configured outside of the game code. * MUST have / on the end of it! - * @type {string} + * @property {string} baseURL + * @default */ this.baseURL = ''; /** - * Event Signals - */ + * @property {Phaser.Signal} onFileComplete - Event signal. + */ this.onFileComplete = new Phaser.Signal; + + /** + * @property {Phaser.Signal} onFileError - Event signal. + */ this.onFileError = new Phaser.Signal; + + /** + * @property {Phaser.Signal} onLoadStart - Event signal. + */ this.onLoadStart = new Phaser.Signal; + + /** + * @property {Phaser.Signal} onLoadComplete - Event signal. + */ this.onLoadComplete = new Phaser.Signal; }; /** - * TextureAtlas data format constants - */ +* @constant +* @type {number} +*/ Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY = 0; + +/** +* @constant +* @type {number} +*/ Phaser.Loader.TEXTURE_ATLAS_JSON_HASH = 1; + +/** +* @constant +* @type {number} +*/ Phaser.Loader.TEXTURE_ATLAS_XML_STARLING = 2; Phaser.Loader.prototype = { + /** + * You can set a Sprite to be a "preload" sprite by passing it to this method. + * A "preload" sprite will have its width or height crop adjusted based on the percentage of the loader in real-time. + * This allows you to easily make loading bars for games. + * + * @method Phaser.Loader#setPreloadSprite + * @param {Phaser.Sprite} sprite - The sprite that will be cropped during the load. + * @param {number} [direction=0] - A value of zero means the sprite width will be cropped, a value of 1 means its height will be cropped. + */ setPreloadSprite: function (sprite, direction) { direction = direction || 0; @@ -105,22 +152,25 @@ Phaser.Loader.prototype = { if (direction == 0) { // Horizontal crop - this.preloadSprite.crop = new Phaser.Rectangle(0, 0, 0, sprite.height); + this.preloadSprite.crop = new Phaser.Rectangle(0, 0, 1, sprite.height); } else { // Vertical crop - this.preloadSprite.crop = new Phaser.Rectangle(0, 0, sprite.width, 0); + this.preloadSprite.crop = new Phaser.Rectangle(0, 0, sprite.width, 1); } sprite.crop = this.preloadSprite.crop; + sprite.cropEnabled = true; }, /** * Check whether asset exists with a specific key. - * @param key {string} Key of the asset you want to check. - * @return {bool} Return true if exists, otherwise return false. + * + * @method Phaser.Loader#checkKeyExists + * @param {string} key - Key of the asset you want to check. + * @return {boolean} Return true if exists, otherwise return false. */ checkKeyExists: function (key) { @@ -136,8 +186,10 @@ Phaser.Loader.prototype = { }, /** - * Reset loader, this will remove all loaded assets. - */ + * Reset loader, this will remove all loaded assets. + * + * @method Phaser.Loader#reset + */ reset: function () { this.preloadSprite = null; @@ -147,7 +199,14 @@ Phaser.Loader.prototype = { }, /** - * Internal function that adds a new entry to the file list. + * Internal function that adds a new entry to the file list. Do not call directly. + * + * @method Phaser.Loader#addToFileList + * @param {Description} type - Description. + * @param {string} key - Description. + * @param {string} url - URL of Description. + * @param {Description} properties - Description. + * @protected */ addToFileList: function (type, key, url, properties) { @@ -178,9 +237,11 @@ Phaser.Loader.prototype = { /** * Add an image to the Loader. - * @param key {string} Unique asset key of this image file. - * @param url {string} URL of image file. - * @param overwrite {boolean} If an entry with a matching key already exists this will over-write it + * + * @method Phaser.Loader#image + * @param {string} key - Unique asset key of this image file. + * @param {string} url - URL of image file. + * @param {boolean} overwrite - If an entry with a matching key already exists this will over-write it */ image: function (key, url, overwrite) { @@ -191,12 +252,17 @@ Phaser.Loader.prototype = { this.addToFileList('image', key, url); } + return this; + }, /** * Add a text file to the Loader. - * @param key {string} Unique asset key of the text file. - * @param url {string} URL of the text file. + * + * @method Phaser.Loader#text + * @param {string} key - Unique asset key of the text file. + * @param {string} url - URL of the text file. + * @param {boolean} overwrite - True if Description. */ text: function (key, url, overwrite) { @@ -207,15 +273,19 @@ Phaser.Loader.prototype = { this.addToFileList('text', key, url); } + return this; + }, /** - * Add a new sprite sheet loading request. - * @param key {string} Unique asset key of the sheet file. - * @param url {string} URL of sheet file. - * @param frameWidth {number} Width of each single frame. - * @param frameHeight {number} Height of each single frame. - * @param frameMax {number} How many frames in this sprite sheet. + * Add a new sprite sheet to the loader. + * + * @method Phaser.Loader#spritesheet + * @param {string} key - Unique asset key of the sheet file. + * @param {string} url - URL of the sheet file. + * @param {number} frameWidth - Width of each single frame. + * @param {number} frameHeight - Height of each single frame. + * @param {number} [frameMax=-1] - How many frames in this sprite sheet. If not specified it will divide the whole image into frames. */ spritesheet: function (key, url, frameWidth, frameHeight, frameMax) { @@ -226,13 +296,44 @@ Phaser.Loader.prototype = { this.addToFileList('spritesheet', key, url, { frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax }); } + return this; + }, /** - * Add a new audio file loading request. - * @param key {string} Unique asset key of the audio file. - * @param urls {Array} An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ] - * @param autoDecode {bool} When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process. + * Add a new tile set to the loader. These are used in the rendering of tile maps. + * + * @method Phaser.Loader#tileset + * @param {string} key - Unique asset key of the tileset file. + * @param {string} url - URL of the tileset. + * @param {number} tileWidth - Width of each single tile in pixels. + * @param {number} tileHeight - Height of each single tile in pixels. + * @param {number} [tileMax=-1] - How many tiles in this tileset. If not specified it will divide the whole image into tiles. + * @param {number} [tileMargin=0] - If the tiles have been drawn with a margin, specify the amount here. + * @param {number} [tileSpacing=0] - If the tiles have been drawn with spacing between them, specify the amount here. + */ + tileset: function (key, url, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing) { + + if (typeof tileMax === "undefined") { tileMax = -1; } + if (typeof tileMargin === "undefined") { tileMargin = 0; } + if (typeof tileSpacing === "undefined") { tileSpacing = 0; } + + if (this.checkKeyExists(key) === false) + { + this.addToFileList('tileset', key, url, { tileWidth: tileWidth, tileHeight: tileHeight, tileMax: tileMax, tileMargin: tileMargin, tileSpacing: tileSpacing }); + } + + return this; + + }, + + /** + * Add a new audio file to the loader. + * + * @method Phaser.Loader#audio + * @param {string} key - Unique asset key of the audio file. + * @param {Array} urls - An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ]. + * @param {boolean} autoDecode - When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process. */ audio: function (key, urls, autoDecode) { @@ -243,28 +344,39 @@ Phaser.Loader.prototype = { this.addToFileList('audio', key, urls, { buffer: null, autoDecode: autoDecode }); } + return this; + }, /** * Add a new tilemap loading request. - * @param key {string} Unique asset key of the tilemap data. - * @param tilesetURL {string} The url of the tile set image file. - * @param [mapDataURL] {string} The url of the map data file (csv/json) - * @param [mapData] {object} An optional JSON data object (can be given in place of a URL). - * @param [format] {string} The format of the map data. + * + * @method Phaser.Loader#tilemap + * @param {string} key - Unique asset key of the tilemap data. + * @param {string} tilesetURL - The url of the tile set image file. + * @param {string} [mapDataURL] - The url of the map data file (csv/json) + * @param {object} [mapData] - An optional JSON data object (can be given in place of a URL). + * @param {string} [format] - The format of the map data. */ - tilemap: function (key, tilesetURL, mapDataURL, mapData, format) { + tilemap: function (key, mapDataURL, mapData, format) { if (typeof mapDataURL === "undefined") { mapDataURL = null; } if (typeof mapData === "undefined") { mapData = null; } if (typeof format === "undefined") { format = Phaser.Tilemap.CSV; } + if (mapDataURL == null && mapData == null) + { + console.warn('Phaser.Loader.tilemap - Both mapDataURL and mapData are null. One must be set.'); + + return this; + } + if (this.checkKeyExists(key) === false) { // A URL to a json/csv file has been given if (mapDataURL) { - this.addToFileList('tilemap', key, tilesetURL, { mapDataURL: mapDataURL, format: format }); + this.addToFileList('tilemap', key, mapDataURL, { format: format }); } else { @@ -275,7 +387,7 @@ Phaser.Loader.prototype = { break; // An xml string or object has been given - case Phaser.Tilemap.JSON: + case Phaser.Tilemap.TILED_JSON: if (typeof mapData === 'string') { @@ -284,19 +396,23 @@ Phaser.Loader.prototype = { break; } - this.addToFileList('tilemap', key, tilesetURL, { mapDataURL: null, mapData: mapData, format: format }); + this.game.cache.addTilemap(key, null, mapData, format); } } + return this; + }, /** * Add a new bitmap font loading request. - * @param key {string} Unique asset key of the bitmap font. - * @param textureURL {string} The url of the font image file. - * @param [xmlURL] {string} The url of the font data file (xml/fnt) - * @param [xmlData] {object} An optional XML data object. + * + * @method Phaser.Loader#bitmapFont + * @param {string} key - Unique asset key of the bitmap font. + * @param {string} textureURL - The url of the font image file. + * @param {string} [xmlURL] - The url of the font data file (xml/fnt) + * @param {object} [xmlData] - An optional XML data object. */ bitmapFont: function (key, textureURL, xmlURL, xmlData) { @@ -347,33 +463,61 @@ Phaser.Loader.prototype = { } } - }, - - atlasJSONArray: function (key, textureURL, atlasURL, atlasData) { - - this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY); - - }, - - atlasJSONHash: function (key, textureURL, atlasURL, atlasData) { - - this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH); - - }, - - atlasXML: function (key, textureURL, atlasURL, atlasData) { - - this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); + return this; }, /** - * Add a new texture atlas loading request. - * @param key {string} Unique asset key of the texture atlas file. - * @param textureURL {string} The url of the texture atlas image file. - * @param [atlasURL] {string} The url of the texture atlas data file (json/xml) - * @param [atlasData] {object} A JSON or XML data object. - * @param [format] {number} A value describing the format of the data. + * Add a new texture atlas to the loader. This atlas uses the JSON Array data format. + * + * @method Phaser.Loader#atlasJSONArray + * @param {string} key - Unique asset key of the bitmap font. + * @param {Description} atlasURL - The url of the Description. + * @param {Description} atlasData - Description. + */ + atlasJSONArray: function (key, textureURL, atlasURL, atlasData) { + + return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY); + + }, + + /** + * Add a new texture atlas to the loader. This atlas uses the JSON Hash data format. + * + * @method Phaser.Loader#atlasJSONHash + * @param {string} key - Unique asset key of the bitmap font. + * @param {Description} atlasURL - The url of the Description. + * @param {Description} atlasData - Description. + */ + atlasJSONHash: function (key, textureURL, atlasURL, atlasData) { + + return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_JSON_HASH); + + }, + + /** + * Add a new texture atlas to the loader. This atlas uses the Starling XML data format. + * + * @method Phaser.Loader#atlasXML + * @param {string} key - Unique asset key of the bitmap font. + * @param {Description} atlasURL - The url of the Description. + * @param {Description} atlasData - Description. + */ + atlasXML: function (key, textureURL, atlasURL, atlasData) { + + return this.atlas(key, textureURL, atlasURL, atlasData, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); + + }, + + /** + * Add a new texture atlas to the loader. + * + * @method Phaser.Loader#atlas + * @param {string} key - Unique asset key of the texture atlas file. + * @param {string} textureURL - The url of the texture atlas image file. + * @param {string} [atlasURL] - The url of the texture atlas data file (json/xml). You don't need this if you are passing an atlasData object instead. + * @param {object} [atlasData] - A JSON or XML data object. You don't need this if the data is being loaded from a URL. + * @param {number} [format] - A value describing the format of the data, the default is Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY. */ atlas: function (key, textureURL, atlasURL, atlasData, format) { @@ -444,12 +588,16 @@ Phaser.Loader.prototype = { } + return this; + }, /** - * Remove loading request of a file. - * @param key {string} Key of the file you want to remove. - */ + * Remove loading request of a file. + * + * @method Phaser.Loader#removeFile + * @param key {string} Key of the file you want to remove. + */ removeFile: function (key) { delete this._fileList[key]; @@ -457,8 +605,10 @@ Phaser.Loader.prototype = { }, /** - * Remove all file loading requests. - */ + * Remove all file loading requests. + * + * @method Phaser.Loader#removeAll + */ removeAll: function () { this._fileList = {}; @@ -466,8 +616,10 @@ Phaser.Loader.prototype = { }, /** - * Load assets. - */ + * Start loading the assets. Normally you don't need to call this yourself as the StateManager will do so. + * + * @method Phaser.Loader#start + */ start: function () { if (this.isLoading) @@ -497,6 +649,8 @@ Phaser.Loader.prototype = { /** * Load files. Private method ONLY used by loader. + * + * @method Phaser.Loader#loadFile * @private */ loadFile: function () { @@ -511,7 +665,7 @@ Phaser.Loader.prototype = { case 'spritesheet': case 'textureatlas': case 'bitmapfont': - case 'tilemap': + case 'tileset': file.data = new Image(); file.data.name = file.key; file.data.onload = function () { @@ -574,6 +728,29 @@ Phaser.Loader.prototype = { break; + case 'tilemap': + this._xhr.open("GET", this.baseURL + file.url, true); + this._xhr.responseType = "text"; + + if (file.format == Phaser.Tilemap.TILED_JSON) + { + this._xhr.onload = function () { + return _this.jsonLoadComplete(file.key); + }; + } + else if (file.format == Phaser.Tilemap.CSV) + { + this._xhr.onload = function () { + return _this.csvLoadComplete(file.key); + }; + } + + this._xhr.onerror = function () { + return _this.dataLoadError(file.key); + }; + this._xhr.send(); + break; + case 'text': this._xhr.open("GET", this.baseURL + file.url, true); this._xhr.responseType = "text"; @@ -589,6 +766,12 @@ Phaser.Loader.prototype = { }, + /** + * Private method ONLY used by loader. + * @method Phaser.Loader#getAudioURL + * @param {Description} urls - Description. + * @private + */ getAudioURL: function (urls) { var extension; @@ -610,9 +793,11 @@ Phaser.Loader.prototype = { }, /** - * Error occured when load a file. - * @param key {string} Key of the error loading file. - */ + * Error occured when load a file. + * + * @method Phaser.Loader#fileError + * @param {string} key - Key of the error loading file. + */ fileError: function (key) { this._fileList[key].loaded = true; @@ -620,16 +805,18 @@ Phaser.Loader.prototype = { this.onFileError.dispatch(key); - console.warn("Phaser.Loader error loading file: " + key); + console.warn("Phaser.Loader error loading file: " + key + ' from URL ' + this._fileList[key].url); this.nextFile(key, false); }, /** - * Called when a file is successfully loaded. - * @param key {string} Key of the successfully loaded file. - */ + * Called when a file is successfully loaded. + * + * @method Phaser.Loader#fileComplete + * @param {string} key - Key of the successfully loaded file. + */ fileComplete: function (key) { if (!this._fileList[key]) @@ -656,37 +843,9 @@ Phaser.Loader.prototype = { this.game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax); break; - case 'tilemap': + case 'tileset': - if (file.mapDataURL == null) - { - this.game.cache.addTilemap(file.key, file.url, file.data, file.mapData, file.format); - } - else - { - // Load the JSON or CSV before carrying on with the next file - loadNext = false; - this._xhr.open("GET", this.baseURL + file.mapDataURL, true); - this._xhr.responseType = "text"; - - if (file.format == Phaser.Tilemap.JSON) - { - this._xhr.onload = function () { - return _this.jsonLoadComplete(file.key); - }; - } - else if (file.format == Phaser.Tilemap.CSV) - { - this._xhr.onload = function () { - return _this.csvLoadComplete(file.key); - }; - } - - this._xhr.onerror = function () { - return _this.dataLoadError(file.key); - }; - this._xhr.send(); - } + this.game.cache.addTileset(file.key, file.url, file.data, file.tileWidth, file.tileHeight, file.tileMax, file.tileMargin, file.tileSpacing); break; case 'textureatlas': @@ -777,7 +936,7 @@ Phaser.Loader.prototype = { break; case 'text': - file.data = this._xhr.response; + file.data = this._xhr.responseText; this.game.cache.addText(file.key, file.url, file.data); break; } @@ -790,17 +949,19 @@ Phaser.Loader.prototype = { }, /** - * Successfully loaded a JSON file. - * @param key {string} Key of the loaded JSON file. - */ + * Successfully loaded a JSON file. + * + * @method Phaser.Loader#jsonLoadComplete + * @param {string} key - Key of the loaded JSON file. + */ jsonLoadComplete: function (key) { - var data = JSON.parse(this._xhr.response); + var data = JSON.parse(this._xhr.responseText); var file = this._fileList[key]; if (file.type == 'tilemap') { - this.game.cache.addTilemap(file.key, file.url, file.data, data, file.format); + this.game.cache.addTilemap(file.key, file.url, data, file.format); } else { @@ -812,24 +973,28 @@ Phaser.Loader.prototype = { }, /** - * Successfully loaded a CSV file. - * @param key {string} Key of the loaded CSV file. - */ + * Successfully loaded a CSV file. + * + * @method Phaser.Loader#csvLoadComplete + * @param {string} key - Key of the loaded CSV file. + */ csvLoadComplete: function (key) { - var data = this._xhr.response; + var data = this._xhr.responseText; var file = this._fileList[key]; - this.game.cache.addTilemap(file.key, file.url, file.data, data, file.format); + this.game.cache.addTilemap(file.key, file.url, data, file.format); this.nextFile(key, true); }, /** - * Error occured when load a JSON. - * @param key {string} Key of the error loading JSON file. - */ + * Error occured when load a JSON. + * + * @method Phaser.Loader#dataLoadError + * @param {string} key - Key of the error loading JSON file. + */ dataLoadError: function (key) { var file = this._fileList[key]; @@ -842,9 +1007,15 @@ Phaser.Loader.prototype = { }, + /** + * Successfully loaded an XML file. + * + * @method Phaser.Loader#xmlLoadComplete + * @param {string} key - Key of the loaded XML file. + */ xmlLoadComplete: function (key) { - var data = this._xhr.response; + var data = this._xhr.responseText; var xml; try @@ -887,10 +1058,12 @@ Phaser.Loader.prototype = { }, /** - * Handle loading next file. - * @param previousKey {string} Key of previous loaded asset. - * @param success {bool} Whether the previous asset loaded successfully or not. - */ + * Handle loading next file. + * + * @param previousKey {string} Key of previous loaded asset. + * @param success {boolean} Whether the previous asset loaded successfully or not. + * @private + */ nextFile: function (previousKey, success) { this.progress = Math.round(this.progress + this._progressChunk); @@ -904,11 +1077,11 @@ Phaser.Loader.prototype = { { if (this.preloadSprite.direction == 0) { - this.preloadSprite.crop.width = (this.preloadSprite.width / 100) * this.progress; + this.preloadSprite.crop.width = Math.floor((this.preloadSprite.width / 100) * this.progress); } else { - this.preloadSprite.crop.height = (this.preloadSprite.height / 100) * this.progress; + this.preloadSprite.crop.height = Math.floor((this.preloadSprite.height / 100) * this.progress); } this.preloadSprite.sprite.crop = this.preloadSprite.crop; diff --git a/src/loader/Parser.js b/src/loader/LoaderParser.js similarity index 81% rename from src/loader/Parser.js rename to src/loader/LoaderParser.js index 1ef50442..3cae9348 100644 --- a/src/loader/Parser.js +++ b/src/loader/LoaderParser.js @@ -1,8 +1,20 @@ -Phaser.Loader.Parser = { +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser.LoaderParser parses data objects from Phaser.Loader that need more preparation before they can be inserted into the Cache. +* +* @class Phaser.LoaderParser +*/ +Phaser.LoaderParser = { /** * Parse frame data from an XML file. - * @param xml {object} XML data you want to parse. + * @method Phaser.LoaderParser.bitmapFont + * @param {object} xml - XML data you want to parse. * @return {FrameData} Generated FrameData object. */ bitmapFont: function (game, xml, cacheKey) { @@ -10,7 +22,7 @@ Phaser.Loader.Parser = { // Malformed? if (!xml.getElementsByTagName('font')) { - console.warn("Phaser.Loader.Parser.bitmapFont: Invalid XML given, missing tag"); + console.warn("Phaser.LoaderParser.bitmapFont: Invalid XML given, missing tag"); return; } diff --git a/src/math/Math.js b/src/math/Math.js index d9f46edc..086d622d 100644 --- a/src/math/Math.js +++ b/src/math/Math.js @@ -1,32 +1,88 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* A collection of mathematical methods. +* +* @class Phaser.Math +*/ Phaser.Math = { + /** + * = 2 π + * @method Phaser.Math#PI2 + */ PI2: Math.PI * 2, + /** + * Two number are fuzzyEqual if their difference is less than ε. + * @method Phaser.Math#fuzzyEqual + * @param {number} a + * @param {number} b + * @param {number} epsilon + * @return {boolean} True if |a-b|<ε + */ fuzzyEqual: function (a, b, epsilon) { if (typeof epsilon === "undefined") { epsilon = 0.0001; } return Math.abs(a - b) < epsilon; }, + /** + * a is fuzzyLessThan b if it is less than b + ε. + * @method Phaser.Math#fuzzyEqual + * @param {number} a + * @param {number} b + * @param {number} epsilon + * @return {boolean} True if ab+ε + */ fuzzyGreaterThan: function (a, b, epsilon) { if (typeof epsilon === "undefined") { epsilon = 0.0001; } return a > b - epsilon; }, + /** + * @method Phaser.Math#fuzzyCeil + * @param {number} val + * @param {number} epsilon + * @return {boolean} ceiling(val-ε) + */ fuzzyCeil: function (val, epsilon) { if (typeof epsilon === "undefined") { epsilon = 0.0001; } return Math.ceil(val - epsilon); }, + /** + * @method Phaser.Math#fuzzyFloor + * @param {number} val + * @param {number} epsilon + * @return {boolean} floor(val-ε) + */ fuzzyFloor: function (val, epsilon) { if (typeof epsilon === "undefined") { epsilon = 0.0001; } return Math.floor(val + epsilon); }, + /** + * Averages all values passed to the function and returns the result. You can pass as many parameters as you like. + * @method Phaser.Math#average + * @return {number} The average of all given values. + */ average: function () { var args = []; @@ -45,10 +101,20 @@ Phaser.Math = { }, + /** + * @method Phaser.Math#truncate + * @param {number} n + * @return {number} + */ truncate: function (n) { return (n > 0) ? Math.floor(n) : Math.ceil(n); }, + /** + * @method Phaser.Math#shear + * @param {number} n + * @return {number} n mod 1 + */ shear: function (n) { return n % 1; }, @@ -56,11 +122,13 @@ Phaser.Math = { /** * Snap a value to nearest grid slice, using rounding. * - * example if you have an interval gap of 5 and a position of 12... you will snap to 10. Where as 14 will snap to 15 + * Example: if you have an interval gap of 5 and a position of 12... you will snap to 10 whereas 14 will snap to 15. * - * @param input - the value to snap - * @param gap - the interval gap of the grid - * @param [start] - optional starting offset for gap + * @method Phaser.Math#snapTo + * @param {number} input - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start] - Optional starting offset for gap. + * @return {number} */ snapTo: function (input, gap, start) { @@ -80,11 +148,13 @@ Phaser.Math = { /** * Snap a value to nearest grid slice, using floor. * - * example if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15 + * Example: if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15 * - * @param input - the value to snap - * @param gap - the interval gap of the grid - * @param [start] - optional starting offset for gap + * @method Phaser.Math#snapToFloor + * @param {number} input - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start] - Optional starting offset for gap. + * @return {number} */ snapToFloor: function (input, gap, start) { @@ -104,11 +174,13 @@ Phaser.Math = { /** * Snap a value to nearest grid slice, using ceil. * - * example if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20 + * Example: if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20. * - * @param input - the value to snap - * @param gap - the interval gap of the grid - * @param [start] - optional starting offset for gap + * @method Phaser.Math#snapToCeil + * @param {number} input - The value to snap. + * @param {number} gap - The interval gap of the grid. + * @param {number} [start] - Optional starting offset for gap. + * @return {number} */ snapToCeil: function (input, gap, start) { @@ -128,6 +200,11 @@ Phaser.Math = { /** * Snaps a value to the nearest value in an array. + * @method Phaser.Math#snapToInArray + * @param {number} input + * @param {array} arr + * @param {boolean} sort - True if the array needs to be sorted. + * @return {number} */ snapToInArray: function (input, arr, sort) { @@ -155,16 +232,10 @@ Phaser.Math = { }, /** - * roundTo some place comparative to a 'base', default is 10 for decimal place + * Round to some place comparative to a 'base', default is 10 for decimal place. * * 'place' is represented by the power applied to 'base' to get that place - * - * @param value - the value to round - * @param place - the place to round to - * @param base - the base to round in... default is 10 for decimal - * * e.g. - * * 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011 * * roundTo(2000/7,3) == 0 @@ -187,8 +258,14 @@ Phaser.Math = { * roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011 * roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111 * - * note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed + * Note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed * because we are rounding 100011.1011011011011011 which rounds up. + * + * @method Phaser.Math#roundTo + * @param {number} value - The value to round. + * @param {number} place - The place to round to. + * @param {number} base - The base to round in... default is 10 for decimal. + * @return {number} */ roundTo: function (value, place, base) { @@ -201,6 +278,13 @@ Phaser.Math = { }, + /** + * @method Phaser.Math#floorTo + * @param {number} value - The value to round. + * @param {number} place - The place to round to. + * @param {number} base - The base to round in... default is 10 for decimal. + * @return {number} + */ floorTo: function (value, place, base) { if (typeof place === "undefined") { place = 0; } @@ -212,6 +296,13 @@ Phaser.Math = { }, + /** + * @method Phaser.Math#ceilTo + * @param {number} value - The value to round. + * @param {number} place - The place to round to. + * @param {number} base - The base to round in... default is 10 for decimal. + * @return {number} + */ ceilTo: function (value, place, base) { if (typeof place === "undefined") { place = 0; } @@ -224,34 +315,54 @@ Phaser.Math = { }, /** - * a one dimensional linear interpolation of a value. + * A one dimensional linear interpolation of a value. + * @method Phaser.Math#interpolateFloat + * @param {number} a + * @param {number} b + * @param {number} weight + * @return {number} */ interpolateFloat: function (a, b, weight) { return (b - a) * weight + a; }, /** - * Find the angle of a segment from (x1, y1) -> (x2, y2 ) + * Find the angle of a segment from (x1, y1) -> (x2, y2 ). + * @method Phaser.Math#angleBetween + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @return {number} */ angleBetween: function (x1, y1, x2, y2) { return Math.atan2(y2 - y1, x2 - x1); }, /** - * set an angle within the bounds of -PI to PI + * Set an angle within the bounds of -π toπ. + * @method Phaser.Math#normalizeAngle + * @param {number} angle + * @param {boolean} radians - True if angle size is expressed in radians. + * @return {number} */ normalizeAngle: function (angle, radians) { if (typeof radians === "undefined") { radians = true; } - var rd = (radians) ? Math.PI : 180; - return this.wrap(angle, -rd, rd); + var rd = (radians) ? GameMath.PI : 180; + return this.wrap(angle, rd, -rd); }, /** - * closest angle between two angles from a1 to a2 + * Closest angle between two angles from a1 to a2 * absolute value the return for exact angle + * @method Phaser.Math#nearestAngleBetween + * @param {number} a1 + * @param {number} a2 + * @param {boolean} radians - True if angle sizes are expressed in radians. + * @return {number} */ nearestAngleBetween: function (a1, a2, radians) { @@ -276,7 +387,14 @@ Phaser.Math = { }, /** - * interpolate across the shortest arc between two angles + * Interpolate across the shortest arc between two angles. + * @method Phaser.Math#interpolateAngles + * @param {number} a1 - Description. + * @param {number} a2 - Description. + * @param {number} weight - Description. + * @param {boolean} radians - True if angle sizes are expressed in radians. + * @param {Description} ease - Description. + * @return {number} */ interpolateAngles: function (a1, a2, weight, radians, ease) { @@ -291,13 +409,14 @@ Phaser.Math = { }, /** - * Generate a random bool result based on the chance value + * Generate a random bool result based on the chance value. *

    * Returns true or false based on the chance value (default 50%). For example if you wanted a player to have a 30% chance * of getting a bonus, call chanceRoll(30) - true means the chance passed, false means it failed. *

    - * @param chance The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%) - * @return true if the roll passed, or false + * @method Phaser.Math#chanceRoll + * @param {number} chance - The chance of receiving the value. A number between 0 and 100 (effectively 0% to 100%). + * @return {boolean} True if the roll passed, or false otherwise. */ chanceRoll: function (chance) { @@ -326,11 +445,12 @@ Phaser.Math = { }, /** - * Returns an Array containing the numbers from min to max (inclusive) + * Returns an Array containing the numbers from min to max (inclusive). * - * @param min The minimum value the array starts with - * @param max The maximum value the array contains - * @return The array of number values + * @method Phaser.Math#numberArray + * @param {number} min - The minimum value the array starts with. + * @param {number} max - The maximum value the array contains. + * @return {array} The array of number values. */ numberArray: function (min, max) { @@ -346,12 +466,13 @@ Phaser.Math = { }, /** - * Adds the given amount to the value, but never lets the value go over the specified maximum + * Adds the given amount to the value, but never lets the value go over the specified maximum. * - * @param value The value to add the amount to - * @param amount The amount to add to the value - * @param max The maximum the value is allowed to be - * @return The new value + * @method Phaser.Math#maxAdd + * @param {number} value - The value to add the amount to. + * @param {number} amount - The amount to add to the value. + * @param {number} max- The maximum the value is allowed to be. + * @return {number} */ maxAdd: function (value, amount, max) { @@ -367,12 +488,13 @@ Phaser.Math = { }, /** - * Subtracts the given amount from the value, but never lets the value go below the specified minimum + * Subtracts the given amount from the value, but never lets the value go below the specified minimum. * - * @param value The base value - * @param amount The amount to subtract from the base value - * @param min The minimum the value is allowed to be - * @return The new value + * @method Phaser.Math#minSub + * @param {number} value - The base value. + * @param {number} amount - The amount to subtract from the base value. + * @param {number} min - The minimum the value is allowed to be. + * @return {number} The new value. */ minSub: function (value, amount, min) { @@ -391,34 +513,41 @@ Phaser.Math = { * Ensures that the value always stays between min and max, by wrapping the value around. *

    max should be larger than min, or the function will return 0

    * + * @method Phaser.Math#wrap * @param value The value to wrap * @param min The minimum the value is allowed to be * @param max The maximum the value is allowed to be - * @return The wrapped value + * @return {number} The wrapped value */ wrap: function (value, min, max) { var range = max - min; + if (range <= 0) { return 0; } + var result = (value - min) % range; + if (result < 0) { result += range; } + return result + min; + }, /** * Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around. *

    Values must be positive integers, and are passed through Math.abs

    * - * @param value The value to add the amount to - * @param amount The amount to add to the value - * @param max The maximum the value is allowed to be - * @return The wrapped value + * @method Phaser.Math#wrapValue + * @param {number} value - The value to add the amount to. + * @param {number} amount - The amount to add to the value. + * @param {number} max - The maximum the value is allowed to be. + * @return {number} The wrapped value. */ wrapValue: function (value, amount, max) { @@ -433,9 +562,10 @@ Phaser.Math = { }, /** - * Randomly returns either a 1 or -1 + * Randomly returns either a 1 or -1. * - * @return 1 or -1 + * @method Phaser.Math#randomSign + * @return {number} 1 or -1 */ randomSign: function () { return (Math.random() > 0.5) ? 1 : -1; @@ -444,9 +574,9 @@ Phaser.Math = { /** * Returns true if the number given is odd. * - * @param n The number to check - * - * @return True if the given number is odd. False if the given number is even. + * @method Phaser.Math#isOdd + * @param {number} n - The number to check. + * @return {boolean} True if the given number is odd. False if the given number is even. */ isOdd: function (n) { @@ -457,9 +587,9 @@ Phaser.Math = { /** * Returns true if the number given is even. * - * @param n The number to check - * - * @return True if the given number is even. False if the given number is odd. + * @method Phaser.Math#isEven + * @param {number} n - The number to check. + * @return {boolean} True if the given number is even. False if the given number is odd. */ isEven: function (n) { @@ -478,7 +608,8 @@ Phaser.Math = { * Significantly faster version of Math.max * See http://jsperf.com/math-s-min-max-vs-homemade/5 * - * @return The highest value from those given. + * @method Phaser.Math#max + * @return {number} The highest value from those given. */ max: function () { @@ -498,7 +629,8 @@ Phaser.Math = { * Significantly faster version of Math.min * See http://jsperf.com/math-s-min-max-vs-homemade/5 * - * @return The lowest value from those given. + * @method Phaser.Math#min + * @return {number} The lowest value from those given. */ min: function () { @@ -518,9 +650,9 @@ Phaser.Math = { * Keeps an angle value between -180 and +180
    * Should be called whenever the angle is updated on the Sprite to stop it from going insane. * - * @param angle The angle value to check - * - * @return The new angle value, returns the same as the input angle if it was within bounds + * @method Phaser.Math#wrapAngle + * @param {number} angle - The angle value to check + * @return {number} The new angle value, returns the same as the input angle if it was within bounds. */ wrapAngle: function (angle) { @@ -545,63 +677,86 @@ Phaser.Math = { }, /** - * Keeps an angle value between the given min and max values + * Keeps an angle value between the given min and max values. * - * @param angle The angle value to check. Must be between -180 and +180 - * @param min The minimum angle that is allowed (must be -180 or greater) - * @param max The maximum angle that is allowed (must be 180 or less) + * @method Phaser.Math#angleLimit + * @param {number} angle - The angle value to check. Must be between -180 and +180. + * @param {number} min - The minimum angle that is allowed (must be -180 or greater). + * @param {number} max - The maximum angle that is allowed (must be 180 or less). * - * @return The new angle value, returns the same as the input angle if it was within bounds + * @return {number} The new angle value, returns the same as the input angle if it was within bounds */ angleLimit: function (angle, min, max) { + var result = angle; - if (angle > max) { + + if (angle > max) + { result = max; - } else if (angle < min) { + } + else if (angle < min) + { result = min; } + return result; + }, /** - * @method linearInterpolation - * @param {Any} v - * @param {Any} k - * @public + * Description. + * @method Phaser.Math#linearInterpolation + * @param {number} v + * @param {number} k + * @return {number} */ linearInterpolation: function (v, k) { + var m = v.length - 1; var f = m * k; var i = Math.floor(f); - if (k < 0) { + + if (k < 0) + { return this.linear(v[0], v[1], f); } - if (k > 1) { + + if (k > 1) + { return this.linear(v[m], v[m - 1], m - f); } + return this.linear(v[i], v[i + 1 > m ? m : i + 1], f - i); + }, /** - * @method bezierInterpolation - * @param {Any} v - * @param {Any} k - * @public + * Description. + * @method Phaser.Math#bezierInterpolation + * @param {number} v + * @param {number} k + * @return {number} */ bezierInterpolation: function (v, k) { + var b = 0; var n = v.length - 1; - for (var i = 0; i <= n; i++) { + + for (var i = 0; i <= n; i++) + { b += Math.pow(1 - k, n - i) * Math.pow(k, i) * v[i] * this.bernstein(n, i); } + return b; + }, /** - * @method catmullRomInterpolation - * @param {Any} v - * @param {Any} k - * @public + * Description. + * @method Phaser.Math#catmullRomInterpolation + * @param {number} v + * @param {number} k + * @return {number} */ catmullRomInterpolation: function (v, k) { @@ -609,57 +764,79 @@ Phaser.Math = { var f = m * k; var i = Math.floor(f); - if (v[0] === v[m]) { - if (k < 0) { + if (v[0] === v[m]) + { + if (k < 0) + { i = Math.floor(f = m * (1 + k)); } + return this.catmullRom(v[(i - 1 + m) % m], v[i], v[(i + 1) % m], v[(i + 2) % m], f - i); - } else { - if (k < 0) { + + } + else + { + if (k < 0) + { return v[0] - (this.catmullRom(v[0], v[0], v[1], v[1], -f) - v[0]); } - if (k > 1) { + + if (k > 1) + { return v[m] - (this.catmullRom(v[m], v[m], v[m - 1], v[m - 1], f - m) - v[m]); } + return this.catmullRom(v[i ? i - 1 : 0], v[i], v[m < i + 1 ? m : i + 1], v[m < i + 2 ? m : i + 2], f - i); } + }, /** - * @method Linear - * @param {Any} p0 - * @param {Any} p1 - * @param {Any} t - * @public + * Description. + * @method Phaser.Math#Linear + * @param {number} p0 + * @param {number} p1 + * @param {number} t + * @return {number} */ linear: function (p0, p1, t) { return (p1 - p0) * t + p0; }, /** - * @method bernstein - * @param {Any} n - * @param {Any} i - * @public + * @method Phaser.Math#bernstein + * @param {number} n + * @param {number} i + * @return {number} */ bernstein: function (n, i) { return this.factorial(n) / this.factorial(i) / this.factorial(n - i); }, /** - * @method catmullRom - * @param {Any} p0 - * @param {Any} p1 - * @param {Any} p2 - * @param {Any} p3 - * @param {Any} t - * @public + * Description. + * @method Phaser.Math#catmullRom + * @param {number} p0 + * @param {number} p1 + * @param {number} p2 + * @param {number} p3 + * @param {number} t + * @return {number} */ catmullRom: function (p0, p1, p2, p3, t) { + var v0 = (p2 - p0) * 0.5, v1 = (p3 - p1) * 0.5, t2 = t * t, t3 = t * t2; + return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; + }, + /** + * @method Phaser.Math#difference + * @param {number} a + * @param {number} b + * @return {number} + */ difference: function (a, b) { return Math.abs(a - b); }, @@ -668,11 +845,11 @@ Phaser.Math = { * Fetch a random entry from the given array. * Will return null if random selection is missing, or array has no entries. * - * @param objects An array of objects. - * @param startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array. - * @param length Optional restriction on the number of values you want to randomly select from. - * - * @return The random object that was selected. + * @method Phaser.Math#getRandom + * @param {array} objects - An array of objects. + * @param {number} startIndex - Optional offset off the front of the array. Default value is 0, or the beginning of the array. + * @param {number} length - Optional restriction on the number of values you want to randomly select from. + * @return {object} The random object that was selected. */ getRandom: function (objects, startIndex, length) { @@ -701,9 +878,9 @@ Phaser.Math = { /** * Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2. * - * @param Value Any number. - * - * @return The rounded value of that number. + * @method Phaser.Math#floor + * @param {number} Value Any number. + * @return {number} The rounded value of that number. */ floor: function (value) { @@ -716,9 +893,9 @@ Phaser.Math = { /** * Round up to the next whole number. E.g. ceil(1.3) == 2, and ceil(-2.3) == -3. * - * @param Value Any number. - * - * @return The rounded value of that number. + * @method Phaser.Math#ceil + * @param {number} value - Any number. + * @return {number} The rounded value of that number. */ ceil: function (value) { var n = value | 0; @@ -731,13 +908,12 @@ Phaser.Math = { * The parameters allow you to specify the length, amplitude and frequency of the wave. Once you have called this function * you should get the results via getSinTable() and getCosTable(). This generator is fast enough to be used in real-time. *

    - * @param length The length of the wave - * @param sinAmplitude The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value - * @param cosAmplitude The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value - * @param frequency The frequency of the sine and cosine table data - * @return Returns the sine table - * @see getSinTable - * @see getCosTable + * @method Phaser.Math#sinCosGenerator + * @param {number} length - The length of the wave + * @param {number} sinAmplitude - The amplitude to apply to the sine table (default 1.0) if you need values between say -+ 125 then give 125 as the value + * @param {number} cosAmplitude - The amplitude to apply to the cosine table (default 1.0) if you need values between say -+ 125 then give 125 as the value + * @param {number} frequency - The frequency of the sine and cosine table data + * @return {Array} Returns the sine table */ sinCosGenerator: function (length, sinAmplitude, cosAmplitude, frequency) { @@ -768,9 +944,11 @@ Phaser.Math = { /** * Removes the top element from the stack and re-inserts it onto the bottom, then returns it. - * The original stack is modified in the process. - * This effectively moves the position of the data from the start to the end of the table. - * @return The value. + * The original stack is modified in the process. This effectively moves the position of the data from the start to the end of the table. + * + * @method Phaser.Math#shift + * @param {array} stack - The array to shift. + * @return {any} The shifted value. */ shift: function (stack) { @@ -783,8 +961,9 @@ Phaser.Math = { /** * Shuffles the data in the given array into a new order - * @param array The array to shuffle - * @return The array + * @method Phaser.Math#shuffleArray + * @param {array} array - The array to shuffle + * @return {array} The array */ shuffleArray: function (array) { @@ -802,12 +981,13 @@ Phaser.Math = { /** * Returns the distance between the two given set of coordinates. - * @method distance - * @param {Number} x1 - * @param {Number} y1 - * @param {Number} x2 - * @param {Number} y2 - * @return {Number} The distance between this Point object and the destination Point object. + * + * @method Phaser.Math#distance + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @return {number} The distance between this Point object and the destination Point object. **/ distance: function (x1, y1, x2, y2) { @@ -818,6 +998,16 @@ Phaser.Math = { }, + /** + * Returns the rounded distance between the two given set of coordinates. + * + * @method Phaser.Math#distanceRounded + * @param {number} x1 + * @param {number} y1 + * @param {number} x2 + * @param {number} y2 + * @return {number} The distance between this Point object and the destination Point object. + **/ distanceRounded: function (x1, y1, x2, y2) { return Math.round(Phaser.Math.distance(x1, y1, x2, y2)); @@ -825,34 +1015,77 @@ Phaser.Math = { }, /** - * force a value within the boundaries of two values - * + * Force a value within the boundaries of two values. * Clamp value to range + * + * @method Phaser.Math#clamp + * @param {number} x + * @param {number} a + * @param {number} b + * @return {number} */ clamp: function ( x, a, b ) { return ( x < a ) ? a : ( ( x > b ) ? b : x ); }, - - // Clamp value to range to range + /** + * Checks if two values are within the given tolerance of each other. + * + * @method Phaser.Math#within + * @param {number} a - The first number to check + * @param {number} b - The second number to check + * @param {number} tolerance - The tolerance. Anything equal to or less than this is considered within the range. + * @return {boolean} True if a is <= tolerance of b. + */ + within: function ( a, b, tolerance ) { + return (Math.abs(a - b) <= tolerance); + + }, + + /** + * Linear mapping from range to range + * + * @method Phaser.Math#mapLinear + * @param {number} x + * @param {number} a1 + * @param {number} a1 + * @param {number} a2 + * @param {number} b1 + * @param {number} b2 + * @return {number} + */ mapLinear: function ( x, a1, a2, b1, b2 ) { return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 ); }, - // http://en.wikipedia.org/wiki/Smoothstep - + /** + * Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep + * + * @method Phaser.Math#smoothstep + * @param {number} x + * @param {number} min + * @param {number} max + * @return {number} + */ smoothstep: function ( x, min, max ) { if ( x <= min ) return 0; @@ -864,6 +1097,15 @@ Phaser.Math = { }, + /** + * Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep + * + * @method Phaser.Math#smootherstep + * @param {number} x + * @param {number} min + * @param {number} max + * @return {number} + */ smootherstep: function ( x, min, max ) { if ( x <= min ) return 0; @@ -876,8 +1118,12 @@ Phaser.Math = { }, /** - * a value representing the sign of the value. + * A value representing the sign of the value. * -1 for negative, +1 for positive, 0 if value is 0 + * + * @method Phaser.Math#sign + * @param {number} x + * @return {number} */ sign: function ( x ) { @@ -885,6 +1131,12 @@ Phaser.Math = { }, + /** + * Convert degrees to radians. + * + * @method Phaser.Math#degToRad + * @return {function} + */ degToRad: function() { var degreeToRadiansFactor = Math.PI / 180; @@ -897,6 +1149,12 @@ Phaser.Math = { }(), + /** + * Convert degrees to radians. + * + * @method Phaser.Math#radToDeg + * @return {function} + */ radToDeg: function() { var radianToDegreesFactor = 180 / Math.PI; diff --git a/src/math/QuadTree.js b/src/math/QuadTree.js index 0c6e317c..35046538 100644 --- a/src/math/QuadTree.js +++ b/src/math/QuadTree.js @@ -1,4 +1,10 @@ -/* +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** * Javascript QuadTree * @version 1.0 * @author Timo Hausmann @@ -12,35 +18,45 @@ * Original version at https://github.com/timohausmann/quadtree-js/ */ -/* - Copyright © 2012 Timo Hausmann - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +/** +* @copyright © 2012 Timo Hausmann +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* -* QuadTree Constructor -* @param Integer maxObjects (optional) max objects a node can hold before splitting into 4 subnodes (default: 10) -* @param Integer maxLevels (optional) total max levels inside root QuadTree (default: 4) -* @param Integer level (optional) deepth level, required for subnodes -*/ +/** + * QuadTree Constructor + * + * @class Phaser.QuadTree + * @classdesc A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked + * it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result. Original version at https://github.com/timohausmann/quadtree-js/ + * @constructor + * @param {Description} physicsManager - Description. + * @param {Description} x - Description. + * @param {Description} y - Description. + * @param {number} width - The width of your game in game pixels. + * @param {number} height - The height of your game in game pixels. + * @param {number} maxObjects - Description. + * @param {number} maxLevels - Description. + * @param {number} level - Description. + */ Phaser.QuadTree = function (physicsManager, x, y, width, height, maxObjects, maxLevels, level) { this.physicsManager = physicsManager; @@ -70,8 +86,10 @@ Phaser.QuadTree = function (physicsManager, x, y, width, height, maxObjects, max Phaser.QuadTree.prototype = { /* - * Split the node into 4 subnodes - */ + * Split the node into 4 subnodes + * + * @method Phaser.QuadTree#split + */ split: function() { this.level++; @@ -94,7 +112,9 @@ Phaser.QuadTree.prototype = { * Insert the object into the node. If the node * exceeds the capacity, it will split and add all * objects to their corresponding subnodes. - * @param Object pRect bounds of the object to be added, with x, y, width, height + * + * @method Phaser.QuadTree#insert + * @param {object} body - Description. */ insert: function (body) { @@ -142,9 +162,11 @@ Phaser.QuadTree.prototype = { }, /* - * Determine which node the object belongs to - * @param Object pRect bounds of the area to be checked, with x, y, width, height - * @return Integer index of the subnode (0-3), or -1 if pRect cannot completely fit within a subnode and is part of the parent node + * Determine which node the object belongs to. + * + * @method Phaser.QuadTree#getIndex + * @param {object} rect - Description. + * @return {number} index - Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node. */ getIndex: function (rect) { @@ -184,9 +206,11 @@ Phaser.QuadTree.prototype = { }, /* - * Return all objects that could collide with the given object - * @param Object pRect bounds of the object to be checked, with x, y, width, height - * @Return Array array with all detected objects + * Return all objects that could collide with the given object. + * + * @method Phaser.QuadTree#retrieve + * @param {object} rect - Description. + * @Return {array} - Array with all detected objects. */ retrieve: function (sprite) { @@ -219,7 +243,8 @@ Phaser.QuadTree.prototype = { }, /* - * Clear the quadtree + * Clear the quadtree. + * @method Phaser.QuadTree#clear */ clear: function () { diff --git a/src/math/RandomDataGenerator.js b/src/math/RandomDataGenerator.js index c34ba800..7155902c 100644 --- a/src/math/RandomDataGenerator.js +++ b/src/math/RandomDataGenerator.js @@ -1,9 +1,19 @@ /** -* Phaser.RandomDataGenerator -* -* An extremely useful repeatable random data generator. Access it via Phaser.Game.rnd -* Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser.RandomDataGenerator constructor. +* +* @class Phaser.RandomDataGenerator +* @classdesc An extremely useful repeatable random data generator. Access it via Phaser.Game.rnd +* Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense. * Random number generator from http://baagoe.org/en/wiki/Better_random_numbers_for_javascript +* +* @constructor +* @param {array} seeds */ Phaser.RandomDataGenerator = function (seeds) { @@ -16,37 +26,34 @@ Phaser.RandomDataGenerator = function (seeds) { Phaser.RandomDataGenerator.prototype = { /** - * @property c - * @type Number + * @property {number} c * @private */ c: 1, /** - * @property s0 - * @type Number + * @property {number} s0 * @private */ s0: 0, /** - * @property s1 - * @type Number + * @property {number} s1 * @private */ s1: 0, /** - * @property s2 - * @type Number + * @property {number} s2 * @private */ s2: 0, /** - * Private random helper - * @method rnd + * Private random helper. + * @method Phaser.RandomDataGenerator#rnd * @private + * @return {number} Description. */ rnd: function () { @@ -61,9 +68,10 @@ Phaser.RandomDataGenerator.prototype = { }, /** - * Reset the seed of the random data generator - * @method sow - * @param {Array} seeds + * Reset the seed of the random data generator. + * + * @method Phaser.RandomDataGenerator#sow + * @param {array} seeds */ sow: function (seeds) { @@ -72,10 +80,12 @@ Phaser.RandomDataGenerator.prototype = { this.s0 = this.hash(' '); this.s1 = this.hash(this.s0); this.s2 = this.hash(this.s1); + this.c = 1; var seed; - for (var i = 0; seed = seeds[i++]; ) { + for (var i = 0; seed = seeds[i++]; ) + { this.s0 -= this.hash(seed); this.s0 += ~~(this.s0 < 0); this.s1 -= this.hash(seed); @@ -87,9 +97,11 @@ Phaser.RandomDataGenerator.prototype = { }, /** - * @method hash + * Description. + * @method Phaser.RandomDataGenerator#hash * @param {Any} data * @private + * @return {number} Description. */ hash: function (data) { @@ -113,72 +125,69 @@ Phaser.RandomDataGenerator.prototype = { }, /** - * Returns a random integer between 0 and 2^32 - * @method integer - * @return {Number} + * Returns a random integer between 0 and 2^32. + * @method Phaser.RandomDataGenerator#integer + * @return {number} */ integer: function() { return this.rnd.apply(this) * 0x100000000;// 2^32 }, /** - * Returns a random real number between 0 and 1 - * @method frac - * @return {Number} + * Returns a random real number between 0 and 1. + * @method Phaser.RandomDataGenerator#frac + * @return {number} */ frac: function() { return this.rnd.apply(this) + (this.rnd.apply(this) * 0x200000 | 0) * 1.1102230246251565e-16;// 2^-53 }, /** - * Returns a random real number between 0 and 2^32 - * @method real - * @return {Number} + * Returns a random real number between 0 and 2^32. + * @method Phaser.RandomDataGenerator#real + * @return {number} */ real: function() { return this.integer() + this.frac(); }, /** - * Returns a random integer between min and max - * @method integerInRange - * @param {Number} min - * @param {Number} max - * @return {Number} + * Returns a random integer between min and max. + * @method Phaser.RandomDataGenerator#integerInRange + * @param {number} min + * @param {number} max + * @return {number} */ integerInRange: function (min, max) { return Math.floor(this.realInRange(min, max)); }, /** - * Returns a random real number between min and max - * @method realInRange - * @param {Number} min - * @param {Number} max - * @return {Number} + * Returns a random real number between min and max. + * @method Phaser.RandomDataGenerator#realInRange + * @param {number} min + * @param {number} max + * @return {number} */ realInRange: function (min, max) { - min = min || 0; - max = max || 0; - return this.frac() * (max - min) + min; }, /** - * Returns a random real number between -1 and 1 - * @method normal - * @return {Number} + * Returns a random real number between -1 and 1. + * @method Phaser.RandomDataGenerator#normal + * @return {number} */ normal: function () { return 1 - 2 * this.frac(); }, /** - * Returns a valid RFC4122 version4 ID hex string (from https://gist.github.com/1308368) - * @method uuid - * @return {String} + * Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368 + * @method Phaser.RandomDataGenerator#uuid + * @return {string} */ uuid: function () { @@ -195,36 +204,40 @@ Phaser.RandomDataGenerator.prototype = { }, /** - * Returns a random member of `array` - * @method pick - * @param {Any} array + * Returns a random member of `array`. + * @method Phaser.RandomDataGenerator#pick + * @param {Any} ary + * @return {number} */ pick: function (ary) { return ary[this.integerInRange(0, ary.length)]; }, /** - * Returns a random member of `array`, favoring the earlier entries - * @method weightedPick - * @param {Any} array + * Returns a random member of `array`, favoring the earlier entries. + * @method Phaser.RandomDataGenerator#weightedPick + * @param {Any} ary + * @return {number} */ weightedPick: function (ary) { return ary[~~(Math.pow(this.frac(), 2) * ary.length)]; }, /** - * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified - * @method timestamp - * @param {Number} min - * @param {Number} max + * Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified. + * @method Phaser.RandomDataGenerator#timestamp + * @param {number} min + * @param {number} max + * @return {number} */ timestamp: function (a, b) { return this.realInRange(a || 946684800000, b || 1577862000000); }, /** - * Returns a random angle between -180 and 180 - * @method angle + * Returns a random angle between -180 and 180. + * @method Phaser.RandomDataGenerator#angle + * @return {number} */ angle: function() { return this.integerInRange(-180, 180); diff --git a/src/net/Net.js b/src/net/Net.js index 0e6e7c60..cb5dbf23 100644 --- a/src/net/Net.js +++ b/src/net/Net.js @@ -1,3 +1,16 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Description of Phaser.Net +* +* @class Phaser.Net +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +*/ Phaser.Net = function (game) { this.game = game; @@ -8,6 +21,9 @@ Phaser.Net.prototype = { /** * Returns the hostname given by the browser. + * + * @method Phaser.Net#getHostName + * @return {string} */ getHostName: function () { @@ -24,6 +40,10 @@ Phaser.Net.prototype = { * If the domain name is found it returns true. * You can specify a part of a domain, for example 'google' would match 'google.com', 'google.co.uk', etc. * Do not include 'http://' at the start. + * + * @method Phaser.Net#checkDomainName + * @param {string} domain + * @return {boolean} */ checkDomainName: function (domain) { return window.location.hostname.indexOf(domain) !== -1; @@ -34,6 +54,13 @@ Phaser.Net.prototype = { * If the value doesn't already exist it is set. * If the value exists it is replaced with the new value given. If you don't provide a new value it is removed from the query string. * Optionally you can redirect to the new url, or just return it as a string. + * + * @method Phaser.Net#updateQueryString + * @param {string} key - The querystring key to update. + * @param {string} value - The new value to be set. If it already exists it will be replaced. + * @param {boolean} redirect - If true the browser will issue a redirect to the url with the new querystring. + * @param {string} url - The URL to modify. If none is given it uses window.location.href. + * @return {string} If redirect is false then the modified url and query string is returned. */ updateQueryString: function (key, value, redirect, url) { @@ -93,6 +120,10 @@ Phaser.Net.prototype = { /** * Returns the Query String as an object. * If you specify a parameter it will return just the value of that parameter, should it exist. + * + * @method Phaser.Net#getQueryString + * @param {string} [parameter=''] - If specified this will return just the value for that key. + * @return {string|object} An object containing the key value pairs found in the query string or just the value if a parameter was given. */ getQueryString: function (parameter) { @@ -122,9 +153,16 @@ Phaser.Net.prototype = { }, + /** + * Returns the Query String as an object. + * If you specify a parameter it will return just the value of that parameter, should it exist. + * + * @method Phaser.Net#decodeURI + * @param {string} value - The URI component to be decoded. + * @return {string} The decoded value. + */ decodeURI: function (value) { return decodeURIComponent(value.replace(/\+/g, " ")); } }; - diff --git a/src/particles/Particles.js b/src/particles/Particles.js index 1e1d0cd0..69d0987e 100644 --- a/src/particles/Particles.js +++ b/src/particles/Particles.js @@ -1,15 +1,40 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + +/** +* Phaser.Particles is the Particle Manager for the game. It is called during the game update loop and in turn updates any Emitters attached to it. +* +* @class Phaser.Particles +* @classdesc Phaser Particles +* @constructor +* @param {Phaser.Game} game - A reference to the currently running game. +*/ Phaser.Particles = function (game) { + /** + * @property {Description} emitters - Description. + */ this.emitters = {}; + /** + * @property {number} ID - Description. + * @default + */ this.ID = 0; }; Phaser.Particles.prototype = { - emitters: null, - + /** + * Adds a new Particle Emitter to the Particle Manager. + * @method Phaser.Particles#add + * @param {Phaser.Emitter} emitter - Description. + * @return {Phaser.Emitter} The emitter that was added. + */ add: function (emitter) { this.emitters[emitter.name] = emitter; @@ -18,12 +43,22 @@ Phaser.Particles.prototype = { }, + /** + * Removes an existing Particle Emitter from the Particle Manager. + * @method Phaser.Particles#remove + * @param {Phaser.Emitter} emitter - The emitter to remove. + */ remove: function (emitter) { delete this.emitters[emitter.name]; }, + /** + * Called by the core game loop. Updates all Emitters who have their exists value set to true. + * @method Phaser.Particles#update + * @protected + */ update: function () { for (var key in this.emitters) @@ -34,6 +69,6 @@ Phaser.Particles.prototype = { } } - }, + } }; \ No newline at end of file diff --git a/src/particles/arcade/Emitter.js b/src/particles/arcade/Emitter.js index d8d886f3..501afcb2 100644 --- a/src/particles/arcade/Emitter.js +++ b/src/particles/arcade/Emitter.js @@ -1,145 +1,205 @@ +/** +* @author Richard Davey +* @copyright 2013 Photon Storm Ltd. +* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} +*/ + /** * Phaser - ArcadeEmitter * -* Emitter is a lightweight particle emitter. It can be used for one-time explosions or for +* @class Phaser.Particles.Arcade.Emitter +* @classdesc Emitter is a lightweight particle emitter. It can be used for one-time explosions or for * continuous effects like rain and fire. All it really does is launch Particle objects out * at set intervals, and fixes their positions and velocities accorindgly. +* @constructor +* @extends Phaser.Group +* @param {Phaser.Game} game - Current game instance. +* @param {number} [x=0] - The x coordinate within the Emitter that the particles are emitted from. +* @param {number} [y=0] - The y coordinate within the Emitter that the particles are emitted from. +* @param {number} [maxParticles=50] - The total number of particles in this emitter.. */ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) { - maxParticles = maxParticles || 50; + /** + * The total number of particles in this emitter. + * @property {number} maxParticles - The total number of particles in this emitter.. + * @default + */ + this.maxParticles = maxParticles || 50; Phaser.Group.call(this, game); + /** + * @property {string} name - Description. + */ this.name = 'emitter' + this.game.particles.ID++; + /** + * @property {Description} type - Description. + */ this.type = Phaser.EMITTER; /** - * The X position of the top left corner of the emitter in world space. + * @property {number} x - The X position of the top left corner of the emitter in world space. + * @default */ this.x = 0; /** - * The Y position of the top left corner of emitter in world space. + * @property {number} y - The Y position of the top left corner of emitter in world space. + * @default */ this.y = 0; /** - * The width of the emitter. Particles can be randomly generated from anywhere within this box. + * @property {number} width - The width of the emitter. Particles can be randomly generated from anywhere within this box. + * @default */ this.width = 1; /** - * The height of the emitter. Particles can be randomly generated from anywhere within this box. - */ + * @property {number} height - The height of the emitter. Particles can be randomly generated from anywhere within this box. + * @default + */ this.height = 1; /** - * The minimum possible velocity of a particle. - * The default value is (-100,-100). - */ + * The minimum possible velocity of a particle. + * The default value is (-100,-100). + * @property {Phaser.Point} minParticleSpeed + */ this.minParticleSpeed = new Phaser.Point(-100, -100); /** - * The maximum possible velocity of a particle. - * The default value is (100,100). - */ + * The maximum possible velocity of a particle. + * The default value is (100,100). + * @property {Phaser.Point} maxParticleSpeed + */ this.maxParticleSpeed = new Phaser.Point(100, 100); /** - * The minimum possible scale of a particle. - * The default value is 1. - */ + * The minimum possible scale of a particle. + * The default value is 1. + * @property {number} minParticleScale + * @default + */ this.minParticleScale = 1; /** * The maximum possible scale of a particle. * The default value is 1. + * @property {number} maxParticleScale + * @default */ this.maxParticleScale = 1; /** * The minimum possible angular velocity of a particle. The default value is -360. + * @property {number} minRotation + * @default */ this.minRotation = -360; /** * The maximum possible angular velocity of a particle. The default value is 360. + * @property {number} maxRotation + * @default */ this.maxRotation = 360; /** * Sets the gravity.y of each particle to this value on launch. + * @property {number} gravity + * @default */ this.gravity = 2; /** * Set your own particle class type here. - * Default is Particle. + * @property {Description} particleClass + * @default */ this.particleClass = null; /** * The X and Y drag component of particles launched from the emitter. + * @property {Phaser.Point} particleDrag */ this.particleDrag = new Phaser.Point(); /** * The angular drag component of particles launched from the emitter if they are rotating. + * @property {number} angularDrag + * @default */ this.angularDrag = 0; /** * How often a particle is emitted in ms (if emitter is started with Explode == false). + * @property {boolean} frequency + * @default */ this.frequency = 100; - /** - * The total number of particles in this emitter. - */ - this.maxParticles = maxParticles; - /** * How long each particle lives once it is emitted in ms. Default is 2 seconds. * Set lifespan to 'zero' for particles to live forever. + * @property {number} lifespan + * @default */ this.lifespan = 2000; /** * How much each particle should bounce on each axis. 1 = full bounce, 0 = no bounce. + * @property {Phaser.Point} bounce */ this.bounce = new Phaser.Point(); /** * Internal helper for deciding how many particles to launch. + * @property {number} _quantity + * @private + * @default */ this._quantity = 0; /** * Internal helper for deciding when to launch particles or kill them. + * @property {number} _timer + * @private + * @default */ this._timer = 0; /** * Internal counter for figuring out how many particles to launch. + * @property {number} _counter + * @private + * @default */ this._counter = 0; /** * Internal helper for the style of particle emission (all at once, or one at a time). + * @property {boolean} _explode + * @private + * @default */ this._explode = true; /** * Determines whether the emitter is currently emitting particles. * It is totally safe to directly toggle this. + * @property {boolean} on + * @default */ this.on = false; /** * Determines whether the emitter is being updated by the core game loop. + * @property {boolean} exists + * @default */ this.exists = true; @@ -147,8 +207,16 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) { * The point the particles are emitted from. * Emitter.x and Emitter.y control the containers location, which updates all current particles * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. + * @property {boolean} emitX */ this.emitX = x; + + /** + * The point the particles are emitted from. + * Emitter.x and Emitter.y control the containers location, which updates all current particles + * Emitter.emitX and Emitter.emitY control the emission location relative to the x/y position. + * @property {boolean} emitY + */ this.emitY = y; }; @@ -157,8 +225,9 @@ Phaser.Particles.Arcade.Emitter.prototype = Object.create(Phaser.Group.prototype Phaser.Particles.Arcade.Emitter.prototype.constructor = Phaser.Particles.Arcade.Emitter; /** - * Called automatically by the game loop, decides when to launch particles and when to "die". - */ +* Called automatically by the game loop, decides when to launch particles and when to "die". +* @method Phaser.Particles.Arcade.Emitter#update +*/ Phaser.Particles.Arcade.Emitter.prototype.update = function () { if (this.on) @@ -200,15 +269,16 @@ Phaser.Particles.Arcade.Emitter.prototype.update = function () { } /** - * This function generates a new array of particle sprites to attach to the emitter. - * - * @param graphics If you opted to not pre-configure an array of Sprite objects, you can simply pass in a particle image or sprite sheet. - * @param quantity {number} The number of particles to generate when using the "create from image" option. - * @param multiple {boolean} Whether the image in the Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!). - * @param collide {number} Whether the particles should be flagged as not 'dead' (non-colliding particles are higher performance). 0 means no collisions, 0-1 controls scale of particle's bounding box. - * - * @return This Emitter instance (nice for chaining stuff together, if you're into that). - */ +* This function generates a new array of particle sprites to attach to the emitter. +* +* @method Phaser.Particles.Arcade.Emitter#makeParticles +* @param {Description} keys - Description. +* @param {number} frames - Description. +* @param {number} quantity - The number of particles to generate when using the "create from image" option. +* @param {number} collide - Description. +* @param {boolean} collideWorldBounds - Description. +* @return This Emitter instance (nice for chaining stuff together, if you're into that). +*/ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames, quantity, collide, collideWorldBounds) { if (typeof frames == 'undefined') @@ -278,6 +348,7 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames /** * Call this function to turn off all the particles and the emitter. + * @method Phaser.Particles.Arcade.Emitter#kill */ Phaser.Particles.Arcade.Emitter.prototype.kill = function () { @@ -290,6 +361,7 @@ Phaser.Particles.Arcade.Emitter.prototype.kill = function () { /** * Handy for bringing game objects "back to life". Just sets alive and exists back to true. * In practice, this is most often called by Object.reset(). + * @method Phaser.Particles.Arcade.Emitter#revive */ Phaser.Particles.Arcade.Emitter.prototype.revive = function () { @@ -300,11 +372,11 @@ Phaser.Particles.Arcade.Emitter.prototype.revive = function () { /** * Call this function to start emitting particles. - * - * @param explode {boolean} Whether the particles should all burst out at once. - * @param lifespan {number} How long each particle lives once emitted. 0 = forever. - * @param frequency {number} Ignored if Explode is set to true. Frequency is how often to emit a particle in ms. - * @param quantity {number} How many particles to launch. 0 = "all of the particles". + * @method Phaser.Particles.Arcade.Emitter#start + * @param {boolean} explode - Whether the particles should all burst out at once. + * @param {number} lifespan - How long each particle lives once emitted. 0 = forever. + * @param {number} frequency - Ignored if Explode is set to true. Frequency is how often to emit a particle in ms. + * @param {number} quantity - How many particles to launch. 0 = "all of the particles". */ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, frequency, quantity) { @@ -346,6 +418,7 @@ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, f /** * This function can be used both internally and externally to emit the next particle. + * @method Phaser.Particles.Arcade.Emitter#emitParticle */ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () { @@ -358,7 +431,7 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () { if (this.width > 1 || this.height > 1) { - particle.reset(this.emiteX - this.game.rnd.integerInRange(this.left, this.right), this.emiteY - this.game.rnd.integerInRange(this.top, this.bottom)); + particle.reset(this.game.rnd.integerInRange(this.left, this.right), this.game.rnd.integerInRange(this.top, this.bottom)); } else { @@ -411,11 +484,11 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () { } /** - * A more compact way of setting the width and height of the emitter. - * - * @param width {number} The desired width of the emitter (particles are spawned randomly within these dimensions). - * @param height {number} The desired height of the emitter. - */ +* A more compact way of setting the width and height of the emitter. +* @method Phaser.Particles.Arcade.Emitter#setSize +* @param {number} width - The desired width of the emitter (particles are spawned randomly within these dimensions). +* @param {number} height - The desired height of the emitter. +*/ Phaser.Particles.Arcade.Emitter.prototype.setSize = function (width, height) { this.width = width; @@ -424,11 +497,11 @@ Phaser.Particles.Arcade.Emitter.prototype.setSize = function (width, height) { } /** - * A more compact way of setting the X velocity range of the emitter. - * - * @param Min {number} The minimum value for this range. - * @param Max {number} The maximum value for this range. - */ +* A more compact way of setting the X velocity range of the emitter. +* @method Phaser.Particles.Arcade.Emitter#setXSpeed +* @param {number} min - The minimum value for this range. +* @param {number} max - The maximum value for this range. +*/ Phaser.Particles.Arcade.Emitter.prototype.setXSpeed = function (min, max) { min = min || 0; @@ -440,11 +513,11 @@ Phaser.Particles.Arcade.Emitter.prototype.setXSpeed = function (min, max) { } /** - * A more compact way of setting the Y velocity range of the emitter. - * - * @param Min {number} The minimum value for this range. - * @param Max {number} The maximum value for this range. - */ +* A more compact way of setting the Y velocity range of the emitter. +* @method Phaser.Particles.Arcade.Emitter#setYSpeed +* @param {number} min - The minimum value for this range. +* @param {number} max - The maximum value for this range. +*/ Phaser.Particles.Arcade.Emitter.prototype.setYSpeed = function (min, max) { min = min || 0; @@ -456,11 +529,11 @@ Phaser.Particles.Arcade.Emitter.prototype.setYSpeed = function (min, max) { } /** - * A more compact way of setting the angular velocity constraints of the emitter. - * - * @param Min {number} The minimum value for this range. - * @param Max {number} The maximum value for this range. - */ +* A more compact way of setting the angular velocity constraints of the emitter. +* @method Phaser.Particles.Arcade.Emitter#setRotation +* @param {number} min - The minimum value for this range. +* @param {number} max - The maximum value for this range. +*/ Phaser.Particles.Arcade.Emitter.prototype.setRotation = function (min, max) { min = min || 0; @@ -472,10 +545,10 @@ Phaser.Particles.Arcade.Emitter.prototype.setRotation = function (min, max) { } /** - * Change the emitter's midpoint to match the midpoint of a Object. - * - * @param Object {object} The Object that you want to sync up with. - */ +* Change the emitter's midpoint to match the midpoint of a Object. +* @method Phaser.Particles.Arcade.Emitter#at +* @param {object} object - The Object that you want to sync up with. +*/ Phaser.Particles.Arcade.Emitter.prototype.at = function (object) { this.emitX = object.center.x; @@ -483,42 +556,44 @@ Phaser.Particles.Arcade.Emitter.prototype.at = function (object) { } +/** +* The emitters alpha value. +* @name Phaser.Particles.Arcade.Emitter#alpha +* @property {number} alpha - Gets or sets the alpha value of the Emitter. +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "alpha", { - /** - * Get the emitter alpha. - */ get: function () { return this._container.alpha; }, - /** - * Set the emiter alpha value. - */ set: function (value) { this._container.alpha = value; } }); +/** +* The emitter visible state. +* @name Phaser.Particles.Arcade.Emitter#visible +* @property {boolean} visible - Gets or sets the Emitter visible state. +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "visible", { - /** - * Get the emitter visible state. - */ get: function () { return this._container.visible; }, - /** - * Set the emitter visible state. - */ set: function (value) { this._container.visible = value; } }); +/** +* @name Phaser.Particles.Arcade.Emitter#x +* @property {number} x - Gets or sets the x position of the Emitter. +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "x", { get: function () { @@ -531,6 +606,10 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "x", { }); +/** +* @name Phaser.Particles.Arcade.Emitter#y +* @property {number} y - Gets or sets the y position of the Emitter. +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "y", { get: function () { @@ -543,6 +622,11 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "y", { }); +/** +* @name Phaser.Particles.Arcade.Emitter#left +* @property {number} left - Gets the left position of the Emitter. +* @readonly +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "left", { get: function () { @@ -551,6 +635,11 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "left", { }); +/** +* @name Phaser.Particles.Arcade.Emitter#right +* @property {number} right - Gets the right position of the Emitter. +* @readonly +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "right", { get: function () { @@ -559,6 +648,11 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "right", { }); +/** +* @name Phaser.Particles.Arcade.Emitter#top +* @property {number} top - Gets the top position of the Emitter. +* @readonly +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "top", { get: function () { @@ -567,6 +661,11 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "top", { }); +/** +* @name Phaser.Particles.Arcade.Emitter#bottom +* @property {number} bottom - Gets the bottom position of the Emitter. +* @readonly +*/ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", { get: function () { diff --git a/src/physics/advanced/Body.js b/src/physics/advanced/Body.js deleted file mode 100644 index 03dbcba0..00000000 --- a/src/physics/advanced/Body.js +++ /dev/null @@ -1,402 +0,0 @@ -/* -* Copyright (c) 2012 Ju Hyung Lee -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software -* and associated documentation files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or -* substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -Body = function(type, pos, angle) { - if (Body.id_counter == undefined) { - Body.id_counter = 0; - } - - this.id = Body.id_counter++; - - // Identifier - this.name = "body" + this.id; - - // STATIC or DYNAMIC - this.type = type; - - // Default values - pos = pos || new vec2(0, 0); - angle = angle || 0; - - // Local to world transform - this.xf = new Transform(pos, angle); - - // Local center of mass - this.centroid = new vec2(0, 0); - - // World position of centroid - this.p = new vec2(pos.x, pos.y); - - // Velocity - this.v = new vec2(0, 0); - - // Force - this.f = new vec2(0, 0); - - // Orientation (angle) - this.a = angle; - - // Angular velocity - this.w = 0; - - // Torque - this.t = 0; - - // Linear damping - this.linearDamping = 0; - - // Angular damping - this.angularDamping = 0; - - // Sleep time - this.sleepTime = 0; - - // Awaked flag - this.awaked = false; - - // Shape list for this body - this.shapeArr = []; - - // Joint hash for this body - this.jointArr = []; - this.jointHash = {}; - - // Bounds of all shapes - this.bounds = new Bounds; - - this.fixedRotation = false; - - this.categoryBits = 0x0001; - this.maskBits = 0xFFFF; - - this.stepCount = 0; -} - -Body.STATIC = 0; -Body.KINETIC = 1; -Body.DYNAMIC = 2; - -Body.prototype.duplicate = function() { - var body = new Body(this.type, this.xf.t, this.a); - for (var i = 0; i < this.shapeArr.length; i++) { - body.addShape(this.shapeArr[i].duplicate()); - } - body.resetMassData(); - - return body; -} - -Body.prototype.serialize = function() { - var shapes = []; - for (var i = 0; i < this.shapeArr.length; i++) { - var obj = this.shapeArr[i].serialize(); - shapes.push(obj); - } - - return { - "type": ["static", "kinetic", "dynamic"][this.type], - "name": this.name, - "position": this.xf.t, - "angle": this.xf.a, - "shapes": shapes - }; -} - -Body.prototype.toString = function() { - return "[{Body (name=" + this.name + " velocity=" + this.v.toString() + " angularVelocity: " + this.w + ")}]"; -} - -Body.prototype.isStatic = function() { - return this.type == Body.STATIC ? true : false; -} - -Body.prototype.isDynamic = function() { - return this.type == Body.DYNAMIC ? true : false; -} - -Body.prototype.isKinetic = function() { - return this.type == Body.KINETIC ? true : false; -} - -Body.prototype.setType = function(type) { - if (type == this.type) { - return; - } - - this.f.set(0, 0); - this.v.set(0, 0); - this.t = 0; - this.w = 0; - this.type = type; - - this.awake(true); -} - -Body.prototype.addShape = function(shape) { - shape.body = this; - this.shapeArr.push(shape); -} - -Body.prototype.removeShape = function(shape) { - var index = this.shapeArr.indexOf(shape); - if (index != -1) { - this.shapeArr.splice(index, 1); - shape.body = undefined; - } -} - -// Internal function -Body.prototype.setMass = function(mass) { - this.m = mass; - this.m_inv = mass > 0 ? 1 / mass : 0; -} - -// Internal function -Body.prototype.setInertia = function(inertia) { - this.i = inertia; - this.i_inv = inertia > 0 ? 1 / inertia : 0; -} - -Body.prototype.setTransform = function(pos, angle) { - this.xf.set(pos, angle); - this.p = this.xf.transform(this.centroid); - this.a = angle; -} - -Body.prototype.syncTransform = function() { - this.xf.setRotation(this.a); - this.xf.setPosition(vec2.sub(this.p, this.xf.rotate(this.centroid))); -} - -Body.prototype.getWorldPoint = function(p) { - return this.xf.transform(p); -} - -Body.prototype.getWorldVector = function(v) { - return this.xf.rotate(v); -} - -Body.prototype.getLocalPoint = function(p) { - return this.xf.untransform(p); -} - -Body.prototype.getLocalVector = function(v) { - return this.xf.unrotate(v); -} - -Body.prototype.setFixedRotation = function(flag) { - this.fixedRotation = flag; - this.resetMassData(); -} - -Body.prototype.resetMassData = function() { - this.centroid.set(0, 0); - this.m = 0; - this.m_inv = 0; - this.i = 0; - this.i_inv = 0; - - if (!this.isDynamic()) { - this.p = this.xf.transform(this.centroid); - return; - } - - var totalMassCentroid = new vec2(0, 0); - var totalMass = 0; - var totalInertia = 0; - - for (var i = 0; i < this.shapeArr.length; i++) { - var shape = this.shapeArr[i]; - var centroid = shape.centroid(); - var mass = shape.area() * shape.density; - var inertia = shape.inertia(mass); - - totalMassCentroid.mad(centroid, mass); - totalMass += mass; - totalInertia += inertia; - } - - this.centroid.copy(vec2.scale(totalMassCentroid, 1 / totalMass)); - this.setMass(totalMass); - - if (!this.fixedRotation) { - this.setInertia(totalInertia - totalMass * vec2.dot(this.centroid, this.centroid)); - } - - // Move center of mass - var old_p = this.p; - this.p = this.xf.transform(this.centroid); - - // Update center of mass velocity ?? - this.v.mad(vec2.perp(vec2.sub(this.p, old_p)), this.w); -} - -Body.prototype.resetJointAnchors = function() { - for (var i = 0; i < this.jointArr.length; i++) { - var joint = this.jointArr[i]; - if (!joint) { - continue; - } - - var anchor1 = joint.getWorldAnchor1(); - var anchor2 = joint.getWorldAnchor2(); - - joint.setWorldAnchor1(anchor1); - joint.setWorldAnchor2(anchor2); - } -} - -Body.prototype.cacheData = function() { - - this.bounds.clear(); - - for (var i = 0; i < this.shapeArr.length; i++) { - var shape = this.shapeArr[i]; - shape.cacheData(this.xf); - this.bounds.addBounds(shape.bounds); - } - -} - -Body.prototype.updateVelocity = function(gravity, dt, damping) { - this.v = vec2.mad(this.v, vec2.mad(gravity, this.f, this.m_inv), dt); - this.w = this.w + this.t * this.i_inv * dt; - - // Apply damping. - // ODE: dv/dt + c * v = 0 - // Solution: v(t) = v0 * exp(-c * t) - // Time step: v(t + dt) = v0 * exp(-c * (t + dt)) = v0 * exp(-c * t) * exp(-c * dt) = v * exp(-c * dt) - // v2 = exp(-c * dt) * v1 - // Taylor expansion: - // v2 = (1.0f - c * dt) * v1 - this.v.scale(Math.clamp(1 - dt * (damping + this.linearDamping), 0, 1)); - this.w *= Math.clamp(1 - dt * (damping + this.angularDamping), 0, 1); - - this.f.set(0, 0); - this.t = 0; -} - -Body.prototype.updatePosition = function(dt) { - this.p.addself(vec2.scale(this.v, dt)); - this.a += this.w * dt; -} - -Body.prototype.resetForce = function() { - this.f.set(0, 0); - this.t = 0; -} - -Body.prototype.applyForce = function(force, p) { - if (!this.isDynamic()) - return; - - if (!this.isAwake()) - this.awake(true); - - this.f.addself(force); - this.t += vec2.cross(vec2.sub(p, this.p), force); -} - -Body.prototype.applyForceToCenter = function(force) { - if (!this.isDynamic()) - return; - - if (!this.isAwake()) - this.awake(true); - - this.f.addself(force); -} - -Body.prototype.applyTorque = function(torque) { - if (!this.isDynamic()) - return; - - if (!this.isAwake()) - this.awake(true); - - this.t += torque; -} - -Body.prototype.applyLinearImpulse = function(impulse, p) { - if (!this.isDynamic()) - return; - - if (!this.isAwake()) - this.awake(true); - - this.v.mad(impulse, this.m_inv); - this.w += vec2.cross(vec2.sub(p, this.p), impulse) * this.i_inv; -} - -Body.prototype.applyAngularImpulse = function(impulse) { - if (!this.isDynamic()) - return; - - if (!this.isAwake()) - this.awake(true); - - this.w += impulse * this.i_inv; -} - -Body.prototype.kineticEnergy = function() { - var vsq = this.v.dot(this.v); - var wsq = this.w * this.w; - return 0.5 * (this.m * vsq + this.i * wsq); -} - -Body.prototype.isAwake = function() { - return this.awaked; -} - -Body.prototype.awake = function(flag) { - this.awaked = flag; - if (flag) { - this.sleepTime = 0; - } - else { - this.v.set(0, 0); - this.w = 0; - this.f.set(0, 0); - this.t = 0; - } -} - -Body.prototype.isCollidable = function(other) { - if (this == other) - return false; - - if (!this.isDynamic() && !other.isDynamic()) - return false; - - if (!(this.maskBits & other.categoryBits) || !(other.maskBits & this.categoryBits)) - return false; - - for (var i = 0; i < this.jointArr.length; i++) { - var joint = this.jointArr[i]; - if (!joint) { - continue; - } - - if (!joint.collideConnected && other.jointHash[joint.id] != undefined) { - return false; - } - } - - return true; -} \ No newline at end of file diff --git a/src/physics/advanced/Collision.js b/src/physics/advanced/Collision.js deleted file mode 100644 index 848a07aa..00000000 --- a/src/physics/advanced/Collision.js +++ /dev/null @@ -1,382 +0,0 @@ -/* -* Copyright (c) 2012 Ju Hyung Lee -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software -* and associated documentation files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or -* substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -var collision = {}; - -(function() { - var colFuncs = []; - - function addCollideFunc(a, b, func) { - colFuncs[a * Shape.NUM_TYPES + b] = func; - } - - function _circle2Circle(c1, r1, c2, r2, contactArr) { - var rmax = r1 + r2; - var t = vec2.sub(c2, c1); - var distsq = t.lengthsq(); - - if (distsq > rmax * rmax) { - return 0; - } - - var dist = Math.sqrt(distsq); - - var p = vec2.mad(c1, t, 0.5 + (r1 - r2) * 0.5 / dist); - var n = (dist != 0) ? vec2.scale(t, 1 / dist) : vec2.zero; - var d = dist - rmax; - - contactArr.push(new Contact(p, n, d, 0)); - - return 1; - } - - function circle2Circle(circ1, circ2, contactArr) { - return _circle2Circle(circ1.tc, circ1.r, circ2.tc, circ2.r, contactArr); - } - - function circle2Segment(circ, seg, contactArr) { - var rsum = circ.r + seg.r; - - // Normal distance from segment - var dn = vec2.dot(circ.tc, seg.tn) - vec2.dot(seg.ta, seg.tn); - var dist = (dn < 0 ? dn * -1 : dn) - rsum; - if (dist > 0) { - return 0; - } - - // Tangential distance along segment - var dt = vec2.cross(circ.tc, seg.tn); - var dtMin = vec2.cross(seg.ta, seg.tn); - var dtMax = vec2.cross(seg.tb, seg.tn); - - if (dt < dtMin) { - if (dt < dtMin - rsum) { - return 0; - } - - return _circle2Circle(circ.tc, circ.r, seg.ta, seg.r, contactArr); - } - else if (dt > dtMax) { - if (dt > dtMax + rsum) { - return 0; - } - - return _circle2Circle(circ.tc, circ.r, seg.tb, seg.r, contactArr); - } - - var n = (dn > 0) ? seg.tn : vec2.neg(seg.tn); - - contactArr.push(new Contact(vec2.mad(circ.tc, n, -(circ.r + dist * 0.5)), vec2.neg(n), dist, 0)); - - return 1; - } - - function circle2Poly(circ, poly, contactArr) { - var minDist = -999999; - var minIdx = -1; - - for (var i = 0; i < poly.verts.length; i++) { - var plane = poly.tplanes[i]; - var dist = vec2.dot(circ.tc, plane.n) - plane.d - circ.r; - - if (dist > 0) { - return 0; - } - else if (dist > minDist) { - minDist = dist; - minIdx = i; - } - } - - var n = poly.tplanes[minIdx].n; - var a = poly.tverts[minIdx]; - var b = poly.tverts[(minIdx + 1) % poly.verts.length]; - var dta = vec2.cross(a, n); - var dtb = vec2.cross(b, n); - var dt = vec2.cross(circ.tc, n); - - if (dt > dta) { - return _circle2Circle(circ.tc, circ.r, a, 0, contactArr); - } - else if (dt < dtb) { - return _circle2Circle(circ.tc, circ.r, b, 0, contactArr); - } - - contactArr.push(new Contact(vec2.mad(circ.tc, n, -(circ.r + minDist * 0.5)), vec2.neg(n), minDist, 0)); - - return 1; - } - - function segmentPointDistanceSq(seg, p) { - var w = vec2.sub(p, seg.ta); - var d = vec2.sub(seg.tb, seg.ta); - - var proj = w.dot(d); - if (proj <= 0) { - return w.dot(w); - } - - var vsq = d.dot(d) - if (proj >= vsq) { - return w.dot(w) - 2 * proj + vsq; - } - - return w.dot(w) - proj * proj / vsq; - } - - // FIXME !! - function segment2Segment(seg1, seg2, contactArr) { - var d = []; - d[0] = segmentPointDistanceSq(seg1, seg2.ta); - d[1] = segmentPointDistanceSq(seg1, seg2.tb); - d[2] = segmentPointDistanceSq(seg2, seg1.ta); - d[3] = segmentPointDistanceSq(seg2, seg1.tb); - - var idx1 = d[0] < d[1] ? 0 : 1; - var idx2 = d[2] < d[3] ? 2 : 3; - var idxm = d[idx1] < d[idx2] ? idx1 : idx2; - var s, t; - - var u = vec2.sub(seg1.tb, seg1.ta); - var v = vec2.sub(seg2.tb, seg2.ta); - - switch (idxm) { - case 0: - s = vec2.dot(vec2.sub(seg2.ta, seg1.ta), u) / vec2.dot(u, u); - s = s < 0 ? 0 : (s > 1 ? 1 : s); - t = 0; - break; - case 1: - s = vec2.dot(vec2.sub(seg2.tb, seg1.ta), u) / vec2.dot(u, u); - s = s < 0 ? 0 : (s > 1 ? 1 : s); - t = 1; - break; - case 2: - s = 0; - t = vec2.dot(vec2.sub(seg1.ta, seg2.ta), v) / vec2.dot(v, v); - t = t < 0 ? 0 : (t > 1 ? 1 : t); - break; - case 3: - s = 1; - t = vec2.dot(vec2.sub(seg1.tb, seg2.ta), v) / vec2.dot(v, v); - t = t < 0 ? 0 : (t > 1 ? 1 : t); - break; - } - - var minp1 = vec2.mad(seg1.ta, u, s); - var minp2 = vec2.mad(seg2.ta, v, t); - - return _circle2Circle(minp1, seg1.r, minp2, seg2.r, contactArr); - } - - // Identify vertexes that have penetrated the segment. - function findPointsBehindSeg(contactArr, seg, poly, dist, coef) { - var dta = vec2.cross(seg.tn, seg.ta); - var dtb = vec2.cross(seg.tn, seg.tb); - var n = vec2.scale(seg.tn, coef); - - for (var i = 0; i < poly.verts.length; i++) { - var v = poly.tverts[i]; - if (vec2.dot(v, n) < vec2.dot(seg.tn, seg.ta) * coef + seg.r) { - var dt = vec2.cross(seg.tn, v); - if (dta >= dt && dt >= dtb) { - contactArr.push(new Contact(v, n, dist, (poly.id << 16) | i)); - } - } - } - } - - function segment2Poly(seg, poly, contactArr) { - var seg_td = vec2.dot(seg.tn, seg.ta); - var seg_d1 = poly.distanceOnPlane(seg.tn, seg_td) - seg.r; - if (seg_d1 > 0) { - return 0; - } - var seg_d2 = poly.distanceOnPlane(vec2.neg(seg.tn), -seg_td) - seg.r; - if (seg_d2 > 0) { - return 0; - } - - var poly_d = -999999; - var poly_i = -1; - - for (var i = 0; i < poly.verts.length; i++) { - var plane = poly.tplanes[i]; - var dist = seg.distanceOnPlane(plane.n, plane.d); - if (dist > 0) { - return 0; - } - - if (dist > poly_d) { - poly_d = dist; - poly_i = i; - } - } - - var poly_n = vec2.neg(poly.tplanes[poly_i].n); - var va = vec2.mad(seg.ta, poly_n, seg.r); - var vb = vec2.mad(seg.tb, poly_n, seg.r); - - if (poly.containPoint(va)) { - contactArr.push(new Contact(va, poly_n, poly_d, (seg.id << 16) | 0)); - } - - if (poly.containPoint(vb)) { - contactArr.push(new Contact(vb, poly_n, poly_d, (seg.id << 16) | 1)); - } - - // Floating point precision problems here. - // This will have to do for now. - poly_d -= 0.1 - if (seg_d1 >= poly_d || seg_d2 >= poly_d) { - if (seg_d1 > seg_d2) { - findPointsBehindSeg(contactArr, seg, poly, seg_d1, 1); - } - else { - findPointsBehindSeg(contactArr, seg, poly, seg_d2, -1); - } - } - - // If no other collision points are found, try colliding endpoints. - if (contactArr.length == 0) { - var poly_a = poly.tverts[poly_i]; - var poly_b = poly.tverts[(poly_i + 1) % poly.verts.length]; - - if (_circle2Circle(seg.ta, seg.r, poly_a, 0, contactArr)) - return 1; - - if (_circle2Circle(seg.tb, seg.r, poly_a, 0, contactArr)) - return 1; - - if (_circle2Circle(seg.ta, seg.r, poly_b, 0, contactArr)) - return 1; - - if (_circle2Circle(seg.tb, seg.r, poly_b, 0, contactArr)) - return 1; - } - - return contactArr.length; - } - - // Find the minimum separating axis for the given poly and plane list. - function findMSA(poly, planes, num) { - var min_dist = -999999; - var min_index = -1; - - for (var i = 0; i < num; i++) { - var dist = poly.distanceOnPlane(planes[i].n, planes[i].d); - if (dist > 0) { // no collision - return { dist: 0, index: -1 }; - } - else if (dist > min_dist) { - min_dist = dist; - min_index = i; - } - } - - return { dist: min_dist, index: min_index }; - } - - function findVertsFallback(contactArr, poly1, poly2, n, dist) { - var num = 0; - - for (var i = 0; i < poly1.verts.length; i++) { - var v = poly1.tverts[i]; - if (poly2.containPointPartial(v, n)) { - contactArr.push(new Contact(v, n, dist, (poly1.id << 16) | i)); - - num++; - } - } - - for (var i = 0; i < poly2.verts.length; i++) { - var v = poly2.tverts[i]; - if (poly1.containPointPartial(v, n)) { - contactArr.push(new Contact(v, n, dist, (poly2.id << 16) | i)); - - num++; - } - } - - return num; - } - - // Find the overlapped vertices. - function findVerts(contactArr, poly1, poly2, n, dist) { - var num = 0; - - for (var i = 0; i < poly1.verts.length; i++) { - var v = poly1.tverts[i]; - if (poly2.containPoint(v)) { - contactArr.push(new Contact(v, n, dist, (poly1.id << 16) | i)); - - num++; - } - } - - for (var i = 0; i < poly2.verts.length; i++) { - var v = poly2.tverts[i]; - if (poly1.containPoint(v)) { - contactArr.push(new Contact(v, n, dist, (poly2.id << 16) | i)); - - num++; - } - } - - return num > 0 ? num : findVertsFallback(contactArr, poly1, poly2, n, dist); - } - - function poly2Poly(poly1, poly2, contactArr) { - var msa1 = findMSA(poly2, poly1.tplanes, poly1.verts.length); - if (msa1.index == -1) { - return 0; - } - - var msa2 = findMSA(poly1, poly2.tplanes, poly2.verts.length); - if (msa2.index == -1) { - return 0; - } - - // Penetration normal direction shoud be from poly1 to poly2 - if (msa1.dist > msa2.dist) { - return findVerts(contactArr, poly1, poly2, poly1.tplanes[msa1.index].n, msa1.dist); - } - - return findVerts(contactArr, poly1, poly2, vec2.neg(poly2.tplanes[msa2.index].n), msa2.dist); - } - - collision.init = function() { - addCollideFunc(Shape.TYPE_CIRCLE, Shape.TYPE_CIRCLE, circle2Circle); - addCollideFunc(Shape.TYPE_CIRCLE, Shape.TYPE_SEGMENT, circle2Segment); - addCollideFunc(Shape.TYPE_CIRCLE, Shape.TYPE_POLY, circle2Poly); - addCollideFunc(Shape.TYPE_SEGMENT, Shape.TYPE_SEGMENT, segment2Segment); - addCollideFunc(Shape.TYPE_SEGMENT, Shape.TYPE_POLY, segment2Poly); - addCollideFunc(Shape.TYPE_POLY, Shape.TYPE_POLY, poly2Poly); - }; - - collision.collide = function(a, b, contactArr) { - if (a.type > b.type) { - var c = a; - a = b; - b = c; - } - - return colFuncs[a.type * Shape.NUM_TYPES + b.type](a, b, contactArr); - }; -})(); diff --git a/src/physics/advanced/Contact.js b/src/physics/advanced/Contact.js deleted file mode 100644 index f4ab7423..00000000 --- a/src/physics/advanced/Contact.js +++ /dev/null @@ -1,37 +0,0 @@ -/* -* Copyright (c) 2012 Ju Hyung Lee -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software -* and associated documentation files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or -* substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -function Contact(p, n, d, hash) { - this.hash = hash; - - // Contact point - this.p = p; - - // Contact normal (toward shape2) - this.n = n; - - // Penetration depth (d < 0) - this.d = d; - - // Accumulated normal constraint impulse - this.lambda_n_acc = 0; - - // Accumulated tangential constraint impulse - this.lambda_t_acc = 0; -} \ No newline at end of file diff --git a/src/physics/advanced/ContactSolver.js b/src/physics/advanced/ContactSolver.js deleted file mode 100644 index b5f2b31b..00000000 --- a/src/physics/advanced/ContactSolver.js +++ /dev/null @@ -1,267 +0,0 @@ -/* -* Copyright (c) 2012 Ju Hyung Lee -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software -* and associated documentation files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or -* substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -//------------------------------------------------------------------------------------------------- -// Contact Constraint -// -// Non-penetration constraint: -// C = dot(p2 - p1, n) -// Cdot = dot(v2 - v1, n) -// J = [ -n, -cross(r1, n), n, cross(r2, n) ] -// -// impulse = JT * lambda = [ -n * lambda, -cross(r1, n) * lambda, n * lambda, cross(r1, n) * lambda ] -// -// Friction constraint: -// C = dot(p2 - p1, t) -// Cdot = dot(v2 - v1, t) -// J = [ -t, -cross(r1, t), t, cross(r2, t) ] -// -// impulse = JT * lambda = [ -t * lambda, -cross(r1, t) * lambda, t * lambda, cross(r1, t) * lambda ] -// -// NOTE: lambda is an impulse in constraint space. -//------------------------------------------------------------------------------------------------- - -function ContactSolver(shape1, shape2) { - // Contact shapes - this.shape1 = shape1; - this.shape2 = shape2; - - // Contact list - this.contactArr = []; - - // Coefficient of restitution (elasticity) - this.e = 1; - - // Frictional coefficient - this.u = 1; -} - -ContactSolver.COLLISION_SLOP = 0.0008; -ContactSolver.BAUMGARTE = 0.28; -ContactSolver.MAX_LINEAR_CORRECTION = 1;//Infinity; - -ContactSolver.prototype.update = function(newContactArr) { - for (var i = 0; i < newContactArr.length; i++) { - var newContact = newContactArr[i]; - var k = -1; - for (var j = 0; j < this.contactArr.length; j++) { - if (newContact.hash == this.contactArr[j].hash) { - k = j; - break; - } - } - - if (k > -1) { - newContact.lambda_n_acc = this.contactArr[k].lambda_n_acc; - newContact.lambda_t_acc = this.contactArr[k].lambda_t_acc; - } - } - - this.contactArr = newContactArr; -} - -ContactSolver.prototype.initSolver = function(dt_inv) { - var body1 = this.shape1.body; - var body2 = this.shape2.body; - - var sum_m_inv = body1.m_inv + body2.m_inv; - - for (var i = 0; i < this.contactArr.length; i++) { - var con = this.contactArr[i]; - - // Transformed r1, r2 - con.r1 = vec2.sub(con.p, body1.p); - con.r2 = vec2.sub(con.p, body2.p); - - // Local r1, r2 - con.r1_local = body1.xf.unrotate(con.r1); - con.r2_local = body2.xf.unrotate(con.r2); - - var n = con.n; - var t = vec2.perp(con.n); - - // invEMn = J * invM * JT - // J = [ -n, -cross(r1, n), n, cross(r2, n) ] - var sn1 = vec2.cross(con.r1, n); - var sn2 = vec2.cross(con.r2, n); - var emn_inv = sum_m_inv + body1.i_inv * sn1 * sn1 + body2.i_inv * sn2 * sn2; - con.emn = emn_inv == 0 ? 0 : 1 / emn_inv; - - // invEMt = J * invM * JT - // J = [ -t, -cross(r1, t), t, cross(r2, t) ] - var st1 = vec2.cross(con.r1, t); - var st2 = vec2.cross(con.r2, t); - var emt_inv = sum_m_inv + body1.i_inv * st1 * st1 + body2.i_inv * st2 * st2; - con.emt = emt_inv == 0 ? 0 : 1 / emt_inv; - - // Linear velocities at contact point - // in 2D: cross(w, r) = perp(r) * w - var v1 = vec2.mad(body1.v, vec2.perp(con.r1), body1.w); - var v2 = vec2.mad(body2.v, vec2.perp(con.r2), body2.w); - - // relative velocity at contact point - var rv = vec2.sub(v2, v1); - - // bounce velocity dot n - con.bounce = vec2.dot(rv, con.n) * this.e; - } -} - -ContactSolver.prototype.warmStart = function() { - - var body1 = this.shape1.body; - var body2 = this.shape2.body; - - for (var i = 0; i < this.contactArr.length; i++) { - var con = this.contactArr[i]; - var n = con.n; - var lambda_n = con.lambda_n_acc; - var lambda_t = con.lambda_t_acc; - - // Apply accumulated impulses - //var impulse = vec2.rotate_vec(new vec2(lambda_n, lambda_t), n); - var impulse = new vec2(lambda_n * n.x - lambda_t * n.y, lambda_t * n.x + lambda_n * n.y); - - body1.v.mad(impulse, -body1.m_inv); - body1.w -= vec2.cross(con.r1, impulse) * body1.i_inv; - - body2.v.mad(impulse, body2.m_inv); - body2.w += vec2.cross(con.r2, impulse) * body2.i_inv; - } -} - -ContactSolver.prototype.solveVelocityConstraints = function() { - - var body1 = this.shape1.body; - var body2 = this.shape2.body; - - var m1_inv = body1.m_inv; - var i1_inv = body1.i_inv; - var m2_inv = body2.m_inv; - var i2_inv = body2.i_inv; - - for (var i = 0; i < this.contactArr.length; i++) { - - var con = this.contactArr[i]; - var n = con.n; - var t = vec2.perp(n); - var r1 = con.r1; - var r2 = con.r2; - - // Linear velocities at contact point - // in 2D: cross(w, r) = perp(r) * w - var v1 = vec2.mad(body1.v, vec2.perp(r1), body1.w); - var v2 = vec2.mad(body2.v, vec2.perp(r2), body2.w); - - // Relative velocity at contact point - var rv = vec2.sub(v2, v1); - - // Compute normal constraint impulse + adding bounce as a velocity bias - // lambda_n = -EMn * J * V - var lambda_n = -con.emn * (vec2.dot(n, rv) + con.bounce); - - // Accumulate and clamp - var lambda_n_old = con.lambda_n_acc; - con.lambda_n_acc = Math.max(lambda_n_old + lambda_n, 0); - lambda_n = con.lambda_n_acc - lambda_n_old; - - // Compute frictional constraint impulse - // lambda_t = -EMt * J * V - var lambda_t = -con.emt * vec2.dot(t, rv); - - // Max friction constraint impulse (Coulomb's Law) - var lambda_t_max = con.lambda_n_acc * this.u; - - // Accumulate and clamp - var lambda_t_old = con.lambda_t_acc; - con.lambda_t_acc = Math.clamp(lambda_t_old + lambda_t, -lambda_t_max, lambda_t_max); - lambda_t = con.lambda_t_acc - lambda_t_old; - - // Apply the final impulses - //var impulse = vec2.rotate_vec(new vec2(lambda_n, lambda_t), n); - var impulse = new vec2(lambda_n * n.x - lambda_t * n.y, lambda_t * n.x + lambda_n * n.y); - - body1.v.mad(impulse, -m1_inv); - body1.w -= vec2.cross(r1, impulse) * i1_inv; - - body2.v.mad(impulse, m2_inv); - body2.w += vec2.cross(r2, impulse) * i2_inv; - - } -} - -ContactSolver.prototype.solvePositionConstraints = function() { - - var body1 = this.shape1.body; - var body2 = this.shape2.body; - - var m1_inv = body1.m_inv; - var i1_inv = body1.i_inv; - var m2_inv = body2.m_inv; - var i2_inv = body2.i_inv; - var sum_m_inv = m1_inv + m2_inv; - - var max_penetration = 0; - - for (var i = 0; i < this.contactArr.length; i++) { - - var con = this.contactArr[i]; - var n = con.n; - - // Transformed r1, r2 - var r1 = vec2.rotate(con.r1_local, body1.a); - var r2 = vec2.rotate(con.r2_local, body2.a); - - // Contact points (corrected) - var p1 = vec2.add(body1.p, r1); - var p2 = vec2.add(body2.p, r2); - - // Corrected delta vector - var dp = vec2.sub(p2, p1); - - // Position constraint - var c = vec2.dot(dp, n) + con.d; - var correction = Math.clamp(ContactSolver.BAUMGARTE * (c + ContactSolver.COLLISION_SLOP), -ContactSolver.MAX_LINEAR_CORRECTION, 0); - - if (correction == 0) { - continue; - } - - // We don't need max_penetration less than or equal slop - max_penetration = Math.max(max_penetration, -c); - - // Compute lambda for position constraint - // Solve (J * invM * JT) * lambda = -C / dt - var sn1 = vec2.cross(r1, n); - var sn2 = vec2.cross(r2, n); - var em_inv = sum_m_inv + body1.i_inv * sn1 * sn1 + body2.i_inv * sn2 * sn2; - var lambda_dt = em_inv == 0 ? 0 : -correction / em_inv; - - // Apply correction impulses - var impulse_dt = vec2.scale(n, lambda_dt); - - body1.p.mad(impulse_dt, -m1_inv); - body1.a -= sn1 * lambda_dt * i1_inv; - - body2.p.mad(impulse_dt, m2_inv); - body2.a += sn2 * lambda_dt * i2_inv; - } - - return max_penetration <= ContactSolver.COLLISION_SLOP * 3; -} diff --git a/src/physics/advanced/Joint.js b/src/physics/advanced/Joint.js deleted file mode 100644 index 1dc01968..00000000 --- a/src/physics/advanced/Joint.js +++ /dev/null @@ -1,76 +0,0 @@ -/* -* Copyright (c) 2012 Ju Hyung Lee -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software -* and associated documentation files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or -* substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -Joint = function(type, body1, body2, collideConnected) { - if (arguments.length == 0) - return; - - if (Joint.id_counter == undefined) - Joint.id_counter = 0; - - this.id = Joint.id_counter++; - this.type = type; - - this.body1 = body1; - this.body2 = body2; - - // Allow collision between to cennected body - this.collideConnected = collideConnected; - - // Constraint force limit - this.maxForce = 9999999999; - - // Is breakable ? - this.breakable = false; -} - -Joint.TYPE_ANGLE = 0; -Joint.TYPE_REVOLUTE = 1; -Joint.TYPE_WELD = 2; -Joint.TYPE_WHEEL = 3; -Joint.TYPE_PRISMATIC = 4; -Joint.TYPE_DISTANCE = 5; -Joint.TYPE_ROPE = 6; -Joint.TYPE_MOUSE = 7; - -Joint.LINEAR_SLOP = 0.0008; -Joint.ANGULAR_SLOP = deg2rad(2); -Joint.MAX_LINEAR_CORRECTION = 0.5; -Joint.MAX_ANGULAR_CORRECTION = deg2rad(8); - -Joint.LIMIT_STATE_INACTIVE = 0; -Joint.LIMIT_STATE_AT_LOWER = 1; -Joint.LIMIT_STATE_AT_UPPER = 2; -Joint.LIMIT_STATE_EQUAL_LIMITS = 3; - -Joint.prototype.getWorldAnchor1 = function() { - return this.body1.getWorldPoint(this.anchor1); -} - -Joint.prototype.getWorldAnchor2 = function() { - return this.body2.getWorldPoint(this.anchor2); -} - -Joint.prototype.setWorldAnchor1 = function(anchor1) { - this.anchor1 = this.body1.getLocalPoint(anchor1); -} - -Joint.prototype.setWorldAnchor2 = function(anchor2) { - this.anchor2 = this.body2.getLocalPoint(anchor2); -} \ No newline at end of file diff --git a/src/physics/advanced/Math.js b/src/physics/advanced/Math.js deleted file mode 100644 index b144f8b0..00000000 --- a/src/physics/advanced/Math.js +++ /dev/null @@ -1,817 +0,0 @@ -/* -* Copyright (c) 2012 Ju Hyung Lee -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software -* and associated documentation files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or -* substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -Math.clamp = function(v, min, max) { return v < min ? min : (v > max ? max : v); } -Math.log2 = function(a) { return Math.log(a) / Math.log(2); } - -function deg2rad(deg) { return (deg / 180) * Math.PI; } -function rad2deg(rad) { return (rad / Math.PI) * 180; } - -function pixel2meter(px) { return px * 0.02; } -function meter2pixel(mt) { return mt * 50; } - -//----------------------------------- -// 2D Vector -//----------------------------------- - -function vec2(x, y) { - this.x = x || 0; - this.y = y || 0; -} - -vec2.zero = new vec2(0, 0); - -vec2.prototype.toString = function() { - //return ["x:", this.x, "y:", this.y].join(" "); - return "x=" + this.x + " y=" + this.y; -} - -vec2.prototype.set = function(x, y) { - this.x = x; - this.y = y; - - return this; -} - -vec2.prototype.copy = function(v) { - this.x = v.x; - this.y = v.y; - - return this; -} - -vec2.prototype.duplicate = function() { - return new vec2(this.x, this.y); -} - -vec2.prototype.equal = function(v) { - return (this.x != v.x || this.y != v.y) ? false : true; -} - -vec2.prototype.add = function(v1, v2) { - this.x = v1.x + v2.x; - this.y = v1.y + v2.y; - - return this; -} - -vec2.prototype.addself = function(v) { - this.x += v.x; - this.y += v.y; - - return this; -} - -vec2.prototype.sub = function(v1, v2) { - this.x = v1.x - v2.x; - this.y = v1.y - v2.y; - - return this; -} - -vec2.prototype.subself = function(v) { - this.x -= v.x; - this.y -= v.y; - - return this; -} - -vec2.prototype.scale = function(s) { - this.x *= s; - this.y *= s; - - return this; -} - -vec2.prototype.scale2 = function(s) { - this.x *= s.x; - this.y *= s.y; - - return this; -} - -vec2.prototype.mad = function(v, s) { - this.x += v.x * s; - this.y += v.y * s; -} - -vec2.prototype.neg = function() { - this.x *= -1; - this.y *= -1; - - return this; -} - -vec2.prototype.rcp = function() { - this.x = 1 / this.x; - this.y = 1 / this.y; - - return this; -} - -vec2.prototype.lengthsq = function() { - return this.x * this.x + this.y * this.y; -} - -vec2.prototype.length = function() { - return Math.sqrt(this.x * this.x + this.y * this.y); -} - -vec2.prototype.normalize = function() { - var inv = (this.x != 0 || this.y != 0) ? 1 / Math.sqrt(this.x * this.x + this.y * this.y) : 0; - this.x *= inv; - this.y *= inv; - - return this; -} - -vec2.prototype.dot = function(v) { - return this.x * v.x + this.y * v.y; -} - -// Z-component of 3d cross product (ax, ay, 0) x (bx, by, 0) -vec2.prototype.cross = function(v) { - return this.x * v.y - this.y * v.x; -} - -vec2.prototype.toAngle = function() { - return Math.atan2(this.y, this.x); -} - -vec2.prototype.rotation = function(angle) { - this.x = Math.cos(angle); - this.y = Math.sin(angle); - return this; -} - -vec2.prototype.rotate = function(angle) { - var c = Math.cos(angle); - var s = Math.sin(angle); - return this.set(this.x * c - this.y * s, this.x * s + this.y * c); -} - -vec2.prototype.lerp = function(v1, v2, t) { - return this.add(vec2.scale(v1, 1 - t), vec2.scale(v2, t)); -} - -vec2.add = function(v1, v2) { - return new vec2(v1.x + v2.x, v1.y + v2.y); -} - -vec2.sub = function(v1, v2) { - return new vec2(v1.x - v2.x, v1.y - v2.y); -} - -vec2.scale = function(v, s) { - return new vec2(v.x * s, v.y * s); -} - -vec2.scale2 = function(v, s) { - return new vec2(v.x * s.x, v.y * s.y); -} - -vec2.mad = function(v1, v2, s) { - return new vec2(v1.x + v2.x * s, v1.y + v2.y * s); -} - -vec2.neg = function(v) { - return new vec2(-v.x, -v.y); -} - -vec2.rcp = function(v) { - return new vec2(1 / v.x, 1 / v.y); -} - -vec2.normalize = function(v) { - var inv = (v.x != 0 || v.y != 0) ? 1 / Math.sqrt(v.x * v.x + v.y * v.y) : 0; - return new vec2(v.x * inv, v.y * inv); -} - -vec2.dot = function(v1, v2) { - return v1.x * v2.x + v1.y * v2.y; -} - -vec2.cross = function(v1, v2) { - return v1.x * v2.y - v1.y * v2.x; -} - -vec2.toAngle = function(v) { - return Math.atan2(v.y, v.x); -} - -vec2.rotation = function(angle) { - return new vec2(Math.cos(angle), Math.sin(angle)); -} - -vec2.rotate = function(v, angle) { - var c = Math.cos(angle); - var s = Math.sin(angle); - return new vec2(v.x * c - v.y * s, v.x * s + v.y * c); -} - -// Return perpendicular vector (90 degree rotation) -vec2.perp = function(v) { - return new vec2(-v.y, v.x); -} - -// Return perpendicular vector (-90 degree rotation) -vec2.rperp = function(v) { - return new vec2(v.y, -v.x); -} - -vec2.dist = function(v1, v2) { - var dx = v2.x - v1.x; - var dy = v2.y - v1.y; - return Math.sqrt(dx * dx + dy * dy); -} - -vec2.distsq = function(v1, v2) { - var dx = v2.x - v1.x; - var dy = v2.y - v1.y; - return dx * dx + dy * dy; -} - -vec2.lerp = function(v1, v2, t) { - return vec2.add(vec2.scale(v1, 1 - t), vec2.scale(v2, t)); -} - -vec2.truncate = function(v, length) { - var ret = v.duplicate(); - var length_sq = v.x * v.x + v.y * v.y; - if (length_sq > length * length) { - ret.scale(length / Math.sqrt(length_sq)); - } - - return ret; -} - -//----------------------------------- -// 3D Vector -//----------------------------------- - -function vec3(x, y, z) { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; -} - -vec3.zero = new vec3(0, 0, 0); - -vec3.prototype.toString = function() { - return ["x:", this.x, "y:", this.y, "z:", this.z].join(" "); -} - -vec3.prototype.set = function(x, y, z) { - this.x = x; - this.y = y; - this.z = z; - - return this; -} - -vec3.prototype.copy = function(v) { - this.x = v.x; - this.y = v.y; - this.z = v.z; - - return this; -} - -vec3.prototype.duplicate = function() { - return new vec3(this.x, this.y, this.z); -} - -vec3.prototype.equal = function(v) { - return this.x != v.x || this.y != v.y || this.z != v.z ? false : true; -} - -vec3.prototype.add = function(v1, v2) { - this.x = v1.x + v2.x; - this.y = v1.y + v2.y; - this.z = v1.z + v2.z; - - return this; -} - -vec3.prototype.addself = function(v) { - this.x += v.x; - this.y += v.y; - this.z += v.z; - - return this; -} - -vec3.prototype.sub = function(v1, v2) { - this.x = v1.x - v2.x; - this.y = v1.y - v2.y; - this.z = v1.z - v2.z; - - return this; -} - -vec3.prototype.subself = function(v) { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; - - return this; -} - -vec3.prototype.scale = function(s) { - this.x *= s; - this.y *= s; - this.z *= s; - - return this; -} - -vec3.prototype.mad = function(v, s) { - this.x += v.x * s; - this.y += v.y * s; - this.z += v.z * s; -} - -vec3.prototype.neg = function() { - this.x *= -1; - this.y *= -1; - this.z *= -1; - - return this; -} - -vec3.prototype.rcp = function() { - this.x = 1 / this.x; - this.y = 1 / this.y; - this.z = 1 / this.z; - - return this; -} - -vec3.prototype.lengthsq = function() { - return this.x * this.x + this.y * this.y + this.z * this.z; -} - -vec3.prototype.length = function() { - return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); -} - -vec3.prototype.normalize = function() { - var inv = (this.x != 0 || this.y != 0 || this.z != 0) ? 1 / Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z) : 0; - this.x *= inv; - this.y *= inv; - this.z *= inv; - - return this; -} - -vec3.prototype.dot = function(v) { - return this.x * v.x + this.y * v.y + this.z * v.z; -} - -vec3.prototype.toVec2 = function() { - return new vec2(this.x, this.y); -} - -vec3.fromVec2 = function(v, z) { - return new vec3(v.x, v.y, z); -} - -vec3.truncate = function(v, length) { - var ret = v.duplicate(); - var length_sq = v.x * v.x + v.y * v.y + v.z * v.z; - if (length_sq > length * length) { - ret.scale(length / Math.sqrt(length_sq)); - } - - return ret; -} - -//----------------------------------- -// 2x2 Matrix (row major) -//----------------------------------- - -function mat2(_11, _12, _21, _22) { - this._11 = _11 || 0; - this._12 = _12 || 0; - this._21 = _21 || 0; - this._22 = _22 || 0; -} - -mat2.zero = new mat2(0, 0, 0, 0); - -mat2.prototype.toString = function() { - return ["[", this._11, this._12, this_21, this._22, "]"].join(" "); -} - -mat2.prototype.set = function(_11, _12, _21, _22) { - this._11 = _11; - this._12 = _12; - this._21 = _21; - this._22 = _22; - - return this; -} - -mat2.prototype.copy = function(m) { - this._11 = m._11; - this._12 = m._12; - this._21 = m._21; - this._22 = m._22; - - return this; -} - -mat2.prototype.duplicate = function() { - return new mat2(this._11, this._12, this._21, this._22); -} - -mat2.prototype.scale = function(s) { - this._11 *= s; - this._12 *= s; - this._21 *= s; - this._22 *= s; - - return this; -} - -mat2.prototype.mul = function(m) { - return this.set( - this._11 * m2._11 + this._12 * m2._21, - this._11 * m2._12 + this._12 * m2._22, - this._21 * m2._11 + this._22 * m2._21, - this._21 * m2._12 + this._22 * m2._22); -} - -mat2.prototype.mulvec = function(v) { - return new vec2( - this._11 * v.x + this._12 * v.y, - this._21 * v.x + this._22 * v.y); -} - -mat2.prototype.invert = function() { - var det = this._11 * this._22 - this._12 * this._21; - if (det != 0) - det = 1 / det; - - return this.set( - this._22 * det, -this._12 * det, - -this._21 * det, this._11 * det); -} - -// Solve A * x = b -mat2.prototype.solve = function(b) { - var det = this._11 * this._22 - this._12 * this._21; - if (det != 0) - det = 1 / det; - - return new vec2( - det * (this._22 * b.x - this._12 * b.y), - det * (this._11 * b.y - this._21 * b.x)); -} - -mat2.mul = function(m1, m2) { - return new mat2( - m1._11 * m2._11 + m1._12 * m2._21, - m1._11 * m2._12 + m1._12 * m2._22, - m1._21 * m2._11 + m1._22 * m2._21, - m1._21 * m2._12 + m1._22 * m2._22); -} - -//----------------------------------- -// 3x3 Matrix (row major) -//----------------------------------- - -function mat3(_11, _12, _13, _21, _22, _23, _31, _32, _33) { - this._11 = _11 || 0; - this._12 = _12 || 0; - this._13 = _13 || 0; - this._21 = _21 || 0; - this._22 = _22 || 0; - this._23 = _23 || 0; - this._31 = _31 || 0; - this._32 = _32 || 0; - this._33 = _33 || 0; -} - -mat3.zero = new mat3(0, 0, 0, 0, 0, 0, 0, 0, 0); - -mat3.prototype.toString = function() { - return ["[", this._11, this._12, this._13, this_21, this._22, this._23, this._31, this._32, this._33, "]"].join(" "); -} - -mat3.prototype.set = function(_11, _12, _13, _21, _22, _23, _31, _32, _33) { - this._11 = _11; - this._12 = _12; - this._13 = _13; - this._21 = _21; - this._22 = _22; - this._23 = _23; - this._31 = _31; - this._32 = _32; - this._33 = _33; - - return this; -} - -mat3.prototype.copy = function(m) { - this._11 = m._11; - this._12 = m._12; - this._13 = m._13; - this._21 = m._21; - this._22 = m._22; - this._23 = m._23; - this._31 = m._31; - this._32 = m._32; - this._33 = m._33; - - return this; -} - -mat3.prototype.duplicate = function() { - return new mat3(this._11, this._12, this._13, this._21, this._22, this._23, this._31, this._32, this._33); -} - -mat3.prototype.scale = function(s) { - this._11 *= s; - this._12 *= s; - this._13 *= s; - this._21 *= s; - this._22 *= s; - this._23 *= s; - this._31 *= s; - this._32 *= s; - this._33 *= s; - - return this; -} - -mat3.prototype.mul = function(m) { - return this.set( - this._11 * m2._11 + this._12 * m2._21 + this._13 * m2._31, - this._11 * m2._12 + this._12 * m2._22 + this._13 * m2._32, - this._11 * m2._13 + this._12 * m2._23 + this._13 * m2._33, - this._21 * m2._11 + this._22 * m2._21 + this._23 * m2._31, - this._21 * m2._12 + this._22 * m2._22 + this._23 * m2._32, - this._21 * m2._13 + this._22 * m2._23 + this._23 * m2._33, - this._31 * m2._11 + this._32 * m2._21 + this._33 * m2._31, - this._31 * m2._12 + this._32 * m2._22 + this._33 * m2._32, - this._31 * m2._13 + this._32 * m2._23 + this._33 * m2._33); -} - -mat3.prototype.mulvec = function(v) { - return new vec2( - this._11 * v.x + this._12 * v.y + this._13 * v.z, - this._21 * v.x + this._22 * v.y + this._23 * v.z, - this._31 * v.x + this._32 * v.y + this._33 * v.z); -} - -mat3.prototype.invert = function() { - var det2_11 = this._22 * this._33 - this._23 * this._32; - var det2_12 = this._23 * this._31 - this._21 * this._33; - var det2_13 = this._21 * this._32 - this._22 * this._31; - - var det = this._11 * det2_11 + this._12 * det2_12 + this._13 * det2_13; - if (det != 0) - det = 1 / det; - - var det2_21 = this._13 * this._32 - this._12 * this._33; - var det2_22 = this._11 * this._33 - this._13 * this._31; - var det2_23 = this._12 * this._31 - this._11 * this._32; - var det2_31 = this._12 * this._23 - this._13 * this._22; - var det2_32 = this._13 * this._21 - this._11 * this._23; - var det2_33 = this._11 * this._22 - this._12 * this._21; - - return this.set( - det2_11 * det, det2_12 * det, det2_13 * det, - det2_21 * det, det2_22 * det, det2_23 * det, - det2_31 * det, det2_32 * det, det2_33 * det); -} - -// Solve A(2x2) * x = b -mat3.prototype.solve2x2 = function(b) { - var det = this._11 * this._22 - this._12 * this._21; - if (det != 0) - det = 1 / det; - - return new vec2( - det * (this._22 * b.x - this._12 * b.y), - det * (this._11 * b.y - this._21 * b.x)); -} - -// Solve A(3x3) * x = b -mat3.prototype.solve = function(b) { - var det2_11 = this._22 * this._33 - this._23 * this._32; - var det2_12 = this._23 * this._31 - this._21 * this._33; - var det2_13 = this._21 * this._32 - this._22 * this._31; - - var det = this._11 * det2_11 + this._12 * det2_12 + this._13 * det2_13; - if (det != 0) - det = 1 / det; - - var det2_21 = this._13 * this._32 - this._12 * this._33; - var det2_22 = this._11 * this._33 - this._13 * this._31; - var det2_23 = this._12 * this._31 - this._11 * this._32; - var det2_31 = this._12 * this._23 - this._13 * this._22; - var det2_32 = this._13 * this._21 - this._11 * this._23; - var det2_33 = this._11 * this._22 - this._12 * this._21; - - return new vec3( - det * (det2_11 * b.x + det2_12 * b.y + det2_13 * b.z), - det * (det2_21 * b.x + det2_22 * b.y + det2_23 * b.z), - det * (det2_31 * b.x + det2_32 * b.y + det2_33 * b.z)); -} - -mat3.mul = function(m1, m2) { - return new mat3( - m1._11 * m2._11 + m1._12 * m2._21 + m1._13 * m2._31, - m1._11 * m2._12 + m1._12 * m2._22 + m1._13 * m2._32, - m1._11 * m2._13 + m1._12 * m2._23 + m1._13 * m2._33, - m1._21 * m2._11 + m1._22 * m2._21 + m1._23 * m2._31, - m1._21 * m2._12 + m1._22 * m2._22 + m1._23 * m2._32, - m1._21 * m2._13 + m1._22 * m2._23 + m1._23 * m2._33, - m1._31 * m2._11 + m1._32 * m2._21 + m1._33 * m2._31, - m1._31 * m2._12 + m1._32 * m2._22 + m1._33 * m2._32, - m1._31 * m2._13 + m1._32 * m2._23 + m1._33 * m2._33); -} - -//----------------------------------- -// 2D Transform -//----------------------------------- - -Transform = function(pos, angle) { - this.t = pos.duplicate(); - this.c = Math.cos(angle); - this.s = Math.sin(angle); - this.a = angle; -} - -Transform.prototype.toString = function() { - return 't=' + this.t.toString() + ' c=' + this.c + ' s=' + this.s + ' a=' + this.a; -} - -Transform.prototype.set = function(pos, angle) { - this.t.copy(pos); - this.c = Math.cos(angle); - this.s = Math.sin(angle); - this.a = angle; - return this; -} - -Transform.prototype.setRotation = function(angle) { - this.c = Math.cos(angle); - this.s = Math.sin(angle); - this.a = angle; - return this; -} - -Transform.prototype.setPosition = function(p) { - this.t.copy(p); - return this; -} - -Transform.prototype.identity = function() { - this.t.set(0, 0); - this.c = 1; - this.s = 0; - this.a = 0; - return this; -} - -Transform.prototype.rotate = function(v) { - return new vec2(v.x * this.c - v.y * this.s, v.x * this.s + v.y * this.c); -} - -Transform.prototype.unrotate = function(v) { - return new vec2(v.x * this.c + v.y * this.s, -v.x * this.s + v.y * this.c); -} - -Transform.prototype.transform = function(v) { - return new vec2(v.x * this.c - v.y * this.s + this.t.x, v.x * this.s + v.y * this.c + this.t.y); -} - -Transform.prototype.untransform = function(v) { - var px = v.x - this.t.x; - var py = v.y - this.t.y; - return new vec2(px * this.c + py * this.s, -px * this.s + py * this.c); -} - -//----------------------------------- -// 2D AABB -//----------------------------------- - -Bounds = function(mins, maxs) { - this.mins = mins ? new vec2(mins.x, mins.y) : new vec2(999999, 999999); - this.maxs = maxs ? new vec2(maxs.x, maxs.y) : new vec2(-999999, -999999); -} - -Bounds.prototype.toString = function() { - return ["mins:", this.mins.toString(), "maxs:", this.maxs.toString()].join(" "); -} - -Bounds.prototype.set = function(mins, maxs) { - this.mins.set(mins.x, mins.y); - this.maxs.set(maxs.x, maxs.y); -} - -Bounds.prototype.copy = function(b) { - this.mins.copy(b.mins); - this.maxs.copy(b.maxs); - return this; -} - -Bounds.prototype.clear = function() { - this.mins.set(999999, 999999); - this.maxs.set(-999999, -999999); - return this; -} - -Bounds.prototype.isEmpty = function() { - if (this.mins.x > this.maxs.x || this.mins.y > this.maxs.y) - return true; -} - -Bounds.prototype.getCenter = function() { - return vec2.scale(vec2.add(this.mins, this.maxs), 0.5); -} - -Bounds.prototype.getExtent = function() { - return vec2.scale(vec2.sub(this.maxs, this.mins), 0.5); -} - -Bounds.prototype.getPerimeter = function() { - return (maxs.x - mins.x + maxs.y - mins.y) * 2; -} - -Bounds.prototype.addPoint = function(p) { - if (this.mins.x > p.x) this.mins.x = p.x; - if (this.maxs.x < p.x) this.maxs.x = p.x; - if (this.mins.y > p.y) this.mins.y = p.y; - if (this.maxs.y < p.y) this.maxs.y = p.y; - return this; -} - -Bounds.prototype.addBounds = function(b) { - if (this.mins.x > b.mins.x) this.mins.x = b.mins.x; - if (this.maxs.x < b.maxs.x) this.maxs.x = b.maxs.x; - if (this.mins.y > b.mins.y) this.mins.y = b.mins.y; - if (this.maxs.y < b.maxs.y) this.maxs.y = b.maxs.y; - return this; -} - -Bounds.prototype.addBounds2 = function(mins, maxs) { - if (this.mins.x > mins.x) this.mins.x = mins.x; - if (this.maxs.x < maxs.x) this.maxs.x = maxs.x; - if (this.mins.y > mins.y) this.mins.y = mins.y; - if (this.maxs.y < maxs.y) this.maxs.y = maxs.y; - return this; -} - -Bounds.prototype.addExtents = function(center, extent_x, extent_y) { - if (this.mins.x > center.x - extent_x) this.mins.x = center.x - extent_x; - if (this.maxs.x < center.x + extent_x) this.maxs.x = center.x + extent_x; - if (this.mins.y > center.y - extent_y) this.mins.y = center.y - extent_y; - if (this.maxs.y < center.y + extent_y) this.maxs.y = center.y + extent_y; - return this; -} - -Bounds.prototype.expand = function(ax, ay) { - this.mins.x -= ax; - this.mins.y -= ay; - this.maxs.x += ax; - this.maxs.y += ay; - return this; -} - -Bounds.prototype.containPoint = function(p) { - if (p.x < this.mins.x || p.x > this.maxs.x || p.y < this.mins.y || p.y > this.maxs.y) - return false; - return true; -} - -Bounds.prototype.intersectsBounds = function(b) { - if (this.mins.x > b.maxs.x || this.maxs.x < b.mins.x || this.mins.y > b.maxs.y || this.maxs.y < b.mins.y) - return false; - return true; -} - -Bounds.expand = function(b, ax, ay) { - var b = new Bounds(b.mins, b.maxs); - b.expand(ax, ay); - return b; -} \ No newline at end of file diff --git a/src/physics/advanced/Shape.js b/src/physics/advanced/Shape.js deleted file mode 100644 index 0e31f21f..00000000 --- a/src/physics/advanced/Shape.js +++ /dev/null @@ -1,47 +0,0 @@ -/* -* Copyright (c) 2012 Ju Hyung Lee -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software -* and associated documentation files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or -* substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -Shape = function(type) { - if (arguments.length == 0) - return; - - if (Shape.id_counter == undefined) - Shape.id_counter = 0; - - this.id = Shape.id_counter++; - this.type = type; - - // Coefficient of restitution (elasticity) - this.e = 0.0; - - // Frictional coefficient - this.u = 1.0; - - // Mass density - this.density = 1; - - // Axis-aligned bounding box - this.bounds = new Bounds; -} - -Shape.TYPE_CIRCLE = 0; -Shape.TYPE_SEGMENT = 1; -Shape.TYPE_POLY = 2; -Shape.NUM_TYPES = 3; - diff --git a/src/physics/advanced/Space.js b/src/physics/advanced/Space.js deleted file mode 100644 index e869af2e..00000000 --- a/src/physics/advanced/Space.js +++ /dev/null @@ -1,797 +0,0 @@ -/* -* Copyright (c) 2012 Ju Hyung Lee -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software -* and associated documentation files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or -* substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -function Space() { - this.bodyArr = []; - this.bodyHash = {}; - - this.jointArr = []; - this.jointHash = {}; - - this.numContacts = 0; - this.contactSolverArr = []; - - this.postSolve = function(arb) {}; - - this.gravity = new vec2(0, 0); - this.damping = 0; - - this.log = []; -} - -Space.TIME_TO_SLEEP = 0.5; -Space.SLEEP_LINEAR_TOLERANCE = 0.5; -Space.SLEEP_ANGULAR_TOLERANCE = deg2rad(2); - -Space.prototype.clear = function() { - Shape.id_counter = 0; - Body.id_counter = 0; - Joint.id_counter = 0; - - for (var i = 0; i < this.bodyArr.length; i++) { - if (this.bodyArr[i]) { - this.removeBody(this.bodyArr[i]); - } - } - - this.bodyArr = []; - this.bodyHash = {}; - - this.jointArr = []; - this.jointHash = {}; - - this.contactSolverArr = []; - - this.stepCount = 0; -} - -Space.prototype.toJSON = function(key) { - var o_bodies = []; - for (var i = 0; i < this.bodyArr.length; i++) { - if (this.bodyArr[i]) { - o_bodies.push(this.bodyArr[i].serialize()); - } - } - - var o_joints = []; - for (var i = 0; i < this.jointArr.length; i++) { - if (this.jointArr[i]) { - o_joints.push(this.jointHash[i].serialize()); - } - } - - return { - bodies: o_bodies, - joints: o_joints - }; -} - -Space.prototype.create = function(text) { - var config = JSON.parse(text); - - this.clear(); - - for (var i = 0; i < config.bodies.length; i++) { - var config_body = config.bodies[i]; - var type = {"static": Body.Static, "kinetic": Body.KINETIC, "dynamic": Body.DYNAMIC}[config_body.type]; - var body = new Body(type, config_body.position.x, config_body.position.y, config_body.angle); - - for (var j = 0; j < config_body.shapes.length; j++) { - var config_shape = config_body.shapes[j]; - var shape; - - switch (config_shape.type) { - case "ShapeCircle": - shape = new ShapeCircle(config_shape.center.x, config_shape.center.y, config_shape.radius); - break; - case "ShapeSegment": - shape = new ShapeSegment(config_shape.a, config_shape.b, config_shape.radius); - break; - case "ShapePoly": - shape = new ShapePoly(config_shape.verts); - break; - } - - shape.e = config_shape.e; - shape.u = config_shape.u; - shape.density = config_shape.density; - - body.addShape(shape); - } - - body.resetMassData(); - this.addBody(body); - } - - for (var i = 0; i < config.joints.length; i++) { - var config_joint = config.joints[i]; - var body1 = this.bodyArr[this.bodyHash[config_joint.body1]]; - var body2 = this.bodyArr[this.bodyHash[config_joint.body2]]; - var joint; - - switch (config_joint.type) { - case "AngleJoint": - joint = new AngleJoint(body1, body2); - break; - case "RevoluteJoint": - joint = new RevoluteJoint(body1, body2, config_joint.anchor); - joint.enableLimit(config_joint.limitEnabled); - joint.setLimits(config_joint.limitLowerAngle, config_joint.limitUpperAngle); - joint.enableMotor(config_joint.motorEnabled); - joint.setMotorSpeed(config_joint.motorSpeed); - joint.setMaxMotorTorque(config_joint.maxMotorTorque); - break; - case "WeldJoint": - joint = new WeldJoint(body1, body2, config_joint.anchor); - joint.setSpringFrequencyHz(config_joint.frequencyHz); - joint.setSpringDampingRatio(config_joint.dampingRatio); - break; - case "WheelJoint": - joint = new WheelJoint(body1, body2, config_joint.anchor1, config_joint.anchor2); - joint.enableMotor(config_joint.motorEnabled); - joint.setMotorSpeed(config_joint.motorSpeed); - joint.setMaxMotorTorque(config_joint.maxMotorTorque); - break; - case "PrismaticJoint": - joint = new PrismaticJoint(body1, body2, config_joint.anchor1, config_joint.anchor2); - break; - case "DistanceJoint": - joint = new DistanceJoint(body1, body2, config_joint.anchor1, config_joint.anchor2); - joint.setSpringFrequencyHz(config_joint.frequencyHz); - joint.setSpringDampingRatio(config_joint.dampingRatio); - break; - case "RopeJoint": - joint = new RopeJoint(body1, body2, config_joint.anchor1, config_joint.anchor2); - break; - } - - joint.collideConnected = config_joint.collideConnected; - joint.maxForce = config_joint.maxForce; - joint.breakable = config_joint.breakable; - - this.addJoint(joint); - } -} - -Space.prototype.addBody = function(body) { - if (this.bodyHash[body.id] != undefined) { - return; - } - - var index = this.bodyArr.push(body) - 1; - this.bodyHash[body.id] = index; - - body.awake(true); - body.space = this; - body.cacheData(); -} - -Space.prototype.removeBody = function(body) { - if (this.bodyHash[body.id] == undefined) { - return; - } - - // Remove linked joint - for (var i = 0; i < body.jointArr.length; i++) { - if (body.jointArr[i]) { - this.removeJoint(body.jointArr[i]); - } - } - - body.space = null; - - var index = this.bodyHash[body.id]; - delete this.bodyHash[body.id]; - delete this.bodyArr[index]; -} - -Space.prototype.addJoint = function(joint) { - if (this.jointHash[joint.id] != undefined) { - return; - } - - joint.body1.awake(true); - joint.body2.awake(true); - - var index = this.jointArr.push(joint) - 1; - this.jointHash[joint.id] = index; - - var index = joint.body1.jointArr.push(joint) - 1; - joint.body1.jointHash[joint.id] = index; - - var index = joint.body2.jointArr.push(joint) - 1; - joint.body2.jointHash[joint.id] = index; -} - -Space.prototype.removeJoint = function(joint) { - if (this.jointHash[joint.id] == undefined) { - return; - } - - joint.body1.awake(true); - joint.body2.awake(true); - - var index = joint.body1.jointHash[joint.id]; - delete joint.body1.jointHash[joint.id]; - delete joint.body1.jointArr[index]; - - var index = joint.body2.jointHash[joint.id]; - delete joint.body2.jointHash[joint.id]; - delete joint.body2.jointArr[index]; - - var index = this.jointHash[joint.id]; - delete this.jointHash[joint.id]; - delete this.jointArr[index]; -} - -Space.prototype.findShapeByPoint = function(p, refShape) { - var firstShape; - - for (var i = 0; i < this.bodyArr.length; i++) { - var body = this.bodyArr[i]; - if (!body) { - continue; - } - - for (var j = 0; j < body.shapeArr.length; j++) { - var shape = body.shapeArr[j]; - - if (shape.pointQuery(p)) { - if (!refShape) { - return shape; - } - - if (!firstShape) { - firstShape = shape; - } - - if (shape == refShape) { - refShape = null; - } - } - } - } - - return firstShape; -} - -Space.prototype.findBodyByPoint = function(p, refBody) { - var firstBody; - - for (var i = 0; i < this.bodyArr.length; i++) { - var body = this.bodyArr[i]; - if (!body) { - continue; - } - - for (var j = 0; j < body.shapeArr.length; j++) { - var shape = body.shapeArr[j]; - - if (shape.pointQuery(p)) { - if (!refBody) { - return shape.body; - } - - if (!firstBody) { - firstBody = shape.body; - } - - if (shape.body == refBody) { - refBody = null; - } - - break; - } - } - } - - return firstBody; -} - -// TODO: Replace this function to shape hashing -Space.prototype.shapeById = function(id) { - var shape; - for (var i = 0; i < this.bodyArr.length; i++) { - var body = this.bodyArr[i]; - if (!body) { - continue; - } - - for (var j = 0; j < body.shapeArr.length; j++) { - if (body.shapeArr[j].id == id) { - return body.shapeArr[j]; - } - } - } - - return null; -} - -Space.prototype.jointById = function(id) { - var index = this.jointHash[id]; - if (index != undefined) { - return this.jointArr[index]; - } - - return null; -} - -Space.prototype.findVertexByPoint = function(p, minDist, refVertexId) { - var firstVertexId = -1; - - refVertexId = refVertexId || -1; - - for (var i = 0; i < this.bodyArr.length; i++) { - var body = this.bodyArr[i]; - if (!body) { - continue; - } - - for (var j = 0; j < body.shapeArr.length; j++) { - var shape = body.shapeArr[j]; - var index = shape.findVertexByPoint(p, minDist); - if (index != -1) { - var vertex = (shape.id << 16) | index; - if (refVertexId == -1) { - return vertex; - } - - if (firstVertexId == -1) { - firstVertexId = vertex; - } - - if (vertex == refVertexId) { - refVertexId = -1; - } - } - } - } - - return firstVertexId; -} - -Space.prototype.findEdgeByPoint = function(p, minDist, refEdgeId) { - var firstEdgeId = -1; - - refEdgeId = refEdgeId || -1; - - for (var i = 0; i < this.bodyArr.length; i++) { - var body = this.bodyArr[i]; - if (!body) { - continue; - } - - for (var j = 0; j < body.shapeArr.length; j++) { - var shape = body.shapeArr[j]; - if (shape.type != Shape.TYPE_POLY) { - continue; - } - - var index = shape.findEdgeByPoint(p, minDist); - if (index != -1) { - var edge = (shape.id << 16) | index; - if (refEdgeId == -1) { - return edge; - } - - if (firstEdgeId == -1) { - firstEdgeId = edge; - } - - if (edge == refEdgeId) { - refEdgeId = -1; - } - } - } - } - - return firstEdgeId; -} - -Space.prototype.findJointByPoint = function(p, minDist, refJointId) { - var firstJointId = -1; - - var dsq = minDist * minDist; - - refJointId = refJointId || -1; - - for (var i = 0; i < this.jointArr.length; i++) { - var joint = this.jointArr[i]; - if (!joint) { - continue; - } - - var jointId = -1; - - if (vec2.distsq(p, joint.getWorldAnchor1()) < dsq) { - jointId = (joint.id << 16 | 0); - } - else if (vec2.distsq(p, joint.getWorldAnchor2()) < dsq) { - jointId = (joint.id << 16 | 1); - } - - if (jointId != -1) { - if (refJointId == -1) { - return jointId; - } - - if (firstJointId == -1) { - firstJointId = jointId; - } - - if (jointId == refJointId) { - refJointId = -1; - } - } - } - - return firstJointId; -} - -Space.prototype.findContactSolver = function(shape1, shape2) { - - for (var i = 0; i < this.contactSolverArr.length; i++) { - var contactSolver = this.contactSolverArr[i]; - if (shape1 == contactSolver.shape1 && shape2 == contactSolver.shape2) { - return contactSolver; - } - } - - return null; -} - -Space.dump = function (phase, body) { - - var s = "\n\nPhase: " + phase + "\n"; - s += "Position: " + body.p.toString() + "\n"; - s += "Velocity: " + body.v.toString() + "\n"; - s += "Angle: " + body.a + "\n"; - s += "Force: " + body.f.toString() + "\n"; - s += "Torque: " + body.t + "\n"; - s += "Bounds: " + body.bounds.toString() + "\n"; - s += "Shape ***\n"; - s += "Vert 0: " + body.shapeArr[0].verts[0].toString() + "\n"; - s += "Vert 1: " + body.shapeArr[0].verts[1].toString() + "\n"; - s += "Vert 2: " + body.shapeArr[0].verts[2].toString() + "\n"; - s += "Vert 3: " + body.shapeArr[0].verts[3].toString() + "\n"; - s += "TVert 0: " + body.shapeArr[0].tverts[0].toString() + "\n"; - s += "TVert 1: " + body.shapeArr[0].tverts[1].toString() + "\n"; - s += "TVert 2: " + body.shapeArr[0].tverts[2].toString() + "\n"; - s += "TVert 3: " + body.shapeArr[0].tverts[3].toString() + "\n"; - s += "Plane 0: " + body.shapeArr[0].planes[0].n.toString() + "\n"; - s += "Plane 1: " + body.shapeArr[0].planes[1].n.toString() + "\n"; - s += "Plane 2: " + body.shapeArr[0].planes[2].n.toString() + "\n"; - s += "Plane 3: " + body.shapeArr[0].planes[3].n.toString() + "\n"; - s += "TPlane 0: " + body.shapeArr[0].tplanes[0].n.toString() + "\n"; - s += "TPlane 1: " + body.shapeArr[0].tplanes[1].n.toString() + "\n"; - s += "TPlane 2: " + body.shapeArr[0].tplanes[2].n.toString() + "\n"; - s += "TPlane 3: " + body.shapeArr[0].tplanes[3].n.toString() + "\n"; - - this.log.push(s); - -} - -Space.prototype.genTemporalContactSolvers = function() { - - var t0 = Date.now(); - var newContactSolverArr = []; - - this.numContacts = 0; - - for (var body1_index = 0; body1_index < this.bodyArr.length; body1_index++) { - var body1 = this.bodyArr[body1_index]; - if (!body1) { - continue; - } - - body1.stepCount = this.stepCount; - - for (var body2_index = 0; body2_index < this.bodyArr.length; body2_index++) { - var body2 = this.bodyArr[body2_index]; - if (!body2) { - continue; - } - - if (body1.stepCount == body2.stepCount) { - continue; - } - - var active1 = body1.isAwake() && !body1.isStatic(); - var active2 = body2.isAwake() && !body2.isStatic(); - - if (!active1 && !active2) { - continue; - } - - if (!body1.isCollidable(body2)) { - continue; - } - - if (!body1.bounds.intersectsBounds(body2.bounds)) { - continue; - } - - for (var i = 0; i < body1.shapeArr.length; i++) { - for (var j = 0; j < body2.shapeArr.length; j++) { - var shape1 = body1.shapeArr[i]; - var shape2 = body2.shapeArr[j]; - - var contactArr = []; - if (!collision.collide(shape1, shape2, contactArr)) { - continue; - } - - if (shape1.type > shape2.type) { - var temp = shape1; - shape1 = shape2; - shape2 = temp; - } - - this.numContacts += contactArr.length; - - var contactSolver = this.findContactSolver(shape1, shape2); - - if (contactSolver) { - contactSolver.update(contactArr); - newContactSolverArr.push(contactSolver); - } - else { - body1.awake(true); - body2.awake(true); - - var newContactSolver = new ContactSolver(shape1, shape2); - newContactSolver.contactArr = contactArr; - newContactSolver.e = Math.max(shape1.e, shape2.e); - newContactSolver.u = Math.sqrt(shape1.u * shape2.u); - newContactSolverArr.push(newContactSolver); - } - } - } - } - } - - stats.timeCollision = Date.now() - t0; - - return newContactSolverArr; -} - -Space.prototype.initSolver = function(dt, dt_inv, warmStarting) { - - var t0 = Date.now(); - - // Initialize contact solvers - for (var i = 0; i < this.contactSolverArr.length; i++) { - this.contactSolverArr[i].initSolver(dt_inv); - } - - // Initialize joint solver - for (var i = 0; i < this.jointArr.length; i++) { - if (this.jointArr[i]) { - this.jointArr[i].initSolver(dt, warmStarting); - } - } - - // Warm starting (apply cached impulse) - if (warmStarting) { - for (var i = 0; i < this.contactSolverArr.length; i++) { - this.contactSolverArr[i].warmStart(); - } - } - - stats.timeInitSolver = Date.now() - t0; -} - -Space.prototype.velocitySolver = function(iteration) { - - var t0 = Date.now(); - - for (var i = 0; i < iteration; i++) { - for (var j = 0; j < this.jointArr.length; j++) { - if (this.jointArr[j]) { - this.jointArr[j].solveVelocityConstraints(); - } - } - - for (var j = 0; j < this.contactSolverArr.length; j++) { - this.contactSolverArr[j].solveVelocityConstraints(); - } - } - - stats.timeVelocitySolver = Date.now() - t0; -} - -Space.prototype.positionSolver = function(iteration) { - var t0 = Date.now(); - - var positionSolved = false; - - stats.positionIterations = 0; - - for (var i = 0; i < iteration; i++) { - var contactsOk = true; - var jointsOk = true; - - for (var j = 0; j < this.contactSolverArr.length; j++) { - var contactOk = this.contactSolverArr[j].solvePositionConstraints(); - contactsOk = contactOk && contactsOk; - } - - for (var j = 0; j < this.jointArr.length; j++) { - if (this.jointArr[j]) { - var jointOk = this.jointArr[j].solvePositionConstraints(); - jointsOk = jointOk && jointsOk; - } - } - - if (contactsOk && jointsOk) { - // exit early if the position errors are small - positionSolved = true; - break; - } - - stats.positionIterations++; - } - - stats.timePositionSolver = Date.now() - t0; - - return positionSolved; -} - -Space.prototype.step = function(dt, vel_iteration, pos_iteration, warmStarting, allowSleep) { - - var dt_inv = 1 / dt; - - this.stepCount++; - - // Generate contact & contactSolver - this.contactSolverArr = this.genTemporalContactSolvers(); - - // Initialize contacts & joints solver - this.initSolver(dt, dt_inv, warmStarting); - - // Intergrate velocity - for (var i = 0; i < this.bodyArr.length; i++) { - var body = this.bodyArr[i]; - if (!body) { - continue; - } - - if (body.isDynamic() && body.isAwake()) { - body.updateVelocity(this.gravity, dt, this.damping); - } - } - - for (var i = 0; i < this.jointArr.length; i++) { - var joint = this.jointArr[i]; - if (!joint) { - continue; - } - - var body1 = joint.body1; - var body2 = joint.body2; - - var awake1 = body1.isAwake() && !body1.isStatic(); - var awake2 = body2.isAwake() && !body2.isStatic(); - - if (awake1 ^ awake2) { - if (!awake1) - body1.awake(true); - if (!awake2) - body2.awake(true); - } - } - - // Iterative velocity constraints solver - this.velocitySolver(vel_iteration); - - // Intergrate position - for (var i = 0; i < this.bodyArr.length; i++) { - var body = this.bodyArr[i]; - if (!body) { - continue - } - - if (body.isDynamic() && body.isAwake()) { - body.updatePosition(dt); - } - } - - // Process breakable joint - for (var i = 0; i < this.jointArr.length; i++) { - var joint = this.jointArr[i]; - if (!joint) { - continue; - } - - if (joint.breakable) { - if (joint.getReactionForce(dt_inv).lengthsq() >= joint.maxForce * joint.maxForce) - this.removeJoint(joint); - } - } - - // Iterative position constraints solver - var positionSolved = this.positionSolver(pos_iteration); - - for (var i = 0; i < this.bodyArr.length; i++) { - var body = this.bodyArr[i]; - if (!body) { - continue; - } - - body.syncTransform(); - } - - // Post solve collision callback - for (var i = 0; i < this.contactSolverArr.length; i++) { - var arb = this.contactSolverArr[i]; - //this.postSolve(arb); - } - - for (var i = 0; i < this.bodyArr.length; i++) { - var body = this.bodyArr[i]; - if (!body) { - continue; - } - - if (body.isDynamic() && body.isAwake()) { - body.cacheData(); - } - } - - // Process sleeping - if (allowSleep) { - var minSleepTime = 999999; - - var linTolSqr = Space.SLEEP_LINEAR_TOLERANCE * Space.SLEEP_LINEAR_TOLERANCE; - var angTolSqr = Space.SLEEP_ANGULAR_TOLERANCE * Space.SLEEP_ANGULAR_TOLERANCE; - - for (var i = 0; i < this.bodyArr.length; i++) { - var body = this.bodyArr[i]; - if (!body) { - continue; - } - - if (!body.isDynamic()) { - continue; - } - - if (body.w * body.w > angTolSqr || body.v.dot(body.v) > linTolSqr) { - body.sleepTime = 0; - minSleepTime = 0; - } - else { - body.sleepTime += dt; - minSleepTime = Math.min(minSleepTime, body.sleepTime); - } - } - - if (positionSolved && minSleepTime >= Space.TIME_TO_SLEEP) { - for (var i = 0; i < this.bodyArr.length; i++) { - var body = this.bodyArr[i]; - if (!body) { - continue; - } - - body.awake(false); - } - } - } - -} - diff --git a/src/physics/advanced/Util.js b/src/physics/advanced/Util.js deleted file mode 100644 index 93b0e793..00000000 --- a/src/physics/advanced/Util.js +++ /dev/null @@ -1,147 +0,0 @@ -/* -* Copyright (c) 2012 Ju Hyung Lee -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software -* and associated documentation files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or -* substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING -* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -function areaForCircle(radius_outer, radius_inner) { - return Math.PI * (radius_outer * radius_outer - radius_inner * radius_inner); -} - -function inertiaForCircle(mass, center, radius_outer, radius_inner) { - return mass * ((radius_outer * radius_outer + radius_inner * radius_inner) * 0.5 + center.lengthsq()); -} - -function areaForSegment(a, b, radius) { - return radius * (Math.PI * radius + 2 * vec2.dist(a, b)); -} - -function centroidForSegment(a, b) { - return vec2.scale(vec2.add(a, b), 0.5); -} - -function inertiaForSegment(mass, a, b) { - var distsq = vec2.distsq(b, a); - var offset = vec2.scale(vec2.add(a, b), 0.5); - - return mass * (distsq / 12 + offset.lengthsq()); -} - -function areaForPoly(verts) { - var area = 0; - for (var i = 0; i < verts.length; i++) { - area += vec2.cross(verts[i], verts[(i + 1) % verts.length]); - } - - return area / 2; -} - -function centroidForPoly(verts) { - var area = 0; - var vsum = new vec2(0, 0); - - for (var i = 0; i < verts.length; i++) { - var v1 = verts[i]; - var v2 = verts[(i + 1) % verts.length]; - var cross = vec2.cross(v1, v2); - - area += cross; - vsum.addself(vec2.scale(vec2.add(v1, v2), cross)); - } - - return vec2.scale(vsum, 1 / (3 * area)); -} - -function inertiaForPoly(mass, verts, offset) { - var sum1 = 0; - var sum2 = 0; - - for (var i = 0; i < verts.length; i++) { - var v1 = vec2.add(verts[i], offset); - var v2 = vec2.add(verts[(i+1) % verts.length], offset); - - var a = vec2.cross(v2, v1); - var b = vec2.dot(v1, v1) + vec2.dot(v1, v2) + vec2.dot(v2, v2); - - sum1 += a * b; - sum2 += a; - } - - return (mass * sum1) / (6 * sum2); -} - -function inertiaForBox(mass, w, h) { - return mass * (w * w + h * h) / 12; -} - -// Create the convex hull using the Gift wrapping algorithm -// http://en.wikipedia.org/wiki/Gift_wrapping_algorithm -function createConvexHull(points) { - // Find the right most point on the hull - var i0 = 0; - var x0 = points[0].x; - for (var i = 1; i < points.length; i++) { - var x = points[i].x; - if (x > x0 || (x == x0 && points[i].y < points[i0].y)) { - i0 = i; - x0 = x; - } - } - - var n = points.length; - var hull = []; - var m = 0; - var ih = i0; - - while (1) { - hull[m] = ih; - - var ie = 0; - for (var j = 1; j < n; j++) { - if (ie == ih) { - ie = j; - continue; - } - - var r = vec2.sub(points[ie], points[hull[m]]); - var v = vec2.sub(points[j], points[hull[m]]); - var c = vec2.cross(r, v); - if (c < 0) { - ie = j; - } - - // Collinearity check - if (c == 0 && v.lengthsq() > r.lengthsq()) { - ie = j; - } - } - - m++; - ih = ie; - - if (ie == i0) { - break; - } - } - - // Copy vertices - var newPoints = []; - for (var i = 0; i < m; ++i) { - newPoints.push(points[hull[i]]); - } - - return newPoints; -} \ No newline at end of file diff --git a/src/physics/advanced/collision/Broadphase.js b/src/physics/advanced/collision/Broadphase.js new file mode 100644 index 00000000..b0d6129c --- /dev/null +++ b/src/physics/advanced/collision/Broadphase.js @@ -0,0 +1,43 @@ +var vec2 = require('../math/vec2') +, Nearphase = require('./Nearphase') +, Shape = require('./../shapes/Shape') + +module.exports = Broadphase; + +/** + * Base class for broadphase implementations. + * @class Broadphase + * @constructor + */ +function Broadphase(){ + this.result = []; +}; + +/** + * Get all potential intersecting body pairs. + * @method getCollisionPairs + * @param {World} world The world to search in. + * @return {Array} An array of the bodies, ordered in pairs. Example: A result of [a,b,c,d] means that the potential pairs are: (a,b), (c,d). + */ +Broadphase.prototype.getCollisionPairs = function(world){ + throw new Error("getCollisionPairs must be implemented in a subclass!"); +}; + +// Temp things +var dist = vec2.create(), + worldNormal = vec2.create(), + yAxis = vec2.fromValues(0,1); + +/** + * Check whether the bounding radius of two bodies overlap. + * @method boundingRadiusCheck + * @param {Body} bodyA + * @param {Body} bodyB + * @return {Boolean} + */ +Broadphase.boundingRadiusCheck = function(bodyA, bodyB){ + vec2.sub(dist, bodyA.position, bodyB.position); + var d2 = vec2.squaredLength(dist), + r = bodyA.boundingRadius + bodyB.boundingRadius; + return d2 <= r*r; +}; diff --git a/src/physics/advanced/collision/GridBroadphase.js b/src/physics/advanced/collision/GridBroadphase.js new file mode 100644 index 00000000..d0a7172b --- /dev/null +++ b/src/physics/advanced/collision/GridBroadphase.js @@ -0,0 +1,159 @@ +var Circle = require('../shapes/Circle') +, Plane = require('../shapes/Plane') +, Particle = require('../shapes/Particle') +, Broadphase = require('../collision/Broadphase') +, vec2 = require('../math/vec2') + +module.exports = GridBroadphase; + +/** + * Broadphase that uses axis-aligned bins. + * @class GridBroadphase + * @constructor + * @extends Broadphase + * @param {number} xmin Lower x bound of the grid + * @param {number} xmax Upper x bound + * @param {number} ymin Lower y bound + * @param {number} ymax Upper y bound + * @param {number} nx Number of bins along x axis + * @param {number} ny Number of bins along y axis + * @todo test + */ +function GridBroadphase(xmin,xmax,ymin,ymax,nx,ny){ + Broadphase.apply(this); + + nx = nx || 10; + ny = ny || 10; + + this.binsizeX = (xmax-xmin) / nx; + this.binsizeY = (ymax-ymin) / ny; + this.nx = nx; + this.ny = ny; + this.xmin = xmin; + this.ymin = ymin; + this.xmax = xmax; + this.ymax = ymax; +}; +GridBroadphase.prototype = new Broadphase(); + +/** + * Get a bin index given a world coordinate + * @method getBinIndex + * @param {Number} x + * @param {Number} y + * @return {Number} Integer index + */ +GridBroadphase.prototype.getBinIndex = function(x,y){ + var nx = this.nx, + ny = this.ny, + xmin = this.xmin, + ymin = this.ymin, + xmax = this.xmax, + ymax = this.ymax; + + var xi = Math.floor(nx * (x - xmin) / (xmax-xmin)); + var yi = Math.floor(ny * (y - ymin) / (ymax-ymin)); + return xi*ny + yi; +} + +/** + * Get collision pairs. + * @method getCollisionPairs + * @param {World} world + * @return {Array} + */ +GridBroadphase.prototype.getCollisionPairs = function(world){ + var result = [], + collidingBodies = world.bodies, + Ncolliding = Ncolliding=collidingBodies.length, + binsizeX = this.binsizeX, + binsizeY = this.binsizeY; + + var bins=[], Nbins=nx*ny; + for(var i=0; i= 0 && xi*(ny-1) + yi < Nbins) + bins[ xi*(ny-1) + yi ].push(bi); + } + } + } else if(si instanceof Plane){ + // Put in all bins for now + if(bi.angle == 0){ + var y = bi.position[1]; + for(var j=0; j!==Nbins && ymin+binsizeY*(j-1) pos0 && pos < pos1){ + // We got contact! + + if(justTest) return true; + + var c = this.createContactEquation(circleBody,lineBody); + + vec2.scale(c.ni, orthoDist, -1); + vec2.normalize(c.ni, c.ni); + + vec2.scale( c.ri, c.ni, circleRadius); + add(c.ri, c.ri, circleOffset); + sub(c.ri, c.ri, circleBody.position); + + sub(c.rj, projectedPoint, lineOffset); + add(c.rj, c.rj, lineOffset); + sub(c.rj, c.rj, lineBody.position); + + this.contactEquations.push(c); + + if(this.enableFriction){ + this.frictionEquations.push(this.createFrictionFromContact(c)); + } + + return true; + } + } + + // Add corner + var verts = [worldVertex0, worldVertex1]; + + for(var i=0; i 0){ + + // Now project the circle onto the edge + vec2.scale(orthoDist, worldTangent, d); + sub(projectedPoint, circleOffset, orthoDist); + + // Check if the point is within the edge span + var pos = dot(worldEdgeUnit, projectedPoint); + var pos0 = dot(worldEdgeUnit, worldVertex0); + var pos1 = dot(worldEdgeUnit, worldVertex1); + + if(pos > pos0 && pos < pos1){ + // We got contact! + + var c = this.createContactEquation(circleBody,convexBody); + + vec2.scale(c.ni, orthoDist, -1); + vec2.normalize(c.ni, c.ni); + + vec2.scale( c.ri, c.ni, circleShape.radius); + add(c.ri, c.ri, circleOffset); + sub(c.ri, c.ri, circleBody.position); + + sub( c.rj, projectedPoint, convexOffset); + add(c.rj, c.rj, convexOffset); + sub(c.rj, c.rj, convexBody.position); + + this.contactEquations.push(c); + + if(this.enableFriction){ + this.frictionEquations.push( this.createFrictionFromContact(c) ); + } + + return true; + } + } + } + + // Check all vertices + for(var i=0; i= 0){ + + // Now project the particle onto the edge + vec2.scale(orthoDist, worldTangent, d); + sub(projectedPoint, particleOffset, orthoDist); + + // Check if the point is within the edge span + var pos = dot(worldEdgeUnit, projectedPoint); + var pos0 = dot(worldEdgeUnit, worldVertex0); + var pos1 = dot(worldEdgeUnit, worldVertex1); + + if(pos > pos0 && pos < pos1){ + // We got contact! + if(justTest) return true; + + if(closestEdgeDistance === null || d*d r*r){ + return false; + } + + if(justTest) return true; + + var c = this.createContactEquation(bodyA,bodyB); + sub(c.ni, offsetB, offsetA); + vec2.normalize(c.ni,c.ni); + + vec2.scale( c.ri, c.ni, shapeA.radius); + vec2.scale( c.rj, c.ni, -shapeB.radius); + + add(c.ri, c.ri, offsetA); + sub(c.ri, c.ri, bodyA.position); + + add(c.rj, c.rj, offsetB); + sub(c.rj, c.rj, bodyB.position); + + this.contactEquations.push(c); + + if(this.enableFriction){ + this.frictionEquations.push(this.createFrictionFromContact(c)); + } + return true; +}; + +/** + * Convex/Plane nearphase + * @method convexPlane + * @param {Body} bi + * @param {Convex} si + * @param {Array} xi + * @param {Number} ai + * @param {Body} bj + * @param {Plane} sj + * @param {Array} xj + * @param {Number} aj + */ +Nearphase.prototype.convexPlane = function( bi,si,xi,ai, bj,sj,xj,aj ){ + var convexBody = bi, + convexOffset = xi, + convexShape = si, + convexAngle = ai, + planeBody = bj, + planeShape = sj, + planeOffset = xj, + planeAngle = aj; + + var worldVertex = tmp1, + worldNormal = tmp2, + dist = tmp3; + + var numReported = 0; + vec2.rotate(worldNormal, yAxis, planeAngle); + + for(var i=0; i= 2) + break; + } + } + return numReported > 0; +}; + +/** + * Nearphase for particle vs plane + * @method particlePlane + * @param {Body} bi The particle body + * @param {Particle} si Particle shape + * @param {Array} xi World position for the particle + * @param {Number} ai World angle for the particle + * @param {Body} bj Plane body + * @param {Plane} sj Plane shape + * @param {Array} xj World position for the plane + * @param {Number} aj World angle for the plane + */ +Nearphase.prototype.particlePlane = function( bi,si,xi,ai, bj,sj,xj,aj, justTest ){ + var particleBody = bi, + particleShape = si, + particleOffset = xi, + planeBody = bj, + planeShape = sj, + planeOffset = xj, + planeAngle = aj; + + var dist = tmp1, + worldNormal = tmp2; + + planeAngle = planeAngle || 0; + + sub(dist, particleOffset, planeOffset); + vec2.rotate(worldNormal, yAxis, planeAngle); + + var d = dot(dist, worldNormal); + + if(d > 0) return false; + if(justTest) return true; + + var c = this.createContactEquation(planeBody,particleBody); + + vec2.copy(c.ni, worldNormal); + vec2.scale( dist, c.ni, d ); + // dist is now the distance vector in the normal direction + + // ri is the particle position projected down onto the plane, from the plane center + sub( c.ri, particleOffset, dist); + sub( c.ri, c.ri, planeBody.position); + + // rj is from the body center to the particle center + sub( c.rj, particleOffset, particleBody.position ); + + this.contactEquations.push(c); + + if(this.enableFriction){ + this.frictionEquations.push(this.createFrictionFromContact(c)); + } + return true; +}; + +/** + * Circle/Particle nearphase + * @method circleParticle + * @param {Body} bi + * @param {Circle} si + * @param {Array} xi + * @param {Number} ai + * @param {Body} bj + * @param {Particle} sj + * @param {Array} xj + * @param {Number} aj + */ +Nearphase.prototype.circleParticle = function( bi,si,xi,ai, bj,sj,xj,aj, justTest ){ + var circleBody = bi, + circleShape = si, + circleOffset = xi, + particleBody = bj, + particleShape = sj, + particleOffset = xj, + dist = tmp1; + + sub(dist, particleOffset, circleOffset); + if(vec2.squaredLength(dist) > circleShape.radius*circleShape.radius) return false; + if(justTest) return true; + + var c = this.createContactEquation(circleBody,particleBody); + vec2.copy(c.ni, dist); + vec2.normalize(c.ni,c.ni); + + // Vector from circle to contact point is the normal times the circle radius + vec2.scale(c.ri, c.ni, circleShape.radius); + add(c.ri, c.ri, circleOffset); + sub(c.ri, c.ri, circleBody.position); + + // Vector from particle center to contact point is zero + sub(c.rj, particleOffset, particleBody.position); + + this.contactEquations.push(c); + + if(this.enableFriction){ + this.frictionEquations.push(this.createFrictionFromContact(c)); + } + + return true; +}; + +var capsulePlane_tmpCircle = new Circle(1), + capsulePlane_tmp1 = vec2.create(), + capsulePlane_tmp2 = vec2.create(), + capsulePlane_tmp3 = vec2.create(); +Nearphase.prototype.capsulePlane = function( bi,si,xi,ai, bj,sj,xj,aj ){ + var end1 = capsulePlane_tmp1, + end2 = capsulePlane_tmp2, + circle = capsulePlane_tmpCircle, + dst = capsulePlane_tmp3; + + // Compute world end positions + vec2.set(end1, -si.length/2, 0); + vec2.rotate(end1,end1,ai); + add(end1,end1,xi); + + vec2.set(end2, si.length/2, 0); + vec2.rotate(end2,end2,ai); + add(end2,end2,xi); + + circle.radius = si.radius; + + // Do nearphase as two circles + this.circlePlane(bi,circle,end1,0, bj,sj,xj,aj); + this.circlePlane(bi,circle,end2,0, bj,sj,xj,aj); +}; + +/** + * Creates ContactEquations and FrictionEquations for a collision. + * @method circlePlane + * @param {Body} bi The first body that should be connected to the equations. + * @param {Circle} si The circle shape participating in the collision. + * @param {Array} xi Extra offset to take into account for the Shape, in addition to the one in circleBody.position. Will *not* be rotated by circleBody.angle (maybe it should, for sake of homogenity?). Set to null if none. + * @param {Body} bj The second body that should be connected to the equations. + * @param {Plane} sj The Plane shape that is participating + * @param {Array} xj Extra offset for the plane shape. + * @param {Number} aj Extra angle to apply to the plane + */ +Nearphase.prototype.circlePlane = function( bi,si,xi,ai, bj,sj,xj,aj ){ + var circleBody = bi, + circleShape = si, + circleOffset = xi, // Offset from body center, rotated! + planeBody = bj, + shapeB = sj, + planeOffset = xj, + planeAngle = aj; + + planeAngle = planeAngle || 0; + + // Vector from plane to circle + var planeToCircle = tmp1, + worldNormal = tmp2, + temp = tmp3; + + sub(planeToCircle, circleOffset, planeOffset); + + // World plane normal + vec2.rotate(worldNormal, yAxis, planeAngle); + + // Normal direction distance + var d = dot(worldNormal, planeToCircle); + + if(d > circleShape.radius) return false; // No overlap. Abort. + + // Create contact + var contact = this.createContactEquation(planeBody,circleBody); + + // ni is the plane world normal + vec2.copy(contact.ni, worldNormal); + + // rj is the vector from circle center to the contact point + vec2.scale(contact.rj, contact.ni, -circleShape.radius); + add(contact.rj, contact.rj, circleOffset); + sub(contact.rj, contact.rj, circleBody.position); + + // ri is the distance from plane center to contact. + vec2.scale(temp, contact.ni, d); + sub(contact.ri, planeToCircle, temp ); // Subtract normal distance vector from the distance vector + add(contact.ri, contact.ri, planeOffset); + sub(contact.ri, contact.ri, planeBody.position); + + this.contactEquations.push(contact); + + if(this.enableFriction){ + this.frictionEquations.push( this.createFrictionFromContact(contact) ); + } + + return true; +}; + + +/** + * Convex/convex nearphase.See this article for more info. + * @method convexConvex + * @param {Body} bi + * @param {Convex} si + * @param {Array} xi + * @param {Number} ai + * @param {Body} bj + * @param {Convex} sj + * @param {Array} xj + * @param {Number} aj + */ +Nearphase.prototype.convexConvex = function( bi,si,xi,ai, bj,sj,xj,aj ){ + var sepAxis = tmp1, + worldPoint = tmp2, + worldPoint0 = tmp3, + worldPoint1 = tmp4, + worldEdge = tmp5, + projected = tmp6, + penetrationVec = tmp7, + dist = tmp8, + worldNormal = tmp9; + + var found = Nearphase.findSeparatingAxis(si,xi,ai,sj,xj,aj,sepAxis); + if(!found) return false; + + // Make sure the separating axis is directed from shape i to shape j + sub(dist,xj,xi); + if(dot(sepAxis,dist) > 0){ + vec2.scale(sepAxis,sepAxis,-1); + } + + // Find edges with normals closest to the separating axis + var closestEdge1 = Nearphase.getClosestEdge(si,ai,sepAxis,true), // Flipped axis + closestEdge2 = Nearphase.getClosestEdge(sj,aj,sepAxis); + + if(closestEdge1==-1 || closestEdge2==-1) return false; + + // Loop over the shapes + for(var k=0; k<2; k++){ + + var closestEdgeA = closestEdge1, + closestEdgeB = closestEdge2, + shapeA = si, shapeB = sj, + offsetA = xi, offsetB = xj, + angleA = ai, angleB = aj, + bodyA = bi, bodyB = bj; + + if(k==0){ + // Swap! + var tmp; + tmp = closestEdgeA; closestEdgeA = closestEdgeB; closestEdgeB = tmp; + tmp = shapeA; shapeA = shapeB; shapeB = tmp; + tmp = offsetA; offsetA = offsetB; offsetB = tmp; + tmp = angleA; angleA = angleB; angleB = tmp; + tmp = bodyA; bodyA = bodyB; bodyB = tmp; + } + + // Loop over 2 points in convex B + for(var j=closestEdgeB; j max) max = value; + if(min === null || value < min) min = value; + } + + if(min > max){ + var t = min; + min = max; + max = t; + } + + // Project the position of the body onto the axis - need to add this to the result + var offset = dot(convexOffset, worldAxis); + + vec2.set( result, min + offset, max + offset); +}; + +// .findSeparatingAxis is called by other functions, need local tmp vectors +var fsa_tmp1 = vec2.fromValues(0,0) +, fsa_tmp2 = vec2.fromValues(0,0) +, fsa_tmp3 = vec2.fromValues(0,0) +, fsa_tmp4 = vec2.fromValues(0,0) +, fsa_tmp5 = vec2.fromValues(0,0) +, fsa_tmp6 = vec2.fromValues(0,0) + +/** + * Find a separating axis between the shapes, that maximizes the separating distance between them. + * @method findSeparatingAxis + * @static + * @param {Convex} c1 + * @param {Array} offset1 + * @param {Number} angle1 + * @param {Convex} c2 + * @param {Array} offset2 + * @param {Number} angle2 + * @param {Array} sepAxis The resulting axis + * @return {Boolean} Whether the axis could be found. + */ +Nearphase.findSeparatingAxis = function(c1,offset1,angle1,c2,offset2,angle2,sepAxis){ + var maxDist = null, + overlap = false, + found = false, + edge = fsa_tmp1, + worldPoint0 = fsa_tmp2, + worldPoint1 = fsa_tmp3, + normal = fsa_tmp4, + span1 = fsa_tmp5, + span2 = fsa_tmp6; + + for(var j=0; j!==2; j++){ + var c = c1, + angle = angle1; + if(j===1){ + c = c2; + angle = angle2; + } + + for(var i=0; i!==c.vertices.length; i++){ + // Get the world edge + vec2.rotate(worldPoint0, c.vertices[i], angle); + vec2.rotate(worldPoint1, c.vertices[(i+1)%c.vertices.length], angle); + + sub(edge, worldPoint1, worldPoint0); + + // Get normal - just rotate 90 degrees since vertices are given in CCW + vec2.rotate(normal, edge, -Math.PI / 2); + vec2.normalize(normal,normal); + + // Project hulls onto that normal + Nearphase.projectConvexOntoAxis(c1,offset1,angle1,normal,span1); + Nearphase.projectConvexOntoAxis(c2,offset2,angle2,normal,span2); + + // Order by span position + var a=span1, + b=span2, + swapped = false; + if(span1[0] > span2[0]){ + b=span1; + a=span2; + swapped = true; + } + + // Get separating distance + var dist = b[0] - a[1]; + overlap = dist < 0; + + if(maxDist===null || dist > maxDist){ + vec2.copy(sepAxis, normal); + maxDist = dist; + found = overlap; + } + } + } + + return found; +}; + +// .getClosestEdge is called by other functions, need local tmp vectors +var gce_tmp1 = vec2.fromValues(0,0) +, gce_tmp2 = vec2.fromValues(0,0) +, gce_tmp3 = vec2.fromValues(0,0) + +/** + * Get the edge that has a normal closest to an axis. + * @method getClosestEdge + * @static + * @param {Convex} c + * @param {Number} angle + * @param {Array} axis + * @param {Boolean} flip + * @return {Number} Index of the edge that is closest. This index and the next spans the resulting edge. Returns -1 if failed. + */ +Nearphase.getClosestEdge = function(c,angle,axis,flip){ + var localAxis = gce_tmp1, + edge = gce_tmp2, + normal = gce_tmp3; + + // Convert the axis to local coords of the body + vec2.rotate(localAxis, axis, -angle); + if(flip){ + vec2.scale(localAxis,localAxis,-1); + } + + var closestEdge = -1, + N = c.vertices.length, + halfPi = Math.PI / 2; + for(var i=0; i!==N; i++){ + // Get the edge + sub(edge, c.vertices[(i+1)%N], c.vertices[i%N]); + + // Get normal - just rotate 90 degrees since vertices are given in CCW + vec2.rotate(normal, edge, -halfPi); + vec2.normalize(normal,normal); + + var d = dot(normal,localAxis); + if(closestEdge == -1 || d > maxDot){ + closestEdge = i % N; + maxDot = d; + } + } + + return closestEdge; +}; + diff --git a/src/physics/advanced/collision/QuadTree.js b/src/physics/advanced/collision/QuadTree.js new file mode 100644 index 00000000..b0a48a73 --- /dev/null +++ b/src/physics/advanced/collision/QuadTree.js @@ -0,0 +1,376 @@ +var Plane = require("../shapes/Plane"); +var Broadphase = require("../collision/Broadphase"); + +module.exports = { + QuadTree : QuadTree, + Node : Node, + BoundsNode : BoundsNode, +}; + +/** + * QuadTree data structure. See https://github.com/mikechambers/ExamplesByMesh/tree/master/JavaScript/QuadTree + * @class QuadTree + * @constructor + * @param {Object} An object representing the bounds of the top level of the QuadTree. The object + * should contain the following properties : x, y, width, height + * @param {Boolean} pointQuad Whether the QuadTree will contain points (true), or items with bounds + * (width / height)(false). Default value is false. + * @param {Number} maxDepth The maximum number of levels that the quadtree will create. Default is 4. + * @param {Number} maxChildren The maximum number of children that a node can contain before it is split into sub-nodes. + */ +function QuadTree(bounds, pointQuad, maxDepth, maxChildren){ + var node; + if(pointQuad){ + node = new Node(bounds, 0, maxDepth, maxChildren); + } else { + node = new BoundsNode(bounds, 0, maxDepth, maxChildren); + } + + /** + * The root node of the QuadTree which covers the entire area being segmented. + * @property root + * @type Node + */ + this.root = node; +} + +/** + * Inserts an item into the QuadTree. + * @method insert + * @param {Object|Array} item The item or Array of items to be inserted into the QuadTree. The item should expose x, y + * properties that represents its position in 2D space. + */ +QuadTree.prototype.insert = function(item){ + if(item instanceof Array){ + var len = item.length; + for(var i = 0; i < len; i++){ + this.root.insert(item[i]); + } + } else { + this.root.insert(item); + } +} + +/** + * Clears all nodes and children from the QuadTree + * @method clear + */ +QuadTree.prototype.clear = function(){ + this.root.clear(); +} + +/** + * Retrieves all items / points in the same node as the specified item / point. If the specified item + * overlaps the bounds of a node, then all children in both nodes will be returned. + * @method retrieve + * @param {Object} item An object representing a 2D coordinate point (with x, y properties), or a shape + * with dimensions (x, y, width, height) properties. + */ +QuadTree.prototype.retrieve = function(item){ + //get a copy of the array of items + var out = this.root.retrieve(item).slice(0); + return out; +} + +QuadTree.prototype.getCollisionPairs = function(world){ + + var result = []; + + // Add all bodies + this.insert(world.bodies); + + /* + console.log("bodies",world.bodies.length); + console.log("maxDepth",this.root.maxDepth,"maxChildren",this.root.maxChildren); + */ + + for(var i=0; i!==world.bodies.length; i++){ + var b = world.bodies[i], + items = this.retrieve(b); + + //console.log("items",items.length); + + // Check results + for(var j=0, len=items.length; j!==len; j++){ + var item = items[j]; + + if(b === item) continue; // Do not add self + + // Check if they were already added + var found = false; + for(var k=0, numAdded=result.length; k= this.maxDepth) && len > this.maxChildren) { + this.subdivide(); + + for(var i = 0; i < len; i++){ + this.insert(this.children[i]); + } + + this.children.length = 0; + } +} + +Node.prototype.retrieve = function(item){ + if(this.nodes.length){ + var index = this.findIndex(item); + return this.nodes[index].retrieve(item); + } + + return this.children; +} + +Node.prototype.findIndex = function(item){ + var b = this.bounds; + var left = (item.position[0]-item.boundingRadius > b.x + b.width / 2) ? false : true; + var top = (item.position[1]-item.boundingRadius > b.y + b.height / 2) ? false : true; + + if(item instanceof Plane){ + left = top = false; // Will overlap the left/top boundary since it is infinite + } + + //top left + var index = Node.TOP_LEFT; + if(left){ + if(!top){ + index = Node.BOTTOM_LEFT; + } + } else { + if(top){ + index = Node.TOP_RIGHT; + } else { + index = Node.BOTTOM_RIGHT; + } + } + + return index; +} + + +Node.prototype.subdivide = function(){ + var depth = this.depth + 1; + + var bx = this.bounds.x; + var by = this.bounds.y; + + //floor the values + var b_w_h = (this.bounds.width / 2); + var b_h_h = (this.bounds.height / 2); + var bx_b_w_h = bx + b_w_h; + var by_b_h_h = by + b_h_h; + + //top left + this.nodes[Node.TOP_LEFT] = new this.classConstructor({ + x:bx, + y:by, + width:b_w_h, + height:b_h_h + }, + depth); + + //top right + this.nodes[Node.TOP_RIGHT] = new this.classConstructor({ + x:bx_b_w_h, + y:by, + width:b_w_h, + height:b_h_h + }, + depth); + + //bottom left + this.nodes[Node.BOTTOM_LEFT] = new this.classConstructor({ + x:bx, + y:by_b_h_h, + width:b_w_h, + height:b_h_h + }, + depth); + + + //bottom right + this.nodes[Node.BOTTOM_RIGHT] = new this.classConstructor({ + x:bx_b_w_h, + y:by_b_h_h, + width:b_w_h, + height:b_h_h + }, + depth); +} + +Node.prototype.clear = function(){ + this.children.length = 0; + + var len = this.nodes.length; + for(var i = 0; i < len; i++){ + this.nodes[i].clear(); + } + + this.nodes.length = 0; +} + + +// BoundsQuadTree + +function BoundsNode(bounds, depth, maxChildren, maxDepth){ + Node.call(this, bounds, depth, maxChildren, maxDepth); + this.stuckChildren = []; +} + +BoundsNode.prototype = new Node(); +BoundsNode.prototype.classConstructor = BoundsNode; +BoundsNode.prototype.stuckChildren = null; + +//we use this to collect and conctenate items being retrieved. This way +//we dont have to continuously create new Array instances. +//Note, when returned from QuadTree.retrieve, we then copy the array +BoundsNode.prototype.out = []; + +BoundsNode.prototype.insert = function(item){ + if(this.nodes.length){ + var index = this.findIndex(item); + var node = this.nodes[index]; + + /* + console.log("radius:",item.boundingRadius); + console.log("item x:",item.position[0] - item.boundingRadius,"x range:",node.bounds.x,node.bounds.x+node.bounds.width); + console.log("item y:",item.position[1] - item.boundingRadius,"y range:",node.bounds.y,node.bounds.y+node.bounds.height); + */ + + //todo: make _bounds bounds + if( !(item instanceof Plane) && // Plane is infinite.. Make it a "stuck" child + item.position[0] - item.boundingRadius >= node.bounds.x && + item.position[0] + item.boundingRadius <= node.bounds.x + node.bounds.width && + item.position[1] - item.boundingRadius >= node.bounds.y && + item.position[1] + item.boundingRadius <= node.bounds.y + node.bounds.height){ + this.nodes[index].insert(item); + } else { + this.stuckChildren.push(item); + } + + return; + } + + this.children.push(item); + + var len = this.children.length; + + if(this.depth < this.maxDepth && len > this.maxChildren){ + this.subdivide(); + + for(var i=0; i