mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
Merge pull request #647 from xtian/grunt-jshint
Run jshint as part of build process and fix jshint errors
This commit is contained in:
commit
06c953a293
165 changed files with 2156 additions and 2070 deletions
102
.jshintrc
102
.jshintrc
|
@ -1,75 +1,49 @@
|
|||
{
|
||||
"globals" : { "Phaser": false, "PIXI": false, "p2": false },
|
||||
"globals" : { "Phaser": false, "PIXI": false, "p2": false },
|
||||
// Ignore Environment Globals
|
||||
"browser" : true, // Standard browser globals e.g. `window`, `document`.
|
||||
"couch" : false,
|
||||
"dojo" : false,
|
||||
"jquery" : true,
|
||||
"mootools" : false,
|
||||
"node" : false,
|
||||
"nonstandard" : false,
|
||||
"phantom" : false,
|
||||
"prototypejs" : false,
|
||||
"rhino" : false,
|
||||
"worker" : false,
|
||||
"wsh" : true, // Windows Scripting Host.
|
||||
"yui" : false,
|
||||
"browser" : true, // Standard browser globals e.g. `window`, `document`.
|
||||
|
||||
// Development
|
||||
"debug" : true, // Allow debugger statements e.g. browser breakpoints.
|
||||
"devel" : true, // Allow developments statements e.g. `console.log();`.
|
||||
"devel" : true, // Allow developments statements e.g. `console.log();`.
|
||||
|
||||
// ECMAScript Support
|
||||
"es3" : true, // Support legacy browser and javascript environments.
|
||||
"esnext" : false, // This option tells JSHint that your code uses ECMAScript 6 specific syntax.
|
||||
"strict" : false, // Require `use strict` pragma in every file.
|
||||
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
|
||||
"es3" : true, // Support legacy browser and javascript environments.
|
||||
"esnext" : false, // This option tells JSHint that your code uses ECMAScript 6 specific syntax.
|
||||
"strict" : false, // Require `use strict` pragma in every file.
|
||||
"globalstrict": false, // Allow global "use strict" (also enables 'strict').
|
||||
|
||||
// Functionality
|
||||
"asi" : true, // Tolerate Automatic Semicolon Insertion (no semicolons).
|
||||
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
|
||||
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
|
||||
"camelcase" : true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
|
||||
"curly" : true, // Require {} for every new block or scope.
|
||||
"eqeqeq" : false, // Require triple equals i.e. `===`.
|
||||
"eqnull" : true, // Tolerate use of `== null`.
|
||||
"evil" : false, // Tolerate use of `eval`.
|
||||
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
|
||||
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
|
||||
"freeze" : true, // Prohibits overwriting prototypes of native objects such as Array and Date.
|
||||
"funcscope" : true, // This option suppresses warnings about declaring variables inside of control structures while accessing them later from the outside.
|
||||
"immed" : false, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
|
||||
"iterator" : true, // This option suppresses warnings about the __iterator__ property.
|
||||
"lastsemic" : true, // This option suppresses warnings about missing semicolons, but only when the semicolon is omitted for the last statement in a one-line block.
|
||||
"latedef" : false, // Prohipit variable use before definition.
|
||||
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
|
||||
"laxcomma" : false, // This option suppresses warnings about comma-first coding style.
|
||||
"loopfunc" : true, // Allow functions to be defined within loops.
|
||||
// "maxcomplexity" : 10, // This option lets you control cyclomatic complexity throughout your code.
|
||||
// "maxdepth" : 2, // This option lets you control how nested do you want your blocks to be.
|
||||
// "maxlen" : 80, // This option lets you set the maximum length of a line.
|
||||
// "maxparams" : 5, // This option lets you set the max number of formal parameters allowed per function.
|
||||
// "maxstatements" : 25, // This option lets you set the max number of statements allowed per function.This option lets you set the max number of formal parameters allowed per function.
|
||||
"moz" : false, // This options tells JSHint that your code uses Mozilla JavaScript extensions.
|
||||
"multistr" : true, // This option suppresses warnings about multi-line strings.
|
||||
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
|
||||
"notypeof" : false, // This option suppresses warnings about invalid typeof operator values.
|
||||
"proto" : true, // This option suppresses warnings about the __proto__ property.
|
||||
"scripturl" : true, // Tolerate script-targeted URLs.
|
||||
"shadow" : true, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
|
||||
"smarttabs" : false, // This option suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only.
|
||||
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
|
||||
"undef" : true, // Require all non-global variables be declared before they are used.
|
||||
"unused" : true, // This option warns when you define and never use your variables.
|
||||
"validthis" : true, // This option suppresses warnings about possible strict violations when the code is running in strict mode and you use this in a non-constructor function.
|
||||
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
|
||||
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
|
||||
"camelcase" : true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
|
||||
"curly" : true, // Require {} for every new block or scope.
|
||||
"eqeqeq" : false, // Require triple equals i.e. `===`.
|
||||
"eqnull" : true, // Tolerate use of `== null`.
|
||||
"evil" : false, // Tolerate use of `eval`.
|
||||
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
|
||||
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
|
||||
"freeze" : true, // Prohibits overwriting prototypes of native objects such as Array and Date.
|
||||
"funcscope" : true, // This option suppresses warnings about declaring variables inside of control structures while accessing them later from the outside.
|
||||
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
|
||||
"latedef" : true, // Prohibit variable use before definition.
|
||||
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
|
||||
"laxcomma" : false, // This option suppresses warnings about comma-first coding style.
|
||||
"loopfunc" : true, // Allow functions to be defined within loops.
|
||||
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
|
||||
"notypeof" : false, // This option suppresses warnings about invalid typeof operator values.
|
||||
"shadow" : true, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
|
||||
"smarttabs" : false, // This option suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only.
|
||||
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
|
||||
"undef" : true, // Require all non-global variables be declared before they are used.
|
||||
"unused" : true, // This option warns when you define and never use your variables.
|
||||
|
||||
// Styling
|
||||
"indent" : 4, // Specify indentation spacing
|
||||
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
|
||||
"noempty" : true, // Prohibit use of empty blocks.
|
||||
"nonew" : true, // Prohibit use of constructors for side-effects.
|
||||
"plusplus" : false, // Prohibit use of `++` & `--`.
|
||||
"quotmark" : false, // This option enforces the consistency of quotation marks used throughout your code.
|
||||
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
|
||||
"trailing" : true // Prohibit trailing whitespaces.
|
||||
"indent" : 4, // Specify indentation spacing
|
||||
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
|
||||
"noempty" : true, // Prohibit use of empty blocks.
|
||||
"nonew" : true, // Prohibit use of constructors for side-effects.
|
||||
"plusplus" : false, // Prohibit use of `++` & `--`.
|
||||
"quotmark" : false, // This option enforces the consistency of quotation marks used throughout your code.
|
||||
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
|
||||
"trailing" : true // Prohibit trailing whitespaces.
|
||||
}
|
||||
|
|
38
Gruntfile.js
38
Gruntfile.js
|
@ -4,6 +4,7 @@ module.exports = function (grunt) {
|
|||
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||
grunt.loadNpmTasks('grunt-contrib-copy');
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-text-replace');
|
||||
grunt.loadTasks('./tasks');
|
||||
|
@ -379,12 +380,43 @@ module.exports = function (grunt) {
|
|||
hostname: '*'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
jshint: {
|
||||
src: {
|
||||
src: [
|
||||
'plugins/**/*.js',
|
||||
'src/**/*.js',
|
||||
'!src/Intro.js',
|
||||
'!src/Outro.js',
|
||||
'!src/pixi/**/*',
|
||||
'!src/physics/p2/p2.js'
|
||||
],
|
||||
options: { jshintrc: '.jshintrc' }
|
||||
},
|
||||
|
||||
filters: {
|
||||
src: ['filters/**/*.js'],
|
||||
options: { jshintrc: 'filters/.jshintrc', }
|
||||
},
|
||||
|
||||
tooling: {
|
||||
src: [
|
||||
'Gruntfile.js',
|
||||
'tasks/**/*.js'
|
||||
],
|
||||
options: { jshintrc: 'tasks/.jshintrc' }
|
||||
},
|
||||
|
||||
options: {
|
||||
force: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerTask('default', ['build']);
|
||||
grunt.registerTask('build', ['clean', 'concat', 'uglify']);
|
||||
grunt.registerTask('dist', ['clean', 'concat', 'uglify', 'copy']);
|
||||
|
||||
grunt.registerTask('build', ['clean', 'jshint', 'concat', 'uglify']);
|
||||
grunt.registerTask('dist', ['build', 'copy']);
|
||||
|
||||
};
|
||||
|
|
|
@ -282,7 +282,7 @@ We now have a full [Contributors Guide][contribute] which goes into the process
|
|||
|
||||
- If you issue a Pull Request for Phaser, please only do so againt the `dev` branch and *not* against the `master` branch.
|
||||
|
||||
- Before submitting a Pull Request please run your code through [JSHint](http://www.jshint.com/) to check for stylistic or formatting errors. To use JSHint, first install it by running `npm install jshint`, then test your code by running `jshint src`. This isn't a strict requirement and we are happy to receive Pull Requests that haven't been JSHinted, so don't let it put you off contributing, but do know that we'll reformat your source before going live with it.
|
||||
- Before submitting a Pull Request please run your code through [JSHint](http://www.jshint.com/) to check for stylistic or formatting errors. To use JSHint, run `grunt jshint`. This isn't a strict requirement and we are happy to receive Pull Requests that haven't been JSHinted, so don't let it put you off contributing, but do know that we'll reformat your source before going live with it.
|
||||
|
||||
|
||||
Bugs?
|
||||
|
|
49
filters/.jshintrc
Normal file
49
filters/.jshintrc
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
"globals" : { "Phaser": false, "PIXI": false, "p2": false },
|
||||
// Ignore Environment Globals
|
||||
"browser" : true, // Standard browser globals e.g. `window`, `document`.
|
||||
|
||||
// Development
|
||||
"devel" : true, // Allow developments statements e.g. `console.log();`.
|
||||
|
||||
// ECMAScript Support
|
||||
"es3" : true, // Support legacy browser and javascript environments.
|
||||
"esnext" : false, // This option tells JSHint that your code uses ECMAScript 6 specific syntax.
|
||||
"strict" : false, // Require `use strict` pragma in every file.
|
||||
"globalstrict": false, // Allow global "use strict" (also enables 'strict').
|
||||
|
||||
// Functionality
|
||||
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
|
||||
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
|
||||
"camelcase" : false, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
|
||||
"curly" : true, // Require {} for every new block or scope.
|
||||
"eqeqeq" : false, // Require triple equals i.e. `===`.
|
||||
"eqnull" : true, // Tolerate use of `== null`.
|
||||
"evil" : false, // Tolerate use of `eval`.
|
||||
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
|
||||
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
|
||||
"freeze" : true, // Prohibits overwriting prototypes of native objects such as Array and Date.
|
||||
"funcscope" : true, // This option suppresses warnings about declaring variables inside of control structures while accessing them later from the outside.
|
||||
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
|
||||
"latedef" : true, // Prohibit variable use before definition.
|
||||
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
|
||||
"laxcomma" : false, // This option suppresses warnings about comma-first coding style.
|
||||
"loopfunc" : true, // Allow functions to be defined within loops.
|
||||
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
|
||||
"notypeof" : false, // This option suppresses warnings about invalid typeof operator values.
|
||||
"shadow" : true, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
|
||||
"smarttabs" : false, // This option suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only.
|
||||
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
|
||||
"undef" : true, // Require all non-global variables be declared before they are used.
|
||||
"unused" : true, // This option warns when you define and never use your variables.
|
||||
|
||||
// Styling
|
||||
"indent" : false, // Specify indentation spacing
|
||||
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
|
||||
"noempty" : true, // Prohibit use of empty blocks.
|
||||
"nonew" : true, // Prohibit use of constructors for side-effects.
|
||||
"plusplus" : false, // Prohibit use of `++` & `--`.
|
||||
"quotmark" : false, // This option enforces the consistency of quotation marks used throughout your code.
|
||||
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
|
||||
"trailing" : true // Prohibit trailing whitespaces.
|
||||
}
|
|
@ -9,7 +9,7 @@ Phaser.Filter.BinarySerpents = function (game) {
|
|||
this.uniforms.march = { type: '1i', value: 100 };
|
||||
this.uniforms.maxDistance = { type: '1f', value: 5.0 };
|
||||
this.uniforms.fog = { type: '1f', value: 5.0 };
|
||||
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
|
@ -65,7 +65,7 @@ Phaser.Filter.BinarySerpents = function (game) {
|
|||
"float r = Texture3D(ray, 33.);",
|
||||
"gl_FragColor = result * (step(r, .3) + r * .2 + .1);",
|
||||
"}"
|
||||
];
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
|
@ -81,7 +81,7 @@ Phaser.Filter.BinarySerpents.prototype.init = function (width, height, march, ma
|
|||
this.uniforms.march.value = march;
|
||||
this.uniforms.maxDistance.value = maxDistance;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(Phaser.Filter.BinarySerpents.prototype, 'fog', {
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ Phaser.Filter.BlurX = function (game) {
|
|||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.blur = { type: '1f', value: 1 / 512 };
|
||||
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
|
@ -27,7 +27,7 @@ Phaser.Filter.BlurX = function (game) {
|
|||
"sum += texture2D(uSampler, vec2(vTextureCoord.x + 2.0*blur, vTextureCoord.y)) * 0.12;",
|
||||
"sum += texture2D(uSampler, vec2(vTextureCoord.x + 3.0*blur, vTextureCoord.y)) * 0.09;",
|
||||
"sum += texture2D(uSampler, vec2(vTextureCoord.x + 4.0*blur, vTextureCoord.y)) * 0.05;",
|
||||
|
||||
|
||||
"gl_FragColor = sum;",
|
||||
|
||||
"}"
|
||||
|
|
|
@ -6,7 +6,7 @@ Phaser.Filter.BlurY = function (game) {
|
|||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.blur = { type: '1f', value: 1 / 512 };
|
||||
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
|
@ -27,7 +27,7 @@ Phaser.Filter.BlurY = function (game) {
|
|||
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 2.0*blur)) * 0.12;",
|
||||
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 3.0*blur)) * 0.09;",
|
||||
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 4.0*blur)) * 0.05;",
|
||||
|
||||
|
||||
"gl_FragColor = sum;",
|
||||
|
||||
"}"
|
||||
|
|
|
@ -6,7 +6,7 @@ Phaser.Filter.SampleFilter = function (game) {
|
|||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.divisor = { type: '1f', value: 0.5 };
|
||||
|
||||
|
||||
// The fragment shader source
|
||||
this.fragmentSrc = [
|
||||
|
||||
|
@ -53,9 +53,9 @@ Phaser.Filter.SampleFilter.prototype.constructor = Phaser.Filter.SampleFilter;
|
|||
|
||||
Phaser.Filter.SampleFilter.prototype.init = function (width, height, divisor) {
|
||||
|
||||
if (typeof divisor == 'undefined') { divisor = 0.5 };
|
||||
if (typeof divisor == 'undefined') { divisor = 0.5; }
|
||||
|
||||
this.setResolution(width, height);
|
||||
this.uniforms.divisor.value = divisor;
|
||||
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,7 +10,7 @@ Phaser.Filter.CheckerWave = function (game) {
|
|||
this.uniforms.vrp = { type: '3f', value: { x: 0.0, y: -5.0, z: 0.0 }};
|
||||
this.uniforms.color1 = { type: '3f', value: { x: 0, y: 1, z: 1 }};
|
||||
this.uniforms.color2 = { type: '3f', value: { x: 1, y: 1, z: 1 }};
|
||||
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
|
@ -91,7 +91,7 @@ Phaser.Filter.CheckerWave = function (game) {
|
|||
"gl_FragColor=color;",
|
||||
"}",
|
||||
"else gl_FragColor=vec4(0,0,0.1,alpha); //background color",
|
||||
"}",
|
||||
"}"
|
||||
|
||||
];
|
||||
|
||||
|
@ -104,7 +104,7 @@ Phaser.Filter.CheckerWave.prototype.init = function (width, height) {
|
|||
|
||||
this.setResolution(width, height);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Filter.CheckerWave.prototype.setColor1 = function (red, green, blue) {
|
||||
|
||||
|
@ -112,7 +112,7 @@ Phaser.Filter.CheckerWave.prototype.setColor1 = function (red, green, blue) {
|
|||
this.uniforms.color1.value.y = green;
|
||||
this.uniforms.color1.value.z = blue;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Filter.CheckerWave.prototype.setColor2 = function (red, green, blue) {
|
||||
|
||||
|
@ -120,7 +120,7 @@ Phaser.Filter.CheckerWave.prototype.setColor2 = function (red, green, blue) {
|
|||
this.uniforms.color2.value.y = green;
|
||||
this.uniforms.color2.value.z = blue;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(Phaser.Filter.CheckerWave.prototype, 'alpha', {
|
||||
|
||||
|
|
|
@ -6,11 +6,11 @@ Phaser.Filter.ColorBars = function (game) {
|
|||
|
||||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1 }
|
||||
this.uniforms.alpha = { type: '1f', value: 1 };
|
||||
// this.uniforms.origin = { type: '1f', value: 2.0 }
|
||||
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
|
||||
"// bars - thygate@gmail.com",
|
||||
"// rotation and color mix modifications by malc (mlashley@gmail.com)",
|
||||
"// modified by @hintz 2013-04-30",
|
||||
|
@ -58,8 +58,8 @@ Phaser.Filter.ColorBars = function (game) {
|
|||
"color.a = alpha;",
|
||||
"gl_FragColor = color;",
|
||||
"}"
|
||||
|
||||
];
|
||||
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
|
@ -70,7 +70,7 @@ Phaser.Filter.ColorBars.prototype.init = function (width, height) {
|
|||
|
||||
this.setResolution(width, height);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(Phaser.Filter.ColorBars.prototype, 'alpha', {
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ Phaser.Filter.Fire = function (game) {
|
|||
|
||||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1.0 }
|
||||
this.uniforms.shift = { type: '1f', value: 1.6 }
|
||||
this.uniforms.alpha = { type: '1f', value: 1.0 };
|
||||
this.uniforms.shift = { type: '1f', value: 1.6 };
|
||||
this.uniforms.speed = { type: '2f', value: { x: 0.7, y: 0.4 } };
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
@ -54,7 +54,7 @@ Phaser.Filter.Fire = function (game) {
|
|||
"vec3 c = mix(c1, c2, fbm(p + r)) + mix(c3, c4, r.x) - mix(c5, c6, r.y);",
|
||||
"gl_FragColor = vec4(c * cos(shift * gl_FragCoord.y / resolution.y), alpha);",
|
||||
"}"
|
||||
];
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
|
@ -65,15 +65,15 @@ Phaser.Filter.Fire.prototype.init = function (width, height, alpha, shift) {
|
|||
|
||||
this.setResolution(width, height);
|
||||
|
||||
if (typeof alpha !== 'undefined') {
|
||||
if (typeof alpha !== 'undefined') {
|
||||
this.uniforms.alpha.value = alpha;
|
||||
}
|
||||
|
||||
if (typeof shift !== 'undefined') {
|
||||
if (typeof shift !== 'undefined') {
|
||||
this.uniforms.shift.value = shift;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(Phaser.Filter.Fire.prototype, 'alpha', {
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ Phaser.Filter.Gray = function (game) {
|
|||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.gray = { type: '1f', value: 1.0 };
|
||||
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
|
|
|
@ -8,8 +8,8 @@ Phaser.Filter.HueRotate = function (game) {
|
|||
|
||||
this.uniforms.alpha = { type: '1f', value: 1.0 };
|
||||
this.uniforms.size = { type: '1f', value: 0.03 };
|
||||
this.uniforms.iChannel0 = { type: 'sampler2D', value: null, textureData: { repeat: true } }
|
||||
|
||||
this.uniforms.iChannel0 = { type: 'sampler2D', value: null, textureData: { repeat: true } };
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
|
@ -64,7 +64,7 @@ Phaser.Filter.HueRotate.prototype.init = function (width, height, texture) {
|
|||
|
||||
this.uniforms.iChannel0.value = texture;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'alpha', {
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@ Phaser.Filter.LightBeam = function (game) {
|
|||
|
||||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1 }
|
||||
this.uniforms.thickness = { type: '1f', value: 70.0 }
|
||||
this.uniforms.speed = { type: '1f', value: 1.0 }
|
||||
this.uniforms.red = { type: '1f', value: 2.0 }
|
||||
this.uniforms.green = { type: '1f', value: 1.0 }
|
||||
this.uniforms.blue = { type: '1f', value: 1.0 }
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1 };
|
||||
this.uniforms.thickness = { type: '1f', value: 70.0 };
|
||||
this.uniforms.speed = { type: '1f', value: 1.0 };
|
||||
this.uniforms.red = { type: '1f', value: 2.0 };
|
||||
this.uniforms.green = { type: '1f', value: 1.0 };
|
||||
this.uniforms.blue = { type: '1f', value: 1.0 };
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
|
@ -28,9 +28,9 @@ Phaser.Filter.LightBeam = function (game) {
|
|||
"void main(void) {",
|
||||
|
||||
"vec2 uPos = (gl_FragCoord.xy / resolution.xy);",
|
||||
|
||||
|
||||
"uPos.y -= 0.50;",
|
||||
|
||||
|
||||
"float vertColor = 0.0;",
|
||||
|
||||
"for (float i = 0.0; i < 1.0; i++)",
|
||||
|
@ -40,11 +40,11 @@ Phaser.Filter.LightBeam = function (game) {
|
|||
"float fTemp = abs(1.0 / uPos.y / thickness);",
|
||||
"vertColor += fTemp;",
|
||||
"}",
|
||||
|
||||
|
||||
"vec4 color = vec4(vertColor * red, vertColor * green, vertColor * blue, alpha);",
|
||||
"gl_FragColor = color;",
|
||||
"}"
|
||||
];
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ Phaser.Filter.LightBeam.prototype.init = function (width, height) {
|
|||
|
||||
this.setResolution(width, height);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(Phaser.Filter.LightBeam.prototype, 'alpha', {
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@ Phaser.Filter.Marble = function (game) {
|
|||
|
||||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1.0 }
|
||||
this.uniforms.alpha = { type: '1f', value: 1.0 };
|
||||
|
||||
// Drives speed, higher number will make it slower.
|
||||
this.uniforms.fluid_speed = { type: '1f', value: 10.0 }
|
||||
this.uniforms.fluid_speed = { type: '1f', value: 10.0 };
|
||||
|
||||
this.uniforms.color_intensity = { type: '1f', value: 0.30 };
|
||||
|
||||
this.uniforms.color_intensity = { type: '1f', value: 0.30 }
|
||||
|
||||
// The fragment shader source
|
||||
this.fragmentSrc = [
|
||||
|
||||
|
@ -69,7 +69,7 @@ Phaser.Filter.Marble.prototype.init = function (width, height, speed, intensity)
|
|||
this.uniforms.fluid_speed.value = speed;
|
||||
this.uniforms.color_intensity.value = intensity;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(Phaser.Filter.Marble.prototype, 'alpha', {
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ Phaser.Filter.Plasma = function (game) {
|
|||
this.uniforms.redShift = { type: '1f', value: 0.5 };
|
||||
this.uniforms.greenShift = { type: '1f', value: 0.5 };
|
||||
this.uniforms.blueShift = { type: '1f', value: 0.9 };
|
||||
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
|
@ -52,15 +52,15 @@ Phaser.Filter.Plasma.prototype.init = function (width, height, alpha, size) {
|
|||
|
||||
this.setResolution(width, height);
|
||||
|
||||
if (typeof alpha !== 'undefined') {
|
||||
if (typeof alpha !== 'undefined') {
|
||||
this.uniforms.alpha.value = alpha;
|
||||
}
|
||||
|
||||
if (typeof size !== 'undefined') {
|
||||
if (typeof size !== 'undefined') {
|
||||
this.uniforms.size.value = size;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(Phaser.Filter.Plasma.prototype, 'alpha', {
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Phaser.Filter.SampleFilter = function (game) {
|
|||
*/
|
||||
|
||||
this.uniforms.divisor = { type: '1f', value: 0.5 };
|
||||
|
||||
|
||||
// The fragment shader source
|
||||
this.fragmentSrc = [
|
||||
|
||||
|
@ -43,9 +43,9 @@ Phaser.Filter.SampleFilter.prototype.constructor = Phaser.Filter.SampleFilter;
|
|||
|
||||
Phaser.Filter.SampleFilter.prototype.init = function (width, height, divisor) {
|
||||
|
||||
if (typeof divisor == 'undefined') { divisor = 0.5 };
|
||||
if (typeof divisor == 'undefined') { divisor = 0.5; }
|
||||
|
||||
this.setResolution(width, height);
|
||||
this.uniforms.divisor.value = divisor;
|
||||
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,10 +6,10 @@ Phaser.Filter.Tunnel = function (game) {
|
|||
|
||||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1 }
|
||||
this.uniforms.origin = { type: '1f', value: 2.0 }
|
||||
this.uniforms.iChannel0 = { type: 'sampler2D', value: null, textureData: { repeat: true } }
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1 };
|
||||
this.uniforms.origin = { type: '1f', value: 2.0 };
|
||||
this.uniforms.iChannel0 = { type: 'sampler2D', value: null, textureData: { repeat: true } };
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
|
@ -30,7 +30,7 @@ Phaser.Filter.Tunnel = function (game) {
|
|||
"gl_FragColor = vec4(c / (t.y + 0.5), alpha);",
|
||||
"}"
|
||||
|
||||
];
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
|
@ -44,7 +44,7 @@ Phaser.Filter.Tunnel.prototype.init = function (width, height, texture) {
|
|||
|
||||
texture.baseTexture._powerOf2 = true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Object.defineProperty(Phaser.Filter.Tunnel.prototype, 'alpha', {
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
"grunt-contrib-connect": "~0.5.0",
|
||||
"grunt-contrib-copy": "~0.5.0",
|
||||
"grunt-contrib-clean": "~0.5.0",
|
||||
"grunt-contrib-jshint": "^0.9.2",
|
||||
"grunt-contrib-uglify": "~0.3.3",
|
||||
"lodash": "~2.2.1",
|
||||
"grunt-text-replace": "~0.3.11"
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
/* jshint camelcase:false */
|
||||
/**
|
||||
* A collection of methods useful for manipulating and comparing colors.
|
||||
*
|
||||
* @class ColorHarmony
|
||||
* @class ColorHarmony
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
|
@ -10,7 +11,7 @@
|
|||
|
||||
Phaser.Plugins.ColorHarmony.prototype = {
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns a Complementary Color Harmony for the given color.
|
||||
* <p>A complementary hue is one directly opposite the color given on the color wheel</p>
|
||||
* <p>Value returned in 0xAARRGGBB format with Alpha set to 255.</p>
|
||||
|
@ -27,7 +28,7 @@ Phaser.Plugins.ColorHarmony.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns an Analogous Color Harmony for the given color.
|
||||
* <p>An Analogous harmony are hues adjacent to each other on the color wheel</p>
|
||||
* <p>Values returned in 0xAARRGGBB format with Alpha set to 255.</p>
|
||||
|
@ -41,7 +42,7 @@ Phaser.Plugins.ColorHarmony.prototype = {
|
|||
if (typeof threshold === "undefined") { threshold = 30; }
|
||||
var hsv = Phaser.Color.RGBtoHSV(color);
|
||||
if(threshold > 359 || threshold < 0) {
|
||||
throw Error("Color Warning: Invalid threshold given to getAnalogousHarmony()");
|
||||
throw new Error("Color Warning: Invalid threshold given to getAnalogousHarmony()");
|
||||
}
|
||||
var warmer = Phaser.Color.game.math.wrapValue(hsv.hue, 359 - threshold, 359);
|
||||
var colder = Phaser.Color.game.math.wrapValue(hsv.hue, threshold, 359);
|
||||
|
@ -55,7 +56,7 @@ Phaser.Plugins.ColorHarmony.prototype = {
|
|||
};
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns an Split Complement Color Harmony for the given color.
|
||||
* <p>A Split Complement harmony are the two hues on either side of the color's Complement</p>
|
||||
* <p>Values returned in 0xAARRGGBB format with Alpha set to 255.</p>
|
||||
|
@ -69,7 +70,7 @@ Phaser.Plugins.ColorHarmony.prototype = {
|
|||
if (typeof threshold === "undefined") { threshold = 30; }
|
||||
var hsv = Phaser.Color.RGBtoHSV(color);
|
||||
if(threshold >= 359 || threshold <= 0) {
|
||||
throw Error("Phaser.Color Warning: Invalid threshold given to getSplitComplementHarmony()");
|
||||
throw new Error("Phaser.Color Warning: Invalid threshold given to getSplitComplementHarmony()");
|
||||
}
|
||||
var opposite = Phaser.Color.game.math.wrapValue(hsv.hue, 180, 359);
|
||||
var warmer = Phaser.Color.game.math.wrapValue(hsv.hue, opposite - threshold, 359);
|
||||
|
@ -84,7 +85,7 @@ Phaser.Plugins.ColorHarmony.prototype = {
|
|||
};
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns a Triadic Color Harmony for the given color.
|
||||
* <p>A Triadic harmony are 3 hues equidistant from each other on the color wheel</p>
|
||||
* <p>Values returned in 0xAARRGGBB format with Alpha set to 255.</p>
|
||||
|
@ -104,16 +105,16 @@ Phaser.Plugins.ColorHarmony.prototype = {
|
|||
};
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get HSV color wheel values in an array which will be 360 elements in size.
|
||||
*
|
||||
* @method getHSVColorWheel
|
||||
* @param {Number} alpha Alpha value for each color of the color wheel, between 0 (transparent) and 255 (opaque)
|
||||
* @param {Number} alpha Alpha value for each color of the color wheel, between 0 (transparent) and 255 (opaque)
|
||||
* @return {Array} An array containing 360 elements corresponding to the HSV color wheel.
|
||||
*/
|
||||
getHSVColorWheel: function (alpha) {
|
||||
|
||||
alpha = alpha || 255;
|
||||
alpha = alpha || 255;
|
||||
|
||||
var colors = [];
|
||||
|
||||
|
@ -125,7 +126,7 @@ Phaser.Plugins.ColorHarmony.prototype = {
|
|||
return colors;
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Convert a HSV (hue, saturation, lightness) color space value to an RGB color
|
||||
*
|
||||
* @method HSVtoRGB
|
||||
|
@ -138,7 +139,7 @@ Phaser.Plugins.ColorHarmony.prototype = {
|
|||
HSVtoRGB: function (h, s, v, alpha) {
|
||||
if (typeof alpha === "undefined") { alpha = 255; }
|
||||
var result;
|
||||
if(s == 0.0) {
|
||||
if(s === 0.0) {
|
||||
result = Phaser.Color.getColor32(alpha, v * 255, v * 255, v * 255);
|
||||
} else {
|
||||
h = h / 60.0;
|
||||
|
@ -172,7 +173,7 @@ Phaser.Plugins.ColorHarmony.prototype = {
|
|||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Convert an RGB color value to an object containing the HSV color space values: Hue, Saturation and Lightness
|
||||
*
|
||||
* @method RGBtoHSV
|
||||
|
@ -191,7 +192,7 @@ Phaser.Plugins.ColorHarmony.prototype = {
|
|||
var hue;
|
||||
var saturation;
|
||||
// Grey color, no chroma
|
||||
if(delta == 0) {
|
||||
if(delta === 0) {
|
||||
hue = 0;
|
||||
saturation = 0;
|
||||
} else {
|
||||
|
@ -217,7 +218,7 @@ Phaser.Plugins.ColorHarmony.prototype = {
|
|||
hue -= 1;
|
||||
}
|
||||
}
|
||||
// Keep the value with 0 to 359
|
||||
// Keep the value with 0 to 359
|
||||
hue *= 360;
|
||||
hue = Math.round(hue);
|
||||
return {
|
||||
|
@ -228,4 +229,4 @@ Phaser.Plugins.ColorHarmony.prototype = {
|
|||
};
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
/* jshint asi:true,camelcase:false,curly:false,indent:2,unused:false */
|
||||
/*
|
||||
amiga protracker module player for web audio api
|
||||
(c) 2012-2013 firehawk/tda (firehawk@haxor.fi)
|
||||
|
||||
|
||||
originally hacked together in a weekend, so please excuse
|
||||
me for the spaghetti code. :)
|
||||
|
||||
AMIGAAAAAAAAH!!
|
||||
|
||||
|
||||
kinda sorta changelog:
|
||||
(apr 2013)
|
||||
- changed the logic for pattern break/jump. mod.pattern_skank now
|
||||
|
@ -55,7 +56,7 @@ function Protracker()
|
|||
this.separation=true;
|
||||
|
||||
this.palclock=true;
|
||||
|
||||
|
||||
this.autostart=false;
|
||||
|
||||
this.onReady=function(){};
|
||||
|
@ -69,14 +70,14 @@ function Protracker()
|
|||
214,202,190,180,170,160,151,143,135,127,120,113);
|
||||
|
||||
// finetune multipliers
|
||||
this.finetunetable=new Array();
|
||||
this.finetunetable=[];
|
||||
for(t=0;t<16;t++) this.finetunetable[t]=Math.pow(2, (t-8)/12/8);
|
||||
|
||||
|
||||
// calc tables for vibrato waveforms
|
||||
this.vibratotable=new Array();
|
||||
this.vibratotable=[];
|
||||
for(t=0;t<4;t++) {
|
||||
this.vibratotable[t]=new Array();
|
||||
for(i=0;i<64;i++) {
|
||||
this.vibratotable[t]=[];
|
||||
for(var i=0;i<64;i++) {
|
||||
switch(t) {
|
||||
case 0:
|
||||
this.vibratotable[t][i]=127*Math.sin(Math.PI*2*(i/64));
|
||||
|
@ -118,9 +119,11 @@ function Protracker()
|
|||
// create the web audio context
|
||||
Protracker.prototype.createContext = function()
|
||||
{
|
||||
/* global webkitAudioContext:false */
|
||||
/* jshint newcap:false */
|
||||
this.context = new webkitAudioContext();
|
||||
this.samplerate=this.context.sampleRate;
|
||||
this.bufferlen=(this.samplerate > 44100) ? 4096 : 2048;
|
||||
this.bufferlen=(this.samplerate > 44100) ? 4096 : 2048;
|
||||
|
||||
// fixed filter at 6kHz
|
||||
this.filterNode=this.context.createBiquadFilter();
|
||||
|
@ -138,7 +141,7 @@ Protracker.prototype.createContext = function()
|
|||
// compressor for a bit of volume boost
|
||||
this.compressorNode=this.context.createDynamicsCompressor();
|
||||
|
||||
// patch up some cables :)
|
||||
// patch up some cables :)
|
||||
this.mixerNode.connect(this.filterNode);
|
||||
this.filterNode.connect(this.lowpassNode);
|
||||
this.lowpassNode.connect(this.compressorNode);
|
||||
|
@ -151,7 +154,7 @@ Protracker.prototype.createContext = function()
|
|||
Protracker.prototype.play = function()
|
||||
{
|
||||
if (this.context==null) this.createContext();
|
||||
|
||||
|
||||
if (!this.ready) return false;
|
||||
if (this.paused) {
|
||||
this.paused=false;
|
||||
|
@ -194,7 +197,7 @@ Protracker.prototype.jump = function(step)
|
|||
this.tick=0;
|
||||
this.row=0;
|
||||
this.position+=step;
|
||||
this.flags=1+2;
|
||||
this.flags=1+2;
|
||||
if (this.position<0) this.position=0;
|
||||
if (this.position >= this.songlen) this.stop();
|
||||
}
|
||||
|
@ -235,20 +238,20 @@ Protracker.prototype.setautostart = function(st)
|
|||
|
||||
// clear song data
|
||||
Protracker.prototype.clearsong = function()
|
||||
{
|
||||
{
|
||||
this.title="";
|
||||
this.signature="";
|
||||
this.songlen=1;
|
||||
this.repeatpos=0;
|
||||
this.patterntable=new ArrayBuffer(128);
|
||||
for(i=0;i<128;i++) this.patterntable[i]=0;
|
||||
for(var i=0;i<128;i++) this.patterntable[i]=0;
|
||||
|
||||
this.channels=4;
|
||||
|
||||
this.sample=new Array();
|
||||
this.sample=[];
|
||||
this.samples=31;
|
||||
for(i=0;i<31;i++) {
|
||||
this.sample[i]=new Object();
|
||||
for(var i=0;i<31;i++) {
|
||||
this.sample[i]={};
|
||||
this.sample[i].name="";
|
||||
this.sample[i].length=0;
|
||||
this.sample[i].finetune=0;
|
||||
|
@ -259,13 +262,13 @@ Protracker.prototype.clearsong = function()
|
|||
}
|
||||
|
||||
this.patterns=0;
|
||||
this.pattern=new Array();
|
||||
this.note=new Array();
|
||||
|
||||
this.pattern=[];
|
||||
this.note=[];
|
||||
|
||||
this.looprow=0;
|
||||
this.loopstart=0;
|
||||
this.loopcount=0;
|
||||
|
||||
|
||||
this.patterndelay=0;
|
||||
this.patternwait=0;
|
||||
}
|
||||
|
@ -286,14 +289,14 @@ Protracker.prototype.initialize = function()
|
|||
this.patternjump=0;
|
||||
this.patterndelay=0;
|
||||
this.patternwait=0;
|
||||
|
||||
this.channel=new Array();
|
||||
for(i=0;i<this.channels;i++) {
|
||||
this.channel[i]=new Object();
|
||||
|
||||
this.channel=[];
|
||||
for(var i=0;i<this.channels;i++) {
|
||||
this.channel[i]={};
|
||||
this.channel[i].sample=0;
|
||||
this.channel[i].period=214;
|
||||
this.channel[i].voiceperiod=214;
|
||||
this.channel[i].note=24;
|
||||
this.channel[i].note=24;
|
||||
this.channel[i].volume=64;
|
||||
this.channel[i].command=0;
|
||||
this.channel[i].data=0;
|
||||
|
@ -312,7 +315,7 @@ Protracker.prototype.initialize = function()
|
|||
this.channel[i].vibratopos=0;
|
||||
this.channel[i].vibratowave=0;
|
||||
}
|
||||
this.vu=new Array();
|
||||
this.vu=[];
|
||||
}
|
||||
|
||||
|
||||
|
@ -320,21 +323,21 @@ Protracker.prototype.initialize = function()
|
|||
// load module from url into local buffer
|
||||
Protracker.prototype.load = function(url)
|
||||
{
|
||||
this.url=url;
|
||||
this.clearsong();
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
request.open("GET", this.url, true);
|
||||
request.responseType = "arraybuffer";
|
||||
this.request = request;
|
||||
this.loading=true;
|
||||
var asset = this;
|
||||
request.onload = function() {
|
||||
asset.buffer=new Uint8Array(request.response);
|
||||
asset.parse();
|
||||
if (asset.autostart) asset.play();
|
||||
}
|
||||
request.send();
|
||||
this.url=url;
|
||||
this.clearsong();
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
request.open("GET", this.url, true);
|
||||
request.responseType = "arraybuffer";
|
||||
this.request = request;
|
||||
this.loading=true;
|
||||
var asset = this;
|
||||
request.onload = function() {
|
||||
asset.buffer=new Uint8Array(request.response);
|
||||
asset.parse();
|
||||
if (asset.autostart) asset.play();
|
||||
}
|
||||
request.send();
|
||||
}
|
||||
|
||||
|
||||
|
@ -343,10 +346,10 @@ Protracker.prototype.load = function(url)
|
|||
Protracker.prototype.parse = function()
|
||||
{
|
||||
var i,j,c;
|
||||
|
||||
|
||||
if (!this.buffer) return false;
|
||||
|
||||
for(i=0;i<4;i++) this.signature+=String.fromCharCode(this.buffer[1080+i]);
|
||||
|
||||
for(var i=0;i<4;i++) this.signature+=String.fromCharCode(this.buffer[1080+i]);
|
||||
switch (this.signature) {
|
||||
case "M.K.":
|
||||
case "M!K!":
|
||||
|
@ -357,7 +360,7 @@ Protracker.prototype.parse = function()
|
|||
case "6CHN":
|
||||
this.channels=6;
|
||||
break;
|
||||
|
||||
|
||||
case "8CHN":
|
||||
case "FLT8":
|
||||
this.channels=8;
|
||||
|
@ -366,23 +369,23 @@ Protracker.prototype.parse = function()
|
|||
case "28CH":
|
||||
this.channels=28;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
this.vu=new Array();
|
||||
for(i=0;i<this.channels;i++) this.vu[i]=0.0;
|
||||
|
||||
this.vu=[];
|
||||
for(var i=0;i<this.channels;i++) this.vu[i]=0.0;
|
||||
|
||||
i=0;
|
||||
while(this.buffer[i] && i<20)
|
||||
this.title=this.title+String.fromCharCode(this.buffer[i++]);
|
||||
|
||||
for(i=0;i<this.samples;i++) {
|
||||
for(var i=0;i<this.samples;i++) {
|
||||
var st=20+i*30;
|
||||
j=0;
|
||||
while(this.buffer[st+j] && j<22) {
|
||||
while(this.buffer[st+j] && j<22) {
|
||||
this.sample[i].name+=
|
||||
((this.buffer[st+j]>0x1f) && (this.buffer[st+j]<0x7f)) ?
|
||||
((this.buffer[st+j]>0x1f) && (this.buffer[st+j]<0x7f)) ?
|
||||
(String.fromCharCode(this.buffer[st+j])) :
|
||||
(" ");
|
||||
j++;
|
||||
|
@ -402,29 +405,32 @@ Protracker.prototype.parse = function()
|
|||
|
||||
this.songlen=this.buffer[950];
|
||||
if (this.buffer[951] != 127) this.repeatpos=this.buffer[951];
|
||||
for(i=0;i<128;i++) {
|
||||
for(var i=0;i<128;i++) {
|
||||
this.patterntable[i]=this.buffer[952+i];
|
||||
if (this.patterntable[i] > this.patterns) this.patterns=this.patterntable[i];
|
||||
}
|
||||
this.patterns+=1;
|
||||
var patlen=4*64*this.channels;
|
||||
|
||||
this.pattern=new Array();
|
||||
this.note=new Array();
|
||||
for(i=0;i<this.patterns;i++) {
|
||||
this.pattern=[];
|
||||
this.note=[];
|
||||
for(var i=0;i<this.patterns;i++) {
|
||||
this.pattern[i]=new Uint8Array(patlen);
|
||||
this.note[i]=new Uint8Array(this.channels*64);
|
||||
for(j=0;j<patlen;j++) this.pattern[i][j]=this.buffer[1084+i*patlen+j];
|
||||
for(j=0;j<64;j++) for(c=0;c<this.channels;c++) {
|
||||
this.note[i][j*this.channels+c]=0;
|
||||
var n=(this.pattern[i][j*4*this.channels+c*4]&0x0f)<<8 | this.pattern[i][j*4*this.channels+c*4+1];
|
||||
for(var np=0; np<this.baseperiodtable.length; np++)
|
||||
if (n==this.baseperiodtable[np]) this.note[i][j*this.channels+c]=np;
|
||||
}
|
||||
for(j=0;j<64;j++) {
|
||||
for(c=0;c<this.channels;c++) {
|
||||
this.note[i][j*this.channels+c]=0;
|
||||
var n=(this.pattern[i][j*4*this.channels+c*4]&0x0f)<<8 | this.pattern[i][j*4*this.channels+c*4+1];
|
||||
for(var np=0; np<this.baseperiodtable.length; np++) {
|
||||
if (n==this.baseperiodtable[np]) this.note[i][j*this.channels+c]=np;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var sst=1084+this.patterns*patlen;
|
||||
for(i=0;i<this.samples;i++) {
|
||||
for(var i=0;i<this.samples;i++) {
|
||||
this.sample[i].data=new Float32Array(this.sample[i].length);
|
||||
for(j=0;j<this.sample[i].length;j++) {
|
||||
var q=this.buffer[sst+j];
|
||||
|
@ -433,7 +439,7 @@ Protracker.prototype.parse = function()
|
|||
} else {
|
||||
q=((q-128)/128.0)-1.0;
|
||||
}
|
||||
|
||||
|
||||
this.sample[i].data[j]=q;
|
||||
}
|
||||
sst+=this.sample[i].length;
|
||||
|
@ -462,8 +468,10 @@ Protracker.prototype.advance=function(mod) {
|
|||
if (mod.tick < ((mod.patternwait+1)*mod.speed)) {
|
||||
mod.patternwait++;
|
||||
} else {
|
||||
mod.row++; mod.tick=0; mod.flags|=2; mod.patterndelay=0;
|
||||
|
||||
mod.row++;
|
||||
mod.tick=0;
|
||||
mod.flags|=2;
|
||||
mod.patterndelay=0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -487,12 +495,18 @@ Protracker.prototype.advance=function(mod) {
|
|||
}
|
||||
mod.tick=0;
|
||||
} else {
|
||||
mod.row++; mod.tick=0; mod.flags|=2;
|
||||
mod.row++;
|
||||
mod.tick=0;
|
||||
mod.flags|=2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mod.row>=64) { mod.position++; mod.row=0; mod.flags|=4; }
|
||||
|
||||
if (mod.row>=64) {
|
||||
mod.position++;
|
||||
mod.row=0;
|
||||
mod.flags|=4;
|
||||
}
|
||||
if (mod.position>=mod.songlen) {
|
||||
if (mod.repeat) {
|
||||
mod.position=0;
|
||||
|
@ -510,7 +524,7 @@ Protracker.prototype.mix = function(ape) {
|
|||
var f;
|
||||
var p, pp, n, nn;
|
||||
var mod=ape.srcElement.module;
|
||||
outp=new Array();
|
||||
var outp=[];
|
||||
|
||||
var bufs=new Array(ape.outputBuffer.getChannelData(0), ape.outputBuffer.getChannelData(1));
|
||||
var buflen=ape.outputBuffer.length;
|
||||
|
@ -530,7 +544,6 @@ Protracker.prototype.mix = function(ape) {
|
|||
p=mod.patterntable[mod.position];
|
||||
pp=mod.row*4*mod.channels + ch*4;
|
||||
if (mod.flags&2) { // new row
|
||||
modrow = mod.row; // here
|
||||
mod.channel[ch].command=mod.pattern[p][pp+2]&0x0f;
|
||||
mod.channel[ch].data=mod.pattern[p][pp+3];
|
||||
|
||||
|
@ -542,37 +555,37 @@ Protracker.prototype.mix = function(ape) {
|
|||
if ((mod.channel[ch].command != 0x03) && (mod.channel[ch].command != 0x05)) {
|
||||
mod.channel[ch].period=n;
|
||||
mod.channel[ch].samplepos=0;
|
||||
if (mod.channel[ch].vibratowave>3) mod.channel[ch].vibratopos=0;
|
||||
if (mod.channel[ch].vibratowave>3) mod.channel[ch].vibratopos=0;
|
||||
mod.channel[ch].flags|=3; // recalc speed
|
||||
mod.channel[ch].noteon=1;
|
||||
} else {
|
||||
mod.channel[ch].slideto=n;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
nn=mod.pattern[p][pp+0]&0xf0 | mod.pattern[p][pp+2]>>4;
|
||||
if (nn) {
|
||||
mod.channel[ch].sample=nn-1;
|
||||
|
||||
|
||||
mod.channel[ch].volume=mod.sample[nn-1].volume;
|
||||
if (!n && (mod.channel[ch].samplepos > mod.sample[nn-1].length)) mod.channel[ch].samplepos=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
mod.channel[ch].voiceperiod=mod.channel[ch].period;
|
||||
if (mod.channel[ch].samplepos==0) modsample[ch]=mod.channel[ch].sample;
|
||||
|
||||
|
||||
if (mod.channel[ch].samplepos===0) mod.sample[ch]=mod.channel[ch].sample;
|
||||
|
||||
|
||||
// kill empty samples
|
||||
if (!mod.sample[mod.channel[ch].sample].length) mod.channel[ch].noteon=0;
|
||||
|
||||
// effects
|
||||
// effects
|
||||
if (mod.flags&1) {
|
||||
if (!mod.tick) {
|
||||
// process only on tick 0
|
||||
mod.effects_t0[mod.channel[ch].command](mod, ch);
|
||||
} else {
|
||||
mod.effects_t1[mod.channel[ch].command](mod, ch);
|
||||
mod.effects_t1[mod.channel[ch].command](mod, ch);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -589,14 +602,14 @@ Protracker.prototype.mix = function(ape) {
|
|||
if ((mod.channel[ch].flags&1 || mod.flags&2) && mod.channel[ch].voiceperiod)
|
||||
mod.channel[ch].samplespeed=
|
||||
(mod.palclock ? 7093789.2 : 7159090.5)/(mod.channel[ch].voiceperiod*2) * mod.finetunetable[mod.sample[mod.channel[ch].sample].finetune+8] / mod.samplerate;
|
||||
|
||||
|
||||
// advance vibrato on each new tick
|
||||
if (mod.flags&1) {
|
||||
mod.channel[ch].vibratopos+=mod.channel[ch].vibratospeed;
|
||||
mod.channel[ch].vibratopos&=0x3f;
|
||||
}
|
||||
|
||||
// mix channel to output
|
||||
// mix channel to output
|
||||
och=och^(ch&1);
|
||||
f=0.0;
|
||||
if (mod.channel[ch].noteon) {
|
||||
|
@ -606,7 +619,7 @@ Protracker.prototype.mix = function(ape) {
|
|||
outp[och]+=f;
|
||||
mod.channel[ch].samplepos+=mod.channel[ch].samplespeed;
|
||||
}
|
||||
if (s==0) mod.vu[ch]=Math.abs(f);
|
||||
if (s===0) mod.vu[ch]=Math.abs(f);
|
||||
|
||||
// loop or end samples
|
||||
if (mod.channel[ch].noteon) {
|
||||
|
@ -623,14 +636,14 @@ Protracker.prototype.mix = function(ape) {
|
|||
|
||||
// clear channel flags
|
||||
mod.channel[ch].flags=0;
|
||||
}
|
||||
}
|
||||
mod.offset++;
|
||||
mod.flags&=0x70;
|
||||
mod.flags&=0x70;
|
||||
}
|
||||
|
||||
|
||||
// a more headphone-friendly stereo separation (aka. betterpaula)
|
||||
if (mod.separation) {
|
||||
t=outp[0];
|
||||
var t=outp[0];
|
||||
outp[0]=outp[0]*0.6 + outp[1]*0.4;
|
||||
outp[1]=outp[1]*0.6 + t*0.4;
|
||||
}
|
||||
|
@ -662,7 +675,7 @@ Protracker.prototype.effect_t0_4=function(mod, ch) { // 4 vibrato
|
|||
mod.channel[ch].vibratospeed=(mod.channel[ch].data&0xf0)>>4;
|
||||
}
|
||||
mod.channel[ch].voiceperiod+=
|
||||
(mod.channel[ch].vibratodepth/32)*mod.channel[ch].semitone*(mod.vibratotable[mod.channel[ch].vibratowave&3][mod.channel[ch].vibratopos]/127);
|
||||
(mod.channel[ch].vibratodepth/32)*mod.channel[ch].semitone*(mod.vibratotable[mod.channel[ch].vibratowave&3][mod.channel[ch].vibratopos]/127);
|
||||
mod.channel[ch].flags|=1;
|
||||
}
|
||||
Protracker.prototype.effect_t0_5=function(mod, ch) { // 5
|
||||
|
@ -689,7 +702,7 @@ Protracker.prototype.effect_t0_c=function(mod, ch) { // c set volume
|
|||
Protracker.prototype.effect_t0_d=function(mod, ch) { // d pattern break
|
||||
mod.breakrow=((mod.channel[ch].data&0xf0)>>4)*10 + (mod.channel[ch].data&0x0f);
|
||||
if (!(mod.flags&16)) mod.patternjump=mod.position+1;
|
||||
mod.flags|=16;
|
||||
mod.flags|=16;
|
||||
}
|
||||
Protracker.prototype.effect_t0_e=function(mod, ch) { // e
|
||||
var i=(mod.channel[ch].data&0xf0)>>4;
|
||||
|
@ -763,11 +776,11 @@ Protracker.prototype.effect_t0_ed=function(mod, ch) { // ed delay sample
|
|||
if (mod.tick==(mod.channel[ch].data&0x0f)) {
|
||||
// start note
|
||||
var p=mod.patterntable[mod.position];
|
||||
var pp=mod.row*4*mod.channels + ch*4;
|
||||
n=(mod.pattern[p][pp]&0x0f)<<8 | mod.pattern[p][pp+1];
|
||||
var pp=mod.row*4*mod.channels + ch*4;
|
||||
var n=(mod.pattern[p][pp]&0x0f)<<8 | mod.pattern[p][pp+1];
|
||||
if (n) {
|
||||
mod.channel[ch].period=n;
|
||||
mod.channel[ch].voiceperiod=mod.channel[ch].period;
|
||||
mod.channel[ch].voiceperiod=mod.channel[ch].period;
|
||||
mod.channel[ch].samplepos=0;
|
||||
if (mod.channel[ch].vibratowave>3) mod.channel[ch].vibratopos=0;
|
||||
mod.channel[ch].flags|=3; // recalc speed
|
||||
|
@ -810,7 +823,7 @@ Protracker.prototype.effect_t1_1=function(mod, ch) { // 1 slide up
|
|||
Protracker.prototype.effect_t1_2=function(mod, ch) { // 2 slide down
|
||||
mod.channel[ch].period+=mod.channel[ch].slidespeed;
|
||||
if (mod.channel[ch].period>856) mod.channel[ch].period=856;
|
||||
mod.channel[ch].flags|=3; // recalc speed
|
||||
mod.channel[ch].flags|=3; // recalc speed
|
||||
}
|
||||
Protracker.prototype.effect_t1_3=function(mod, ch) { // 3 slide to note
|
||||
if (mod.channel[ch].period < mod.channel[ch].slideto) {
|
||||
|
@ -853,7 +866,7 @@ Protracker.prototype.effect_t1_a=function(mod, ch) { // a volume slide
|
|||
if (!(mod.channel[ch].data&0xf0)) {
|
||||
// x is zero, slide down
|
||||
mod.channel[ch].volume-=(mod.channel[ch].data&0x0f);
|
||||
if (mod.channel[ch].volume<0) mod.channel[ch].volume=0;
|
||||
if (mod.channel[ch].volume<0) mod.channel[ch].volume=0;
|
||||
}
|
||||
}
|
||||
Protracker.prototype.effect_t1_b=function(mod, ch) { // b pattern jump
|
||||
|
@ -893,7 +906,7 @@ Protracker.prototype.effect_t1_e7=function(mod, ch) { // e7
|
|||
Protracker.prototype.effect_t1_e8=function(mod, ch) { // e8
|
||||
}
|
||||
Protracker.prototype.effect_t1_e9=function(mod, ch) { // e9 retrig sample
|
||||
if (mod.tick%(mod.channel[ch].data&0x0f)==0)
|
||||
if (mod.tick%(mod.channel[ch].data&0x0f)===0)
|
||||
mod.channel[ch].samplepos=0;
|
||||
}
|
||||
Protracker.prototype.effect_t1_ea=function(mod, ch) { // ea
|
||||
|
|
|
@ -3,20 +3,20 @@
|
|||
*/
|
||||
Phaser.Plugin.Webcam = function (game, parent) {
|
||||
|
||||
Phaser.Plugin.call(this, game, parent);
|
||||
Phaser.Plugin.call(this, game, parent);
|
||||
|
||||
if (!game.device.getUserMedia)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!game.device.getUserMedia)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
||||
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
||||
|
||||
this.context = null;
|
||||
this.stream = null;
|
||||
this.context = null;
|
||||
this.stream = null;
|
||||
|
||||
this.video = document.createElement('video');
|
||||
this.video.autoplay = true;
|
||||
this.video = document.createElement('video');
|
||||
this.video.autoplay = true;
|
||||
|
||||
};
|
||||
|
||||
|
@ -25,56 +25,56 @@ Phaser.Plugin.Webcam.prototype.constructor = Phaser.Plugin.Webcam;
|
|||
|
||||
Phaser.Plugin.Webcam.prototype.start = function (width, height, context) {
|
||||
|
||||
console.log('Webcam start', width, height);
|
||||
console.log('Webcam start', width, height);
|
||||
|
||||
this.context = context;
|
||||
this.context = context;
|
||||
|
||||
if (!this.stream)
|
||||
{
|
||||
navigator.getUserMedia( { video: { mandatory: { minWidth: width, minHeight: height } } }, this.connectCallback.bind(this), this.errorCallback.bind(this));
|
||||
}
|
||||
if (!this.stream)
|
||||
{
|
||||
navigator.getUserMedia( { video: { mandatory: { minWidth: width, minHeight: height } } }, this.connectCallback.bind(this), this.errorCallback.bind(this));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Plugin.Webcam.prototype.stop = function () {
|
||||
|
||||
if (this.stream)
|
||||
{
|
||||
this.stream.stop();
|
||||
this.stream = null;
|
||||
}
|
||||
if (this.stream)
|
||||
{
|
||||
this.stream.stop();
|
||||
this.stream = null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Plugin.Webcam.prototype.connectCallback = function (stream) {
|
||||
|
||||
this.stream = stream;
|
||||
this.stream = stream;
|
||||
|
||||
this.video.src = window.URL.createObjectURL(this.stream);
|
||||
this.video.src = window.URL.createObjectURL(this.stream);
|
||||
|
||||
};
|
||||
|
||||
Phaser.Plugin.Webcam.prototype.errorCallback = function (e) {
|
||||
|
||||
console.log('Video Stream rejected', e);
|
||||
console.log('Video Stream rejected', e);
|
||||
|
||||
};
|
||||
|
||||
Phaser.Plugin.Webcam.prototype.grab = function (context, x, y) {
|
||||
|
||||
if (this.stream)
|
||||
{
|
||||
context.drawImage(this.video, x, y);
|
||||
}
|
||||
if (this.stream)
|
||||
{
|
||||
context.drawImage(this.video, x, y);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.Plugin.Webcam.prototype.update = function () {
|
||||
|
||||
if (this.stream)
|
||||
{
|
||||
this.context.drawImage(this.video, 0, 0);
|
||||
}
|
||||
if (this.stream)
|
||||
{
|
||||
this.context.drawImage(this.video, 0, 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -14,4 +14,4 @@
|
|||
} else {
|
||||
root.Phaser = Phaser;
|
||||
}
|
||||
}).call(this);
|
||||
}).call(this);
|
||||
|
|
115
src/Phaser.js
115
src/Phaser.js
|
@ -1,3 +1,4 @@
|
|||
/* global Phaser:true */
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
|
@ -13,68 +14,68 @@ var Phaser = Phaser || {
|
|||
DEV_VERSION: '2.0.2',
|
||||
GAMES: [],
|
||||
|
||||
AUTO: 0,
|
||||
CANVAS: 1,
|
||||
WEBGL: 2,
|
||||
HEADLESS: 3,
|
||||
AUTO: 0,
|
||||
CANVAS: 1,
|
||||
WEBGL: 2,
|
||||
HEADLESS: 3,
|
||||
|
||||
NONE: 0,
|
||||
LEFT: 1,
|
||||
RIGHT: 2,
|
||||
UP: 3,
|
||||
DOWN: 4,
|
||||
NONE: 0,
|
||||
LEFT: 1,
|
||||
RIGHT: 2,
|
||||
UP: 3,
|
||||
DOWN: 4,
|
||||
|
||||
SPRITE: 0,
|
||||
BUTTON: 1,
|
||||
IMAGE: 2,
|
||||
GRAPHICS: 3,
|
||||
TEXT: 4,
|
||||
TILESPRITE: 5,
|
||||
BITMAPTEXT: 6,
|
||||
GROUP: 7,
|
||||
RENDERTEXTURE: 8,
|
||||
TILEMAP: 9,
|
||||
TILEMAPLAYER: 10,
|
||||
EMITTER: 11,
|
||||
POLYGON: 12,
|
||||
BITMAPDATA: 13,
|
||||
CANVAS_FILTER: 14,
|
||||
WEBGL_FILTER: 15,
|
||||
ELLIPSE: 16,
|
||||
SPRITEBATCH: 17,
|
||||
RETROFONT: 18,
|
||||
SPRITE: 0,
|
||||
BUTTON: 1,
|
||||
IMAGE: 2,
|
||||
GRAPHICS: 3,
|
||||
TEXT: 4,
|
||||
TILESPRITE: 5,
|
||||
BITMAPTEXT: 6,
|
||||
GROUP: 7,
|
||||
RENDERTEXTURE: 8,
|
||||
TILEMAP: 9,
|
||||
TILEMAPLAYER: 10,
|
||||
EMITTER: 11,
|
||||
POLYGON: 12,
|
||||
BITMAPDATA: 13,
|
||||
CANVAS_FILTER: 14,
|
||||
WEBGL_FILTER: 15,
|
||||
ELLIPSE: 16,
|
||||
SPRITEBATCH: 17,
|
||||
RETROFONT: 18,
|
||||
|
||||
// The various blend modes supported by pixi / phaser
|
||||
blendModes: {
|
||||
NORMAL:0,
|
||||
ADD:1,
|
||||
MULTIPLY:2,
|
||||
SCREEN:3,
|
||||
OVERLAY:4,
|
||||
DARKEN:5,
|
||||
LIGHTEN:6,
|
||||
COLOR_DODGE:7,
|
||||
COLOR_BURN:8,
|
||||
HARD_LIGHT:9,
|
||||
SOFT_LIGHT:10,
|
||||
DIFFERENCE:11,
|
||||
EXCLUSION:12,
|
||||
HUE:13,
|
||||
SATURATION:14,
|
||||
COLOR:15,
|
||||
LUMINOSITY:16
|
||||
},
|
||||
// The various blend modes supported by pixi / phaser
|
||||
blendModes: {
|
||||
NORMAL:0,
|
||||
ADD:1,
|
||||
MULTIPLY:2,
|
||||
SCREEN:3,
|
||||
OVERLAY:4,
|
||||
DARKEN:5,
|
||||
LIGHTEN:6,
|
||||
COLOR_DODGE:7,
|
||||
COLOR_BURN:8,
|
||||
HARD_LIGHT:9,
|
||||
SOFT_LIGHT:10,
|
||||
DIFFERENCE:11,
|
||||
EXCLUSION:12,
|
||||
HUE:13,
|
||||
SATURATION:14,
|
||||
COLOR:15,
|
||||
LUMINOSITY:16
|
||||
},
|
||||
|
||||
// The scale modes
|
||||
scaleModes: {
|
||||
DEFAULT:0,
|
||||
LINEAR:0,
|
||||
NEAREST:1
|
||||
}
|
||||
// The scale modes
|
||||
scaleModes: {
|
||||
DEFAULT:0,
|
||||
LINEAR:0,
|
||||
NEAREST:1
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
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.
|
||||
PIXI.InteractionManager = function () {
|
||||
// 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.
|
||||
};
|
||||
|
|
|
@ -139,7 +139,7 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loop)
|
|||
// Set-up some event listeners
|
||||
this.game.onPause.add(this.onPause, this);
|
||||
this.game.onResume.add(this.onResume, this);
|
||||
|
||||
|
||||
};
|
||||
|
||||
Phaser.Animation.prototype = {
|
||||
|
@ -338,7 +338,7 @@ Phaser.Animation.prototype = {
|
|||
this._parent.tilingTexture = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.loopCount++;
|
||||
this._parent.events.onAnimationLoop.dispatch(this._parent, this);
|
||||
this.onLoop.dispatch(this._parent, this);
|
||||
|
@ -586,4 +586,4 @@ Phaser.Animation.generateFrameNames = function (prefix, start, stop, suffix, zer
|
|||
|
||||
return output;
|
||||
|
||||
}
|
||||
};
|
||||
|
|
|
@ -29,7 +29,7 @@ Phaser.AnimationManager = function (sprite) {
|
|||
* @default
|
||||
*/
|
||||
this.currentFrame = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {boolean} updateIfVisible - Should the animation data continue to update even if the Sprite.visible is set to false.
|
||||
* @default
|
||||
|
@ -183,7 +183,7 @@ 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 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.
|
||||
|
@ -245,7 +245,7 @@ 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 Phaser.AnimationManager#update
|
||||
* @protected
|
||||
* @return {boolean} True if a new animation frame has been set, otherwise false.
|
||||
|
@ -343,7 +343,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, 'frameData', {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, 'frameTotal', {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
if (this._frameData)
|
||||
|
@ -390,7 +390,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, 'frame', {
|
|||
{
|
||||
return this._frameIndex;
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
@ -398,12 +398,12 @@ Object.defineProperty(Phaser.AnimationManager.prototype, 'frame', {
|
|||
if (typeof value === 'number' && this._frameData && this._frameData.getFrame(value) !== null)
|
||||
{
|
||||
this.currentFrame = this._frameData.getFrame(value);
|
||||
|
||||
|
||||
if (this.currentFrame)
|
||||
{
|
||||
this._frameIndex = value;
|
||||
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
|
||||
|
||||
if (this.sprite.__tilePattern)
|
||||
{
|
||||
this.__tilePattern = false;
|
||||
|
@ -441,7 +441,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, 'frameName', {
|
|||
{
|
||||
this._frameIndex = this.currentFrame.index;
|
||||
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
|
||||
|
||||
if (this.sprite.__tilePattern)
|
||||
{
|
||||
this.__tilePattern = false;
|
||||
|
|
|
@ -50,7 +50,7 @@ Phaser.AnimationParser = {
|
|||
var row = Math.floor((width - margin) / (frameWidth + spacing));
|
||||
var column = Math.floor((height - margin) / (frameHeight + spacing));
|
||||
var total = row * column;
|
||||
|
||||
|
||||
if (frameMax !== -1)
|
||||
{
|
||||
total = frameMax;
|
||||
|
@ -115,11 +115,11 @@ Phaser.AnimationParser = {
|
|||
|
||||
// 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();
|
||||
|
@ -180,7 +180,7 @@ Phaser.AnimationParser = {
|
|||
console.log(json);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Let's create some frames then
|
||||
var data = new Phaser.FrameData();
|
||||
|
||||
|
@ -188,7 +188,7 @@ Phaser.AnimationParser = {
|
|||
var frames = json['frames'];
|
||||
var newFrame;
|
||||
var i = 0;
|
||||
|
||||
|
||||
for (var key in frames)
|
||||
{
|
||||
var uuid = game.rnd.uuid();
|
||||
|
@ -266,7 +266,7 @@ Phaser.AnimationParser = {
|
|||
var frameY;
|
||||
var frameWidth;
|
||||
var frameHeight;
|
||||
|
||||
|
||||
for (var i = 0; i < frames.length; i++)
|
||||
{
|
||||
uuid = game.rnd.uuid();
|
||||
|
|
|
@ -23,7 +23,7 @@ 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.
|
||||
*/
|
||||
|
|
|
@ -102,7 +102,7 @@ Phaser.FrameData.prototype = {
|
|||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -115,7 +115,7 @@ Phaser.FrameData.prototype = {
|
|||
* @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++)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* @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.
|
||||
*/
|
||||
|
@ -36,7 +36,7 @@ Phaser.Camera = function (game, id, x, y, width, height) {
|
|||
this.id = 0;
|
||||
|
||||
/**
|
||||
* Camera 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 if set to camera cull.
|
||||
|
@ -95,7 +95,7 @@ Phaser.Camera = function (game, id, x, y, width, height) {
|
|||
* @property {Phaser.Point} scale - The scale of the display object to which all game objects are added. Set by World.boot
|
||||
*/
|
||||
this.scale = null;
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -306,7 +306,7 @@ 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.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Camera#setPosition
|
||||
* @param {number} x - X position.
|
||||
* @param {number} y - Y position.
|
||||
|
@ -325,7 +325,7 @@ Phaser.Camera.prototype = {
|
|||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -339,7 +339,7 @@ Phaser.Camera.prototype = {
|
|||
|
||||
/**
|
||||
* Resets the camera back to 0,0 and un-follows any object it may have been tracking.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Camera#reset
|
||||
*/
|
||||
reset: function () {
|
||||
|
@ -364,7 +364,7 @@ Object.defineProperty(Phaser.Camera.prototype, "x", {
|
|||
get: function () {
|
||||
return this.view.x;
|
||||
},
|
||||
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.view.x = value;
|
||||
|
@ -383,7 +383,7 @@ Object.defineProperty(Phaser.Camera.prototype, "x", {
|
|||
* @property {number} y - Gets or sets the cameras y position.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Camera.prototype, "y", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.view.y;
|
||||
},
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
* This is a base Filter template to use for any Phaser filter development.
|
||||
*
|
||||
*
|
||||
* @class Phaser.Filter
|
||||
* @classdesc Phaser - Filter
|
||||
* @constructor
|
||||
|
@ -25,8 +25,8 @@ Phaser.Filter = function (game, uniforms, fragmentSrc) {
|
|||
* @property {number} type - The const type of this object, either Phaser.WEBGL_FILTER or Phaser.CANVAS_FILTER.
|
||||
* @default
|
||||
*/
|
||||
this.type = Phaser.WEBGL_FILTER;
|
||||
|
||||
this.type = Phaser.WEBGL_FILTER;
|
||||
|
||||
/**
|
||||
* An array of passes - some filters contain a few steps this array simply stores the steps in a linear fashion.
|
||||
* For example the blur filter has two passes blurX and blurY.
|
||||
|
@ -34,7 +34,7 @@ Phaser.Filter = function (game, uniforms, fragmentSrc) {
|
|||
* @private
|
||||
*/
|
||||
this.passes = [this];
|
||||
|
||||
|
||||
/**
|
||||
* @property {array} shaders - Array an array of shaders.
|
||||
* @private
|
||||
|
@ -63,7 +63,7 @@ Phaser.Filter = function (game, uniforms, fragmentSrc) {
|
|||
mouse: { type: '2f', value: { x: 0.0, y: 0.0 }}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @property {array} fragmentSrc - The fragment shader code.
|
||||
*/
|
||||
|
@ -125,7 +125,7 @@ Phaser.Filter.prototype = {
|
|||
destroy: function () {
|
||||
|
||||
this.game = null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -313,7 +313,7 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
|
|||
|
||||
this._onBoot = function () {
|
||||
return _this.boot();
|
||||
}
|
||||
};
|
||||
|
||||
if (document.readyState === 'complete' || document.readyState === 'interactive')
|
||||
{
|
||||
|
|
|
@ -210,7 +210,7 @@ Phaser.Group.prototype.add = function (child) {
|
|||
|
||||
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.
|
||||
|
@ -247,7 +247,7 @@ Phaser.Group.prototype.addAt = function (child, index) {
|
|||
|
||||
return child;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the child found at the given index within this Group.
|
||||
|
@ -267,7 +267,7 @@ Phaser.Group.prototype.getAt = function (index) {
|
|||
return this.getChildAt(index);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Automatically creates a new Phaser.Sprite object and adds it to the top of this Group.
|
||||
|
@ -297,9 +297,9 @@ Phaser.Group.prototype.create = function (x, y, key, frame, exists) {
|
|||
child.alive = exists;
|
||||
|
||||
this.addChild(child);
|
||||
|
||||
|
||||
child.z = this.children.length;
|
||||
|
||||
|
||||
if (child.events)
|
||||
{
|
||||
child.events.onAddedToGroup.dispatch(child, this);
|
||||
|
@ -312,7 +312,7 @@ Phaser.Group.prototype.create = function (x, y, key, frame, exists) {
|
|||
|
||||
return child;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Automatically creates multiple Phaser.Sprite objects and adds them to the top of this Group.
|
||||
|
@ -334,7 +334,7 @@ Phaser.Group.prototype.createMultiple = function (quantity, key, frame, exists)
|
|||
this.create(0, 0, key, frame, exists);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal method that re-applies all of the childrens Z values.
|
||||
|
@ -351,7 +351,7 @@ Phaser.Group.prototype.updateZ = function () {
|
|||
this.children[i].z = i;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Advances the Group cursor to the next object in the Group. If it's at the end of the Group it wraps around to the first object.
|
||||
|
@ -375,7 +375,7 @@ Phaser.Group.prototype.next = function () {
|
|||
this.cursor = this.children[this._cache[8]];
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Moves the Group cursor to the previous object in the Group. If it's at the start of the Group it wraps around to the last object.
|
||||
|
@ -399,7 +399,7 @@ Phaser.Group.prototype.previous = function () {
|
|||
this.cursor = this.children[this._cache[8]];
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Swaps the position of two children in this Group. Both children must be in this Group.
|
||||
|
@ -419,8 +419,8 @@ Phaser.Group.prototype.swap = function (child1, child2) {
|
|||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Brings the given child to the top of this Group so it renders above all other children.
|
||||
|
@ -439,7 +439,7 @@ Phaser.Group.prototype.bringToTop = function (child) {
|
|||
|
||||
return child;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends the given child to the bottom of this Group so it renders below all other children.
|
||||
|
@ -458,7 +458,7 @@ Phaser.Group.prototype.sendToBack = function (child) {
|
|||
|
||||
return child;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Moves the given child up one place in this Group unless it's already at the top.
|
||||
|
@ -482,7 +482,7 @@ Phaser.Group.prototype.moveUp = function (child) {
|
|||
|
||||
return child;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Moves the given child down one place in this Group unless it's already at the top.
|
||||
|
@ -506,7 +506,7 @@ Phaser.Group.prototype.moveDown = function (child) {
|
|||
|
||||
return child;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Positions the child found at the given index within this Group to the given x and y coordinates.
|
||||
|
@ -528,7 +528,7 @@ Phaser.Group.prototype.xy = function (index, x, y) {
|
|||
this.getChildAt(index).y = y;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Reverses all children in this Group. Note that this does not propagate, only direct children are re-ordered.
|
||||
|
@ -540,7 +540,7 @@ Phaser.Group.prototype.reverse = function () {
|
|||
this.children.reverse();
|
||||
this.updateZ();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the index position of the given child in this Group. This should always match the childs z property.
|
||||
|
@ -553,7 +553,7 @@ Phaser.Group.prototype.getIndex = function (child) {
|
|||
|
||||
return this.children.indexOf(child);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Replaces a child of this Group with the given newChild. The newChild cannot be a member of this Group.
|
||||
|
@ -566,7 +566,7 @@ Phaser.Group.prototype.getIndex = function (child) {
|
|||
Phaser.Group.prototype.replace = function (oldChild, newChild) {
|
||||
|
||||
var index = this.getIndex(oldChild);
|
||||
|
||||
|
||||
if (index !== -1)
|
||||
{
|
||||
if (newChild.parent !== undefined)
|
||||
|
@ -589,7 +589,7 @@ Phaser.Group.prototype.replace = function (oldChild, newChild) {
|
|||
return temp;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the given property to the given value on the child. The operation controls the assignment of the value.
|
||||
|
@ -649,7 +649,7 @@ Phaser.Group.prototype.setProperty = function (child, key, value, operation) {
|
|||
else if (operation == 4) { child[key[0]][key[1]][key[2]][key[3]] /= value; }
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This function allows you to quickly set a property on a single child of this Group to a new value.
|
||||
|
@ -675,7 +675,7 @@ Phaser.Group.prototype.set = function (child, key, value, checkAlive, checkVisib
|
|||
this.setProperty(child, key, value, operation);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This function allows you to quickly set the same property across all children of this Group to a new value.
|
||||
|
@ -708,7 +708,7 @@ Phaser.Group.prototype.setAll = function (key, value, checkAlive, checkVisible,
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This function allows you to quickly set the same property across all children of this Group, and any child Groups, to a new value.
|
||||
|
@ -747,7 +747,7 @@ Phaser.Group.prototype.setAllChildren = function (key, value, checkAlive, checkV
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds the amount to the given property on all children in this Group.
|
||||
|
@ -763,7 +763,7 @@ Phaser.Group.prototype.addAll = function (property, amount, checkAlive, checkVis
|
|||
|
||||
this.setAll(property, amount, checkAlive, checkVisible, 1);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Subtracts the amount from the given property on all children in this Group.
|
||||
|
@ -779,7 +779,7 @@ Phaser.Group.prototype.subAll = function (property, amount, checkAlive, checkVis
|
|||
|
||||
this.setAll(property, amount, checkAlive, checkVisible, 2);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Multiplies the given property by the amount on all children in this Group.
|
||||
|
@ -795,7 +795,7 @@ Phaser.Group.prototype.multiplyAll = function (property, amount, checkAlive, che
|
|||
|
||||
this.setAll(property, amount, checkAlive, checkVisible, 3);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Divides the given property by the amount on all children in this Group.
|
||||
|
@ -811,12 +811,12 @@ Phaser.Group.prototype.divideAll = function (property, amount, checkAlive, check
|
|||
|
||||
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.
|
||||
|
@ -834,11 +834,11 @@ Phaser.Group.prototype.callAllExists = function (callback, existsValue) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a reference to a function that exists on a child of the Group based on the given callback array.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Group#callbackFromArray
|
||||
* @param {object} child - The object to inspect.
|
||||
* @param {array} callback - The array of function names.
|
||||
|
@ -887,12 +887,12 @@ Phaser.Group.prototype.callbackFromArray = function (child, callback, length) {
|
|||
|
||||
return false;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 method parameter and context you can add as many extra parameters as you like, which will all be passed to the child.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Group#callAll
|
||||
* @param {string} method - A string containing the name of the function that will be called. The function must exist on the child.
|
||||
* @param {string} [context=null] - A string containing the context under which the method will be executed. Set to null to default to the child.
|
||||
|
@ -947,7 +947,7 @@ Phaser.Group.prototype.callAll = function (method, context) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The core preUpdate - as called by World.
|
||||
|
@ -971,7 +971,7 @@ Phaser.Group.prototype.preUpdate = function () {
|
|||
|
||||
return true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The core update - as called by World.
|
||||
|
@ -987,7 +987,7 @@ Phaser.Group.prototype.update = function () {
|
|||
this.children[i].update();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The core postUpdate - as called by World.
|
||||
|
@ -1010,14 +1010,14 @@ Phaser.Group.prototype.postUpdate = function () {
|
|||
this.children[i].postUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* Note: Currently this will skip any children which are Groups themselves.
|
||||
*
|
||||
*
|
||||
* @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').
|
||||
|
@ -1039,13 +1039,13 @@ Phaser.Group.prototype.forEach = function (callback, callbackContext, checkExist
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Allows you to call your own function on each member of this Group where child.exists=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.forEachExists(causeDamage, this, 500)
|
||||
*
|
||||
*
|
||||
* @method Phaser.Group#forEachExists
|
||||
* @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').
|
||||
|
@ -1057,13 +1057,13 @@ Phaser.Group.prototype.forEachExists = function (callback, callbackContext) {
|
|||
|
||||
this.iterate('exists', true, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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').
|
||||
|
@ -1075,13 +1075,13 @@ Phaser.Group.prototype.forEachAlive = function (callback, callbackContext) {
|
|||
|
||||
this.iterate('alive', true, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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').
|
||||
|
@ -1093,7 +1093,7 @@ Phaser.Group.prototype.forEachDead = function (callback, callbackContext) {
|
|||
|
||||
this.iterate('alive', false, Phaser.Group.RETURN_TOTAL, callback, callbackContext, args);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to sort the group according to a particular value and order.
|
||||
|
@ -1127,7 +1127,7 @@ Phaser.Group.prototype.sort = function (index, order) {
|
|||
|
||||
this.updateZ();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* An internal helper function for the sort process.
|
||||
|
@ -1158,7 +1158,7 @@ Phaser.Group.prototype.ascendingSortHandler = function (a, b) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* An internal helper function for the sort process.
|
||||
|
@ -1182,13 +1182,13 @@ Phaser.Group.prototype.descendingSortHandler = function (a, b) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterates over the children of the Group. When a child has a property matching key that equals the given value, it is considered as a match.
|
||||
* Matched children can be sent to the optional callback, or simply returned or counted.
|
||||
* You can add as many callback parameters as you like, which will all be passed to the callback along with the child, after the callbackContext parameter.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Group#iterate
|
||||
* @param {string} key - The child property to check, i.e. 'exists', 'alive', 'health'
|
||||
* @param {any} value - If child.key === this value it will be considered a match. Note that a strict comparison is used.
|
||||
|
@ -1239,7 +1239,7 @@ Phaser.Group.prototype.iterate = function (key, value, returnType, callback, cal
|
|||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first object with exists == (the given state) in the Group.
|
||||
|
@ -1257,7 +1257,7 @@ Phaser.Group.prototype.getFirstExists = function (state) {
|
|||
|
||||
return this.iterate('exists', state, Phaser.Group.RETURN_CHILD);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first object with alive === true in the group.
|
||||
|
@ -1270,7 +1270,7 @@ Phaser.Group.prototype.getFirstAlive = function () {
|
|||
|
||||
return this.iterate('alive', true, Phaser.Group.RETURN_CHILD);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to retrieve the first object with alive === false in the group.
|
||||
|
@ -1283,7 +1283,7 @@ Phaser.Group.prototype.getFirstDead = function () {
|
|||
|
||||
return this.iterate('alive', false, Phaser.Group.RETURN_CHILD);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the child at the top of this Group. The top is the one being displayed (rendered) above every other child.
|
||||
|
@ -1298,7 +1298,7 @@ Phaser.Group.prototype.getTop = function () {
|
|||
return this.children[this.children.length - 1];
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the child at the bottom of this Group. The bottom is the one being displayed (rendered) below every other child.
|
||||
|
@ -1313,7 +1313,7 @@ Phaser.Group.prototype.getBottom = function () {
|
|||
return this.children[0];
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to find out how many members of the group are alive.
|
||||
|
@ -1325,7 +1325,7 @@ Phaser.Group.prototype.countLiving = function () {
|
|||
|
||||
return this.iterate('alive', true, Phaser.Group.RETURN_TOTAL);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to find out how many members of the group are dead.
|
||||
|
@ -1337,7 +1337,7 @@ Phaser.Group.prototype.countDead = function () {
|
|||
|
||||
return this.iterate('alive', false, Phaser.Group.RETURN_TOTAL);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a member at random from the group.
|
||||
|
@ -1359,7 +1359,7 @@ Phaser.Group.prototype.getRandom = function (startIndex, length) {
|
|||
|
||||
return this.game.math.getRandom(this.children, startIndex, length);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes the given child from this Group and sets its group property to null.
|
||||
|
@ -1391,7 +1391,7 @@ Phaser.Group.prototype.remove = function (child) {
|
|||
|
||||
return true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes all children from this Group, setting all group properties to null.
|
||||
|
@ -1419,7 +1419,7 @@ Phaser.Group.prototype.removeAll = function () {
|
|||
|
||||
this.cursor = null;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes all children from this Group whos index falls beteen the given startIndex and endIndex values.
|
||||
|
@ -1457,7 +1457,7 @@ Phaser.Group.prototype.removeBetween = function (startIndex, endIndex) {
|
|||
|
||||
this.updateZ();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroys this Group. Removes all children, then removes the container from the display list and nulls references.
|
||||
|
@ -1503,7 +1503,7 @@ Phaser.Group.prototype.destroy = function (destroyChildren, soft) {
|
|||
this.exists = false;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Phaser.Group#total
|
||||
|
@ -1562,7 +1562,7 @@ Object.defineProperty(Phaser.Group.prototype, "angle", {
|
|||
* @property {boolean} fixedToCamera - Set to true to fix this Group to the Camera at its current world coordinates.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Group.prototype, "fixedToCamera", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this._cache[7];
|
||||
|
|
|
@ -35,7 +35,7 @@ Phaser.LinkedList = function () {
|
|||
* @default
|
||||
*/
|
||||
this.last = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {object} game - Number of elements in the list.
|
||||
* @default
|
||||
|
@ -48,7 +48,7 @@ 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.
|
||||
|
@ -81,7 +81,7 @@ 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.
|
||||
*/
|
||||
|
@ -124,7 +124,7 @@ Phaser.LinkedList.prototype = {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
@ -136,7 +136,7 @@ Phaser.LinkedList.prototype = {
|
|||
}
|
||||
|
||||
var entity = this.first;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
if (entity && entity[callback])
|
||||
|
@ -147,7 +147,7 @@ Phaser.LinkedList.prototype = {
|
|||
entity = entity.next;
|
||||
|
||||
}
|
||||
while(entity != this.last.next)
|
||||
while(entity != this.last.next);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* @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
|
||||
|
@ -21,30 +21,30 @@ Phaser.Plugin = function (game, parent) {
|
|||
* @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
|
||||
|
@ -56,13 +56,13 @@ Phaser.Plugin = function (game, parent) {
|
|||
* @default
|
||||
*/
|
||||
this.hasPostUpdate = 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
|
||||
|
@ -115,7 +115,7 @@ Phaser.Plugin.prototype = {
|
|||
this.parent = null;
|
||||
this.active = false;
|
||||
this.visible = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
* The Plugin Manager is responsible for the loading, running and unloading of Phaser Plugins.
|
||||
*
|
||||
*
|
||||
* @class Phaser.PluginManager
|
||||
* @classdesc Phaser - PluginManager
|
||||
* @constructor
|
||||
|
@ -21,18 +21,18 @@ 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
|
||||
|
@ -132,7 +132,7 @@ Phaser.PluginManager.prototype = {
|
|||
* @param {Phaser.Plugin} plugin - The plugin to be removed.
|
||||
*/
|
||||
remove: function (plugin) {
|
||||
|
||||
|
||||
if (this._pluginsLength === 0)
|
||||
{
|
||||
return;
|
||||
|
@ -155,7 +155,7 @@ Phaser.PluginManager.prototype = {
|
|||
* @method Phaser.PluginManager#removeAll
|
||||
*/
|
||||
removeAll: function() {
|
||||
|
||||
|
||||
for (this._p = 0; this._p < this._pluginsLength; this._p++)
|
||||
{
|
||||
this.plugins[this._p].destroy();
|
||||
|
@ -167,7 +167,7 @@ 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 () {
|
||||
|
@ -190,11 +190,11 @@ 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)
|
||||
{
|
||||
return;
|
||||
|
@ -214,11 +214,11 @@ Phaser.PluginManager.prototype = {
|
|||
* PostUpdate is the last thing to be called before the world render.
|
||||
* In particular, it is called after the world postUpdate, which means the camera has been adjusted.
|
||||
* It only calls plugins who have active=true.
|
||||
*
|
||||
*
|
||||
* @method Phaser.PluginManager#postUpdate
|
||||
*/
|
||||
postUpdate: function () {
|
||||
|
||||
|
||||
if (this._pluginsLength === 0)
|
||||
{
|
||||
return;
|
||||
|
@ -237,7 +237,7 @@ 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 () {
|
||||
|
@ -260,7 +260,7 @@ 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 () {
|
||||
|
@ -282,7 +282,7 @@ Phaser.PluginManager.prototype = {
|
|||
|
||||
/**
|
||||
* Clear down this PluginManager and null out references
|
||||
*
|
||||
*
|
||||
* @method Phaser.PluginManager#destroy
|
||||
*/
|
||||
destroy: function () {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
/**
|
||||
* The ScaleManager object is responsible for helping you manage the scaling, resizing and alignment of your game within the browser.
|
||||
*
|
||||
* @class Phaser.ScaleManager
|
||||
* @class Phaser.ScaleManager
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
* @param {number} width - The native width of the game.
|
||||
|
@ -239,7 +239,7 @@ Phaser.ScaleManager = function (game, width, height) {
|
|||
document.addEventListener('fullscreenchange', function (event) {
|
||||
return _this.fullScreenChange(event);
|
||||
}, false);
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -558,7 +558,7 @@ Phaser.ScaleManager.prototype = {
|
|||
{
|
||||
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)
|
||||
|
@ -577,7 +577,7 @@ Phaser.ScaleManager.prototype = {
|
|||
{
|
||||
// Set minimum height of content to new window height
|
||||
document.documentElement['style'].minHeight = window.innerHeight + 'px';
|
||||
|
||||
|
||||
if (this.incorrectOrientation === true)
|
||||
{
|
||||
this.setMaximum();
|
||||
|
@ -643,7 +643,7 @@ Phaser.ScaleManager.prototype = {
|
|||
|
||||
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)
|
||||
|
@ -675,9 +675,9 @@ Phaser.ScaleManager.prototype = {
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -756,7 +756,7 @@ Object.defineProperty(Phaser.ScaleManager.prototype, "isFullScreen", {
|
|||
|
||||
get: function () {
|
||||
|
||||
return (document['fullscreenElement'] || document['mozFullScreenElement'] || document['webkitFullscreenElement'])
|
||||
return (document['fullscreenElement'] || document['mozFullScreenElement'] || document['webkitFullscreenElement']);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ Phaser.Signal = function () {
|
|||
* @private
|
||||
*/
|
||||
this._bindings = [];
|
||||
|
||||
|
||||
/**
|
||||
* @property {any} _prevParams - Internal variable.
|
||||
* @private
|
||||
|
@ -47,7 +47,7 @@ Phaser.Signal.prototype = {
|
|||
memorize: false,
|
||||
|
||||
/**
|
||||
* @property {boolean} _shouldPropagate
|
||||
* @property {boolean} _shouldPropagate
|
||||
* @private
|
||||
*/
|
||||
_shouldPropagate: true,
|
||||
|
@ -68,7 +68,7 @@ Phaser.Signal.prototype = {
|
|||
*/
|
||||
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) );
|
||||
throw new Error('listener is a required param of {fn}() and should be a Function.'.replace('{fn}', fnName));
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -89,14 +89,14 @@ Phaser.Signal.prototype = {
|
|||
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.');
|
||||
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){
|
||||
if (this.memorize && this._prevParams) {
|
||||
binding.execute(this._prevParams);
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ Phaser.Signal.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* @method Phaser.Signal#_addBinding
|
||||
* @method Phaser.Signal#_addBinding
|
||||
* @param {Phaser.SignalBinding} binding - An Object representing the binding between the Signal and listener.
|
||||
* @private
|
||||
*/
|
||||
|
@ -135,7 +135,7 @@ Phaser.Signal.prototype = {
|
|||
|
||||
/**
|
||||
* 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).
|
||||
|
@ -147,7 +147,7 @@ Phaser.Signal.prototype = {
|
|||
|
||||
/**
|
||||
* 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).
|
||||
|
@ -265,7 +265,7 @@ Phaser.Signal.prototype = {
|
|||
//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);
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,8 +67,8 @@ Phaser.SignalBinding.prototype = {
|
|||
|
||||
/**
|
||||
* Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute` (curried parameters).
|
||||
* @property {array|null} params
|
||||
* @default
|
||||
* @property {array|null} params
|
||||
* @default
|
||||
*/
|
||||
params: null,
|
||||
|
||||
|
@ -79,13 +79,13 @@ Phaser.SignalBinding.prototype = {
|
|||
* @param {array} [paramsArr] - Array of parameters that should be passed to the listener.
|
||||
* @return {any} Value returned by the listener.
|
||||
*/
|
||||
execute: function (paramsArr) {
|
||||
execute: function(paramsArr) {
|
||||
|
||||
var handlerReturn, params;
|
||||
|
||||
if (this.active && !!this._listener)
|
||||
{
|
||||
params = this.params? this.params.concat(paramsArr) : paramsArr;
|
||||
params = this.params ? this.params.concat(paramsArr) : paramsArr;
|
||||
handlerReturn = this._listener.apply(this.context, params);
|
||||
|
||||
if (this._isOnce)
|
||||
|
|
|
@ -26,7 +26,7 @@ Phaser.Stage = function (game, width, height) {
|
|||
* @property {Phaser.Point} offset - Holds the offset coordinates of the Game.canvas from the top-left of the browser window (used by Input and other classes)
|
||||
*/
|
||||
this.offset = new Phaser.Point();
|
||||
|
||||
|
||||
PIXI.Stage.call(this, 0x000000, false);
|
||||
|
||||
/**
|
||||
|
@ -96,11 +96,11 @@ Phaser.Stage.prototype.constructor = Phaser.Stage;
|
|||
/**
|
||||
* This is called automatically after the plugins preUpdate and before the State.update.
|
||||
* Most objects have preUpdate methods and it's where initial movement and positioning is done.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Stage#preUpdate
|
||||
*/
|
||||
Phaser.Stage.prototype.preUpdate = function () {
|
||||
|
||||
|
||||
this.currentRenderOrderID = 0;
|
||||
|
||||
// This can't loop in reverse, we need the orderID to be in sequence
|
||||
|
@ -111,11 +111,11 @@ Phaser.Stage.prototype.preUpdate = function () {
|
|||
this.children[i].preUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This is called automatically after the State.update, but before particles or plugins update.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Stage#update
|
||||
*/
|
||||
Phaser.Stage.prototype.update = function () {
|
||||
|
@ -127,14 +127,14 @@ Phaser.Stage.prototype.update = function () {
|
|||
this.children[i].update();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This is called automatically before the renderer runs and after the plugins have updated.
|
||||
* In postUpdate this is where all the final physics calculatations and object positioning happens.
|
||||
* The objects are processed in the order of the display list.
|
||||
* The only exception to this is if the camera is following an object, in which case that is updated first.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Stage#postUpdate
|
||||
*/
|
||||
Phaser.Stage.prototype.postUpdate = function () {
|
||||
|
@ -176,7 +176,7 @@ Phaser.Stage.prototype.postUpdate = function () {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses a Game configuration object.
|
||||
|
@ -229,7 +229,7 @@ Phaser.Stage.prototype.parseConfig = function (config) {
|
|||
this.backgroundColor = config['backgroundColor'];
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialises the stage and adds the event listeners.
|
||||
|
@ -246,14 +246,14 @@ Phaser.Stage.prototype.boot = function () {
|
|||
|
||||
this._onChange = function (event) {
|
||||
return _this.visibilityChange(event);
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Canvas.setUserSelect(this.game.canvas, 'none');
|
||||
Phaser.Canvas.setTouchAction(this.game.canvas, 'none');
|
||||
|
||||
this.checkVisibility();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Starts a page visibility event listener running, or window.blur/focus if not supported by the browser.
|
||||
|
@ -294,7 +294,7 @@ Phaser.Stage.prototype.checkVisibility = function () {
|
|||
window.onblur = this._onChange;
|
||||
window.onfocus = this._onChange;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This method is called when the document visibility is changed.
|
||||
|
@ -331,7 +331,7 @@ Phaser.Stage.prototype.visibilityChange = function (event) {
|
|||
this.game.gameResumed(event);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the background color for the stage.
|
||||
|
@ -346,7 +346,7 @@ Phaser.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
var hex = this._backgroundColor.toString(16);
|
||||
hex = '000000'.substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = '#' + hex;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Phaser.Stage#backgroundColor
|
||||
|
@ -383,7 +383,7 @@ Object.defineProperty(Phaser.Stage.prototype, "backgroundColor", {
|
|||
* @property {boolean} smoothed - Set to true to smooth all sprites rendered on this Stage, or false to disable smoothing (great for pixel art)
|
||||
*/
|
||||
Object.defineProperty(Phaser.Stage.prototype, "smoothed", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return !PIXI.scaleModes.LINEAR;
|
||||
|
|
|
@ -18,12 +18,12 @@ 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.
|
||||
*/
|
||||
this.add = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.GameObjectCreator} make - Reference to the GameObjectCreator.
|
||||
*/
|
||||
|
@ -33,32 +33,32 @@ Phaser.State = function () {
|
|||
* @property {Phaser.Camera} camera - A handy reference to world.camera.
|
||||
*/
|
||||
this.camera = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Cache} cache - Reference to the assets cache.
|
||||
*/
|
||||
this.cache = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Input} input - Reference to the input manager
|
||||
*/
|
||||
this.input = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Loader} load - Reference to the assets loader.
|
||||
*/
|
||||
this.load = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Math} math - Reference to the math helper.
|
||||
*/
|
||||
this.math = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.SoundManager} sound - Reference to the sound manager.
|
||||
*/
|
||||
this.sound = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.ScaleManager} scale - Reference to the game scale manager.
|
||||
*/
|
||||
|
@ -68,27 +68,27 @@ Phaser.State = function () {
|
|||
* @property {Phaser.Stage} stage - Reference to the stage.
|
||||
*/
|
||||
this.stage = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.TimeManager} time - Reference to game clock.
|
||||
*/
|
||||
this.time = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.TweenManager} tweens - Reference to the tween manager.
|
||||
*/
|
||||
this.tweens = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.World} world - Reference to the world.
|
||||
*/
|
||||
this.world = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Particles} particles - The Particle Manager for the game. It is called during the game update loop and in turn updates any Emitters attached to it.
|
||||
*/
|
||||
this.particles = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Physics.World} physics - Reference to the physics manager.
|
||||
*/
|
||||
|
@ -106,7 +106,7 @@ 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 () {
|
||||
|
@ -114,7 +114,7 @@ Phaser.State.prototype = {
|
|||
|
||||
/**
|
||||
* Put update logic here.
|
||||
*
|
||||
*
|
||||
* @method Phaser.State#loadUpdate
|
||||
*/
|
||||
loadUpdate: function () {
|
||||
|
@ -122,7 +122,7 @@ Phaser.State.prototype = {
|
|||
|
||||
/**
|
||||
* Put render operations here.
|
||||
*
|
||||
*
|
||||
* @method Phaser.State#loadRender
|
||||
*/
|
||||
loadRender: function () {
|
||||
|
@ -131,7 +131,7 @@ Phaser.State.prototype = {
|
|||
/**
|
||||
* 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 () {
|
||||
|
@ -139,7 +139,7 @@ Phaser.State.prototype = {
|
|||
|
||||
/**
|
||||
* Put update logic here.
|
||||
*
|
||||
*
|
||||
* @method Phaser.State#update
|
||||
*/
|
||||
update: function () {
|
||||
|
@ -147,7 +147,7 @@ Phaser.State.prototype = {
|
|||
|
||||
/**
|
||||
* Put render operations here.
|
||||
*
|
||||
*
|
||||
* @method Phaser.State#render
|
||||
*/
|
||||
render: function () {
|
||||
|
@ -155,7 +155,7 @@ Phaser.State.prototype = {
|
|||
|
||||
/**
|
||||
* This method will be called when game paused.
|
||||
*
|
||||
*
|
||||
* @method Phaser.State#paused
|
||||
*/
|
||||
paused: function () {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -75,7 +75,7 @@ Phaser.StateManager = function (game, pendingState) {
|
|||
* @property {function} onPreloadCallback - This will be called when init states (loading assets...).
|
||||
*/
|
||||
this.onPreloadCallback = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {function} onCreateCallback - This will be called when create states (setup states...).
|
||||
*/
|
||||
|
@ -256,7 +256,7 @@ Phaser.StateManager.prototype = {
|
|||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Used by onInit and onShutdown when those functions don't exist on the state
|
||||
* @method Phaser.StateManager#dummy
|
||||
|
|
|
@ -33,8 +33,8 @@ Phaser.World = function (game) {
|
|||
* @property {Phaser.Camera} camera - Camera instance.
|
||||
*/
|
||||
this.camera = null;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.World.prototype = Object.create(Phaser.Group.prototype);
|
||||
Phaser.World.prototype.constructor = Phaser.World;
|
||||
|
@ -57,7 +57,7 @@ Phaser.World.prototype.boot = function () {
|
|||
|
||||
this.game.stage.addChild(this);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the size of this world. Note that this doesn't modify the world x/y coordinates, just the width and height.
|
||||
|
@ -90,7 +90,7 @@ Phaser.World.prototype.setBounds = function (x, y, width, height) {
|
|||
|
||||
this.game.physics.setBoundsToWorld();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroyer of worlds.
|
||||
|
@ -102,7 +102,7 @@ Phaser.World.prototype.shutdown = function () {
|
|||
// World is a Group, so run a soft destruction on this and all children.
|
||||
this.destroy(true, true);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Phaser.World#width
|
||||
|
|
|
@ -24,7 +24,7 @@ Phaser.BitmapData = function (game, key, width, height) {
|
|||
if (typeof height === 'undefined') { height = 100; }
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
|
@ -37,7 +37,7 @@ Phaser.BitmapData = function (game, key, width, height) {
|
|||
* @property {number} width - The width of the BitmapData in pixels.
|
||||
*/
|
||||
this.width = width;
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} height - The height of the BitmapData in pixels.
|
||||
*/
|
||||
|
@ -48,7 +48,7 @@ Phaser.BitmapData = function (game, key, width, height) {
|
|||
* @default
|
||||
*/
|
||||
this.canvas = Phaser.Canvas.create(width, height, '', true);
|
||||
|
||||
|
||||
/**
|
||||
* @property {CanvasRenderingContext2D} context - The 2d context of the canvas.
|
||||
* @default
|
||||
|
@ -82,13 +82,13 @@ Phaser.BitmapData = function (game, key, width, height) {
|
|||
* @default
|
||||
*/
|
||||
this.baseTexture = new PIXI.BaseTexture(this.canvas);
|
||||
|
||||
|
||||
/**
|
||||
* @property {PIXI.Texture} texture - The PIXI.Texture.
|
||||
* @default
|
||||
*/
|
||||
this.texture = new PIXI.Texture(this.baseTexture);
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Frame} textureFrame - The Frame this BitmapData uses for rendering.
|
||||
* @default
|
||||
|
@ -106,13 +106,13 @@ Phaser.BitmapData = function (game, key, width, height) {
|
|||
*/
|
||||
this.dirty = false;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.BitmapData.prototype = {
|
||||
|
||||
/**
|
||||
* Updates the given objects so that they use this BitmapData as their texture. This will replace any texture they will currently have set.
|
||||
*
|
||||
*
|
||||
* @method Phaser.BitmapData#add
|
||||
* @param {Phaser.Sprite|Phaser.Sprite[]|Phaser.Image|Phaser.Image[]} object - Either a single Sprite/Image or an Array of Sprites/Images.
|
||||
*/
|
||||
|
@ -142,7 +142,7 @@ Phaser.BitmapData.prototype = {
|
|||
clear: function () {
|
||||
|
||||
this.context.clearRect(0, 0, this.width, this.height);
|
||||
|
||||
|
||||
this.dirty = true;
|
||||
|
||||
},
|
||||
|
@ -163,7 +163,7 @@ Phaser.BitmapData.prototype = {
|
|||
this.textureFrame.height = height;
|
||||
this.imageData = this.context.getImageData(0, 0, width, height);
|
||||
}
|
||||
|
||||
|
||||
this.dirty = true;
|
||||
|
||||
},
|
||||
|
|
|
@ -36,7 +36,7 @@ Phaser.BitmapText = function (game, x, y, font, text, size) {
|
|||
*/
|
||||
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
|
||||
*/
|
||||
|
@ -177,7 +177,7 @@ Phaser.BitmapText.prototype.preUpdate = function () {
|
|||
|
||||
return true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Override and use this function in your own custom objects to handle any update requirements you may have.
|
||||
|
@ -186,7 +186,7 @@ Phaser.BitmapText.prototype.preUpdate = function () {
|
|||
*/
|
||||
Phaser.BitmapText.prototype.update = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Automatically called by World.postUpdate.
|
||||
|
@ -201,7 +201,7 @@ Phaser.BitmapText.prototype.postUpdate = function () {
|
|||
this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy this BitmapText instance. This will remove any filters and un-parent any children.
|
||||
|
@ -257,7 +257,7 @@ Phaser.BitmapText.prototype.destroy = function(destroyChildren) {
|
|||
this.mask = null;
|
||||
this.game = null;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Phaser.BitmapText#align
|
||||
|
@ -401,7 +401,7 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'text', {
|
|||
* @property {boolean} inputEnabled - Set to true to allow this object to receive input events.
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, "inputEnabled", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return (this.input && this.input.enabled);
|
||||
|
@ -438,7 +438,7 @@ Object.defineProperty(Phaser.BitmapText.prototype, "inputEnabled", {
|
|||
* @property {boolean} fixedToCamera - Set to true to fix this BitmapText to the Camera at its current world coordinates.
|
||||
*/
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, "fixedToCamera", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this._cache[7];
|
||||
|
|
|
@ -40,136 +40,136 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
|
|||
|
||||
Phaser.Image.call(this, game, x, y, key, outFrame);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {number} type - The Phaser Object Type.
|
||||
*/
|
||||
this.type = Phaser.BUTTON;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {string} _onOverFrameName - Internal variable.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onOverFrameName = null;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @property {string} _onOutFrameName - Internal variable.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onOutFrameName = null;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @property {string} _onDownFrameName - Internal variable.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onDownFrameName = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {string} _onUpFrameName - Internal variable.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onUpFrameName = null;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @property {number} _onOverFrameID - Internal variable.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onOverFrameID = null;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @property {number} _onOutFrameID - Internal variable.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onOutFrameID = null;
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @property {number} _onDownFrameID - Internal variable.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onDownFrameID = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {number} _onUpFrameID - Internal variable.
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onUpFrameID = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {Phaser.Sound} onOverSound - The Sound to be played when this Buttons Over state is activated.
|
||||
* @default
|
||||
*/
|
||||
this.onOverSound = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {Phaser.Sound} onOutSound - The Sound to be played when this Buttons Out state is activated.
|
||||
* @default
|
||||
*/
|
||||
this.onOutSound = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {Phaser.Sound} onDownSound - The Sound to be played when this Buttons Down state is activated.
|
||||
* @default
|
||||
*/
|
||||
this.onDownSound = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {Phaser.Sound} onUpSound - The Sound to be played when this Buttons Up state is activated.
|
||||
* @default
|
||||
*/
|
||||
this.onUpSound = null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {string} onOverSoundMarker - The Sound Marker used in conjunction with the onOverSound.
|
||||
* @default
|
||||
*/
|
||||
this.onOverSoundMarker = '';
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {string} onOutSoundMarker - The Sound Marker used in conjunction with the onOutSound.
|
||||
* @default
|
||||
*/
|
||||
this.onOutSoundMarker = '';
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {string} onDownSoundMarker - The Sound Marker used in conjunction with the onDownSound.
|
||||
* @default
|
||||
*/
|
||||
this.onDownSoundMarker = '';
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {string} onUpSoundMarker - The Sound Marker used in conjunction with the onUpSound.
|
||||
* @default
|
||||
*/
|
||||
this.onUpSoundMarker = '';
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {Phaser.Signal} onInputOver - The Signal (or event) dispatched when this Button is in an Over state.
|
||||
*/
|
||||
this.onInputOver = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onInputOut - The Signal (or event) dispatched when this Button is in an Out state.
|
||||
*/
|
||||
this.onInputOut = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onInputDown - The Signal (or event) dispatched when this Button is in an Down state.
|
||||
*/
|
||||
this.onInputDown = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onInputUp - The Signal (or event) dispatched when this Button is in an Up state.
|
||||
*/
|
||||
this.onInputUp = new Phaser.Signal();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @property {boolean} freezeFrames - When true the Button will cease to change texture frame on all events (over, out, up, down).
|
||||
*/
|
||||
this.freezeFrames = false;
|
||||
|
@ -222,7 +222,7 @@ Phaser.Button.prototype.clearFrames = function () {
|
|||
this._onUpFrameName = null;
|
||||
this._onUpFrameID = null;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to manually set the frames that will be used for the different states of the Button.
|
||||
|
@ -242,7 +242,7 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame, up
|
|||
if (typeof overFrame === 'string')
|
||||
{
|
||||
this._onOverFrameName = overFrame;
|
||||
|
||||
|
||||
if (this.input.pointerOver())
|
||||
{
|
||||
this.frameName = overFrame;
|
||||
|
@ -349,7 +349,7 @@ Phaser.Button.prototype.setSounds = function (overSound, overMarker, downSound,
|
|||
this.setDownSound(downSound, downMarker);
|
||||
this.setUpSound(upSound, upMarker);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The Sound to be played when a Pointer moves over this Button.
|
||||
|
@ -373,7 +373,7 @@ Phaser.Button.prototype.setOverSound = function (sound, marker) {
|
|||
this.onOverSoundMarker = marker;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The Sound to be played when a Pointer moves out of this Button.
|
||||
|
@ -397,7 +397,7 @@ Phaser.Button.prototype.setOutSound = function (sound, marker) {
|
|||
this.onOutSoundMarker = marker;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The Sound to be played when a Pointer presses down on this Button.
|
||||
|
@ -421,7 +421,7 @@ Phaser.Button.prototype.setDownSound = function (sound, marker) {
|
|||
this.onDownSoundMarker = marker;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The Sound to be played when a Pointer has pressed down and is released from this Button.
|
||||
|
@ -445,7 +445,7 @@ Phaser.Button.prototype.setUpSound = function (sound, marker) {
|
|||
this.onUpSoundMarker = marker;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal function that handles input events.
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* @param {Phaser.Sprite} sprite - A reference to Description.
|
||||
*/
|
||||
Phaser.Events = function (sprite) {
|
||||
|
||||
|
||||
this.parent = sprite;
|
||||
|
||||
this.onAddedToGroup = new Phaser.Signal();
|
||||
|
|
|
@ -18,7 +18,7 @@ Phaser.GameObjectCreator = 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.
|
||||
*/
|
||||
|
@ -121,7 +121,7 @@ Phaser.GameObjectCreator.prototype = {
|
|||
audio: function (key, volume, loop, connect) {
|
||||
|
||||
return this.game.sound.add(key, volume, loop, connect);
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -137,7 +137,7 @@ Phaser.GameObjectCreator.prototype = {
|
|||
sound: function (key, volume, loop, connect) {
|
||||
|
||||
return this.game.sound.add(key, volume, loop, connect);
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -231,7 +231,7 @@ Phaser.GameObjectCreator.prototype = {
|
|||
* A RetroFont uses a bitmap which contains fixed with characters for the font set. You use character spacing to define the set.
|
||||
* If you need variable width character support then use a BitmapText object instead. The main difference between a RetroFont and a BitmapText
|
||||
* is that a RetroFont creates a single texture that you can apply to a game object, where-as a BitmapText creates one Sprite object per letter of text.
|
||||
* The texture can be asssigned or one or multiple images/sprites, but note that the text the RetroFont uses will be shared across them all,
|
||||
* The texture can be asssigned or one or multiple images/sprites, but note that the text the RetroFont uses will be shared across them all,
|
||||
* i.e. if you need each Image to have different text in it, then you need to create multiple RetroFont objects.
|
||||
*
|
||||
* @method Phaser.GameObjectCreator#retroFont
|
||||
|
|
|
@ -17,7 +17,7 @@ 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.
|
||||
*/
|
||||
|
@ -157,7 +157,7 @@ Phaser.GameObjectFactory.prototype = {
|
|||
audio: function (key, volume, loop, connect) {
|
||||
|
||||
return this.game.sound.add(key, volume, loop, connect);
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -173,7 +173,7 @@ Phaser.GameObjectFactory.prototype = {
|
|||
sound: function (key, volume, loop, connect) {
|
||||
|
||||
return this.game.sound.add(key, volume, loop, connect);
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -279,7 +279,7 @@ Phaser.GameObjectFactory.prototype = {
|
|||
* A RetroFont uses a bitmap which contains fixed with characters for the font set. You use character spacing to define the set.
|
||||
* If you need variable width character support then use a BitmapText object instead. The main difference between a RetroFont and a BitmapText
|
||||
* is that a RetroFont creates a single texture that you can apply to a game object, where-as a BitmapText creates one Sprite object per letter of text.
|
||||
* The texture can be asssigned or one or multiple images/sprites, but note that the text the RetroFont uses will be shared across them all,
|
||||
* The texture can be asssigned or one or multiple images/sprites, but note that the text the RetroFont uses will be shared across them all,
|
||||
* i.e. if you need each Image to have different text in it, then you need to create multiple RetroFont objects.
|
||||
*
|
||||
* @method Phaser.GameObjectFactory#retroFont
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
/**
|
||||
* Creates a new `Graphics` object.
|
||||
*
|
||||
*
|
||||
* @class Phaser.Graphics
|
||||
* @constructor
|
||||
*
|
||||
|
@ -23,7 +23,7 @@ Phaser.Graphics = function (game, x, y) {
|
|||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
|
||||
/**
|
||||
* @property {boolean} exists - If exists = false then the Text isn't updated by the core game loop.
|
||||
* @default
|
||||
|
@ -112,7 +112,7 @@ Phaser.Graphics.prototype.preUpdate = function () {
|
|||
|
||||
return true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Override and use this function in your own custom objects to handle any update requirements you may have.
|
||||
|
@ -122,7 +122,7 @@ Phaser.Graphics.prototype.preUpdate = function () {
|
|||
*/
|
||||
Phaser.Graphics.prototype.update = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Automatically called by World.postUpdate.
|
||||
|
@ -137,11 +137,11 @@ Phaser.Graphics.prototype.postUpdate = function () {
|
|||
this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy this Graphics instance.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Graphics.prototype.destroy
|
||||
* @param {boolean} [destroyChildren=true] - Should every child of this object have its destroy method called?
|
||||
*/
|
||||
|
@ -185,11 +185,11 @@ Phaser.Graphics.prototype.destroy = function(destroyChildren) {
|
|||
|
||||
this.game = null;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Draws a {Phaser.Polygon} or a {PIXI.Polygon} filled
|
||||
*
|
||||
*
|
||||
* @method Phaser.Graphics.prototype.drawPolygon
|
||||
*/
|
||||
Phaser.Graphics.prototype.drawPolygon = function (poly) {
|
||||
|
@ -202,8 +202,8 @@ Phaser.Graphics.prototype.drawPolygon = function (poly) {
|
|||
}
|
||||
|
||||
this.lineTo(poly.points[0].x, poly.points[0].y);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Indicates the rotation of the Graphics, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
|
||||
|
@ -233,7 +233,7 @@ Object.defineProperty(Phaser.Graphics.prototype, 'angle', {
|
|||
* @property {boolean} fixedToCamera - Set to true to fix this Graphics to the Camera at its current world coordinates.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Graphics.prototype, "fixedToCamera", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this._cache[7];
|
||||
|
|
|
@ -23,12 +23,12 @@ Phaser.Image = function (game, x, y, key, frame) {
|
|||
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 Image isn't updated by the core game loop.
|
||||
* @default
|
||||
|
@ -164,7 +164,7 @@ Phaser.Image.prototype.preUpdate = function() {
|
|||
|
||||
return true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Override and use this function in your own custom objects to handle any update requirements you may have.
|
||||
|
@ -174,7 +174,7 @@ Phaser.Image.prototype.preUpdate = function() {
|
|||
*/
|
||||
Phaser.Image.prototype.update = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal function called by the World postUpdate cycle.
|
||||
|
@ -202,7 +202,7 @@ Phaser.Image.prototype.postUpdate = function() {
|
|||
this.children[i].postUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Changes the Texture the Image is using entirely. The old texture is removed and the new one is referenced or fetched from the Cache.
|
||||
|
@ -279,7 +279,7 @@ Phaser.Image.prototype.loadTexture = function (key, frame) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Crop allows you to crop the texture used to display this Image.
|
||||
|
@ -326,13 +326,13 @@ Phaser.Image.prototype.crop = function(rect) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Brings a 'dead' Image back to life, optionally giving it the health value specified.
|
||||
* A resurrected Image has its alive, exists and visible properties all set to true.
|
||||
* It will dispatch the onRevived event, you can listen to Image.events.onRevived for the signal.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Image#revive
|
||||
* @memberof Phaser.Image
|
||||
* @return {Phaser.Image} This instance.
|
||||
|
@ -350,14 +350,14 @@ Phaser.Image.prototype.revive = function() {
|
|||
|
||||
return this;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Kills a Image. A killed Image has its alive, exists and visible properties all set to false.
|
||||
* It will dispatch the onKilled event, you can listen to Image.events.onKilled for the signal.
|
||||
* Note that killing a Image is a way for you to quickly recycle it in a Image pool, it doesn't free it up from memory.
|
||||
* If you don't need this Image any more you should call Image.destroy instead.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Image#kill
|
||||
* @memberof Phaser.Image
|
||||
* @return {Phaser.Image} This instance.
|
||||
|
@ -375,12 +375,12 @@ Phaser.Image.prototype.kill = function() {
|
|||
|
||||
return this;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroys the Image. 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.Image#destroy
|
||||
* @memberof Phaser.Image
|
||||
* @param {boolean} [destroyChildren=true] - Should every child of this object have its destroy method called?
|
||||
|
@ -438,11 +438,11 @@ Phaser.Image.prototype.destroy = function(destroyChildren) {
|
|||
this.mask = null;
|
||||
this.game = null;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Resets the Image. This places the Image at the given x/y world coordinates and then sets alive, exists, visible and renderable all to true.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Image#reset
|
||||
* @memberof Phaser.Image
|
||||
* @param {number} x - The x coordinate (in world space) to position the Image at.
|
||||
|
@ -460,13 +460,13 @@ Phaser.Image.prototype.reset = function(x, y) {
|
|||
this.renderable = true;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Brings the Image to the top of the display list it is a child of. Images that are members of a Phaser.Group are only
|
||||
* bought to the top of that Group, not the entire display list.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Image#bringToTop
|
||||
* @memberof Phaser.Image
|
||||
* @return {Phaser.Image} This instance.
|
||||
|
@ -480,13 +480,13 @@ Phaser.Image.prototype.bringToTop = function() {
|
|||
|
||||
return this;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Indicates the rotation of the Image, 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 Image.rotation instead. Working in radians is also a little faster as it doesn't have to convert the angle.
|
||||
*
|
||||
*
|
||||
* @name Phaser.Image#angle
|
||||
* @property {number} angle - The angle of this Image in degrees.
|
||||
*/
|
||||
|
@ -533,7 +533,7 @@ Object.defineProperty(Phaser.Image.prototype, "deltaX", {
|
|||
Object.defineProperty(Phaser.Image.prototype, "deltaY", {
|
||||
|
||||
get: function() {
|
||||
|
||||
|
||||
return this.world.y - this._cache[1];
|
||||
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ Object.defineProperty(Phaser.Image.prototype, "deltaY", {
|
|||
Object.defineProperty(Phaser.Image.prototype, "deltaZ", {
|
||||
|
||||
get: function() {
|
||||
|
||||
|
||||
return this.rotation - this._cache[2];
|
||||
|
||||
}
|
||||
|
@ -584,7 +584,7 @@ Object.defineProperty(Phaser.Image.prototype, "inWorld", {
|
|||
Object.defineProperty(Phaser.Image.prototype, "inCamera", {
|
||||
|
||||
get: function() {
|
||||
|
||||
|
||||
return this.game.world.camera.screenView.intersects(this.getBounds());
|
||||
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ Object.defineProperty(Phaser.Image.prototype, "inCamera", {
|
|||
Object.defineProperty(Phaser.Image.prototype, "frame", {
|
||||
|
||||
get: function() {
|
||||
|
||||
|
||||
return this._frame;
|
||||
|
||||
},
|
||||
|
@ -627,7 +627,7 @@ Object.defineProperty(Phaser.Image.prototype, "frame", {
|
|||
Object.defineProperty(Phaser.Image.prototype, "frameName", {
|
||||
|
||||
get: function() {
|
||||
|
||||
|
||||
return this._frameName;
|
||||
|
||||
},
|
||||
|
@ -672,7 +672,7 @@ Object.defineProperty(Phaser.Image.prototype, "renderOrderID", {
|
|||
* @property {boolean} inputEnabled - Set to true to allow this object to receive input events.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Image.prototype, "inputEnabled", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return (this.input && this.input.enabled);
|
||||
|
@ -709,7 +709,7 @@ Object.defineProperty(Phaser.Image.prototype, "inputEnabled", {
|
|||
* @property {boolean} fixedToCamera - Set to true to fix this Image to the Camera at its current world coordinates.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Image.prototype, "fixedToCamera", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this._cache[7];
|
||||
|
@ -738,7 +738,7 @@ Object.defineProperty(Phaser.Image.prototype, "fixedToCamera", {
|
|||
* @property {boolean} smoothed - Set to true to smooth the texture of this Image, or false to disable smoothing (great for pixel art)
|
||||
*/
|
||||
Object.defineProperty(Phaser.Image.prototype, "smoothed", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return !this.texture.baseTexture.scaleMode;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
Phaser.RenderTexture = function (game, width, height, key) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
|
@ -26,7 +26,7 @@ Phaser.RenderTexture = function (game, width, height, key) {
|
|||
this.key = key;
|
||||
|
||||
/**
|
||||
* @property {number} type - Base Phaser object type.
|
||||
* @property {number} type - Base Phaser object type.
|
||||
*/
|
||||
this.type = Phaser.RENDERTEXTURE;
|
||||
|
||||
|
@ -37,7 +37,7 @@ Phaser.RenderTexture = function (game, width, height, key) {
|
|||
this._temp = new Phaser.Point();
|
||||
|
||||
PIXI.RenderTexture.call(this, width, height);
|
||||
|
||||
|
||||
};
|
||||
|
||||
Phaser.RenderTexture.prototype = Object.create(PIXI.RenderTexture.prototype);
|
||||
|
@ -58,7 +58,7 @@ Phaser.RenderTexture.prototype.renderXY = function (displayObject, x, y, clear)
|
|||
|
||||
this.render(displayObject, this._temp, clear);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Documentation stubs
|
||||
|
||||
|
|
|
@ -108,13 +108,13 @@ Phaser.RetroFont = function (game, key, characterWidth, characterHeight, chars,
|
|||
* @private
|
||||
*/
|
||||
this.grabData = [];
|
||||
|
||||
|
||||
// Now generate our rects for faster copying later on
|
||||
var currentX = this.offsetX;
|
||||
var currentY = this.offsetY;
|
||||
var r = 0;
|
||||
var data = new Phaser.FrameData();
|
||||
|
||||
|
||||
for (var c = 0; c < chars.length; c++)
|
||||
{
|
||||
var uuid = game.rnd.uuid();
|
||||
|
@ -129,9 +129,9 @@ Phaser.RetroFont = function (game, key, characterWidth, characterHeight, chars,
|
|||
width: this.characterWidth,
|
||||
height: this.characterHeight
|
||||
});
|
||||
|
||||
|
||||
r++;
|
||||
|
||||
|
||||
if (r == this.characterPerRow)
|
||||
{
|
||||
r = 0;
|
||||
|
@ -151,10 +151,10 @@ Phaser.RetroFont = function (game, key, characterWidth, characterHeight, chars,
|
|||
Phaser.RenderTexture.call(this, game);
|
||||
|
||||
/**
|
||||
* @property {number} type - Base Phaser object type.
|
||||
* @property {number} type - Base Phaser object type.
|
||||
*/
|
||||
this.type = Phaser.RETROFONT;
|
||||
|
||||
|
||||
};
|
||||
|
||||
Phaser.RetroFont.prototype = Object.create(Phaser.RenderTexture.prototype);
|
||||
|
@ -166,91 +166,91 @@ Phaser.RetroFont.prototype.constructor = Phaser.RetroFont;
|
|||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.ALIGN_LEFT = "left";
|
||||
|
||||
|
||||
/**
|
||||
* Align each line of multi-line text to the right.
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.ALIGN_RIGHT = "right";
|
||||
|
||||
|
||||
/**
|
||||
* Align each line of multi-line text in the center.
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.ALIGN_CENTER = "center";
|
||||
|
||||
|
||||
/**
|
||||
* Text Set 1 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.TEXT_SET1 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
|
||||
|
||||
|
||||
/**
|
||||
* Text Set 2 = !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.TEXT_SET2 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
|
||||
/**
|
||||
* Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
|
||||
* Text Set 3 = ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.TEXT_SET3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";
|
||||
|
||||
|
||||
/**
|
||||
* Text Set 4 = ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.TEXT_SET4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789";
|
||||
|
||||
|
||||
/**
|
||||
* Text Set 5 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.TEXT_SET5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789";
|
||||
|
||||
|
||||
/**
|
||||
* Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.'
|
||||
* Text Set 6 = ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.'
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.TEXT_SET6 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ";
|
||||
|
||||
|
||||
/**
|
||||
* Text Set 7 = AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.TEXT_SET7 = "AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39";
|
||||
|
||||
|
||||
/**
|
||||
* Text Set 8 = 0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.TEXT_SET8 = "0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
|
||||
/**
|
||||
* Text Set 9 = ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.TEXT_SET9 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!";
|
||||
|
||||
|
||||
/**
|
||||
* Text Set 10 = ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
||||
* @constant
|
||||
* @type {string}
|
||||
*/
|
||||
Phaser.RetroFont.TEXT_SET10 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
|
||||
/**
|
||||
* Text Set 11 = ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789
|
||||
* @constant
|
||||
|
@ -274,11 +274,11 @@ Phaser.RetroFont.prototype.setFixedWidth = function (width, lineAlignment) {
|
|||
this.fixedWidth = width;
|
||||
this.align = lineAlignment;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A helper function that quickly sets lots of variables at once, and then updates the text.
|
||||
*
|
||||
*
|
||||
* @method Phaser.RetroFont#setText
|
||||
* @memberof Phaser.RetroFont
|
||||
* @param {string} content - The text of this sprite.
|
||||
|
@ -294,7 +294,7 @@ Phaser.RetroFont.prototype.setText = function (content, multiLine, characterSpac
|
|||
this.customSpacingX = characterSpacing || 0;
|
||||
this.customSpacingY = lineSpacing || 0;
|
||||
this.align = lineAlignment || 'left';
|
||||
|
||||
|
||||
if (allowLowerCase)
|
||||
{
|
||||
this.autoUpperCase = false;
|
||||
|
@ -303,17 +303,17 @@ Phaser.RetroFont.prototype.setText = function (content, multiLine, characterSpac
|
|||
{
|
||||
this.autoUpperCase = true;
|
||||
}
|
||||
|
||||
|
||||
if (content.length > 0)
|
||||
{
|
||||
this.text = content;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Over rides the default PIXI.RenderTexture resize event as we need our baseTexture resized as well.
|
||||
*
|
||||
*
|
||||
* @method Phaser.RetroFont#resize
|
||||
* @memberof Phaser.RetroFont
|
||||
*/
|
||||
|
@ -335,7 +335,7 @@ Phaser.RetroFont.prototype.resize = function (width, height) {
|
|||
|
||||
var gl = this.renderer.gl;
|
||||
gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTextures[gl.id]);
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -344,11 +344,11 @@ Phaser.RetroFont.prototype.resize = function (width, height) {
|
|||
|
||||
PIXI.Texture.frameUpdates.push(this);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the BitmapData of the Sprite with the text
|
||||
*
|
||||
*
|
||||
* @method Phaser.RetroFont#buildRetroFontText
|
||||
* @memberof Phaser.RetroFont
|
||||
*/
|
||||
|
@ -360,7 +360,7 @@ Phaser.RetroFont.prototype.buildRetroFontText = function () {
|
|||
if (this.multiLine)
|
||||
{
|
||||
var lines = this._text.split("\n");
|
||||
|
||||
|
||||
if (this.fixedWidth > 0)
|
||||
{
|
||||
this.resize(this.fixedWidth, (lines.length * (this.characterHeight + this.customSpacingY)) - this.customSpacingY);
|
||||
|
@ -371,7 +371,7 @@ Phaser.RetroFont.prototype.buildRetroFontText = function () {
|
|||
}
|
||||
|
||||
this.textureBuffer.clear();
|
||||
|
||||
|
||||
// Loop through each line of text
|
||||
for (var i = 0; i < lines.length; i++)
|
||||
{
|
||||
|
@ -381,25 +381,25 @@ Phaser.RetroFont.prototype.buildRetroFontText = function () {
|
|||
case Phaser.RetroFont.ALIGN_LEFT:
|
||||
cx = 0;
|
||||
break;
|
||||
|
||||
|
||||
case Phaser.RetroFont.ALIGN_RIGHT:
|
||||
cx = this.width - (lines[i].length * (this.characterWidth + this.customSpacingX));
|
||||
break;
|
||||
|
||||
|
||||
case Phaser.RetroFont.ALIGN_CENTER:
|
||||
cx = (this.width / 2) - ((lines[i].length * (this.characterWidth + this.customSpacingX)) / 2);
|
||||
cx += this.customSpacingX / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Sanity checks
|
||||
if (cx < 0)
|
||||
{
|
||||
cx = 0;
|
||||
}
|
||||
|
||||
|
||||
this.pasteLine(lines[i], cx, cy, this.customSpacingX);
|
||||
|
||||
|
||||
cy += this.characterHeight + this.customSpacingY;
|
||||
}
|
||||
}
|
||||
|
@ -415,32 +415,32 @@ Phaser.RetroFont.prototype.buildRetroFontText = function () {
|
|||
}
|
||||
|
||||
this.textureBuffer.clear();
|
||||
|
||||
|
||||
switch (this.align)
|
||||
{
|
||||
case Phaser.RetroFont.ALIGN_LEFT:
|
||||
cx = 0;
|
||||
break;
|
||||
|
||||
|
||||
case Phaser.RetroFont.ALIGN_RIGHT:
|
||||
cx = this.width - (this._text.length * (this.characterWidth + this.customSpacingX));
|
||||
break;
|
||||
|
||||
|
||||
case Phaser.RetroFont.ALIGN_CENTER:
|
||||
cx = (this.width / 2) - ((this._text.length * (this.characterWidth + this.customSpacingX)) / 2);
|
||||
cx += this.customSpacingX / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
this.pasteLine(this._text, cx, 0, this.customSpacingX);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal function that takes a single line of text (2nd parameter) and pastes it into the BitmapData at the given coordinates.
|
||||
* Used by getLine and getMultiLine
|
||||
*
|
||||
*
|
||||
* @method Phaser.RetroFont#buildRetroFontText
|
||||
* @memberof Phaser.RetroFont
|
||||
* @param {string} line - The single line of text to paste.
|
||||
|
@ -467,9 +467,9 @@ Phaser.RetroFont.prototype.pasteLine = function (line, x, y, customSpacingX) {
|
|||
this.stamp.frame = this.grabData[line.charCodeAt(c)];
|
||||
p.set(x, y);
|
||||
this.render(this.stamp, p, false);
|
||||
|
||||
|
||||
x += this.characterWidth + customSpacingX;
|
||||
|
||||
|
||||
if (x > this.width)
|
||||
{
|
||||
break;
|
||||
|
@ -477,11 +477,11 @@ Phaser.RetroFont.prototype.pasteLine = function (line, x, y, customSpacingX) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Works out the longest line of text in _text and returns its length
|
||||
*
|
||||
*
|
||||
* @method Phaser.RetroFont#getLongestLine
|
||||
* @memberof Phaser.RetroFont
|
||||
* @return {number} The length of the longest line of text.
|
||||
|
@ -489,11 +489,11 @@ Phaser.RetroFont.prototype.pasteLine = function (line, x, y, customSpacingX) {
|
|||
Phaser.RetroFont.prototype.getLongestLine = function () {
|
||||
|
||||
var longestLine = 0;
|
||||
|
||||
|
||||
if (this._text.length > 0)
|
||||
{
|
||||
var lines = this._text.split("\n");
|
||||
|
||||
|
||||
for (var i = 0; i < lines.length; i++)
|
||||
{
|
||||
if (lines[i].length > longestLine)
|
||||
|
@ -502,13 +502,13 @@ Phaser.RetroFont.prototype.getLongestLine = function () {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return longestLine;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal helper function that removes all unsupported characters from the _text String, leaving only characters contained in the font set.
|
||||
*
|
||||
*
|
||||
* @method Phaser.RetroFont#removeUnsupportedCharacters
|
||||
* @memberof Phaser.RetroFont
|
||||
* @protected
|
||||
|
@ -518,7 +518,7 @@ Phaser.RetroFont.prototype.getLongestLine = function () {
|
|||
Phaser.RetroFont.prototype.removeUnsupportedCharacters = function (stripCR) {
|
||||
|
||||
var newString = "";
|
||||
|
||||
|
||||
for (var c = 0; c < this._text.length; c++)
|
||||
{
|
||||
var aChar = this._text[c];
|
||||
|
@ -529,16 +529,16 @@ Phaser.RetroFont.prototype.removeUnsupportedCharacters = function (stripCR) {
|
|||
newString = newString.concat(aChar);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return newString;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Phaser.BitmapText#text
|
||||
* @property {string} text - Set this value to update the text in this sprite. Carriage returns are automatically stripped out if multiLine is false. Text is converted to upper case if autoUpperCase is true.
|
||||
*/
|
||||
Object.defineProperty(Phaser.RetroFont.prototype, "text", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this._text;
|
||||
|
@ -548,7 +548,7 @@ Object.defineProperty(Phaser.RetroFont.prototype, "text", {
|
|||
set: function (value) {
|
||||
|
||||
var newText;
|
||||
|
||||
|
||||
if (this.autoUpperCase)
|
||||
{
|
||||
newText = value.toUpperCase();
|
||||
|
@ -557,13 +557,13 @@ Object.defineProperty(Phaser.RetroFont.prototype, "text", {
|
|||
{
|
||||
newText = value;
|
||||
}
|
||||
|
||||
|
||||
if (newText !== this._text)
|
||||
{
|
||||
this._text = newText;
|
||||
|
||||
|
||||
this.removeUnsupportedCharacters(this.multiLine);
|
||||
|
||||
|
||||
this.buildRetroFontText();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
|||
y = y || 0;
|
||||
key = key || null;
|
||||
frame = frame || null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
|
@ -105,7 +105,7 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
|||
|
||||
/**
|
||||
* By default Sprites won't add themselves to any physics system and their physics body will be `null`.
|
||||
* To enable them for physics you need to call `game.physics.enable(sprite, system)` where `sprite` is this object
|
||||
* To enable them for physics you need to call `game.physics.enable(sprite, system)` where `sprite` is this object
|
||||
* and `system` is the Physics system you want to use to manage this body. Once enabled you can access all physics related properties via `Sprite.body`.
|
||||
*
|
||||
* Important: Enabling a Sprite for P2 or Ninja physics will automatically set `Sprite.anchor` to 0.5 so the physics body is centered on the Sprite.
|
||||
|
@ -456,7 +456,7 @@ Phaser.Sprite.prototype.crop = function(rect) {
|
|||
* 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.
|
||||
|
@ -485,7 +485,7 @@ Phaser.Sprite.prototype.revive = function(health) {
|
|||
* 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.
|
||||
|
@ -508,7 +508,7 @@ Phaser.Sprite.prototype.kill = function() {
|
|||
/**
|
||||
* 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
|
||||
* @param {boolean} [destroyChildren=true] - Should every child of this object have its destroy method called?
|
||||
|
@ -581,7 +581,7 @@ Phaser.Sprite.prototype.destroy = function(destroyChildren) {
|
|||
/**
|
||||
* Damages the Sprite, this removes the given amount from the Sprites health property.
|
||||
* If health is then taken below or is equal to zero `Sprite.kill` is called.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Sprite#damage
|
||||
* @memberof Phaser.Sprite
|
||||
* @param {number} amount - The amount to subtract from the Sprite.health value.
|
||||
|
@ -607,7 +607,7 @@ Phaser.Sprite.prototype.damage = function(amount) {
|
|||
* 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.
|
||||
|
@ -638,13 +638,13 @@ Phaser.Sprite.prototype.reset = function(x, y, health) {
|
|||
this._cache[4] = 1;
|
||||
|
||||
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.
|
||||
|
@ -663,7 +663,7 @@ Phaser.Sprite.prototype.bringToTop = function() {
|
|||
/**
|
||||
* 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".
|
||||
|
@ -701,7 +701,7 @@ Phaser.Sprite.prototype.overlap = function (displayObject) {
|
|||
* 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. Working in radians is also a little faster as it doesn't have to convert the angle.
|
||||
*
|
||||
*
|
||||
* @name Phaser.Sprite#angle
|
||||
* @property {number} angle - The angle of this Sprite in degrees.
|
||||
*/
|
||||
|
@ -748,7 +748,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "deltaX", {
|
|||
Object.defineProperty(Phaser.Sprite.prototype, "deltaY", {
|
||||
|
||||
get: function() {
|
||||
|
||||
|
||||
return this.world.y - this._cache[1];
|
||||
|
||||
}
|
||||
|
@ -765,7 +765,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "deltaY", {
|
|||
Object.defineProperty(Phaser.Sprite.prototype, "deltaZ", {
|
||||
|
||||
get: function() {
|
||||
|
||||
|
||||
return this.rotation - this._cache[2];
|
||||
|
||||
}
|
||||
|
@ -799,7 +799,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "inWorld", {
|
|||
Object.defineProperty(Phaser.Sprite.prototype, "inCamera", {
|
||||
|
||||
get: function() {
|
||||
|
||||
|
||||
return this.game.world.camera.screenView.intersects(this.getBounds());
|
||||
|
||||
}
|
||||
|
@ -861,7 +861,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "renderOrderID", {
|
|||
* @property {boolean} inputEnabled - Set to true to allow this object to receive input events.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return (this.input && this.input.enabled);
|
||||
|
@ -898,7 +898,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", {
|
|||
* @property {boolean} exists - If the Sprite is processed by the core game update and physics.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, "exists", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this._cache[6];
|
||||
|
@ -945,7 +945,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "exists", {
|
|||
* @property {boolean} fixedToCamera - Set to true to fix this Sprite to the Camera at its current world coordinates.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, "fixedToCamera", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this._cache[7];
|
||||
|
@ -974,7 +974,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "fixedToCamera", {
|
|||
* @property {boolean} smoothed - Set to true to smooth the texture of this Sprite, or false to disable smoothing (great for pixel art)
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, "smoothed", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return !this.texture.baseTexture.scaleMode;
|
||||
|
|
|
@ -38,7 +38,7 @@ Phaser.Text = function (game, x, y, text, style) {
|
|||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
|
||||
/**
|
||||
* @property {boolean} exists - If exists = false then the Text isn't updated by the core game loop.
|
||||
* @default
|
||||
|
@ -175,7 +175,7 @@ Phaser.Text.prototype.preUpdate = function () {
|
|||
|
||||
return true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Override and use this function in your own custom objects to handle any update requirements you may have.
|
||||
|
@ -185,7 +185,7 @@ Phaser.Text.prototype.preUpdate = function () {
|
|||
*/
|
||||
Phaser.Text.prototype.update = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Automatically called by World.postUpdate.
|
||||
|
@ -205,7 +205,7 @@ Phaser.Text.prototype.postUpdate = function () {
|
|||
this.children[i].postUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @method Phaser.Text.prototype.destroy
|
||||
|
@ -265,7 +265,7 @@ Phaser.Text.prototype.destroy = function (destroyChildren) {
|
|||
this.mask = null;
|
||||
this.game = null;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @method Phaser.Text.prototype.setShadow
|
||||
|
@ -282,7 +282,7 @@ Phaser.Text.prototype.setShadow = function (x, y, color, blur) {
|
|||
this.style.shadowBlur = blur || 0;
|
||||
this.dirty = true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the style of the text by passing a single style object to it.
|
||||
|
@ -315,7 +315,7 @@ Phaser.Text.prototype.setStyle = function (style) {
|
|||
this.style = style;
|
||||
this.dirty = true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders text. This replaces the Pixi.Text.updateText function as we need a few extra bits in here.
|
||||
|
@ -353,15 +353,15 @@ Phaser.Text.prototype.updateText = function () {
|
|||
this.canvas.width = maxLineWidth + this.style.strokeThickness;
|
||||
|
||||
//calculate text height
|
||||
var lineHeight = this.determineFontHeight('font: ' + this.style.font + ';') + this.style.strokeThickness + this._lineSpacing + this.style.shadowOffsetY;
|
||||
var lineHeight = this.determineFontHeight('font: ' + this.style.font + ';') + this.style.strokeThickness + this._lineSpacing + this.style.shadowOffsetY;
|
||||
|
||||
this.canvas.height = lineHeight * lines.length;
|
||||
|
||||
if (navigator.isCocoonJS)
|
||||
{
|
||||
this.context.clearRect(0,0,this.canvas.width,this.canvas.height);
|
||||
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
}
|
||||
|
||||
|
||||
//set canvas text styles
|
||||
this.context.fillStyle = this.style.fill;
|
||||
this.context.font = this.style.font;
|
||||
|
@ -381,30 +381,30 @@ Phaser.Text.prototype.updateText = function () {
|
|||
{
|
||||
var linePosition = new PIXI.Point(this.style.strokeThickness / 2, this.style.strokeThickness / 2 + i * lineHeight);
|
||||
|
||||
if(this.style.align === 'right')
|
||||
if (this.style.align === 'right')
|
||||
{
|
||||
linePosition.x += maxLineWidth - lineWidths[i];
|
||||
}
|
||||
else if(this.style.align === 'center')
|
||||
else if (this.style.align === 'center')
|
||||
{
|
||||
linePosition.x += (maxLineWidth - lineWidths[i]) / 2;
|
||||
}
|
||||
|
||||
linePosition.y += this._lineSpacing;
|
||||
|
||||
if(this.style.stroke && this.style.strokeThickness)
|
||||
if (this.style.stroke && this.style.strokeThickness)
|
||||
{
|
||||
this.context.strokeText(lines[i], linePosition.x, linePosition.y);
|
||||
}
|
||||
|
||||
if(this.style.fill)
|
||||
if (this.style.fill)
|
||||
{
|
||||
this.context.fillText(lines[i], linePosition.x, linePosition.y);
|
||||
}
|
||||
}
|
||||
|
||||
this.updateTexture();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal bounds.
|
||||
|
@ -452,7 +452,7 @@ Phaser.Text.prototype.runWordWrap = function (text) {
|
|||
|
||||
return result;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Indicates the rotation of the Text, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
|
||||
|
@ -822,7 +822,7 @@ Object.defineProperty(Phaser.Text.prototype, 'shadowBlur', {
|
|||
* @property {boolean} inputEnabled - Set to true to allow this object to receive input events.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Text.prototype, "inputEnabled", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return (this.input && this.input.enabled);
|
||||
|
@ -859,7 +859,7 @@ Object.defineProperty(Phaser.Text.prototype, "inputEnabled", {
|
|||
* @property {boolean} fixedToCamera - Set to true to fix this Text to the Camera at its current world coordinates.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Text.prototype, "fixedToCamera", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this._cache[7];
|
||||
|
|
|
@ -124,7 +124,7 @@ Phaser.TileSprite = function (game, x, y, width, height, key, frame) {
|
|||
|
||||
/**
|
||||
* By default Sprites won't add themselves to any physics system and their physics body will be `null`.
|
||||
* To enable them for physics you need to call `game.physics.enable(sprite, system)` where `sprite` is this object
|
||||
* To enable them for physics you need to call `game.physics.enable(sprite, system)` where `sprite` is this object
|
||||
* and `system` is the Physics system you want to use to manage this body. Once enabled you can access all physics related properties via `Sprite.body`.
|
||||
*
|
||||
* Important: Enabling a Sprite for P2 or Ninja physics will automatically set `Sprite.anchor` to 0.5 so the physics body is centered on the Sprite.
|
||||
|
@ -253,7 +253,7 @@ Phaser.TileSprite.prototype.preUpdate = function() {
|
|||
|
||||
return true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Override and use this function in your own custom objects to handle any update requirements you may have.
|
||||
|
@ -263,7 +263,7 @@ Phaser.TileSprite.prototype.preUpdate = function() {
|
|||
*/
|
||||
Phaser.TileSprite.prototype.update = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal function called by the World postUpdate cycle.
|
||||
|
@ -291,7 +291,7 @@ Phaser.TileSprite.prototype.postUpdate = function() {
|
|||
this.children[i].postUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets this TileSprite to automatically scroll in the given direction until stopped via TileSprite.stopScroll().
|
||||
|
@ -306,7 +306,7 @@ Phaser.TileSprite.prototype.autoScroll = function(x, y) {
|
|||
|
||||
this._scroll.set(x, y);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Stops an automatically scrolling TileSprite.
|
||||
|
@ -318,7 +318,7 @@ Phaser.TileSprite.prototype.stopScroll = function() {
|
|||
|
||||
this._scroll.set(0, 0);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Changes the Texture the TileSprite is using entirely. The old texture is removed and the new one is referenced or fetched from the Cache.
|
||||
|
@ -390,12 +390,12 @@ Phaser.TileSprite.prototype.loadTexture = function (key, frame) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroys the TileSprite. This removes it from its parent group, destroys the event and animation handlers if present
|
||||
* and nulls its reference to game, freeing it up for garbage collection.
|
||||
*
|
||||
*
|
||||
* @method Phaser.TileSprite#destroy
|
||||
* @memberof Phaser.TileSprite
|
||||
* @param {boolean} [destroyChildren=true] - Should every child of this object have its destroy method called?
|
||||
|
@ -451,12 +451,12 @@ Phaser.TileSprite.prototype.destroy = function(destroyChildren) {
|
|||
this.mask = null;
|
||||
this.game = null;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.TileSprite#play
|
||||
* @memberof Phaser.TileSprite
|
||||
* @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump".
|
||||
|
@ -469,7 +469,7 @@ Phaser.TileSprite.prototype.play = function (name, frameRate, loop, killOnComple
|
|||
|
||||
return this.animations.play(name, frameRate, loop, killOnComplete);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Resets the TileSprite. This places the TileSprite at the given x/y world coordinates, resets the tilePosition and then
|
||||
|
@ -511,7 +511,7 @@ Phaser.TileSprite.prototype.reset = function(x, y) {
|
|||
* 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. Working in radians is also a little faster as it doesn't have to convert the angle.
|
||||
*
|
||||
*
|
||||
* @name Phaser.TileSprite#angle
|
||||
* @property {number} angle - The angle of this Sprite in degrees.
|
||||
*/
|
||||
|
@ -582,7 +582,7 @@ Object.defineProperty(Phaser.TileSprite.prototype, "frameName", {
|
|||
* @property {boolean} fixedToCamera - Set to true to fix this TileSprite to the Camera at its current world coordinates.
|
||||
*/
|
||||
Object.defineProperty(Phaser.TileSprite.prototype, "fixedToCamera", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this._cache[7];
|
||||
|
@ -613,7 +613,7 @@ Object.defineProperty(Phaser.TileSprite.prototype, "fixedToCamera", {
|
|||
* @property {boolean} exists - If the TileSprite is processed by the core game update and physics.
|
||||
*/
|
||||
Object.defineProperty(Phaser.TileSprite.prototype, "exists", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this._cache[6];
|
||||
|
@ -659,7 +659,7 @@ Object.defineProperty(Phaser.TileSprite.prototype, "exists", {
|
|||
* @property {boolean} inputEnabled - Set to true to allow this object to receive input events.
|
||||
*/
|
||||
Object.defineProperty(Phaser.TileSprite.prototype, "inputEnabled", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return (this.input && this.input.enabled);
|
||||
|
|
|
@ -119,7 +119,7 @@ Phaser.Circle.prototype = {
|
|||
*/
|
||||
distance: function (dest, round) {
|
||||
|
||||
if (typeof round === "undefined") { round = false }
|
||||
if (typeof round === "undefined") { round = false; }
|
||||
|
||||
if (round)
|
||||
{
|
||||
|
@ -247,7 +247,7 @@ Object.defineProperty(Phaser.Circle.prototype, "diameter", {
|
|||
* @property {number} radius - Gets or sets the radius of the circle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Circle.prototype, "radius", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this._radius;
|
||||
},
|
||||
|
@ -270,7 +270,7 @@ Object.defineProperty(Phaser.Circle.prototype, "radius", {
|
|||
* @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;
|
||||
},
|
||||
|
@ -328,7 +328,7 @@ Object.defineProperty(Phaser.Circle.prototype, "top", {
|
|||
get: function () {
|
||||
return this.y - this._radius;
|
||||
},
|
||||
|
||||
|
||||
set: function (value) {
|
||||
|
||||
if (value > this.y)
|
||||
|
|
|
@ -151,7 +151,7 @@ Phaser.Ellipse.prototype.constructor = Phaser.Ellipse;
|
|||
* @propety {number} left - Gets or sets the value of the leftmost point of the ellipse.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Ellipse.prototype, "left", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.x;
|
||||
},
|
||||
|
@ -199,7 +199,7 @@ Object.defineProperty(Phaser.Ellipse.prototype, "top", {
|
|||
get: function () {
|
||||
return this.y;
|
||||
},
|
||||
|
||||
|
||||
set: function (value) {
|
||||
this.y = value;
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ Phaser.Line.prototype = {
|
|||
while (!((x1 == x2) && (y1 == y2)))
|
||||
{
|
||||
var e2 = err << 1;
|
||||
|
||||
|
||||
if (e2 > -dy)
|
||||
{
|
||||
err -= dy;
|
||||
|
@ -377,7 +377,7 @@ Phaser.Line.intersectsPoints = function (a, b, e, f, asSegment, result) {
|
|||
|
||||
result.x = ((b1 * c2) - (b2 * c1)) / denom;
|
||||
result.y = ((a2 * c1) - (a1 * c2)) / denom;
|
||||
|
||||
|
||||
if (asSegment)
|
||||
{
|
||||
if (Math.pow((result.x - b.x) + (result.y - b.y), 2) > Math.pow((a.x - b.x) + (a.y - b.y), 2))
|
||||
|
|
|
@ -21,7 +21,7 @@ Phaser.Point = function (x, y) {
|
|||
* @property {number} x - The x coordinate of the point.
|
||||
*/
|
||||
this.x = x;
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} y - The y coordinate of the point.
|
||||
*/
|
||||
|
@ -63,7 +63,7 @@ Phaser.Point.prototype = {
|
|||
this.y = y || ( (y !== 0) ? this.x : 0 );
|
||||
|
||||
return this;
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -79,7 +79,7 @@ Phaser.Point.prototype = {
|
|||
this.y = y || ( (y !== 0) ? this.x : 0 );
|
||||
|
||||
return this;
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -153,7 +153,7 @@ Phaser.Point.prototype = {
|
|||
|
||||
this.x = Phaser.Math.clamp(this.x, min, max);
|
||||
return this;
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -167,7 +167,7 @@ Phaser.Point.prototype = {
|
|||
|
||||
this.y = Phaser.Math.clamp(this.y, min, max);
|
||||
return this;
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -411,7 +411,7 @@ Phaser.Point.equals = function (a, b) {
|
|||
*/
|
||||
Phaser.Point.distance = function (a, b, round) {
|
||||
|
||||
if (typeof round === "undefined") { round = false }
|
||||
if (typeof round === "undefined") { round = false; }
|
||||
|
||||
if (round)
|
||||
{
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
/**
|
||||
* Creates a new Polygon. You have to provide a list of points.
|
||||
* This can be an array of Points that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...],
|
||||
* This can be an array of Points that form the polygon, a flat array of numbers that will be interpreted as [x,y, x,y, ...],
|
||||
* or the arguments passed can be all the points of the polygon e.g. `new Phaser.Polygon(new Phaser.Point(), new Phaser.Point(), ...)`, or the
|
||||
* arguments passed can be flat x,y values e.g. `new Phaser.Polygon(x,y, x,y, x,y, ...)` where `x` and `y` are numbers.
|
||||
*
|
||||
|
|
|
@ -26,17 +26,17 @@ Phaser.Rectangle = function (x, y, width, height) {
|
|||
* @property {number} x - The x coordinate of the top-left corner of the Rectangle.
|
||||
*/
|
||||
this.x = x;
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} y - The y coordinate of the top-left corner of the Rectangle.
|
||||
*/
|
||||
this.y = y;
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} width - The width of the Rectangle.
|
||||
*/
|
||||
this.width = width;
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} height - The height of the Rectangle.
|
||||
*/
|
||||
|
@ -61,7 +61,7 @@ Phaser.Rectangle.prototype = {
|
|||
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
|
||||
|
@ -73,7 +73,7 @@ Phaser.Rectangle.prototype = {
|
|||
return this.offset(point.x, point.y);
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Sets the members of Rectangle to the specified values.
|
||||
* @method Phaser.Rectangle#setTo
|
||||
|
@ -104,7 +104,7 @@ Phaser.Rectangle.prototype = {
|
|||
this.y = Math.floor(this.y);
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Runs Math.floor() on the x, y, width and height values of this Rectangle.
|
||||
* @method Phaser.Rectangle#floorAll
|
||||
|
@ -176,7 +176,7 @@ 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 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}
|
||||
* @return {Phaser.Rectangle}
|
||||
*/
|
||||
clone: function (output) {
|
||||
|
||||
|
@ -324,11 +324,11 @@ Object.defineProperty(Phaser.Rectangle.prototype, "halfHeight", {
|
|||
* @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;
|
||||
|
@ -345,7 +345,7 @@ Object.defineProperty(Phaser.Rectangle.prototype, "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);
|
||||
},
|
||||
|
@ -363,7 +363,7 @@ Object.defineProperty(Phaser.Rectangle.prototype, "bottomRight", {
|
|||
* @property {number} left - The x coordinate of the left of the Rectangle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "left", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.x;
|
||||
},
|
||||
|
@ -385,7 +385,7 @@ Object.defineProperty(Phaser.Rectangle.prototype, "left", {
|
|||
* @property {number} right - The sum of the x and width properties.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "right", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.x + this.width;
|
||||
},
|
||||
|
@ -407,7 +407,7 @@ Object.defineProperty(Phaser.Rectangle.prototype, "right", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "volume", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.width * this.height;
|
||||
}
|
||||
|
@ -421,7 +421,7 @@ Object.defineProperty(Phaser.Rectangle.prototype, "volume", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return (this.width * 2) + (this.height * 2);
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ Object.defineProperty(Phaser.Rectangle.prototype, "perimeter", {
|
|||
* @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;
|
||||
},
|
||||
|
@ -451,7 +451,7 @@ Object.defineProperty(Phaser.Rectangle.prototype, "centerX", {
|
|||
* @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;
|
||||
},
|
||||
|
@ -469,7 +469,7 @@ Object.defineProperty(Phaser.Rectangle.prototype, "centerY", {
|
|||
* @property {number} top - The y coordinate of the top of the Rectangle.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Rectangle.prototype, "top", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.y;
|
||||
},
|
||||
|
@ -495,7 +495,7 @@ 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;
|
||||
|
@ -505,12 +505,12 @@ 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.
|
||||
* 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);
|
||||
},
|
||||
|
@ -521,7 +521,7 @@ Object.defineProperty(Phaser.Rectangle.prototype, "empty", {
|
|||
{
|
||||
this.setTo(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -767,7 +767,7 @@ Phaser.Rectangle.union = function (a, b, output) {
|
|||
}
|
||||
|
||||
return output.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));
|
||||
|
||||
|
||||
};
|
||||
|
||||
// Because PIXI uses its own Rectangle, we'll replace it with ours to avoid duplicating code or confusion.
|
||||
|
|
|
@ -299,7 +299,7 @@ Phaser.Gamepad.prototype = {
|
|||
}
|
||||
|
||||
var rawPad = this._rawPads[m];
|
||||
|
||||
|
||||
if (rawPad)
|
||||
{
|
||||
if (validConnections.rawIndices[rawPad.index])
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
Phaser.Input = function (game) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
|
@ -24,7 +24,7 @@ Phaser.Input = function (game) {
|
|||
* @default
|
||||
*/
|
||||
this.hitCanvas = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {CanvasRenderingContext2D} hitContext - The context of the pixel perfect hit canvas.
|
||||
* @default
|
||||
|
@ -57,13 +57,13 @@ Phaser.Input = function (game) {
|
|||
|
||||
/**
|
||||
* @property {number} multiInputOverride - Controls the expected behaviour when using a mouse and touch together on a multi-input device.
|
||||
* @default
|
||||
* @default
|
||||
*/
|
||||
this.multiInputOverride = Phaser.Input.MOUSE_TOUCH_COMBINE;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} position - A point object representing the current position of the Pointer.
|
||||
* @default
|
||||
* @default
|
||||
*/
|
||||
this.position = null;
|
||||
|
||||
|
@ -210,22 +210,22 @@ Phaser.Input = function (game) {
|
|||
* @property {Pointer} mousePointer - The mouse has its own unique Phaser.Pointer object which you can use if making a desktop specific game.
|
||||
*/
|
||||
this.mousePointer = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Mouse} mouse - The Mouse Input manager.
|
||||
*/
|
||||
this.mouse = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Keyboard} keyboard - The Keyboard Input manager.
|
||||
*/
|
||||
this.keyboard = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Touch} touch - the Touch Input manager.
|
||||
*/
|
||||
this.touch = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.MSPointer} mspointer - The MSPointer Input manager.
|
||||
*/
|
||||
|
@ -245,17 +245,17 @@ Phaser.Input = function (game) {
|
|||
* @property {Phaser.Signal} onDown - A Signal that is dispatched each time a pointer is pressed down.
|
||||
*/
|
||||
this.onDown = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onUp - A Signal that is dispatched each time a pointer is released.
|
||||
*/
|
||||
this.onUp = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onTap - A Signal that is dispatched each time a pointer is tapped.
|
||||
*/
|
||||
this.onTap = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Signal} onHold - A Signal that is dispatched each time a pointer is held down.
|
||||
*/
|
||||
|
@ -272,7 +272,7 @@ Phaser.Input = function (game) {
|
|||
* @private
|
||||
*/
|
||||
this._localPoint = new Phaser.Point();
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} _pollCounter - Internal var holding the current poll counter.
|
||||
* @private
|
||||
|
@ -713,7 +713,7 @@ Phaser.Input.prototype = {
|
|||
wt.d * id * pointer.x + -wt.b * id * pointer.y + (wt.ty * wt.b - wt.tx * wt.d) * id,
|
||||
wt.a * id * pointer.y + -wt.c * id * pointer.x + (-wt.ty * wt.a + wt.tx * wt.c) * id
|
||||
);
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -815,7 +815,7 @@ Object.defineProperty(Phaser.Input.prototype, "x", {
|
|||
* @property {number} y - The Y coordinate of the most recently active pointer.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Input.prototype, "y", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this._y;
|
||||
},
|
||||
|
@ -860,7 +860,7 @@ Object.defineProperty(Phaser.Input.prototype, "totalInactivePointers", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
this.currentPointers = 0;
|
||||
|
|
|
@ -18,7 +18,7 @@ Phaser.InputHandler = function (sprite) {
|
|||
this.sprite = sprite;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = sprite.game;
|
||||
|
||||
|
@ -33,13 +33,13 @@ Phaser.InputHandler = function (sprite) {
|
|||
* @default
|
||||
*/
|
||||
this.priorityID = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @property {boolean} useHandCursor - On a desktop browser you can set the 'hand' cursor to appear when moving over the Sprite.
|
||||
* @default
|
||||
*/
|
||||
this.useHandCursor = false;
|
||||
|
||||
|
||||
/**
|
||||
* @property {boolean} _setHandCursor - Did this Sprite trigger the hand cursor?
|
||||
* @private
|
||||
|
@ -51,19 +51,19 @@ Phaser.InputHandler = function (sprite) {
|
|||
* @default
|
||||
*/
|
||||
this.isDragged = false;
|
||||
|
||||
|
||||
/**
|
||||
* @property {boolean} allowHorizontalDrag - Controls if the Sprite is allowed to be dragged horizontally.
|
||||
* @default
|
||||
*/
|
||||
this.allowHorizontalDrag = true;
|
||||
|
||||
|
||||
/**
|
||||
* @property {boolean} allowVerticalDrag - Controls if the Sprite is allowed to be dragged vertically.
|
||||
* @default
|
||||
*/
|
||||
this.allowVerticalDrag = true;
|
||||
|
||||
|
||||
/**
|
||||
* @property {boolean} bringToTop - If true when this Sprite is clicked or dragged it will automatically be bought to the top of the Group it is within.
|
||||
* @default
|
||||
|
@ -75,25 +75,25 @@ Phaser.InputHandler = function (sprite) {
|
|||
* @default
|
||||
*/
|
||||
this.snapOffset = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {boolean} snapOnDrag - When the Sprite is dragged this controls if the center of the Sprite will snap to the pointer on drag or not.
|
||||
* @default
|
||||
*/
|
||||
this.snapOnDrag = false;
|
||||
|
||||
|
||||
/**
|
||||
* @property {boolean} snapOnRelease - When the Sprite is dragged this controls if the Sprite will be snapped on release.
|
||||
* @default
|
||||
*/
|
||||
this.snapOnRelease = false;
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} snapX - When a Sprite has snapping enabled this holds the width of the snap grid.
|
||||
* @default
|
||||
*/
|
||||
this.snapX = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} snapY - When a Sprite has snapping enabled this holds the height of the snap grid.
|
||||
* @default
|
||||
|
@ -105,7 +105,7 @@ Phaser.InputHandler = function (sprite) {
|
|||
* @default
|
||||
*/
|
||||
this.snapOffsetX = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @property {number} snapOffsetY - This defines the top-left Y coordinate of the snap grid..
|
||||
* @default
|
||||
|
@ -138,13 +138,13 @@ Phaser.InputHandler = function (sprite) {
|
|||
|
||||
/**
|
||||
* @property {boolean} draggable - Is this sprite allowed to be dragged by the mouse? true = yes, false = no
|
||||
* @default
|
||||
* @default
|
||||
*/
|
||||
this.draggable = false;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Rectangle} boundsRect - A region of the game world within which the sprite is restricted during drag.
|
||||
* @default
|
||||
* @default
|
||||
*/
|
||||
this.boundsRect = null;
|
||||
|
||||
|
@ -644,7 +644,7 @@ Phaser.InputHandler.prototype = {
|
|||
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)
|
||||
|
@ -1130,7 +1130,7 @@ Phaser.InputHandler.prototype = {
|
|||
}
|
||||
|
||||
this.updateDrag(pointer);
|
||||
|
||||
|
||||
if (this.bringToTop)
|
||||
{
|
||||
this.sprite.bringToTop();
|
||||
|
@ -1150,7 +1150,7 @@ Phaser.InputHandler.prototype = {
|
|||
this.isDragged = false;
|
||||
this._draggedPointerID = -1;
|
||||
this._pointerData[pointer.id].isDragged = false;
|
||||
|
||||
|
||||
if (this.snapOnRelease)
|
||||
{
|
||||
if (this.sprite.fixedToCamera)
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
Phaser.Key = function (game, keycode) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
|
@ -103,7 +103,7 @@ Phaser.Key = function (game, keycode) {
|
|||
* @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 = {
|
||||
|
|
|
@ -50,7 +50,7 @@ Phaser.Keyboard = function (game) {
|
|||
* @private
|
||||
*/
|
||||
this._keys = [];
|
||||
|
||||
|
||||
/**
|
||||
* @property {array} _capture - The array the key capture values are stored in.
|
||||
* @private
|
||||
|
@ -63,14 +63,14 @@ Phaser.Keyboard = function (game) {
|
|||
* @default
|
||||
*/
|
||||
this._onKeyDown = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {function} _onKeyUp
|
||||
* @private
|
||||
* @default
|
||||
*/
|
||||
this._onKeyUp = null;
|
||||
|
||||
|
||||
};
|
||||
|
||||
Phaser.Keyboard.prototype = {
|
||||
|
@ -127,7 +127,7 @@ Phaser.Keyboard.prototype = {
|
|||
if (this._keys[keycode])
|
||||
{
|
||||
this._keys[keycode] = null;
|
||||
|
||||
|
||||
this.removeKeyCapture(keycode);
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ Phaser.Keyboard.prototype = {
|
|||
down: this.addKey(Phaser.Keyboard.DOWN),
|
||||
left: this.addKey(Phaser.Keyboard.LEFT),
|
||||
right: this.addKey(Phaser.Keyboard.RIGHT)
|
||||
}
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
|
@ -288,7 +288,7 @@ Phaser.Keyboard.prototype = {
|
|||
{
|
||||
this._keys[event.keyCode] = new Phaser.Key(this.game, event.keyCode);
|
||||
}
|
||||
|
||||
|
||||
this._keys[event.keyCode].processKeyDown(event);
|
||||
|
||||
},
|
||||
|
|
|
@ -20,7 +20,7 @@ Phaser.MSPointer = function (game) {
|
|||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Object} callbackContext - The context under which callbacks are called (defaults to game).
|
||||
*/
|
||||
|
@ -37,13 +37,13 @@ Phaser.MSPointer = function (game) {
|
|||
* @private
|
||||
*/
|
||||
this._onMSPointerDown = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {function} _onMSPointerMove - Internal function to handle MSPointer events.
|
||||
* @private
|
||||
*/
|
||||
this._onMSPointerMove = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {function} _onMSPointerUp - Internal function to handle MSPointer events.
|
||||
* @private
|
||||
|
|
|
@ -17,7 +17,7 @@ Phaser.Mouse = function (game) {
|
|||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
|
||||
/**
|
||||
* @property {Object} callbackContext - The context under which callbacks are called.
|
||||
*/
|
||||
|
@ -27,12 +27,12 @@ Phaser.Mouse = function (game) {
|
|||
* @property {function} mouseDownCallback - A callback that can be fired when the mouse is pressed down.
|
||||
*/
|
||||
this.mouseDownCallback = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {function} mouseMoveCallback - A callback that can be fired when the mouse is moved while pressed down.
|
||||
*/
|
||||
this.mouseMoveCallback = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {function} mouseUpCallback - A callback that can be fired when the mouse is released from a pressed down state.
|
||||
*/
|
||||
|
|
|
@ -169,7 +169,7 @@ Phaser.Pointer = function (game, id) {
|
|||
* @property {Phaser.Point} position - A Phaser.Point object containing the current x/y values of the pointer on the display.
|
||||
*/
|
||||
this.position = new Phaser.Point();
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} positionDown - A Phaser.Point object containing the x/y values of the pointer when it was last in a down state on the display.
|
||||
*/
|
||||
|
@ -276,7 +276,7 @@ Phaser.Pointer.prototype = {
|
|||
x: this.position.x,
|
||||
y: this.position.y
|
||||
});
|
||||
|
||||
|
||||
if (this._history.length > this.game.input.recordLimit)
|
||||
{
|
||||
this._history.shift();
|
||||
|
@ -378,7 +378,7 @@ Phaser.Pointer.prototype = {
|
|||
}
|
||||
currentNode = currentNode.next;
|
||||
}
|
||||
while (currentNode != null)
|
||||
while (currentNode != null);
|
||||
}
|
||||
|
||||
if (this._highestRenderObject === null)
|
||||
|
@ -498,17 +498,17 @@ Phaser.Pointer.prototype = {
|
|||
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)
|
||||
while (currentNode != null);
|
||||
}
|
||||
|
||||
if (this.targetObject)
|
||||
|
|
|
@ -276,7 +276,7 @@ Phaser.SinglePad.prototype = {
|
|||
}
|
||||
|
||||
this._axes[axisState.axis] = axisState.value;
|
||||
|
||||
|
||||
if (this._padParent.onAxisCallback)
|
||||
{
|
||||
this._padParent.onAxisCallback.call(this._padParent.callbackContext, axisState, this._index);
|
||||
|
|
|
@ -18,7 +18,7 @@ Phaser.Touch = function (game) {
|
|||
* @property {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
|
||||
/**
|
||||
* @property {boolean} disabled - You can disable all Touch events by setting disabled = true. While set all new touch events will be ignored.
|
||||
* @return {boolean}
|
||||
|
@ -34,32 +34,32 @@ Phaser.Touch = function (game) {
|
|||
* @property {function} touchStartCallback - A callback that can be fired on a touchStart event.
|
||||
*/
|
||||
this.touchStartCallback = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {function} touchMoveCallback - A callback that can be fired on a touchMove event.
|
||||
*/
|
||||
this.touchMoveCallback = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {function} touchEndCallback - A callback that can be fired on a touchEnd event.
|
||||
*/
|
||||
this.touchEndCallback = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {function} touchEnterCallback - A callback that can be fired on a touchEnter event.
|
||||
*/
|
||||
this.touchEnterCallback = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {function} touchLeaveCallback - A callback that can be fired on a touchLeave event.
|
||||
*/
|
||||
this.touchLeaveCallback = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {function} touchCancelCallback - A callback that can be fired on a touchCancel event.
|
||||
*/
|
||||
this.touchCancelCallback = null;
|
||||
|
||||
|
||||
/**
|
||||
* @property {boolean} preventDefault - If true the TouchEvent will have prevent.default called on it.
|
||||
* @default
|
||||
|
|
|
@ -371,7 +371,7 @@ Phaser.Cache.prototype = {
|
|||
* Add a new text data.
|
||||
*
|
||||
* @method Phaser.Cache#addText
|
||||
* @param {string} key - Asset key for the text data.
|
||||
* @param {string} key - Asset key for the text data.
|
||||
* @param {string} url - URL of this text data file.
|
||||
* @param {object} data - Extra text data.
|
||||
*/
|
||||
|
@ -385,7 +385,7 @@ Phaser.Cache.prototype = {
|
|||
* Add a new json object into the cache.
|
||||
*
|
||||
* @method Phaser.Cache#addJSON
|
||||
* @param {string} key - Asset key for the text data.
|
||||
* @param {string} key - Asset key for the text data.
|
||||
* @param {string} url - URL of this text data file.
|
||||
* @param {object} data - Extra text data.
|
||||
*/
|
||||
|
@ -485,7 +485,7 @@ Phaser.Cache.prototype = {
|
|||
* @param {string} key - Asset key for the sound.
|
||||
*/
|
||||
updateSound: function (key, property, value) {
|
||||
|
||||
|
||||
if (this._sounds[key])
|
||||
{
|
||||
this._sounds[key][property] = value;
|
||||
|
@ -601,7 +601,7 @@ Phaser.Cache.prototype = {
|
|||
console.warn('Phaser.Cache.getPhysicsData: Invalid key/object: "' + key + ' / ' + object + '"');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
|
||||
},
|
||||
|
@ -890,7 +890,7 @@ Phaser.Cache.prototype = {
|
|||
{
|
||||
console.warn('Phaser.Cache.getText: Invalid key: "' + key + '"');
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -910,7 +910,7 @@ Phaser.Cache.prototype = {
|
|||
{
|
||||
console.warn('Phaser.Cache.getJSON: Invalid key: "' + key + '"');
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -930,7 +930,7 @@ Phaser.Cache.prototype = {
|
|||
{
|
||||
console.warn('Phaser.Cache.getBinary: Invalid key: "' + key + '"');
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* jshint wsh:true */
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
|
@ -97,17 +98,17 @@ Phaser.Loader = function (game) {
|
|||
* @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.
|
||||
*/
|
||||
|
@ -195,7 +196,7 @@ Phaser.Loader.prototype = {
|
|||
}
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -220,7 +221,7 @@ Phaser.Loader.prototype = {
|
|||
}
|
||||
|
||||
return -1;
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -245,7 +246,7 @@ Phaser.Loader.prototype = {
|
|||
}
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1163,11 +1164,11 @@ Phaser.Loader.prototype = {
|
|||
|
||||
if (file.autoDecode)
|
||||
{
|
||||
this.game.cache.updateSound(key, 'isDecoding', true);
|
||||
|
||||
var that = this;
|
||||
var key = file.key;
|
||||
|
||||
this.game.cache.updateSound(key, 'isDecoding', true);
|
||||
|
||||
this.game.sound.context.decodeAudioData(file.data, function (buffer) {
|
||||
if (buffer)
|
||||
{
|
||||
|
@ -1402,7 +1403,7 @@ Phaser.Loader.prototype = {
|
|||
{
|
||||
this.hasLoaded = true;
|
||||
this.isLoading = false;
|
||||
|
||||
|
||||
this.removeAll();
|
||||
|
||||
this.onLoadComplete.dispatch();
|
||||
|
|
102
src/math/Math.js
102
src/math/Math.js
|
@ -18,11 +18,11 @@ Phaser.Math = {
|
|||
PI2: Math.PI * 2,
|
||||
|
||||
/**
|
||||
* Two number are fuzzyEqual if their difference is less than ε.
|
||||
* Two number are fuzzyEqual if their difference is less than ε.
|
||||
* @method Phaser.Math#fuzzyEqual
|
||||
* @param {number} a
|
||||
* @param {number} b
|
||||
* @param {number} epsilon
|
||||
* @param {number} epsilon
|
||||
* @return {boolean} True if |a-b|<ε
|
||||
*/
|
||||
fuzzyEqual: function (a, b, epsilon) {
|
||||
|
@ -31,11 +31,11 @@ Phaser.Math = {
|
|||
},
|
||||
|
||||
/**
|
||||
* a is fuzzyLessThan b if it is less than b + ε.
|
||||
* a is fuzzyLessThan b if it is less than b + ε.
|
||||
* @method Phaser.Math#fuzzyLessThan
|
||||
* @param {number} a
|
||||
* @param {number} b
|
||||
* @param {number} epsilon
|
||||
* @param {number} epsilon
|
||||
* @return {boolean} True if a<b+ε
|
||||
*/
|
||||
fuzzyLessThan: function (a, b, epsilon) {
|
||||
|
@ -44,11 +44,11 @@ Phaser.Math = {
|
|||
},
|
||||
|
||||
/**
|
||||
* a is fuzzyGreaterThan b if it is more than b - ε.
|
||||
* a is fuzzyGreaterThan b if it is more than b - ε.
|
||||
* @method Phaser.Math#fuzzyGreaterThan
|
||||
* @param {number} a
|
||||
* @param {number} b
|
||||
* @param {number} epsilon
|
||||
* @param {number} epsilon
|
||||
* @return {boolean} True if a>b+ε
|
||||
*/
|
||||
fuzzyGreaterThan: function (a, b, epsilon) {
|
||||
|
@ -56,10 +56,10 @@ Phaser.Math = {
|
|||
return a > b - epsilon;
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* @method Phaser.Math#fuzzyCeil
|
||||
* @param {number} val
|
||||
* @param {number} epsilon
|
||||
* @param {number} epsilon
|
||||
* @return {boolean} ceiling(val-ε)
|
||||
*/
|
||||
fuzzyCeil: function (val, epsilon) {
|
||||
|
@ -67,10 +67,10 @@ Phaser.Math = {
|
|||
return Math.ceil(val - epsilon);
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* @method Phaser.Math#fuzzyFloor
|
||||
* @param {number} val
|
||||
* @param {number} epsilon
|
||||
* @param {number} epsilon
|
||||
* @return {boolean} floor(val-ε)
|
||||
*/
|
||||
fuzzyFloor: function (val, epsilon) {
|
||||
|
@ -78,7 +78,7 @@ Phaser.Math = {
|
|||
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.
|
||||
|
@ -101,7 +101,7 @@ Phaser.Math = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* @method Phaser.Math#truncate
|
||||
* @param {number} n
|
||||
* @return {number}
|
||||
|
@ -110,7 +110,7 @@ Phaser.Math = {
|
|||
return (n > 0) ? Math.floor(n) : Math.ceil(n);
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* @method Phaser.Math#shear
|
||||
* @param {number} n
|
||||
* @return {number} n mod 1
|
||||
|
@ -202,7 +202,7 @@ Phaser.Math = {
|
|||
* Snaps a value to the nearest value in an array.
|
||||
* @method Phaser.Math#snapToInArray
|
||||
* @param {number} input
|
||||
* @param {array} arr
|
||||
* @param {array} arr
|
||||
* @param {boolean} sort - True if the array needs to be sorted.
|
||||
* @return {number}
|
||||
*/
|
||||
|
@ -219,14 +219,14 @@ Phaser.Math = {
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
},
|
||||
|
@ -260,7 +260,7 @@ Phaser.Math = {
|
|||
*
|
||||
* 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.
|
||||
|
@ -271,9 +271,9 @@ Phaser.Math = {
|
|||
|
||||
if (typeof place === "undefined") { place = 0; }
|
||||
if (typeof base === "undefined") { base = 10; }
|
||||
|
||||
|
||||
var p = Math.pow(base, -place);
|
||||
|
||||
|
||||
return Math.round(value * p) / p;
|
||||
|
||||
},
|
||||
|
@ -319,7 +319,7 @@ Phaser.Math = {
|
|||
* @method Phaser.Math#interpolateFloat
|
||||
* @param {number} a
|
||||
* @param {number} b
|
||||
* @param {number} weight
|
||||
* @param {number} weight
|
||||
* @return {number}
|
||||
*/
|
||||
interpolateFloat: function (a, b, weight) {
|
||||
|
@ -370,7 +370,7 @@ Phaser.Math = {
|
|||
|
||||
angleRad = angleRad % (2 * Math.PI);
|
||||
return angleRad >= 0 ? angleRad : angleRad + 2 * Math.PI;
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -416,7 +416,7 @@ Phaser.Math = {
|
|||
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;
|
||||
|
@ -466,7 +466,7 @@ Phaser.Math = {
|
|||
chanceRoll: function (chance) {
|
||||
|
||||
if (typeof chance === "undefined") { chance = 50; }
|
||||
|
||||
|
||||
if (chance <= 0)
|
||||
{
|
||||
return false;
|
||||
|
@ -544,7 +544,7 @@ Phaser.Math = {
|
|||
minSub: function (value, amount, min) {
|
||||
|
||||
value -= amount;
|
||||
|
||||
|
||||
if (value < min)
|
||||
{
|
||||
value = min;
|
||||
|
@ -579,7 +579,7 @@ Phaser.Math = {
|
|||
{
|
||||
result += range;
|
||||
}
|
||||
|
||||
|
||||
return result + min;
|
||||
|
||||
},
|
||||
|
@ -814,7 +814,7 @@ Phaser.Math = {
|
|||
* @method Phaser.Math#linearInterpolation
|
||||
* @param {number} v
|
||||
* @param {number} k
|
||||
* @return {number}
|
||||
* @return {number}
|
||||
*/
|
||||
linearInterpolation: function (v, k) {
|
||||
|
||||
|
@ -927,7 +927,7 @@ Phaser.Math = {
|
|||
* @param {number} p2
|
||||
* @param {number} p3
|
||||
* @param {number} t
|
||||
* @return {number}
|
||||
* @return {number}
|
||||
*/
|
||||
catmullRom: function (p0, p1, p2, p3, t) {
|
||||
|
||||
|
@ -961,7 +961,7 @@ Phaser.Math = {
|
|||
|
||||
if (typeof startIndex === "undefined") { startIndex = 0; }
|
||||
if (typeof length === "undefined") { length = 0; }
|
||||
|
||||
|
||||
if (objects != null) {
|
||||
|
||||
var l = length;
|
||||
|
@ -995,7 +995,7 @@ Phaser.Math = {
|
|||
|
||||
if (typeof startIndex === "undefined") { startIndex = 0; }
|
||||
if (typeof length === "undefined") { length = 0; }
|
||||
|
||||
|
||||
if (objects != null) {
|
||||
|
||||
var l = length;
|
||||
|
@ -1062,14 +1062,14 @@ Phaser.Math = {
|
|||
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;
|
||||
|
@ -1087,7 +1087,7 @@ 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.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Math#shift
|
||||
* @param {array} stack - The array to shift.
|
||||
* @return {any} The shifted value.
|
||||
|
@ -1123,7 +1123,7 @@ Phaser.Math = {
|
|||
|
||||
/**
|
||||
* Returns the distance between the two given set of coordinates.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Math#distance
|
||||
* @param {number} x1
|
||||
* @param {number} y1
|
||||
|
@ -1142,7 +1142,7 @@ Phaser.Math = {
|
|||
|
||||
/**
|
||||
* Returns the distance between the two given set of coordinates at the power given.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Math#distancePow
|
||||
* @param {number} x1
|
||||
* @param {number} y1
|
||||
|
@ -1161,7 +1161,7 @@ Phaser.Math = {
|
|||
|
||||
/**
|
||||
* Returns the rounded distance between the two given set of coordinates.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Math#distanceRounded
|
||||
* @param {number} x1
|
||||
* @param {number} y1
|
||||
|
@ -1178,7 +1178,7 @@ Phaser.Math = {
|
|||
/**
|
||||
* 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
|
||||
|
@ -1190,10 +1190,10 @@ Phaser.Math = {
|
|||
return ( x < a ) ? a : ( ( x > b ) ? b : x );
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Clamp value to range <a, inf).
|
||||
*
|
||||
*
|
||||
* @method Phaser.Math#clampBottom
|
||||
* @param {number} x
|
||||
* @param {number} a
|
||||
|
@ -1207,7 +1207,7 @@ Phaser.Math = {
|
|||
|
||||
/**
|
||||
* 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
|
||||
|
@ -1219,10 +1219,10 @@ Phaser.Math = {
|
|||
return (Math.abs(a - b) <= tolerance);
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Linear mapping from range <a1, a2> to range <b1, b2>
|
||||
*
|
||||
*
|
||||
* @method Phaser.Math#mapLinear
|
||||
* @param {number} x the value to map
|
||||
* @param {number} a1 first endpoint of the range <a1, a2>
|
||||
|
@ -1239,7 +1239,7 @@ Phaser.Math = {
|
|||
|
||||
/**
|
||||
* Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep
|
||||
*
|
||||
*
|
||||
* @method Phaser.Math#smoothstep
|
||||
* @param {number} x
|
||||
* @param {number} min
|
||||
|
@ -1266,7 +1266,7 @@ Phaser.Math = {
|
|||
|
||||
/**
|
||||
* Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep
|
||||
*
|
||||
*
|
||||
* @method Phaser.Math#smootherstep
|
||||
* @param {number} x
|
||||
* @param {number} min
|
||||
|
@ -1294,7 +1294,7 @@ Phaser.Math = {
|
|||
/**
|
||||
* 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}
|
||||
|
@ -1307,11 +1307,11 @@ Phaser.Math = {
|
|||
|
||||
/**
|
||||
* Convert degrees to radians.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Math#degToRad
|
||||
* @return {function}
|
||||
*/
|
||||
degToRad: function() {
|
||||
degToRad: (function() {
|
||||
|
||||
var degreeToRadiansFactor = Math.PI / 180;
|
||||
|
||||
|
@ -1321,15 +1321,15 @@ Phaser.Math = {
|
|||
|
||||
};
|
||||
|
||||
}(),
|
||||
}()),
|
||||
|
||||
/**
|
||||
* Convert degrees to radians.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Math#radToDeg
|
||||
* @return {function}
|
||||
*/
|
||||
radToDeg: function() {
|
||||
radToDeg: (function() {
|
||||
|
||||
var radianToDegreesFactor = 180 / Math.PI;
|
||||
|
||||
|
@ -1339,6 +1339,6 @@ Phaser.Math = {
|
|||
|
||||
};
|
||||
|
||||
}()
|
||||
}())
|
||||
|
||||
};
|
||||
|
|
|
@ -8,17 +8,17 @@
|
|||
|
||||
/**
|
||||
* 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 = []; }
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
|
||||
/**
|
||||
* Reset the seed of the random data generator.
|
||||
*
|
||||
*
|
||||
* @method Phaser.RandomDataGenerator#sow
|
||||
* @param {array} seeds
|
||||
*/
|
||||
|
@ -95,7 +95,7 @@ Phaser.RandomDataGenerator.prototype = {
|
|||
this.s2 -= this.hash(seed);
|
||||
this.s2 += ~~(this.s2 < 0);
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
Phaser.Net = function (game) {
|
||||
|
||||
|
||||
this.game = game;
|
||||
|
||||
};
|
||||
|
@ -21,7 +21,7 @@ Phaser.Net.prototype = {
|
|||
|
||||
/**
|
||||
* Returns the hostname given by the browser.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Net#getHostName
|
||||
* @return {string}
|
||||
*/
|
||||
|
@ -40,7 +40,7 @@ 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} true if the given domain fragment can be found in the window.location.hostname
|
||||
|
@ -54,7 +54,7 @@ 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.
|
||||
|
@ -69,7 +69,7 @@ Phaser.Net.prototype = {
|
|||
|
||||
var output = '';
|
||||
var re = new RegExp("([?|&])" + key + "=.*?(&|#|$)(.*)", "gi");
|
||||
|
||||
|
||||
if (re.test(url))
|
||||
{
|
||||
if (typeof value !== 'undefined' && value !== null)
|
||||
|
@ -116,7 +116,7 @@ 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.
|
||||
|
@ -152,7 +152,7 @@ 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.
|
||||
|
|
|
@ -25,7 +25,7 @@ Phaser.Particles = function (game) {
|
|||
this.emitters = {};
|
||||
|
||||
/**
|
||||
* @property {number} ID -
|
||||
* @property {number} ID -
|
||||
* @default
|
||||
*/
|
||||
this.ID = 0;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Phaser.Particles.Arcade = {}
|
||||
Phaser.Particles.Arcade = {};
|
||||
|
|
|
@ -189,7 +189,7 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
|
|||
* @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
|
||||
|
@ -229,7 +229,7 @@ Phaser.Particles.Arcade.Emitter.prototype.update = function () {
|
|||
if (this.game.time.now >= this._timer)
|
||||
{
|
||||
this.emitParticle();
|
||||
|
||||
|
||||
this._counter++;
|
||||
|
||||
if (this._quantity > 0)
|
||||
|
@ -245,7 +245,7 @@ Phaser.Particles.Arcade.Emitter.prototype.update = function () {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This function generates a new array of particle sprites to attach to the emitter.
|
||||
|
@ -312,7 +312,7 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
|
|||
|
||||
return this;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to turn off all the particles and the emitter.
|
||||
|
@ -324,7 +324,7 @@ Phaser.Particles.Arcade.Emitter.prototype.kill = function () {
|
|||
this.alive = false;
|
||||
this.exists = false;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handy for bringing game objects "back to life". Just sets alive and exists back to true.
|
||||
|
@ -335,7 +335,7 @@ Phaser.Particles.Arcade.Emitter.prototype.revive = function () {
|
|||
this.alive = true;
|
||||
this.exists = true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to start emitting particles.
|
||||
|
@ -373,7 +373,7 @@ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, f
|
|||
this._counter = 0;
|
||||
this._timer = this.game.time.now + frequency;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This function can be used both internally and externally to emit the next particle.
|
||||
|
@ -450,7 +450,7 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
|
|||
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.
|
||||
|
@ -463,7 +463,7 @@ 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.
|
||||
|
@ -479,7 +479,7 @@ Phaser.Particles.Arcade.Emitter.prototype.setXSpeed = function (min, max) {
|
|||
this.minParticleSpeed.x = min;
|
||||
this.maxParticleSpeed.x = max;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A more compact way of setting the Y velocity range of the emitter.
|
||||
|
@ -495,7 +495,7 @@ Phaser.Particles.Arcade.Emitter.prototype.setYSpeed = function (min, max) {
|
|||
this.minParticleSpeed.y = min;
|
||||
this.maxParticleSpeed.y = max;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A more compact way of setting the angular velocity constraints of the emitter.
|
||||
|
@ -511,7 +511,7 @@ Phaser.Particles.Arcade.Emitter.prototype.setRotation = function (min, max) {
|
|||
this.minRotation = min;
|
||||
this.maxRotation = max;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Change the emitters center to match the center of any object with a `center` property, such as a Sprite.
|
||||
|
@ -526,7 +526,7 @@ Phaser.Particles.Arcade.Emitter.prototype.at = function (object) {
|
|||
this.emitY = object.center.y;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Phaser.Particles.Arcade.Emitter#x
|
||||
|
@ -566,7 +566,7 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "y", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "left", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return Math.floor(this.x - (this.width / 2));
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "left", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "right", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return Math.floor(this.x + (this.width / 2));
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "right", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "top", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return Math.floor(this.y - (this.height / 2));
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "top", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "bottom", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return Math.floor(this.y + (this.height / 2));
|
||||
}
|
||||
|
|
|
@ -146,11 +146,11 @@ Phaser.Physics.prototype = {
|
|||
}
|
||||
else if (system === Phaser.Physics.BOX2D && this.box2d === null)
|
||||
{
|
||||
// Coming soon
|
||||
throw new Error('The Box2D physics system has not been implemented yet.');
|
||||
}
|
||||
else if (system === Phaser.Physics.CHIPMUNK && this.chipmunk === null)
|
||||
{
|
||||
// Coming soon
|
||||
throw new Error('The Chipmunk physics system has not been implemented yet.');
|
||||
}
|
||||
|
||||
},
|
||||
|
|
|
@ -677,7 +677,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.position.y + this.height;
|
||||
}
|
||||
|
@ -690,7 +690,7 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.position.x + this.width;
|
||||
}
|
||||
|
@ -702,7 +702,7 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "right", {
|
|||
* @property {number} x - The x position.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "x", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.position.x;
|
||||
},
|
||||
|
@ -718,7 +718,7 @@ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "x", {
|
|||
* @property {number} y - The y position.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "y", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.position.y;
|
||||
},
|
||||
|
@ -755,7 +755,7 @@ Phaser.Physics.Arcade.Body.render = function (context, body, filled, color) {
|
|||
context.strokeRect(body.position.x - body.game.camera.x, body.position.y - body.game.camera.y, body.width, body.height);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Render Sprite Body Physics Data as text.
|
||||
|
@ -776,6 +776,6 @@ Phaser.Physics.Arcade.Body.renderBodyInfo = function (debug, body) {
|
|||
debug.line('touching left: ' + body.touching.left, 'right: ' + body.touching.right, 'up: ' + body.touching.up, 'down: ' + body.touching.down);
|
||||
debug.line('blocked left: ' + body.blocked.left, 'right: ' + body.blocked.right, 'up: ' + body.blocked.up, 'down: ' + body.blocked.down);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Physics.Arcade.Body.prototype.constructor = Phaser.Physics.Arcade.Body;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* @param {Phaser.Game} game reference to the current game instance.
|
||||
*/
|
||||
Phaser.Physics.Arcade = function (game) {
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - Local reference to game.
|
||||
*/
|
||||
|
@ -651,10 +651,10 @@ Phaser.Physics.Arcade.prototype = {
|
|||
collideSpriteVsTilemapLayer: function (sprite, tilemapLayer, collideCallback, processCallback, callbackContext) {
|
||||
|
||||
this._mapData = tilemapLayer.getTiles(
|
||||
sprite.body.position.x - sprite.body.tilePadding.x,
|
||||
sprite.body.position.y - sprite.body.tilePadding.y,
|
||||
sprite.body.width + sprite.body.tilePadding.x,
|
||||
sprite.body.height + sprite.body.tilePadding.y,
|
||||
sprite.body.position.x - sprite.body.tilePadding.x,
|
||||
sprite.body.position.y - sprite.body.tilePadding.y,
|
||||
sprite.body.width + sprite.body.tilePadding.x,
|
||||
sprite.body.height + sprite.body.tilePadding.y,
|
||||
false, false);
|
||||
|
||||
if (this._mapData.length === 0)
|
||||
|
@ -1121,7 +1121,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tile.faceTop || tile.faceBottom)
|
||||
{
|
||||
oy = this.tileCheckY(body, tile);
|
||||
|
@ -1139,7 +1139,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tile.faceLeft || tile.faceRight)
|
||||
{
|
||||
ox = this.tileCheckX(body, tile);
|
||||
|
@ -1289,7 +1289,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
* @param {Phaser.Physics.Arcade.Body} body - The Body object to separate.
|
||||
* @param {number} y - The y separation amount.
|
||||
*/
|
||||
processTileSeparationY: function (body, y, tile) {
|
||||
processTileSeparationY: function (body, y) {
|
||||
|
||||
if (y < 0)
|
||||
{
|
||||
|
@ -1320,7 +1320,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
* 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.
|
||||
|
@ -1334,13 +1334,13 @@ Phaser.Physics.Arcade.prototype = {
|
|||
if (typeof maxTime === 'undefined') { 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;
|
||||
|
||||
|
@ -1354,7 +1354,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
* 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)
|
||||
|
@ -1375,7 +1375,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
// 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;
|
||||
|
||||
|
@ -1390,7 +1390,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
* 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.
|
||||
|
@ -1405,13 +1405,13 @@ Phaser.Physics.Arcade.prototype = {
|
|||
if (typeof maxTime === 'undefined') { 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;
|
||||
|
||||
|
@ -1422,7 +1422,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
/**
|
||||
* 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.
|
||||
|
@ -1441,7 +1441,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
/**
|
||||
* 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.
|
||||
|
@ -1460,7 +1460,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
/**
|
||||
* 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: accelerationFromRotation(rotation, 200, sprite.acceleration) which will set the values directly to the sprites acceleration 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.
|
||||
|
@ -1481,7 +1481,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
* 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.
|
||||
|
@ -1510,7 +1510,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
* 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.
|
||||
|
@ -1527,7 +1527,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
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);
|
||||
|
||||
|
@ -1540,7 +1540,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
* 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.
|
||||
|
@ -1567,7 +1567,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -1577,7 +1577,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
this._dx = source.x - target.x;
|
||||
this._dy = source.y - target.y;
|
||||
|
||||
|
||||
return Math.sqrt(this._dx * this._dx + this._dy * this._dy);
|
||||
|
||||
},
|
||||
|
@ -1586,7 +1586,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
* 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.
|
||||
|
@ -1597,7 +1597,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
this._dx = displayObject.x - x;
|
||||
this._dy = displayObject.y - y;
|
||||
|
||||
|
||||
return Math.sqrt(this._dx * this._dx + this._dy * this._dy);
|
||||
|
||||
},
|
||||
|
@ -1606,7 +1606,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
* 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.
|
||||
|
@ -1618,14 +1618,14 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
this._dx = displayObject.x - pointer.x;
|
||||
this._dy = displayObject.y - 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.
|
||||
|
@ -1642,7 +1642,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -1653,14 +1653,14 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
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.
|
||||
|
@ -1672,7 +1672,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
|
||||
this._dx = pointer.worldX - displayObject.x;
|
||||
this._dy = pointer.worldY - displayObject.y;
|
||||
|
||||
|
||||
return Math.atan2(this._dy, this._dx);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* jshint camelcase: false */
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
|
@ -18,7 +19,7 @@
|
|||
* @param {number} height - The height of this AABB.
|
||||
*/
|
||||
Phaser.Physics.Ninja.AABB = function (body, x, y, width, height) {
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Physics.Ninja.Body} system - A reference to the body that owns this shape.
|
||||
*/
|
||||
|
@ -135,7 +136,7 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
* @param {number} dy - Collision normal
|
||||
* @param {number} obj - Object this AABB collided with
|
||||
*/
|
||||
reportCollisionVsWorld: function (px, py, dx, dy, obj) {
|
||||
reportCollisionVsWorld: function (px, py, dx, dy) {
|
||||
|
||||
var p = this.pos;
|
||||
var o = this.oldpos;
|
||||
|
@ -244,16 +245,6 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
var vx1 = this.pos.x - this.oldpos.x; // Calc velocity of this object
|
||||
var vy1 = this.pos.y - this.oldpos.y;
|
||||
var dp1 = (vx1 * dx + vy1 * dy); // Find component of velocity parallel to collision normal
|
||||
var nx1 = dp1 * dx; // Project velocity onto collision normal
|
||||
var ny1 = dp1 * dy; // nx, ny is normal velocity
|
||||
|
||||
var dx2 = dx * -1;
|
||||
var dy2 = dy * -1;
|
||||
var vx2 = obj.pos.x - obj.oldpos.x; // Calc velocity of colliding object
|
||||
var vy2 = obj.pos.y - obj.oldpos.y;
|
||||
var dp2 = (vx2 * dx2 + vy2 * dy2); // Find component of velocity parallel to collision normal
|
||||
var nx2 = dp2 * dx2; // Project velocity onto collision normal
|
||||
var ny2 = dp2 * dy2; // nx, ny is normal velocity
|
||||
|
||||
// We only want to apply collision response forces if the object is travelling into, and not out of, the collision
|
||||
if (this.body.immovable && obj.body.immovable)
|
||||
|
@ -534,16 +525,16 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
projAABB_Half: function (x, y, obj, t) {
|
||||
|
||||
//signx or signy must be 0; the other must be -1 or 1
|
||||
//calculate the projection vector for the half-edge, and then
|
||||
//calculate the projection vector for the half-edge, and then
|
||||
//(if collision is occuring) pick the minimum
|
||||
|
||||
|
||||
var sx = t.signx;
|
||||
var sy = t.signy;
|
||||
|
||||
|
||||
var ox = (obj.pos.x - (sx*obj.xw)) - t.pos.x;//this gives is the coordinates of the innermost
|
||||
var oy = (obj.pos.y - (sy*obj.yw)) - t.pos.y;//point on the AABB, relative to the tile center
|
||||
|
||||
//we perform operations analogous to the 45deg tile, except we're using
|
||||
//we perform operations analogous to the 45deg tile, except we're using
|
||||
//an axis-aligned slope instead of an angled one..
|
||||
|
||||
//if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
|
||||
|
@ -554,11 +545,11 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
{
|
||||
//collision; project delta onto slope and use this to displace the object
|
||||
sx *= -dp;//(sx,sy) is now the projection vector
|
||||
sy *= -dp;
|
||||
|
||||
sy *= -dp;
|
||||
|
||||
var lenN = Math.sqrt(sx*sx + sy*sy);
|
||||
var lenP = Math.sqrt(x*x + y*y);
|
||||
|
||||
|
||||
if (lenP < lenN)
|
||||
{
|
||||
//project along axis; note that we're assuming that this tile is horizontal OR vertical
|
||||
|
@ -568,14 +559,14 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
return Phaser.Physics.Ninja.AABB.COL_AXIS;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
//note that we could use -= instead of -dp
|
||||
obj.reportCollisionVsWorld(sx,sy,t.signx, t.signy, t);
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_OTHER;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_NONE;
|
||||
|
||||
},
|
||||
|
@ -600,7 +591,7 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
|
||||
var sx = t.sx;
|
||||
var sy = t.sy;
|
||||
|
||||
|
||||
//if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
|
||||
//and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
|
||||
var dp = (ox*sx) + (oy*sy);
|
||||
|
@ -609,8 +600,8 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
{
|
||||
//collision; project delta onto slope and use this to displace the object
|
||||
sx *= -dp;//(sx,sy) is now the projection vector
|
||||
sy *= -dp;
|
||||
|
||||
sy *= -dp;
|
||||
|
||||
var lenN = Math.sqrt(sx*sx + sy*sy);
|
||||
var lenP = Math.sqrt(x*x + y*y);
|
||||
|
||||
|
@ -629,7 +620,7 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
return Phaser.Physics.Ninja.AABB.COL_OTHER;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_NONE;
|
||||
},
|
||||
|
||||
|
@ -644,7 +635,7 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
* @return {number} The result of the collision.
|
||||
*/
|
||||
projAABB_22DegS: function (x, y, obj, t) {
|
||||
|
||||
|
||||
var signx = t.signx;
|
||||
var signy = t.signy;
|
||||
|
||||
|
@ -657,10 +648,10 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
{
|
||||
var ox = (obj.pos.x - (signx*obj.xw)) - (t.pos.x + (signx*t.xw));//this gives is the coordinates of the innermost
|
||||
var oy = (obj.pos.y - (signy*obj.yw)) - (t.pos.y - (signy*t.yw));//point on the AABB, relative to a point on the slope
|
||||
|
||||
|
||||
var sx = t.sx;//get slope unit normal
|
||||
var sy = t.sy;
|
||||
|
||||
|
||||
//if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
|
||||
//and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
|
||||
var dp = (ox*sx) + (oy*sy);
|
||||
|
@ -669,11 +660,11 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
{
|
||||
//collision; project delta onto slope and use this to displace the object
|
||||
sx *= -dp;//(sx,sy) is now the projection vector
|
||||
sy *= -dp;
|
||||
sy *= -dp;
|
||||
|
||||
var lenN = Math.sqrt(sx*sx + sy*sy);
|
||||
var lenP = Math.sqrt(x*x + y*y);
|
||||
|
||||
|
||||
var aY = Math.abs(penY);
|
||||
|
||||
if (lenP < lenN)
|
||||
|
@ -681,13 +672,13 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
if (aY < lenP)
|
||||
{
|
||||
obj.reportCollisionVsWorld(0, penY, 0, penY/aY, t);
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_OTHER;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t);
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_AXIS;
|
||||
}
|
||||
}
|
||||
|
@ -696,7 +687,7 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
if (aY < lenN)
|
||||
{
|
||||
obj.reportCollisionVsWorld(0, penY, 0, penY/aY, t);
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_OTHER;
|
||||
}
|
||||
else
|
||||
|
@ -708,7 +699,7 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//if we've reached this point, no collision has occured
|
||||
return Phaser.Physics.Ninja.AABB.COL_NONE;
|
||||
},
|
||||
|
@ -730,10 +721,10 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
|
||||
var ox = (obj.pos.x - (signx*obj.xw)) - (t.pos.x - (signx*t.xw));//this gives is the coordinates of the innermost
|
||||
var oy = (obj.pos.y - (signy*obj.yw)) - (t.pos.y + (signy*t.yw));//point on the AABB, relative to a point on the slope
|
||||
|
||||
|
||||
var sx = t.sx;//get slope unit normal
|
||||
var sy = t.sy;
|
||||
|
||||
|
||||
//if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
|
||||
//and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
|
||||
var dp = (ox*sx) + (oy*sy);
|
||||
|
@ -742,7 +733,7 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
{
|
||||
//collision; project delta onto slope and use this to displace the object
|
||||
sx *= -dp;//(sx,sy) is now the projection vector
|
||||
sy *= -dp;
|
||||
sy *= -dp;
|
||||
|
||||
var lenN = Math.sqrt(sx*sx + sy*sy);
|
||||
var lenP = Math.sqrt(x*x + y*y);
|
||||
|
@ -750,18 +741,18 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
if (lenP < lenN)
|
||||
{
|
||||
obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t);
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_AXIS;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
obj.reportCollisionVsWorld(sx,sy,t.sx,t.sy,t);
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_OTHER;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_NONE;
|
||||
|
||||
},
|
||||
|
@ -791,7 +782,7 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
|
||||
var sx = t.sx;//get slope unit normal
|
||||
var sy = t.sy;
|
||||
|
||||
|
||||
//if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
|
||||
//and we need to project it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
|
||||
var dp = (ox*sx) + (oy*sy);
|
||||
|
@ -800,7 +791,7 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
{
|
||||
//collision; project delta onto slope and use this to displace the object
|
||||
sx *= -dp;//(sx,sy) is now the projection vector
|
||||
sy *= -dp;
|
||||
sy *= -dp;
|
||||
|
||||
var lenN = Math.sqrt(sx*sx + sy*sy);
|
||||
var lenP = Math.sqrt(x*x + y*y);
|
||||
|
@ -812,13 +803,13 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
if (aX < lenP)
|
||||
{
|
||||
obj.reportCollisionVsWorld(penX, 0, penX/aX, 0, t);
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_OTHER;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t);
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_AXIS;
|
||||
}
|
||||
}
|
||||
|
@ -827,11 +818,11 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
if (aX < lenN)
|
||||
{
|
||||
obj.reportCollisionVsWorld(penX, 0, penX/aX, 0, t);
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_OTHER;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
obj.reportCollisionVsWorld(sx,sy,t.sx,t.sy,t);
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_OTHER;
|
||||
|
@ -839,9 +830,9 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//if we've reached this point, no collision has occured
|
||||
return Phaser.Physics.Ninja.AABB.COL_NONE;
|
||||
return Phaser.Physics.Ninja.AABB.COL_NONE;
|
||||
|
||||
},
|
||||
|
||||
|
@ -859,13 +850,13 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
|
||||
var signx = t.signx;
|
||||
var signy = t.signy;
|
||||
|
||||
|
||||
var ox = (obj.pos.x - (signx*obj.xw)) - (t.pos.x + (signx*t.xw));//this gives is the coordinates of the innermost
|
||||
var oy = (obj.pos.y - (signy*obj.yw)) - (t.pos.y - (signy*t.yw));//point on the AABB, relative to a point on the slope
|
||||
|
||||
|
||||
var sx = t.sx;//get slope unit normal
|
||||
var sy = t.sy;
|
||||
|
||||
|
||||
//if the dotprod of (ox,oy) and (sx,sy) is negative, the corner is in the slope
|
||||
//and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy)
|
||||
var dp = (ox*sx) + (oy*sy);
|
||||
|
@ -874,11 +865,11 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
{
|
||||
//collision; project delta onto slope and use this to displace the object
|
||||
sx *= -dp;//(sx,sy) is now the projection vector
|
||||
sy *= -dp;
|
||||
|
||||
sy *= -dp;
|
||||
|
||||
var lenN = Math.sqrt(sx*sx + sy*sy);
|
||||
var lenP = Math.sqrt(x*x + y*y);
|
||||
|
||||
|
||||
if (lenP < lenN)
|
||||
{
|
||||
obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t);
|
||||
|
@ -886,14 +877,14 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
return Phaser.Physics.Ninja.AABB.COL_AXIS;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
obj.reportCollisionVsWorld(sx,sy,t.sx,t.sy,t);
|
||||
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_OTHER;
|
||||
}
|
||||
}
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_NONE;
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_NONE;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -930,7 +921,7 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
var lenP = Math.sqrt(x * x + y * y);
|
||||
obj.reportCollisionVsWorld(x, y, x / lenP, y / lenP, t);
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_AXIS;//we need to report
|
||||
return Phaser.Physics.Ninja.AABB.COL_AXIS;//we need to report
|
||||
}
|
||||
else if (0 < pen)
|
||||
{
|
||||
|
@ -1001,7 +992,7 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
}
|
||||
|
||||
return Phaser.Physics.Ninja.AABB.COL_NONE;
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1014,4 +1005,4 @@ Phaser.Physics.Ninja.AABB.prototype = {
|
|||
this.system = null;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
|
|
@ -441,7 +441,7 @@ Phaser.Physics.Ninja.Body.prototype = {
|
|||
* @property {number} x - The x position.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "x", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.shape.pos.x;
|
||||
},
|
||||
|
@ -457,7 +457,7 @@ Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "x", {
|
|||
* @property {number} y - The y position.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "y", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.shape.pos.y;
|
||||
},
|
||||
|
@ -474,7 +474,7 @@ Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "y", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "width", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.shape.width;
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "width", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "height", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.shape.height;
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "height", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "bottom", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.shape.pos.y + this.shape.yw;
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "bottom", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "right", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.shape.pos.x + this.shape.xw;
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "right", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "speed", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return Math.sqrt(this.shape.velocity.x * this.shape.velocity.x + this.shape.velocity.y * this.shape.velocity.y);
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "speed", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Ninja.Body.prototype, "angle", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return Math.atan2(this.shape.velocity.y, this.shape.velocity.x);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,4 @@
|
|||
/* jshint camelcase: false */
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
|
@ -9,7 +10,7 @@
|
|||
* A Tile is defined by its width, height and type. It's type can include slope data, such as 45 degree slopes, or convex slopes.
|
||||
* Understand that for any type including a slope (types 2 to 29) the Tile must be SQUARE, i.e. have an equal width and height.
|
||||
* Also note that as Tiles are primarily used for levels they have gravity disabled and world bounds collision disabled by default.
|
||||
*
|
||||
*
|
||||
* Note: This class could be massively optimised and reduced in size. I leave that challenge up to you.
|
||||
*
|
||||
* @class Phaser.Physics.Ninja.Tile
|
||||
|
@ -23,7 +24,7 @@
|
|||
* @param {number} [type=1] - The type of Ninja shape to create. 1 = AABB, 2 = Circle or 3 = Tile.
|
||||
*/
|
||||
Phaser.Physics.Ninja.Tile = function (body, x, y, width, height, type) {
|
||||
|
||||
|
||||
if (typeof type === 'undefined') { type = Phaser.Physics.Ninja.Tile.EMPTY; }
|
||||
|
||||
/**
|
||||
|
@ -201,8 +202,7 @@ Phaser.Physics.Ninja.Tile.prototype = {
|
|||
* @param {number} dy - Collision normal
|
||||
* @param {number} obj - Object this Tile collided with
|
||||
*/
|
||||
reportCollisionVsWorld: function (px, py, dx, dy, obj) {
|
||||
|
||||
reportCollisionVsWorld: function (px, py, dx, dy) {
|
||||
var p = this.pos;
|
||||
var o = this.oldpos;
|
||||
|
||||
|
@ -353,28 +353,28 @@ Phaser.Physics.Ninja.Tile.prototype = {
|
|||
this.signx = 1;
|
||||
this.signy = -1;
|
||||
this.sx = this.signx / Math.SQRT2;//get slope _unit_ normal
|
||||
this.sy = this.signy / Math.SQRT2;//since normal is (1,-1), length is sqrt(1*1 + -1*-1) = sqrt(2)
|
||||
this.sy = this.signy / Math.SQRT2;//since normal is (1,-1), length is sqrt(1*1 + -1*-1) = sqrt(2)
|
||||
}
|
||||
else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_45DEGnn)
|
||||
{
|
||||
this.signx = -1;
|
||||
this.signy = -1;
|
||||
this.sx = this.signx / Math.SQRT2;//get slope _unit_ normal
|
||||
this.sy = this.signy / Math.SQRT2;//since normal is (1,-1), length is sqrt(1*1 + -1*-1) = sqrt(2)
|
||||
this.sy = this.signy / Math.SQRT2;//since normal is (1,-1), length is sqrt(1*1 + -1*-1) = sqrt(2)
|
||||
}
|
||||
else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_45DEGnp)
|
||||
{
|
||||
this.signx = -1;
|
||||
this.signy = 1;
|
||||
this.sx = this.signx / Math.SQRT2;//get slope _unit_ normal
|
||||
this.sy = this.signy / Math.SQRT2;//since normal is (1,-1), length is sqrt(1*1 + -1*-1) = sqrt(2)
|
||||
this.sy = this.signy / Math.SQRT2;//since normal is (1,-1), length is sqrt(1*1 + -1*-1) = sqrt(2)
|
||||
}
|
||||
else if (this.id == Phaser.Physics.Ninja.Tile.SLOPE_45DEGpp)
|
||||
{
|
||||
this.signx = 1;
|
||||
this.signy = 1;
|
||||
this.sx = this.signx / Math.SQRT2;//get slope _unit_ normal
|
||||
this.sy = this.signy / Math.SQRT2;//since normal is (1,-1), length is sqrt(1*1 + -1*-1) = sqrt(2)
|
||||
this.sy = this.signy / Math.SQRT2;//since normal is (1,-1), length is sqrt(1*1 + -1*-1) = sqrt(2)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -665,14 +665,14 @@ Phaser.Physics.Ninja.Tile.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.Ninja.Tile#x
|
||||
* @property {number} x - The x position.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Ninja.Tile.prototype, "x", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.pos.x - this.xw;
|
||||
},
|
||||
|
@ -688,7 +688,7 @@ Object.defineProperty(Phaser.Physics.Ninja.Tile.prototype, "x", {
|
|||
* @property {number} y - The y position.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Ninja.Tile.prototype, "y", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.pos.y - this.yw;
|
||||
},
|
||||
|
@ -705,7 +705,7 @@ Object.defineProperty(Phaser.Physics.Ninja.Tile.prototype, "y", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Ninja.Tile.prototype, "bottom", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.pos.y + this.yw;
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ Object.defineProperty(Phaser.Physics.Ninja.Tile.prototype, "bottom", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.Ninja.Tile.prototype, "right", {
|
||||
|
||||
|
||||
get: function () {
|
||||
return this.pos.x + this.xw;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
* @param {Phaser.Game} game reference to the current game instance.
|
||||
*/
|
||||
Phaser.Physics.Ninja = function (game) {
|
||||
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - Local reference to game.
|
||||
*/
|
||||
|
@ -136,7 +136,7 @@ Phaser.Physics.Ninja.prototype = {
|
|||
|
||||
if (Array.isArray(object))
|
||||
{
|
||||
i = object.length;
|
||||
var i = object.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
|
@ -264,9 +264,6 @@ Phaser.Physics.Ninja.prototype = {
|
|||
|
||||
layer = map.getLayer(layer);
|
||||
|
||||
if (typeof addToWorld === 'undefined') { addToWorld = true; }
|
||||
if (typeof optimize === 'undefined') { optimize = true; }
|
||||
|
||||
// If the bodies array is already populated we need to nuke it
|
||||
this.clearTilemapLayerBodies(map, layer);
|
||||
|
||||
|
@ -570,11 +567,9 @@ Phaser.Physics.Ninja.prototype = {
|
|||
* @method Phaser.Physics.Ninja#separate
|
||||
* @param {Phaser.Physics.Ninja.Body} body1 - The Body object to separate.
|
||||
* @param {Phaser.Physics.Ninja.Body} body2 - The Body object to separate.
|
||||
* @param {function} [processCallback=null] - UN-USED: A callback function that lets you perform additional checks against the two objects if they overlap. If this function is set then the sprites will only be collided if it returns true.
|
||||
* @param {object} [callbackContext] - UN-USED: The context in which to run the process callback.
|
||||
* @returns {boolean} Returns true if the bodies collided, otherwise false.
|
||||
*/
|
||||
separate: function (body1, body2, processCallback, callbackContext, overlapOnly) {
|
||||
separate: function (body1, body2) {
|
||||
|
||||
if (body1.type !== Phaser.Physics.NINJA || body2.type !== Phaser.Physics.NINJA)
|
||||
{
|
||||
|
|
|
@ -134,7 +134,7 @@ Phaser.Physics.P2.Body = function (game, sprite, x, y, mass) {
|
|||
/**
|
||||
* @property {Phaser.Physics.P2.BodyDebug} debugBody - Reference to the debug body.
|
||||
*/
|
||||
this.debugBody = null
|
||||
this.debugBody = null;
|
||||
|
||||
// Set-up the default shape
|
||||
if (sprite)
|
||||
|
@ -763,7 +763,7 @@ Phaser.Physics.P2.Body.prototype = {
|
|||
this.debugBody.destroy();
|
||||
}
|
||||
|
||||
this.debugBody = null
|
||||
this.debugBody = null;
|
||||
|
||||
this.sprite = null;
|
||||
|
||||
|
@ -927,12 +927,12 @@ Phaser.Physics.P2.Body.prototype = {
|
|||
* This function expects the x.y values to be given in pixels. If you want to provide them at p2 world scales then call Body.data.fromPolygon directly.
|
||||
*
|
||||
* @method Phaser.Physics.P2.Body#addPolygon
|
||||
* @param {object} options - An object containing the build options:
|
||||
* @param {object} options - An object containing the build options:
|
||||
* @param {boolean} [options.optimalDecomp=false] - Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.
|
||||
* @param {boolean} [options.skipSimpleCheck=false] - Set to true if you already know that the path is not intersecting itself.
|
||||
* @param {boolean|number} [options.removeCollinearPoints=false] - Set to a number (angle threshold value) to remove collinear points, or false to keep all points.
|
||||
* @param {(number[]|...number)} points - An array of 2d vectors that form the convex or concave polygon.
|
||||
* Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...],
|
||||
* @param {(number[]|...number)} points - An array of 2d vectors that form the convex or concave polygon.
|
||||
* Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...],
|
||||
* or the arguments passed can be flat x,y values e.g. `setPolygon(options, x,y, x,y, x,y, ...)` where `x` and `y` are numbers.
|
||||
* @return {boolean} True on success, else false.
|
||||
*/
|
||||
|
@ -965,7 +965,7 @@ Phaser.Physics.P2.Body.prototype = {
|
|||
// top and tail
|
||||
var idx = path.length - 1;
|
||||
|
||||
if ( path[idx][0] === path[0][0] && path[idx][1] === path[0][1] )
|
||||
if (path[idx][0] === path[0][0] && path[idx][1] === path[0][1])
|
||||
{
|
||||
path.pop();
|
||||
}
|
||||
|
@ -1080,7 +1080,7 @@ Phaser.Physics.P2.Body.prototype = {
|
|||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Updates the debug draw if any body shapes change.
|
||||
*
|
||||
|
@ -1123,7 +1123,7 @@ Phaser.Physics.P2.Body.prototype = {
|
|||
return createdFixtures;
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Add a polygon fixture. This is used during #loadPhaserPolygon.
|
||||
*
|
||||
|
@ -1136,28 +1136,26 @@ Phaser.Physics.P2.Body.prototype = {
|
|||
|
||||
if (fixtureData.circle)
|
||||
{
|
||||
var shape = new p2.Circle(this.world.pxm(fixtureData.circle.radius))
|
||||
shape.collisionGroup = fixtureData.filter.categoryBits
|
||||
shape.collisionMask = fixtureData.filter.maskBits
|
||||
shape.sensor = fixtureData.isSensor
|
||||
var shape = new p2.Circle(this.world.pxm(fixtureData.circle.radius));
|
||||
shape.collisionGroup = fixtureData.filter.categoryBits;
|
||||
shape.collisionMask = fixtureData.filter.maskBits;
|
||||
shape.sensor = fixtureData.isSensor;
|
||||
|
||||
var offset = p2.vec2.create();
|
||||
offset[0] = this.world.pxmi(fixtureData.circle.position[0] - this.sprite.width/2)
|
||||
offset[1] = this.world.pxmi(fixtureData.circle.position[1] - this.sprite.height/2)
|
||||
|
||||
offset[0] = this.world.pxmi(fixtureData.circle.position[0] - this.sprite.width/2);
|
||||
offset[1] = this.world.pxmi(fixtureData.circle.position[1] - this.sprite.height/2);
|
||||
|
||||
this.data.addShape(shape, offset);
|
||||
generatedShapes.push(shape)
|
||||
generatedShapes.push(shape);
|
||||
}
|
||||
else
|
||||
{
|
||||
polygons = fixtureData.polygons;
|
||||
|
||||
var polygons = fixtureData.polygons;
|
||||
var cm = p2.vec2.create();
|
||||
|
||||
for (var i = 0; i < polygons.length; i++)
|
||||
{
|
||||
shapes = polygons[i];
|
||||
|
||||
var shapes = polygons[i];
|
||||
var vertices = [];
|
||||
|
||||
for (var s = 0; s < shapes.length; s += 2)
|
||||
|
@ -1279,7 +1277,7 @@ Phaser.Physics.P2.Body.prototype = {
|
|||
* @method Phaser.Physics.P2.Body#loadPolygon
|
||||
* @param {string} key - The key of the Physics Data file as stored in Game.Cache.
|
||||
* @param {string} object - The key of the object within the Physics data file that you wish to load the shape data from.
|
||||
* @param {object} options - An object containing the build options:
|
||||
* @param {object} options - An object containing the build options:
|
||||
* @param {boolean} [options.optimalDecomp=false] - Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.
|
||||
* @param {boolean} [options.skipSimpleCheck=false] - Set to true if you already know that the path is not intersecting itself.
|
||||
* @param {boolean|number} [options.removeCollinearPoints=false] - Set to a number (angle threshold value) to remove collinear points, or false to keep all points.
|
||||
|
@ -1331,7 +1329,7 @@ Phaser.Physics.P2.Body.KINEMATIC = 4;
|
|||
* @property {boolean} static - Returns true if the Body is static. Setting Body.static to 'false' will make it dynamic.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "static", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return (this.data.motionState === Phaser.Physics.P2.Body.STATIC);
|
||||
|
@ -1364,7 +1362,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "static", {
|
|||
* @property {boolean} dynamic - Returns true if the Body is dynamic. Setting Body.dynamic to 'false' will make it static.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "dynamic", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return (this.data.motionState === Phaser.Physics.P2.Body.DYNAMIC);
|
||||
|
@ -1397,7 +1395,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "dynamic", {
|
|||
* @property {boolean} kinematic - Returns true if the Body is kinematic. Setting Body.kinematic to 'false' will make it static.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "kinematic", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return (this.data.motionState === Phaser.Physics.P2.Body.KINEMATIC);
|
||||
|
@ -1423,10 +1421,10 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "kinematic", {
|
|||
|
||||
/**
|
||||
* @name Phaser.Physics.P2.Body#allowSleep
|
||||
* @property {boolean} allowSleep -
|
||||
* @property {boolean} allowSleep -
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "allowSleep", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.data.allowSleep;
|
||||
|
@ -1448,7 +1446,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "allowSleep", {
|
|||
* The angle of the Body 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 Body.angle = 450 is the same as Body.angle = 90.
|
||||
* If you wish to work in radians instead of degrees use the property Body.rotation instead. Working in radians is faster as it doesn't have to convert values.
|
||||
*
|
||||
*
|
||||
* @name Phaser.Physics.P2.Body#angle
|
||||
* @property {number} angle - The angle of this Body in degrees.
|
||||
*/
|
||||
|
@ -1474,7 +1472,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angle", {
|
|||
* @property {number} angularDamping - The angular damping acting acting on the body.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularDamping", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.data.angularDamping;
|
||||
|
@ -1494,7 +1492,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularDamping", {
|
|||
* @property {number} angularForce - The angular force acting on the body.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularForce", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.data.angularForce;
|
||||
|
@ -1514,7 +1512,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularForce", {
|
|||
* @property {number} angularVelocity - The angular velocity of the body.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularVelocity", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.data.angularVelocity;
|
||||
|
@ -1535,7 +1533,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "angularVelocity", {
|
|||
* @property {number} damping - The linear damping acting on the body in the velocity direction.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "damping", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.data.damping;
|
||||
|
@ -1552,10 +1550,10 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "damping", {
|
|||
|
||||
/**
|
||||
* @name Phaser.Physics.P2.Body#fixedRotation
|
||||
* @property {boolean} fixedRotation -
|
||||
* @property {boolean} fixedRotation -
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "fixedRotation", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.data.fixedRotation;
|
||||
|
@ -1578,7 +1576,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "fixedRotation", {
|
|||
* @property {number} inertia - The inertia of the body around the Z axis..
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "inertia", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.data.inertia;
|
||||
|
@ -1595,10 +1593,10 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "inertia", {
|
|||
|
||||
/**
|
||||
* @name Phaser.Physics.P2.Body#mass
|
||||
* @property {number} mass -
|
||||
* @property {number} mass -
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "mass", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.data.mass;
|
||||
|
@ -1622,7 +1620,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "mass", {
|
|||
* @property {number} motionState - The type of motion this body has. Should be one of: Body.STATIC (the body does not move), Body.DYNAMIC (body can move and respond to collisions) and Body.KINEMATIC (only moves according to its .velocity).
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "motionState", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.data.motionState;
|
||||
|
@ -1643,7 +1641,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "motionState", {
|
|||
/**
|
||||
* The angle of the Body in radians.
|
||||
* If you wish to work in degrees instead of radians use the Body.angle property instead. Working in radians is faster as it doesn't have to convert values.
|
||||
*
|
||||
*
|
||||
* @name Phaser.Physics.P2.Body#rotation
|
||||
* @property {number} rotation - The angle of this Body in radians.
|
||||
*/
|
||||
|
@ -1668,7 +1666,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "rotation", {
|
|||
* @property {number} sleepSpeedLimit - .
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "sleepSpeedLimit", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.data.sleepSpeedLimit;
|
||||
|
@ -1688,7 +1686,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "sleepSpeedLimit", {
|
|||
* @property {number} x - The x coordinate of this Body.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "x", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.world.mpxi(this.data.position[0]);
|
||||
|
@ -1708,7 +1706,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "x", {
|
|||
* @property {number} y - The y coordinate of this Body.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "y", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.world.mpxi(this.data.position[1]);
|
||||
|
@ -1729,7 +1727,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "y", {
|
|||
* @readonly
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "id", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.data.id;
|
||||
|
@ -1743,7 +1741,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "id", {
|
|||
* @property {boolean} debug - Enable or disable debug drawing of this body
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "debug", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return (!this.debugBody);
|
||||
|
@ -1755,7 +1753,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "debug", {
|
|||
if (value && !this.debugBody)
|
||||
{
|
||||
// This will be added to the global space
|
||||
this.debugBody = new Phaser.Physics.P2.BodyDebug(this.game, this.data)
|
||||
this.debugBody = new Phaser.Physics.P2.BodyDebug(this.game, this.data);
|
||||
}
|
||||
else if (!value && this.debugBody)
|
||||
{
|
||||
|
@ -1774,7 +1772,7 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "debug", {
|
|||
* @property {boolean} collideWorldBounds - Should the Body collide with the World bounds?
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.Body.prototype, "collideWorldBounds", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this._collideWorldBounds;
|
||||
|
|
|
@ -31,7 +31,7 @@ Phaser.Physics.P2.BodyDebug = function(game, body, settings) {
|
|||
debugPolygons: false,
|
||||
lineWidth: 1,
|
||||
alpha: 0.5
|
||||
}
|
||||
};
|
||||
|
||||
this.settings = Phaser.Utils.extend(defaultSettings, settings);
|
||||
|
||||
|
@ -51,16 +51,16 @@ Phaser.Physics.P2.BodyDebug = function(game, body, settings) {
|
|||
*/
|
||||
this.canvas = new Phaser.Graphics(game);
|
||||
|
||||
this.canvas.alpha = this.settings.alpha
|
||||
this.canvas.alpha = this.settings.alpha;
|
||||
|
||||
this.add(this.canvas);
|
||||
|
||||
this.draw();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Physics.P2.BodyDebug.prototype = Object.create(Phaser.Group.prototype)
|
||||
Phaser.Physics.P2.BodyDebug.prototype.constructor = Phaser.Physics.P2.BodyDebug
|
||||
Phaser.Physics.P2.BodyDebug.prototype = Object.create(Phaser.Group.prototype);
|
||||
Phaser.Physics.P2.BodyDebug.prototype.constructor = Phaser.Physics.P2.BodyDebug;
|
||||
|
||||
Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
|
||||
|
||||
|
@ -95,7 +95,7 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
|
|||
* @method Phaser.Physics.P2.BodyDebug#draw
|
||||
*/
|
||||
draw: function() {
|
||||
|
||||
|
||||
var angle, child, color, i, j, lineColor, lw, obj, offset, sprite, v, verts, vrot, _j, _ref1;
|
||||
obj = this.body;
|
||||
sprite = this.canvas;
|
||||
|
@ -106,10 +106,10 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
|
|||
|
||||
if (obj instanceof p2.Body && obj.shapes.length)
|
||||
{
|
||||
var l = obj.shapes.length
|
||||
var l = obj.shapes.length;
|
||||
|
||||
i = 0;
|
||||
|
||||
|
||||
while (i !== l)
|
||||
{
|
||||
child = obj.shapes[i];
|
||||
|
@ -117,7 +117,7 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
|
|||
angle = obj.shapeAngles[i];
|
||||
offset = offset || 0;
|
||||
angle = angle || 0;
|
||||
|
||||
|
||||
if (child instanceof p2.Circle)
|
||||
{
|
||||
this.drawCircle(sprite, offset[0] * this.ppu, offset[1] * this.ppu, angle, child.radius * this.ppu, color, lw);
|
||||
|
@ -149,7 +149,7 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
|
|||
this.drawRectangle(sprite, offset[0] * this.ppu, -offset[1] * this.ppu, angle, child.width * this.ppu, child.height * this.ppu, lineColor, color, lw);
|
||||
}
|
||||
|
||||
i++
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
|
|||
{
|
||||
colors = [0xff0000, 0x00ff00, 0x0000ff];
|
||||
i = 0;
|
||||
|
||||
|
||||
while (i !== verts.length + 1)
|
||||
{
|
||||
v0 = verts[i % verts.length];
|
||||
|
@ -424,4 +424,4 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, {
|
|||
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
|
|
|
@ -18,4 +18,4 @@ Phaser.Physics.P2.CollisionGroup = function (bitmask) {
|
|||
*/
|
||||
this.mask = bitmask;
|
||||
|
||||
}
|
||||
};
|
||||
|
|
|
@ -58,7 +58,7 @@ Phaser.Physics.P2.ContactMaterial = function (materialA, materialB, options) {
|
|||
|
||||
p2.ContactMaterial.call(this, materialA, materialB, options);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Physics.P2.ContactMaterial.prototype = Object.create(p2.ContactMaterial.prototype);
|
||||
Phaser.Physics.P2.ContactMaterial.prototype.constructor = Phaser.Physics.P2.ContactMaterial;
|
||||
|
|
|
@ -34,7 +34,7 @@ Phaser.Physics.P2.DistanceConstraint = function (world, bodyA, bodyB, distance,
|
|||
|
||||
p2.DistanceConstraint.call(this, bodyA, bodyB, distance, maxForce);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Physics.P2.DistanceConstraint.prototype = Object.create(p2.DistanceConstraint.prototype);
|
||||
Phaser.Physics.P2.DistanceConstraint.prototype.constructor = Phaser.Physics.P2.DistanceConstraint;
|
||||
|
|
|
@ -35,7 +35,7 @@ Phaser.Physics.P2.GearConstraint = function (world, bodyA, bodyB, angle, ratio)
|
|||
|
||||
p2.GearConstraint.call(this, bodyA, bodyB, options);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Physics.P2.GearConstraint.prototype = Object.create(p2.GearConstraint.prototype);
|
||||
Phaser.Physics.P2.GearConstraint.prototype.constructor = Phaser.Physics.P2.GearConstraint;
|
||||
|
|
|
@ -27,7 +27,7 @@ Phaser.Physics.P2.InversePointProxy.prototype.constructor = Phaser.Physics.P2.In
|
|||
* @property {number} x - The x property of this InversePointProxy.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "x", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.destination[0];
|
||||
|
@ -47,7 +47,7 @@ Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "x", {
|
|||
* @property {number} y - The y property of this InversePointProxy.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "y", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.destination[1];
|
||||
|
|
|
@ -39,7 +39,7 @@ Phaser.Physics.P2.LockConstraint = function (world, bodyA, bodyB, offset, angle,
|
|||
|
||||
p2.LockConstraint.call(this, bodyA, bodyB, options);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Physics.P2.LockConstraint.prototype = Object.create(p2.LockConstraint.prototype);
|
||||
Phaser.Physics.P2.LockConstraint.prototype.constructor = Phaser.Physics.P2.LockConstraint;
|
||||
|
|
|
@ -21,7 +21,7 @@ Phaser.Physics.P2.Material = function (name) {
|
|||
|
||||
p2.Material.call(this);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Physics.P2.Material.prototype = Object.create(p2.Material.prototype);
|
||||
Phaser.Physics.P2.Material.prototype.constructor = Phaser.Physics.P2.Material;
|
||||
|
|
|
@ -27,7 +27,7 @@ Phaser.Physics.P2.PointProxy.prototype.constructor = Phaser.Physics.P2.PointProx
|
|||
* @property {number} x - The x property of this PointProxy.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "x", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.destination[0];
|
||||
|
@ -47,7 +47,7 @@ Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "x", {
|
|||
* @property {number} y - The y property of this PointProxy.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "y", {
|
||||
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.destination[1];
|
||||
|
|
|
@ -44,7 +44,7 @@ Phaser.Physics.P2.PrismaticConstraint = function (world, bodyA, bodyB, lockRotat
|
|||
|
||||
p2.PrismaticConstraint.call(this, bodyA, bodyB, options);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Physics.P2.PrismaticConstraint.prototype = Object.create(p2.PrismaticConstraint.prototype);
|
||||
Phaser.Physics.P2.PrismaticConstraint.prototype.constructor = Phaser.Physics.P2.PrismaticConstraint;
|
||||
|
|
|
@ -37,7 +37,7 @@ Phaser.Physics.P2.RevoluteConstraint = function (world, bodyA, pivotA, bodyB, pi
|
|||
|
||||
p2.RevoluteConstraint.call(this, bodyA, pivotA, bodyB, pivotB, maxForce);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Phaser.Physics.P2.RevoluteConstraint.prototype = Object.create(p2.RevoluteConstraint.prototype);
|
||||
Phaser.Physics.P2.RevoluteConstraint.prototype.constructor = Phaser.Physics.P2.RevoluteConstraint;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue