From 0b9d101a250e3f96430481744590cd26a1a7deaa Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sat, 22 Mar 2014 22:43:04 -0700 Subject: [PATCH 01/23] Fix .jshintrc whitespace. --- .jshintrc | 123 ++++++++++++++++++++++++++---------------------------- 1 file changed, 59 insertions(+), 64 deletions(-) diff --git a/.jshintrc b/.jshintrc index 765abc654..50a188ea9 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,75 +1,70 @@ { - "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`. + "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, // Development - "debug" : true, // Allow debugger statements e.g. browser breakpoints. - "devel" : true, // Allow developments statements e.g. `console.log();`. + "debug" : true, // Allow debugger statements e.g. browser breakpoints. + "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. + "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. + "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. // 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. } From 0d12fcd79ac7000ef39216d8c0138ddec069f931 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sat, 22 Mar 2014 22:44:13 -0700 Subject: [PATCH 02/23] Remove unnecessary .jshintrc flags. --- .jshintrc | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.jshintrc b/.jshintrc index 50a188ea9..4d8c17fdb 100644 --- a/.jshintrc +++ b/.jshintrc @@ -2,21 +2,9 @@ "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, // Development - "debug" : true, // Allow debugger statements e.g. browser breakpoints. "devel" : true, // Allow developments statements e.g. `console.log();`. // ECMAScript Support @@ -45,7 +33,6 @@ "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. - "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. From 07498378cab4d10c64596a7ef5e72affd2f02bcd Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sat, 22 Mar 2014 22:47:32 -0700 Subject: [PATCH 03/23] Remove jshint options that contradict coding style. --- .jshintrc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.jshintrc b/.jshintrc index 4d8c17fdb..0421ee80f 100644 --- a/.jshintrc +++ b/.jshintrc @@ -14,7 +14,6 @@ "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. @@ -28,8 +27,7 @@ "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. + "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. From 12c5a1b53422c05bc84c4d3c40c765d3c283b530 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sat, 22 Mar 2014 23:23:45 -0700 Subject: [PATCH 04/23] Run jshint as part of build process. --- Gruntfile.js | 32 +++++++++++++++++++++++++++++--- README.md | 2 +- package.json | 1 + tasks/.jshintrc | 23 +++++++++++++++++++++++ 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 tasks/.jshintrc diff --git a/Gruntfile.js b/Gruntfile.js index 23a5afe58..5d885534b 100644 --- a/Gruntfile.js +++ b/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,37 @@ module.exports = function (grunt) { hostname: '*' } } - } + }, + jshint: { + src: { + src: [ + 'src/**/*.js', + '!src/Intro.js', + '!src/Outro.js', + '!src/pixi/**/*', + '!src/physics/p2/p2.js' + ], + options: { jshintrc: '.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']); }; diff --git a/README.md b/README.md index c7358c479..642d5b5e4 100644 --- a/README.md +++ b/README.md @@ -279,7 +279,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? diff --git a/package.json b/package.json index b1b92f841..4873ac566 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/tasks/.jshintrc b/tasks/.jshintrc new file mode 100644 index 000000000..e08431127 --- /dev/null +++ b/tasks/.jshintrc @@ -0,0 +1,23 @@ +{ + "node" : true, + "browser": false, + "boss" : true, + "curly": true, + "debug": false, + "devel": false, + "eqeqeq": true, + "eqnull": true, + "forin": false, + "immed": false, + "laxbreak": false, + "newcap": true, + "noarg": true, + "noempty": true, + "nonew": true, + "plusplus": false, + "strict": false, + "sub": true, + "trailing": true, + "undef": true, + "white": false +} From 61f18b675c15bc0038e31bbf6546be24adf20108 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 00:59:28 -0700 Subject: [PATCH 05/23] Trim trailing whitespace. --- filters/BinarySerpents.js | 4 +- filters/BlurX.js | 4 +- filters/BlurY.js | 4 +- filters/CheckerWave.js | 2 +- filters/ColorBars.js | 8 +- filters/Fire.js | 6 +- filters/Gray.js | 2 +- filters/HueRotate.js | 2 +- filters/LightBeam.js | 10 +- filters/Marble.js | 2 +- filters/Plasma.js | 6 +- filters/Tunnel.js | 4 +- src/Outro.js | 2 +- src/animation/Animation.js | 4 +- src/animation/AnimationManager.js | 16 +- src/animation/AnimationParser.js | 12 +- src/animation/Frame.js | 2 +- src/animation/FrameData.js | 4 +- src/core/Camera.js | 16 +- src/core/Filter.js | 12 +- src/core/Group.js | 26 +- src/core/LinkedList.js | 10 +- src/core/Plugin.js | 20 +- src/core/PluginManager.js | 30 +- src/core/ScaleManager.js | 14 +- src/core/Signal.js | 12 +- src/core/SignalBinding.js | 4 +- src/core/Stage.js | 12 +- src/core/State.js | 40 +- src/core/StateManager.js | 6 +- src/core/World.js | 2 +- src/gameobjects/BitmapData.js | 16 +- src/gameobjects/BitmapText.js | 6 +- src/gameobjects/Button.js | 62 +- src/gameobjects/Events.js | 2 +- src/gameobjects/GameObjectCreator.js | 8 +- src/gameobjects/GameObjectFactory.js | 8 +- src/gameobjects/Graphics.js | 12 +- src/gameobjects/Image.js | 34 +- src/gameobjects/RenderTexture.js | 6 +- src/gameobjects/RetroFont.js | 108 ++-- src/gameobjects/Sprite.js | 36 +- src/gameobjects/Text.js | 8 +- src/gameobjects/TileSprite.js | 14 +- src/geom/Circle.js | 6 +- src/geom/Ellipse.js | 4 +- src/geom/Line.js | 4 +- src/geom/Point.js | 10 +- src/geom/Polygon.js | 2 +- src/geom/Rectangle.js | 44 +- src/input/Gamepad.js | 2 +- src/input/Input.js | 30 +- src/input/InputHandler.js | 32 +- src/input/Key.js | 4 +- src/input/Keyboard.js | 10 +- src/input/MSPointer.js | 6 +- src/input/Mouse.js | 6 +- src/input/Pointer.js | 8 +- src/input/SinglePad.js | 2 +- src/input/Touch.js | 14 +- src/loader/Cache.js | 14 +- src/loader/Loader.js | 14 +- src/math/Math.js | 92 +-- src/math/RandomDataGenerator.js | 10 +- src/net/Net.js | 14 +- src/particles/Particles.js | 2 +- src/particles/arcade/ArcadeParticles.js | 2 +- src/particles/arcade/Emitter.js | 12 +- src/physics/arcade/Body.js | 8 +- src/physics/arcade/World.js | 68 +- src/physics/ninja/AABB.js | 104 ++-- src/physics/ninja/Body.js | 16 +- src/physics/ninja/Circle.js | 582 +++++++++--------- src/physics/ninja/Tile.js | 20 +- src/physics/ninja/World.js | 2 +- src/physics/p2/Body.js | 56 +- src/physics/p2/BodyDebug.js | 10 +- src/physics/p2/InversePointProxy.js | 4 +- src/physics/p2/PointProxy.js | 4 +- src/physics/p2/World.js | 42 +- src/physics/p2/p2.js | 28 +- src/pixi/InteractionData.js | 4 +- src/pixi/InteractionManager.js | 16 +- src/pixi/Outro.js | 2 +- src/pixi/Pixi.js | 8 +- src/pixi/core/Matrix.js | 6 +- src/pixi/core/Rectangle.js | 2 +- src/pixi/display/DisplayObject.js | 12 +- src/pixi/display/DisplayObjectContainer.js | 24 +- src/pixi/display/Sprite.js | 34 +- src/pixi/display/SpriteBatch.js | 32 +- src/pixi/display/Stage.js | 6 +- src/pixi/extras/Rope.js | 8 +- src/pixi/extras/Strip.js | 12 +- src/pixi/extras/TilingSprite.js | 36 +- src/pixi/filters/AbstractFilter.js | 2 +- src/pixi/filters/ColorMatrixFilter.js | 2 +- src/pixi/filters/DotScreenFilter.js | 2 +- src/pixi/filters/NormalMapFilter.js | 52 +- src/pixi/filters/TwistFilter.js | 2 +- src/pixi/loaders/JsonLoader.js | 4 +- src/pixi/primitives/Graphics.js | 34 +- src/pixi/renderers/canvas/CanvasRenderer.js | 2 +- .../canvas/utils/CanvasMaskManager.js | 10 +- .../renderers/canvas/utils/CanvasTinter.js | 38 +- src/pixi/renderers/webgl/WebGLRenderer.js | 14 +- .../renderers/webgl/shaders/PixiFastShader.js | 10 +- .../renderers/webgl/shaders/PixiShader.js | 2 +- .../renderers/webgl/utils/FilterTexture.js | 2 +- .../webgl/utils/WebGLFastSpriteBatch.js | 38 +- .../webgl/utils/WebGLFilterManager.js | 16 +- .../renderers/webgl/utils/WebGLGraphics.js | 6 +- .../renderers/webgl/utils/WebGLMaskManager.js | 12 +- .../webgl/utils/WebGLShaderManager.js | 14 +- .../renderers/webgl/utils/WebGLShaderUtils.js | 4 +- .../renderers/webgl/utils/WebGLSpriteBatch.js | 50 +- src/pixi/text/BitmapText.js | 2 +- src/pixi/text/Text.js | 6 +- src/pixi/textures/BaseTexture.js | 6 +- src/pixi/textures/RenderTexture.js | 2 +- src/pixi/textures/Texture.js | 8 +- src/pixi/utils/Detector.js | 2 +- src/pixi/utils/EventTarget.js | 2 +- src/pixi/utils/Polyk.js | 4 +- src/pixi/utils/Utils.js | 6 +- src/sound/Sound.js | 50 +- src/sound/SoundManager.js | 24 +- src/system/Canvas.js | 2 +- src/system/Device.js | 16 +- src/system/RequestAnimationFrame.js | 6 +- src/tilemap/Tile.js | 26 +- src/tilemap/Tilemap.js | 2 +- src/tilemap/TilemapLayer.js | 34 +- src/tilemap/TilemapParser.js | 4 +- src/time/Time.js | 4 +- src/time/Timer.js | 6 +- src/tween/Easing.js | 84 +-- src/tween/Tween.js | 14 +- src/tween/TweenManager.js | 10 +- src/utils/Color.js | 14 +- src/utils/Debug.js | 18 +- src/utils/Utils.js | 16 +- 142 files changed, 1396 insertions(+), 1396 deletions(-) diff --git a/filters/BinarySerpents.js b/filters/BinarySerpents.js index 4db93e051..c8e51b84c 100644 --- a/filters/BinarySerpents.js +++ b/filters/BinarySerpents.js @@ -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);", "}" - ]; + ]; }; diff --git a/filters/BlurX.js b/filters/BlurX.js index 66a0a9e6e..e2d94d0b0 100644 --- a/filters/BlurX.js +++ b/filters/BlurX.js @@ -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;", "}" diff --git a/filters/BlurY.js b/filters/BlurY.js index c168f68cb..662dffcb7 100644 --- a/filters/BlurY.js +++ b/filters/BlurY.js @@ -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;", "}" diff --git a/filters/CheckerWave.js b/filters/CheckerWave.js index 0494dd930..93221c5ba 100644 --- a/filters/CheckerWave.js +++ b/filters/CheckerWave.js @@ -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;", diff --git a/filters/ColorBars.js b/filters/ColorBars.js index e2e163b54..fd13e20de 100644 --- a/filters/ColorBars.js +++ b/filters/ColorBars.js @@ -8,9 +8,9 @@ Phaser.Filter.ColorBars = function (game) { 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;", "}" - - ]; + + ]; }; diff --git a/filters/Fire.js b/filters/Fire.js index adfb5c484..dfcb13a4d 100644 --- a/filters/Fire.js +++ b/filters/Fire.js @@ -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,11 +65,11 @@ 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; } diff --git a/filters/Gray.js b/filters/Gray.js index 9aafc8073..9133697e7 100644 --- a/filters/Gray.js +++ b/filters/Gray.js @@ -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;", diff --git a/filters/HueRotate.js b/filters/HueRotate.js index c1e7f60f3..2312a295f 100644 --- a/filters/HueRotate.js +++ b/filters/HueRotate.js @@ -9,7 +9,7 @@ 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.fragmentSrc = [ "precision mediump float;", diff --git a/filters/LightBeam.js b/filters/LightBeam.js index 9f8664e15..988301932 100644 --- a/filters/LightBeam.js +++ b/filters/LightBeam.js @@ -12,7 +12,7 @@ Phaser.Filter.LightBeam = function (game) { 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;", "}" - ]; + ]; }; diff --git a/filters/Marble.js b/filters/Marble.js index 1858b72f1..a960a0e7b 100644 --- a/filters/Marble.js +++ b/filters/Marble.js @@ -12,7 +12,7 @@ Phaser.Filter.Marble = function (game) { this.uniforms.fluid_speed = { type: '1f', value: 10.0 } this.uniforms.color_intensity = { type: '1f', value: 0.30 } - + // The fragment shader source this.fragmentSrc = [ diff --git a/filters/Plasma.js b/filters/Plasma.js index 46d241480..638515db7 100644 --- a/filters/Plasma.js +++ b/filters/Plasma.js @@ -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,11 +52,11 @@ 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; } diff --git a/filters/Tunnel.js b/filters/Tunnel.js index 5cd669987..113792969 100644 --- a/filters/Tunnel.js +++ b/filters/Tunnel.js @@ -9,7 +9,7 @@ Phaser.Filter.Tunnel = function (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.fragmentSrc = [ "precision mediump float;", @@ -30,7 +30,7 @@ Phaser.Filter.Tunnel = function (game) { "gl_FragColor = vec4(c / (t.y + 0.5), alpha);", "}" - ]; + ]; }; diff --git a/src/Outro.js b/src/Outro.js index 3a2239ded..0db90e8e2 100644 --- a/src/Outro.js +++ b/src/Outro.js @@ -14,4 +14,4 @@ } else { root.Phaser = Phaser; } -}).call(this); \ No newline at end of file +}).call(this); diff --git a/src/animation/Animation.js b/src/animation/Animation.js index 74412c424..da0e6fbbb 100644 --- a/src/animation/Animation.js +++ b/src/animation/Animation.js @@ -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); diff --git a/src/animation/AnimationManager.js b/src/animation/AnimationManager.js index a7d780eb5..d13c9dee8 100644 --- a/src/animation/AnimationManager.js +++ b/src/animation/AnimationManager.js @@ -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; diff --git a/src/animation/AnimationParser.js b/src/animation/AnimationParser.js index b1c7dfa75..3dd9ea7d9 100644 --- a/src/animation/AnimationParser.js +++ b/src/animation/AnimationParser.js @@ -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(); diff --git a/src/animation/Frame.js b/src/animation/Frame.js index a650d0901..954cce1d8 100644 --- a/src/animation/Frame.js +++ b/src/animation/Frame.js @@ -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. */ diff --git a/src/animation/FrameData.js b/src/animation/FrameData.js index 1051fcedb..bfb1482e6 100644 --- a/src/animation/FrameData.js +++ b/src/animation/FrameData.js @@ -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++) diff --git a/src/core/Camera.js b/src/core/Camera.js index 69727a0ae..92605db21 100644 --- a/src/core/Camera.js +++ b/src/core/Camera.js @@ -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; }, diff --git a/src/core/Filter.js b/src/core/Filter.js index 34fc51784..a2ea6d397 100644 --- a/src/core/Filter.js +++ b/src/core/Filter.js @@ -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 @@ -26,7 +26,7 @@ Phaser.Filter = function (game, uniforms, fragmentSrc) { * @default */ 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; - + } }; diff --git a/src/core/Group.js b/src/core/Group.js index c77839d1c..5ee54cd38 100644 --- a/src/core/Group.js +++ b/src/core/Group.js @@ -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); @@ -419,7 +419,7 @@ Phaser.Group.prototype.swap = function (child1, child2) { } return result; - + } /** @@ -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) @@ -816,7 +816,7 @@ Phaser.Group.prototype.divideAll = function (property, amount, checkAlive, check /** * 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. @@ -838,7 +838,7 @@ 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. @@ -892,7 +892,7 @@ Phaser.Group.prototype.callbackFromArray = function (child, callback, length) { /** * 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. @@ -1017,7 +1017,7 @@ Phaser.Group.prototype.postUpdate = function () { * 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'). @@ -1048,7 +1048,7 @@ 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'). @@ -1066,7 +1066,7 @@ Phaser.Group.prototype.forEachExists = function (callback, callbackContext) { * Allows you to call your own function on each alive member of this Group (where child.alive=true). You must pass the callback and context in which it will run. * You can add as many parameters as you like, which will all be passed to the callback along with the child. * For example: Group.forEachAlive(causeDamage, this, 500) -* +* * @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'). @@ -1084,7 +1084,7 @@ Phaser.Group.prototype.forEachAlive = function (callback, callbackContext) { * Allows you to call your own function on each dead member of this Group (where alive=false). You must pass the callback and context in which it will run. * You can add as many parameters as you like, which will all be passed to the callback along with the child. * For example: Group.forEachDead(bringToLife, this) -* +* * @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'). @@ -1191,7 +1191,7 @@ Phaser.Group.prototype.descendingSortHandler = function (a, b) { * 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. @@ -1565,7 +1565,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]; diff --git a/src/core/LinkedList.js b/src/core/LinkedList.js index fd2726c1c..d5f2a9d25 100644 --- a/src/core/LinkedList.js +++ b/src/core/LinkedList.js @@ -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]) diff --git a/src/core/Plugin.js b/src/core/Plugin.js index 273f82145..9f94eaa90 100644 --- a/src/core/Plugin.js +++ b/src/core/Plugin.js @@ -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; - + } }; diff --git a/src/core/PluginManager.js b/src/core/PluginManager.js index 0dd7538a3..cb6721428 100644 --- a/src/core/PluginManager.js +++ b/src/core/PluginManager.js @@ -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 () { diff --git a/src/core/ScaleManager.js b/src/core/ScaleManager.js index 3e8d0291a..688a46fc2 100644 --- a/src/core/ScaleManager.js +++ b/src/core/ScaleManager.js @@ -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; diff --git a/src/core/Signal.js b/src/core/Signal.js index 2c8742876..ff4602e6f 100644 --- a/src/core/Signal.js +++ b/src/core/Signal.js @@ -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, @@ -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); - + }, /** diff --git a/src/core/SignalBinding.js b/src/core/SignalBinding.js index 8a0a5f7e3..1c607f181 100644 --- a/src/core/SignalBinding.js +++ b/src/core/SignalBinding.js @@ -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, diff --git a/src/core/Stage.js b/src/core/Stage.js index ac070b378..cb2cef498 100644 --- a/src/core/Stage.js +++ b/src/core/Stage.js @@ -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 @@ -115,7 +115,7 @@ Phaser.Stage.prototype.preUpdate = function () { /** * This is called automatically after the State.update, but before particles or plugins update. -* +* * @method Phaser.Stage#update */ Phaser.Stage.prototype.update = function () { @@ -134,7 +134,7 @@ Phaser.Stage.prototype.update = function () { * 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 () { @@ -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; diff --git a/src/core/State.js b/src/core/State.js index f2b5e1170..c72f7a83e 100644 --- a/src/core/State.js +++ b/src/core/State.js @@ -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 () { diff --git a/src/core/StateManager.js b/src/core/StateManager.js index 0a3a9d7ac..7b7a6ee0c 100644 --- a/src/core/StateManager.js +++ b/src/core/StateManager.js @@ -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 diff --git a/src/core/World.js b/src/core/World.js index 9f45f4d6c..aacf76ad4 100644 --- a/src/core/World.js +++ b/src/core/World.js @@ -33,7 +33,7 @@ Phaser.World = function (game) { * @property {Phaser.Camera} camera - Camera instance. */ this.camera = null; - + } Phaser.World.prototype = Object.create(Phaser.Group.prototype); diff --git a/src/gameobjects/BitmapData.js b/src/gameobjects/BitmapData.js index eb35e5a6f..fe13ac95c 100644 --- a/src/gameobjects/BitmapData.js +++ b/src/gameobjects/BitmapData.js @@ -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 @@ -112,7 +112,7 @@ 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; }, diff --git a/src/gameobjects/BitmapText.js b/src/gameobjects/BitmapText.js index 0e20e16c5..d29d52f5a 100644 --- a/src/gameobjects/BitmapText.js +++ b/src/gameobjects/BitmapText.js @@ -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 */ @@ -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]; diff --git a/src/gameobjects/Button.js b/src/gameobjects/Button.js index 04f3e597d..98715847d 100644 --- a/src/gameobjects/Button.js +++ b/src/gameobjects/Button.js @@ -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; @@ -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; diff --git a/src/gameobjects/Events.js b/src/gameobjects/Events.js index e22db1c80..1cf224898 100644 --- a/src/gameobjects/Events.js +++ b/src/gameobjects/Events.js @@ -22,7 +22,7 @@ * @param {Phaser.Sprite} sprite - A reference to Description. */ Phaser.Events = function (sprite) { - + this.parent = sprite; this.onAddedToGroup = new Phaser.Signal(); diff --git a/src/gameobjects/GameObjectCreator.js b/src/gameobjects/GameObjectCreator.js index 7ed998186..e8ad4d0fa 100644 --- a/src/gameobjects/GameObjectCreator.js +++ b/src/gameobjects/GameObjectCreator.js @@ -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 diff --git a/src/gameobjects/GameObjectFactory.js b/src/gameobjects/GameObjectFactory.js index ea2f6fae6..c3a5711b4 100644 --- a/src/gameobjects/GameObjectFactory.js +++ b/src/gameobjects/GameObjectFactory.js @@ -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 diff --git a/src/gameobjects/Graphics.js b/src/gameobjects/Graphics.js index 75d2260ec..6304d3220 100644 --- a/src/gameobjects/Graphics.js +++ b/src/gameobjects/Graphics.js @@ -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 @@ -141,7 +141,7 @@ Phaser.Graphics.prototype.postUpdate = function () { /** * Destroy this Graphics instance. -* +* * @method Phaser.Graphics.prototype.destroy * @param {boolean} [destroyChildren=true] - Should every child of this object have its destroy method called? */ @@ -189,7 +189,7 @@ Phaser.Graphics.prototype.destroy = function(destroyChildren) { /* * Draws a {Phaser.Polygon} or a {PIXI.Polygon} filled -* +* * @method Phaser.Graphics.prototype.drawPolygon */ Phaser.Graphics.prototype.drawPolygon = function (poly) { @@ -202,7 +202,7 @@ Phaser.Graphics.prototype.drawPolygon = function (poly) { } this.lineTo(poly.points[0].x, poly.points[0].y); - + } /** @@ -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]; diff --git a/src/gameobjects/Image.js b/src/gameobjects/Image.js index c7097acfc..52b2918d7 100644 --- a/src/gameobjects/Image.js +++ b/src/gameobjects/Image.js @@ -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 @@ -332,7 +332,7 @@ 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. @@ -357,7 +357,7 @@ Phaser.Image.prototype.revive = function() { * 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. @@ -380,7 +380,7 @@ Phaser.Image.prototype.kill = function() { /** * 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? @@ -442,7 +442,7 @@ Phaser.Image.prototype.destroy = function(destroyChildren) { /** * 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. @@ -486,7 +486,7 @@ Phaser.Image.prototype.bringToTop = function() { * 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; diff --git a/src/gameobjects/RenderTexture.js b/src/gameobjects/RenderTexture.js index f4db87081..1ddf02cef 100644 --- a/src/gameobjects/RenderTexture.js +++ b/src/gameobjects/RenderTexture.js @@ -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); diff --git a/src/gameobjects/RetroFont.js b/src/gameobjects/RetroFont.js index bba3d36b0..e54577c3c 100644 --- a/src/gameobjects/RetroFont.js +++ b/src/gameobjects/RetroFont.js @@ -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 @@ -278,7 +278,7 @@ Phaser.RetroFont.prototype.setFixedWidth = function (width, 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,7 +303,7 @@ Phaser.RetroFont.prototype.setText = function (content, multiLine, characterSpac { this.autoUpperCase = true; } - + if (content.length > 0) { this.text = content; @@ -313,7 +313,7 @@ Phaser.RetroFont.prototype.setText = function (content, multiLine, characterSpac /** * Over rides the default PIXI.RenderTexture resize event as we need our baseTexture resized as well. -* +* * @method Phaser.RetroFont#resize * @memberof Phaser.RetroFont */ @@ -348,7 +348,7 @@ Phaser.RetroFont.prototype.resize = function (width, height) { /** * 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,23 +415,23 @@ 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); } @@ -440,7 +440,7 @@ Phaser.RetroFont.prototype.buildRetroFontText = function () { /** * 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; @@ -478,10 +478,10 @@ 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,7 +529,7 @@ Phaser.RetroFont.prototype.removeUnsupportedCharacters = function (stripCR) { newString = newString.concat(aChar); } } - + return newString; } @@ -538,7 +538,7 @@ Phaser.RetroFont.prototype.removeUnsupportedCharacters = function (stripCR) { * @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(); } diff --git a/src/gameobjects/Sprite.js b/src/gameobjects/Sprite.js index 945f6f929..1dd6bd646 100644 --- a/src/gameobjects/Sprite.js +++ b/src/gameobjects/Sprite.js @@ -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". @@ -685,7 +685,7 @@ Phaser.Sprite.prototype.play = function (name, frameRate, loop, killOnComplete) * Indicates the rotation of the Sprite, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. * Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90. * If you wish to work in radians instead of degrees use the property Sprite.rotation instead. 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. */ @@ -732,7 +732,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "deltaX", { Object.defineProperty(Phaser.Sprite.prototype, "deltaY", { get: function() { - + return this.world.y - this._cache[1]; } @@ -749,7 +749,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "deltaY", { Object.defineProperty(Phaser.Sprite.prototype, "deltaZ", { get: function() { - + return this.rotation - this._cache[2]; } @@ -783,7 +783,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "inWorld", { Object.defineProperty(Phaser.Sprite.prototype, "inCamera", { get: function() { - + return this.game.world.camera.screenView.intersects(this.getBounds()); } @@ -845,7 +845,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); @@ -882,7 +882,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]; @@ -929,7 +929,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]; @@ -958,7 +958,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; diff --git a/src/gameobjects/Text.js b/src/gameobjects/Text.js index 6c8a6a746..876b0e61d 100644 --- a/src/gameobjects/Text.js +++ b/src/gameobjects/Text.js @@ -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 @@ -361,7 +361,7 @@ Phaser.Text.prototype.updateText = function () { { 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; @@ -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]; diff --git a/src/gameobjects/TileSprite.js b/src/gameobjects/TileSprite.js index f70147b12..fd7171ea4 100644 --- a/src/gameobjects/TileSprite.js +++ b/src/gameobjects/TileSprite.js @@ -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. @@ -395,7 +395,7 @@ 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? @@ -456,7 +456,7 @@ Phaser.TileSprite.prototype.destroy = function(destroyChildren) { /** * 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". @@ -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); diff --git a/src/geom/Circle.js b/src/geom/Circle.js index 605114406..cdea7dc89 100644 --- a/src/geom/Circle.js +++ b/src/geom/Circle.js @@ -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) diff --git a/src/geom/Ellipse.js b/src/geom/Ellipse.js index c632e0fc1..cdd778d0a 100644 --- a/src/geom/Ellipse.js +++ b/src/geom/Ellipse.js @@ -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; } diff --git a/src/geom/Line.js b/src/geom/Line.js index f396fc4ac..6501ad9e2 100644 --- a/src/geom/Line.js +++ b/src/geom/Line.js @@ -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)) diff --git a/src/geom/Point.js b/src/geom/Point.js index 797391894..5136073dc 100644 --- a/src/geom/Point.js +++ b/src/geom/Point.js @@ -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; - + }, /** diff --git a/src/geom/Polygon.js b/src/geom/Polygon.js index 8303a17ea..de1665e5a 100644 --- a/src/geom/Polygon.js +++ b/src/geom/Polygon.js @@ -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. * diff --git a/src/geom/Rectangle.js b/src/geom/Rectangle.js index f6069a81d..1af86d9fc 100644 --- a/src/geom/Rectangle.js +++ b/src/geom/Rectangle.js @@ -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. diff --git a/src/input/Gamepad.js b/src/input/Gamepad.js index ce1edcde1..2ede94b49 100644 --- a/src/input/Gamepad.js +++ b/src/input/Gamepad.js @@ -299,7 +299,7 @@ Phaser.Gamepad.prototype = { } var rawPad = this._rawPads[m]; - + if (rawPad) { if (validConnections.rawIndices[rawPad.index]) diff --git a/src/input/Input.js b/src/input/Input.js index f3012b311..095913f30 100644 --- a/src/input/Input.js +++ b/src/input/Input.js @@ -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; diff --git a/src/input/InputHandler.js b/src/input/InputHandler.js index c66ec68a4..f2efbbc2e 100644 --- a/src/input/InputHandler.js +++ b/src/input/InputHandler.js @@ -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) diff --git a/src/input/Key.js b/src/input/Key.js index 394f4e941..6886b7e3d 100644 --- a/src/input/Key.js +++ b/src/input/Key.js @@ -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 = { diff --git a/src/input/Keyboard.js b/src/input/Keyboard.js index a1220b5f3..596bfe8ab 100644 --- a/src/input/Keyboard.js +++ b/src/input/Keyboard.js @@ -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); } @@ -288,7 +288,7 @@ Phaser.Keyboard.prototype = { { this._keys[event.keyCode] = new Phaser.Key(this.game, event.keyCode); } - + this._keys[event.keyCode].processKeyDown(event); }, diff --git a/src/input/MSPointer.js b/src/input/MSPointer.js index bb0ff5493..98daa200e 100644 --- a/src/input/MSPointer.js +++ b/src/input/MSPointer.js @@ -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 diff --git a/src/input/Mouse.js b/src/input/Mouse.js index ee33edbed..ec2859dbf 100644 --- a/src/input/Mouse.js +++ b/src/input/Mouse.js @@ -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. */ diff --git a/src/input/Pointer.js b/src/input/Pointer.js index c1acd3eb1..87ab6b456 100644 --- a/src/input/Pointer.js +++ b/src/input/Pointer.js @@ -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(); @@ -498,14 +498,14 @@ 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) diff --git a/src/input/SinglePad.js b/src/input/SinglePad.js index d23362af7..1bdf6e80c 100644 --- a/src/input/SinglePad.js +++ b/src/input/SinglePad.js @@ -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); diff --git a/src/input/Touch.js b/src/input/Touch.js index 075cb7a2c..6812210cb 100644 --- a/src/input/Touch.js +++ b/src/input/Touch.js @@ -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 diff --git a/src/loader/Cache.js b/src/loader/Cache.js index 107b13863..ce82c0d56 100644 --- a/src/loader/Cache.js +++ b/src/loader/Cache.js @@ -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 + '"'); } - + }, /** diff --git a/src/loader/Loader.js b/src/loader/Loader.js index 7a35d4554..df0ec5d5c 100644 --- a/src/loader/Loader.js +++ b/src/loader/Loader.js @@ -97,17 +97,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 +195,7 @@ Phaser.Loader.prototype = { } return false; - + }, /** @@ -220,7 +220,7 @@ Phaser.Loader.prototype = { } return -1; - + }, /** @@ -245,7 +245,7 @@ Phaser.Loader.prototype = { } return false; - + }, /** @@ -1402,7 +1402,7 @@ Phaser.Loader.prototype = { { this.hasLoaded = true; this.isLoading = false; - + this.removeAll(); this.onLoadComplete.dispatch(); diff --git a/src/math/Math.js b/src/math/Math.js index 9e72703cd..16a42a868 100644 --- a/src/math/Math.js +++ b/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 ab+ε */ 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; @@ -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 - * + * * @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 to range - * + * * @method Phaser.Math#mapLinear * @param {number} x the value to map * @param {number} a1 first endpoint of the range @@ -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,7 +1307,7 @@ Phaser.Math = { /** * Convert degrees to radians. - * + * * @method Phaser.Math#degToRad * @return {function} */ @@ -1325,7 +1325,7 @@ Phaser.Math = { /** * Convert degrees to radians. - * + * * @method Phaser.Math#radToDeg * @return {function} */ diff --git a/src/math/RandomDataGenerator.js b/src/math/RandomDataGenerator.js index cb64d353c..71873658d 100644 --- a/src/math/RandomDataGenerator.js +++ b/src/math/RandomDataGenerator.js @@ -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); } - + }, /** diff --git a/src/net/Net.js b/src/net/Net.js index 7537d9cff..bb1f09ec4 100644 --- a/src/net/Net.js +++ b/src/net/Net.js @@ -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. diff --git a/src/particles/Particles.js b/src/particles/Particles.js index edad824bf..e7a90b13f 100644 --- a/src/particles/Particles.js +++ b/src/particles/Particles.js @@ -25,7 +25,7 @@ Phaser.Particles = function (game) { this.emitters = {}; /** - * @property {number} ID - + * @property {number} ID - * @default */ this.ID = 0; diff --git a/src/particles/arcade/ArcadeParticles.js b/src/particles/arcade/ArcadeParticles.js index 4a94d33c1..29202324e 100644 --- a/src/particles/arcade/ArcadeParticles.js +++ b/src/particles/arcade/ArcadeParticles.js @@ -1 +1 @@ -Phaser.Particles.Arcade = {} \ No newline at end of file +Phaser.Particles.Arcade = {} diff --git a/src/particles/arcade/Emitter.js b/src/particles/arcade/Emitter.js index b17bc8db6..772005866 100644 --- a/src/particles/arcade/Emitter.js +++ b/src/particles/arcade/Emitter.js @@ -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) @@ -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)); } diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index 2a4a240f0..a98232508 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -669,7 +669,7 @@ Phaser.Physics.Arcade.Body.prototype = { * @readonly */ Object.defineProperty(Phaser.Physics.Arcade.Body.prototype, "bottom", { - + get: function () { return this.position.y + this.height; } @@ -682,7 +682,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; } @@ -694,7 +694,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; }, @@ -710,7 +710,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; }, diff --git a/src/physics/arcade/World.js b/src/physics/arcade/World.js index 2baef41e5..93d4b98e6 100644 --- a/src/physics/arcade/World.js +++ b/src/physics/arcade/World.js @@ -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) @@ -1114,7 +1114,7 @@ Phaser.Physics.Arcade.prototype = { return true; } } - + if (tile.faceTop || tile.faceBottom) { oy = this.tileCheckY(body, tile); @@ -1132,7 +1132,7 @@ Phaser.Physics.Arcade.prototype = { return true; } } - + if (tile.faceLeft || tile.faceRight) { ox = this.tileCheckX(body, tile); @@ -1311,7 +1311,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. @@ -1325,13 +1325,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; @@ -1345,7 +1345,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) @@ -1366,7 +1366,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; @@ -1381,7 +1381,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. @@ -1396,13 +1396,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; @@ -1413,7 +1413,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. @@ -1432,7 +1432,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. @@ -1451,7 +1451,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. @@ -1472,7 +1472,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. @@ -1501,7 +1501,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. @@ -1518,7 +1518,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); @@ -1531,7 +1531,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. @@ -1558,7 +1558,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. @@ -1568,7 +1568,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); }, @@ -1577,7 +1577,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. @@ -1588,7 +1588,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); }, @@ -1597,7 +1597,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. @@ -1609,14 +1609,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. @@ -1633,7 +1633,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. @@ -1644,14 +1644,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. @@ -1663,7 +1663,7 @@ Phaser.Physics.Arcade.prototype = { this._dx = pointer.worldX - displayObject.x; this._dy = pointer.worldY - displayObject.y; - + return Math.atan2(this._dy, this._dx); } diff --git a/src/physics/ninja/AABB.js b/src/physics/ninja/AABB.js index a73066584..262f59c17 100644 --- a/src/physics/ninja/AABB.js +++ b/src/physics/ninja/AABB.js @@ -18,7 +18,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. */ @@ -534,16 +534,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 +554,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 +568,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 +600,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 +609,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 +629,7 @@ Phaser.Physics.Ninja.AABB.prototype = { return Phaser.Physics.Ninja.AABB.COL_OTHER; } } - + return Phaser.Physics.Ninja.AABB.COL_NONE; }, @@ -644,7 +644,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 +657,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 +669,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 +681,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 +696,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 +708,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 +730,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 +742,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 +750,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 +791,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 +800,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 +812,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 +827,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 +839,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 +859,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 +874,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 +886,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 +930,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 +1001,7 @@ Phaser.Physics.Ninja.AABB.prototype = { } return Phaser.Physics.Ninja.AABB.COL_NONE; - + }, /** diff --git a/src/physics/ninja/Body.js b/src/physics/ninja/Body.js index 05126d67a..ae871140b 100644 --- a/src/physics/ninja/Body.js +++ b/src/physics/ninja/Body.js @@ -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); } diff --git a/src/physics/ninja/Circle.js b/src/physics/ninja/Circle.js index a4ba3dbb9..3f9aee118 100644 --- a/src/physics/ninja/Circle.js +++ b/src/physics/ninja/Circle.js @@ -376,10 +376,10 @@ Phaser.Physics.Ninja.Circle.prototype = { } else { - //penetration in y is smaller; project in y + //penetration in y is smaller; project in y var dy = obj.pos.y - t.pos.y;//get sign for projection along y-axis - //NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?) + //NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?) if (dy < 0) { obj.reportCollisionVsWorld(0, -y, 0, -1, t); @@ -414,7 +414,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var vx = t.pos.x + (oH * t.xw); var vy = t.pos.y + (oV * t.yw); - var dx = obj.pos.x - vx;//calc vert->circle vector + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; var len = Math.sqrt(dx * dx + dy * dy); @@ -480,7 +480,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var sy = t.sy; var ox = (obj.pos.x - (sx * obj.radius)) - t.pos.x;//this gives is the coordinates of the innermost - var oy = (obj.pos.y - (sy * obj.radius)) - t.pos.y;//point on the circle, relative to the tile center + var oy = (obj.pos.y - (sy * obj.radius)) - t.pos.y;//point on the circle, relative to the tile center //if the dotprod of (ox,oy) and (sx,sy) is negative, the innermost point is in the slope //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy) @@ -499,7 +499,7 @@ Phaser.Physics.Ninja.Circle.prototype = { lenP = x; y = 0; - //get sign for projection along x-axis + //get sign for projection along x-axis if ((obj.pos.x - t.pos.x) < 0) { x *= -1; @@ -511,7 +511,7 @@ Phaser.Physics.Ninja.Circle.prototype = { lenP = y; x = 0; - //get sign for projection along y-axis + //get sign for projection along y-axis if ((obj.pos.y - t.pos.y) < 0) { y *= -1; @@ -554,13 +554,13 @@ Phaser.Physics.Ninja.Circle.prototype = { var sy = t.sy; var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//this gives is the coordinates of the innermost - var oy = obj.pos.y - (t.pos.y + (oV * t.yw));//point on the circle, relative to the closest tile vert + var oy = obj.pos.y - (t.pos.y + (oV * t.yw));//point on the circle, relative to the closest tile vert //if the component of (ox,oy) parallel to the normal's righthand normal //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy) //then we project by the vertex, otherwise by the normal. - //note that this is simply a VERY tricky/weird method of determining - //if the circle is in side the slope/face's voronoi region, or that of the vertex. + //note that this is simply a VERY tricky/weird method of determining + //if the circle is in side the slope/face's voronoi region, or that of the vertex. var perp = (ox * -sy) + (oy * sx); if (0 < (perp * signx * signy)) { @@ -618,7 +618,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var sy = t.sy; var ox = obj.pos.x - (t.pos.x + (oH * t.xw));//this gives is the coordinates of the innermost - var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//point on the circle, relative to the closest tile vert + var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//point on the circle, relative to the closest tile vert //if the component of (ox,oy) parallel to the normal's righthand normal //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy) @@ -628,8 +628,8 @@ Phaser.Physics.Ninja.Circle.prototype = { // for horizontal, if the perp prod and the slope's slope agree, circle is inside. // ..but this is only a property of flahs' coord system (i.e the rules might swap // in righthanded systems)) - //note that this is simply a VERY tricky/weird method of determining - //if the circle is in side the slope/face's voronio region, or that of the vertex. + //note that this is simply a VERY tricky/weird method of determining + //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox * -sy) + (oy * sx); if ((perp * signx * signy) < 0) { @@ -684,7 +684,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var vx = t.pos.x + (oH * t.xw); var vy = t.pos.y + (oV * t.yw); - var dx = obj.pos.x - vx;//calc vert->circle vector + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; var len = Math.sqrt(dx * dx + dy * dy); @@ -746,7 +746,7 @@ Phaser.Physics.Ninja.Circle.prototype = { { //colliding with current tile - var ox = (t.pos.x + (signx * t.xw)) - obj.pos.x;//(ox,oy) is the vector from the circle to + var ox = (t.pos.x + (signx * t.xw)) - obj.pos.x;//(ox,oy) is the vector from the circle to var oy = (t.pos.y + (signy * t.yw)) - obj.pos.y;//tile-circle's center var twid = t.xw * 2; @@ -765,7 +765,7 @@ Phaser.Physics.Ninja.Circle.prototype = { lenP = x; y = 0; - //get sign for projection along x-axis + //get sign for projection along x-axis if ((obj.pos.x - t.pos.x) < 0) { x *= -1; @@ -777,7 +777,7 @@ Phaser.Physics.Ninja.Circle.prototype = { lenP = y; x = 0; - //get sign for projection along y-axis + //get sign for projection along y-axis if ((obj.pos.y - t.pos.y) < 0) { y *= -1; @@ -828,7 +828,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var vx = t.pos.x - (signx * t.xw); var vy = t.pos.y + (oV * t.yw); - var dx = obj.pos.x - vx;//calc vert->circle vector + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; var len = Math.sqrt(dx * dx + dy * dy); @@ -873,7 +873,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var vx = t.pos.x + (oH * t.xw); var vy = t.pos.y - (signy * t.yw); - var dx = obj.pos.x - vx;//calc vert->circle vector + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; var len = Math.sqrt(dx * dx + dy * dy); @@ -916,7 +916,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var vx = t.pos.x + (oH * t.xw); var vy = t.pos.y + (oV * t.yw); - var dx = obj.pos.x - vx;//calc vert->circle vector + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; var len = Math.sqrt(dx * dx + dy * dy); @@ -981,7 +981,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //colliding with current tile - var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the tile-circle to + var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the tile-circle to var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//the circle's center var twid = t.xw * 2; @@ -1000,7 +1000,7 @@ Phaser.Physics.Ninja.Circle.prototype = { lenP = x; y = 0; - //get sign for projection along x-axis + //get sign for projection along x-axis if ((obj.pos.x - t.pos.x) < 0) { x *= -1; @@ -1012,7 +1012,7 @@ Phaser.Physics.Ninja.Circle.prototype = { lenP = y; x = 0; - //get sign for projection along y-axis + //get sign for projection along y-axis if ((obj.pos.y - t.pos.y) < 0) { y *= -1; @@ -1028,7 +1028,7 @@ Phaser.Physics.Ninja.Circle.prototype = { } else { - //note: len should NEVER be == 0, because if it is, + //note: len should NEVER be == 0, because if it is, //projeciton by an axis shoudl always be shorter, and we should //never arrive here ox /= len; @@ -1056,7 +1056,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //obj in neighboring cell pointed at by tile normal; //we could only be colliding vs the tile-circle surface - var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the tile-circle to + var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the tile-circle to var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//the circle's center var twid = t.xw * 2; @@ -1069,7 +1069,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if (0 < pen) { - //note: len should NEVER be == 0, because if it is, + //note: len should NEVER be == 0, because if it is, //obj is not in a neighboring cell! ox /= len; oy /= len; @@ -1096,7 +1096,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //obj in neighboring cell pointed at by tile normal; //we could only be colliding vs the tile-circle surface - var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the tile-circle to + var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the tile-circle to var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//the circle's center var twid = t.xw * 2; @@ -1109,7 +1109,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if (0 < pen) { - //note: len should NEVER be == 0, because if it is, + //note: len should NEVER be == 0, because if it is, //obj is not in a neighboring cell! ox /= len; oy /= len; @@ -1128,7 +1128,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //obj in diag neighb cell pointed at by tile normal; //we could only be colliding vs the tile-circle surface - var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the tile-circle to + var ox = obj.pos.x - (t.pos.x - (signx * t.xw));//(ox,oy) is the vector from the tile-circle to var oy = obj.pos.y - (t.pos.y - (signy * t.yw));//the circle's center var twid = t.xw * 2; @@ -1141,7 +1141,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if (0 < pen) { - //note: len should NEVER be == 0, because if it is, + //note: len should NEVER be == 0, because if it is, //obj is not in a neighboring cell! ox /= len; oy /= len; @@ -1158,7 +1158,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var vx = t.pos.x + (oH * t.xw); var vy = t.pos.y + (oV * t.yw); - var dx = obj.pos.x - vx;//calc vert->circle vector + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; var len = Math.sqrt(dx * dx + dy * dy); @@ -1234,13 +1234,13 @@ Phaser.Physics.Ninja.Circle.prototype = { var r = obj.radius; var ox = (obj.pos.x - (signx*r)) - t.pos.x;//this gives is the coordinates of the innermost var oy = (obj.pos.y - (signy*r)) - t.pos.y;//point on the circle, 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.. var sx = signx; var sy = signy; - + //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); @@ -1248,12 +1248,12 @@ Phaser.Physics.Ninja.Circle.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); @@ -1261,14 +1261,14 @@ Phaser.Physics.Ninja.Circle.prototype = { return Phaser.Physics.Ninja.Circle.COL_AXIS; } else - { + { obj.reportCollisionVsWorld(sx,sy,t.signx,t.signy); return Phaser.Physics.Ninja.Circle.COL_OTHER; } return true; - } - + } + } else { @@ -1276,24 +1276,24 @@ Phaser.Physics.Ninja.Circle.prototype = { if(celldp == 0) { - + var r = obj.radius; var dx = obj.pos.x - t.pos.x; - + //we're in a cell perpendicular to the normal, and can collide vs. halfedge vertex //or halfedge side if((dx*signx) < 0) { //collision with halfedge side obj.reportCollisionVsWorld(0,y*oV,0,oV,t); - - return Phaser.Physics.Ninja.Circle.COL_AXIS; + + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else { //collision with halfedge vertex var dy = obj.pos.y - (t.pos.y + oV*t.yw);//(dx,dy) is now the vector from the appropriate halfedge vertex to the circle - + var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; if(0 < pen) @@ -1310,12 +1310,12 @@ Phaser.Physics.Ninja.Circle.prototype = { dx /= len; dy /= len; } - + obj.reportCollisionVsWorld(dx*pen, dy*pen, dx, dy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; - } - + } + } } else @@ -1324,10 +1324,10 @@ Phaser.Physics.Ninja.Circle.prototype = { //we can only collide with the cell edge //collision with vertical neighbor obj.reportCollisionVsWorld(0,y*oV,0,oV,t); - + return Phaser.Physics.Ninja.Circle.COL_AXIS; } - + } } else if(oV == 0) @@ -1335,24 +1335,24 @@ Phaser.Physics.Ninja.Circle.prototype = { //colliding horizontally if(celldp == 0) { - + var r = obj.radius; var dy = obj.pos.y - t.pos.y; - + //we're in a cell perpendicular to the normal, and can collide vs. halfedge vertex //or halfedge side if((dy*signy) < 0) { //collision with halfedge side obj.reportCollisionVsWorld(x*oH,0,oH,0,t); - - return Phaser.Physics.Ninja.Circle.COL_AXIS; + + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else { //collision with halfedge vertex var dx = obj.pos.x - (t.pos.x + oH*t.xw);//(dx,dy) is now the vector from the appropriate halfedge vertex to the circle - + var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; if(0 < pen) @@ -1369,25 +1369,25 @@ Phaser.Physics.Ninja.Circle.prototype = { dx /= len; dy /= len; } - + obj.reportCollisionVsWorld(dx*pen, dy*pen, dx, dy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; - } - + } + } } else - { + { //due to the first conditional (celldp >0), we know w're in the cell "opposite" the normal, and so //we can only collide with the cell edge obj.reportCollisionVsWorld(x*oH, 0, oH, 0, t); - + return Phaser.Physics.Ninja.Circle.COL_AXIS; - } + } } else - { + { //colliding diagonally; we know, due to the initial (celldp >0) test which has failed //if we've reached this point, that we're in a diagonal neighbor on the non-normal side, so //we could only be colliding with the cell vertex, if at all. @@ -1395,10 +1395,10 @@ Phaser.Physics.Ninja.Circle.prototype = { //get diag vertex position var vx = t.pos.x + (oH*t.xw); var vy = t.pos.y + (oV*t.yw); - - var dx = obj.pos.x - vx;//calc vert->circle vector + + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; - + var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; if(0 < pen) @@ -1417,14 +1417,14 @@ Phaser.Physics.Ninja.Circle.prototype = { } obj.reportCollisionVsWorld(dx*pen, dy*pen, dx, dy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; - } - + } + } - + return Phaser.Physics.Ninja.Circle.COL_NONE; - + }, /** @@ -1440,7 +1440,7 @@ Phaser.Physics.Ninja.Circle.prototype = { * @return {number} The result of the collision. */ projCircle_22DegS: function (x,y,oH,oV,obj,t) { - + //if the object is in a cell pointed at by signy, no collision will ever occur //otherwise, // @@ -1459,7 +1459,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if(0 < (signy*oV)) { //object will never collide vs tile, it can't reach that far - + return Phaser.Physics.Ninja.Circle.COL_NONE; } else if(oH == 0) @@ -1469,20 +1469,20 @@ Phaser.Physics.Ninja.Circle.prototype = { //colliding with current tile //we could only be colliding vs the slope OR a vertex //look at the vector form the closest vert to the circle to decide - + var sx = t.sx; var sy = t.sy; - + var r = obj.radius; var ox = obj.pos.x - (t.pos.x - (signx*t.xw));//this gives is the coordinates of the innermost - var oy = obj.pos.y - t.pos.y;//point on the circle, relative to the tile corner - + var oy = obj.pos.y - t.pos.y;//point on the circle, relative to the tile corner + //if the component of (ox,oy) parallel to the normal's righthand normal //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy) //then we project by the vertex, otherwise by the normal or axially. - //note that this is simply a VERY tricky/weird method of determining + //note that this is simply a VERY tricky/weird method of determining //if the circle is in side the slope/face's voronio region, or that of the vertex. - + var perp = (ox*-sy) + (oy*sx); if(0 < (perp*signx*signy)) { @@ -1496,50 +1496,50 @@ Phaser.Physics.Ninja.Circle.prototype = { oy /= len; obj.reportCollisionVsWorld(ox*pen, oy*pen, ox, oy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; - } + } } else { //collide vs. slope or vs axis - ox -= r*sx;//this gives us the vector from + ox -= r*sx;//this gives us the vector from oy -= r*sy;//a point on the slope to the innermost point on the circle - + //if the dotprod of (ox,oy) and (sx,sy) is negative, the point on the circle 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); - + if(dp < 0) { //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); - + //find the smallest axial projection vector if(x < y) - { + { //penetration in x is smaller lenP = x; - y = 0; - //get sign for projection along x-axis + y = 0; + //get sign for projection along x-axis if((obj.pos.x - t.pos.x) < 0) { x *= -1; } } else - { + { //penetration in y is smaller lenP = y; - x = 0; - //get sign for projection along y-axis + x = 0; + //get sign for projection along y-axis if((obj.pos.y - t.pos.y)< 0) { y *= -1; - } + } } if(lenP < lenN) @@ -1549,15 +1549,15 @@ Phaser.Physics.Ninja.Circle.prototype = { return Phaser.Physics.Ninja.Circle.COL_AXIS; } else - { + { obj.reportCollisionVsWorld(sx,sy,t.sx,t.sy,t); return Phaser.Physics.Ninja.Circle.COL_OTHER; } - + } } - + } else { @@ -1565,9 +1565,9 @@ Phaser.Physics.Ninja.Circle.prototype = { //due to the first conditional far above obj.reportCollisionVsWorld(0,y*oV, 0, oV, t); - + return Phaser.Physics.Ninja.Circle.COL_AXIS; - } + } } else if(oV == 0) { @@ -1575,26 +1575,26 @@ Phaser.Physics.Ninja.Circle.prototype = { if((signx*oH) < 0) { //colliding with face/edge OR with corner of wedge, depending on our position vertically - + //collide vs. vertex //get diag vertex position var vx = t.pos.x - (signx*t.xw); var vy = t.pos.y; - - var dx = obj.pos.x - vx;//calc vert->circle vector + + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; - + if((dy*signy) < 0) { //colliding vs face obj.reportCollisionVsWorld(x*oH, 0, oH, 0, t); - - return Phaser.Physics.Ninja.Circle.COL_AXIS; + + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else { //colliding vs. vertex - + var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; if(0 < pen) @@ -1613,7 +1613,7 @@ Phaser.Physics.Ninja.Circle.prototype = { } obj.reportCollisionVsWorld(dx*pen, dy*pen, dx, dy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; } } @@ -1622,13 +1622,13 @@ Phaser.Physics.Ninja.Circle.prototype = { { //we could only be colliding vs the slope OR a vertex //look at the vector form the closest vert to the circle to decide - + var sx = t.sx; var sy = t.sy; - + var ox = obj.pos.x - (t.pos.x + (oH*t.xw));//this gives is the coordinates of the innermost - var oy = obj.pos.y - (t.pos.y - (signy*t.yw));//point on the circle, relative to the closest tile vert - + var oy = obj.pos.y - (t.pos.y - (signy*t.yw));//point on the circle, relative to the closest tile vert + //if the component of (ox,oy) parallel to the normal's righthand normal //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy) //then we project by the normal, otherwise by the vertex. @@ -1637,8 +1637,8 @@ Phaser.Physics.Ninja.Circle.prototype = { // for horizontal, if the perp prod and the slope's slope agree, circle is inside. // ..but this is only a property of flahs' coord system (i.e the rules might swap // in righthanded systems)) - //note that this is simply a VERY tricky/weird method of determining - //if the circle is in side the slope/face's voronio region, or that of the vertex. + //note that this is simply a VERY tricky/weird method of determining + //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); if((perp*signx*signy) < 0) { @@ -1652,26 +1652,26 @@ Phaser.Physics.Ninja.Circle.prototype = { oy /= len; obj.reportCollisionVsWorld(ox*pen, oy*pen, ox, oy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; - } + } } else { //collide vs. slope - + //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're //penetrating the slope. note that this method of penetration calculation doesn't hold //in general (i.e it won't work if the circle is in the slope), but works in this case //because we know the circle is in a neighboring cell var dp = (ox*sx) + (oy*sy); - var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case.. + var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case.. if(0 < pen) { //collision; circle out along normal by penetration amount obj.reportCollisionVsWorld(sx*pen, sy*pen, sx, sy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; } } @@ -1687,10 +1687,10 @@ Phaser.Physics.Ninja.Circle.prototype = { //get diag vertex position var vx = t.pos.x + (oH*t.xw); var vy = t.pos.y + (oV*t.yw); - - var dx = obj.pos.x - vx;//calc vert->circle vector + + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; - + var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; if(0 < pen) @@ -1709,7 +1709,7 @@ Phaser.Physics.Ninja.Circle.prototype = { } obj.reportCollisionVsWorld(dx*pen, dy*pen, dx, dy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; } } @@ -1755,70 +1755,70 @@ Phaser.Physics.Ninja.Circle.prototype = { var sx = t.sx; var sy = t.sy; - + var r = obj.radius; var ox = (obj.pos.x - (sx*r)) - (t.pos.x - (signx*t.xw));//this gives is the coordinates of the innermost var oy = (obj.pos.y - (sy*r)) - (t.pos.y + (signy*t.yw));//point on the AABB, relative to a point on the slope - + //if the dotprod of (ox,oy) and (sx,sy) is negative, the point on the circle 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); - + if(dp < 0) { //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); - + //find the smallest axial projection vector if(x < y) - { + { //penetration in x is smaller lenP = x; - y = 0; - //get sign for projection along x-axis + y = 0; + //get sign for projection along x-axis if((obj.pos.x - t.pos.x) < 0) { x *= -1; } } else - { + { //penetration in y is smaller lenP = y; - x = 0; - //get sign for projection along y-axis + x = 0; + //get sign for projection along y-axis if((obj.pos.y - t.pos.y)< 0) { y *= -1; - } + } } - + if(lenP < lenN) { obj.reportCollisionVsWorld(x, y, x/lenP, y/lenP, t); - + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else - { + { obj.reportCollisionVsWorld(sx, sy, t.sx, t.sy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; - } - } + } + } } else { //colliding vertically - + if((signy*oV) < 0) { //colliding with face/edge obj.reportCollisionVsWorld(0, y*oV, 0, oV, t); - + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else @@ -1828,15 +1828,15 @@ Phaser.Physics.Ninja.Circle.prototype = { var sx = t.sx; var sy = t.sy; - + var ox = obj.pos.x - (t.pos.x - (signx*t.xw));//this gives is the coordinates of the innermost - var oy = obj.pos.y - (t.pos.y + (signy*t.yw));//point on the circle, relative to the closest tile vert + var oy = obj.pos.y - (t.pos.y + (signy*t.yw));//point on the circle, relative to the closest tile vert //if the component of (ox,oy) parallel to the normal's righthand normal //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy) //then we project by the vertex, otherwise by the normal. - //note that this is simply a VERY tricky/weird method of determining - //if the circle is in side the slope/face's voronio region, or that of the vertex. + //note that this is simply a VERY tricky/weird method of determining + //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); if(0 < (perp*signx*signy)) { @@ -1850,14 +1850,14 @@ Phaser.Physics.Ninja.Circle.prototype = { oy /= len; obj.reportCollisionVsWorld(ox*pen, oy*pen, ox, oy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; - } + } } else { //collide vs. slope - + //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're //penetrating the slope. note that this method of penetration calculation doesn't hold //in general (i.e it won't work if the circle is in the slope), but works in this case @@ -1868,7 +1868,7 @@ Phaser.Physics.Ninja.Circle.prototype = { { //collision; circle out along normal by penetration amount obj.reportCollisionVsWorld(sx*pen, sy*pen,sx, sy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; } } @@ -1878,27 +1878,27 @@ Phaser.Physics.Ninja.Circle.prototype = { else if(oV == 0) { //colliding horizontally - + if((signx*oH) < 0) { //colliding with face/edge obj.reportCollisionVsWorld(x*oH, 0, oH, 0, t); - + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else { //colliding with edge, slope, or vertex - + var ox = obj.pos.x - (t.pos.x + (signx*t.xw));//this gives is the coordinates of the innermost - var oy = obj.pos.y - t.pos.y;//point on the circle, relative to the closest tile vert - + var oy = obj.pos.y - t.pos.y;//point on the circle, relative to the closest tile vert + if((oy*signy) < 0) { //we're colliding with the halfface obj.reportCollisionVsWorld(x*oH, 0, oH, 0, t); - - return Phaser.Physics.Ninja.Circle.COL_AXIS; + + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else { @@ -1906,12 +1906,12 @@ Phaser.Physics.Ninja.Circle.prototype = { var sx = t.sx; var sy = t.sy; - + //if the component of (ox,oy) parallel to the normal's righthand normal //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy) //then we project by the slope, otherwise by the vertex. - //note that this is simply a VERY tricky/weird method of determining - //if the circle is in side the slope/face's voronio region, or that of the vertex. + //note that this is simply a VERY tricky/weird method of determining + //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); if((perp*signx*signy) < 0) { @@ -1923,16 +1923,16 @@ Phaser.Physics.Ninja.Circle.prototype = { //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0 ox /= len; oy /= len; - + obj.reportCollisionVsWorld(ox*pen, oy*pen, ox, oy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; - } + } } else { //collide vs. slope - + //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're //penetrating the slope. note that this method of penetration calculation doesn't hold //in general (i.e it won't work if the circle is in the slope), but works in this case @@ -1943,42 +1943,42 @@ Phaser.Physics.Ninja.Circle.prototype = { { //collision; circle out along normal by penetration amount obj.reportCollisionVsWorld(sx*pen, sy*pen, t.sx, t.sy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; } - } + } } } } else { //colliding diagonally - if( 0 < ((signx*oH) + (signy*oV)) ) + if( 0 < ((signx*oH) + (signy*oV)) ) { //the dotprod of slope normal and cell offset is strictly positive, //therefore obj is in the diagonal neighb pointed at by the normal. - + //collide vs slope //we should really precalc this at compile time, but for now, fuck it var slen = Math.sqrt(2*2 + 1*1);//the raw slope is (-2,-1) var sx = (signx*1) / slen;//get slope _unit_ normal; var sy = (signy*2) / slen;//raw RH normal is (1,-2) - + var r = obj.radius; var ox = (obj.pos.x - (sx*r)) - (t.pos.x - (signx*t.xw));//this gives is the coordinates of the innermost var oy = (obj.pos.y - (sy*r)) - (t.pos.y + (signy*t.yw));//point on the circle, relative to a point on the slope - + //if the dotprod of (ox,oy) and (sx,sy) is negative, the point on the circle 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); - + if(dp < 0) { - //collision; project delta onto slope and use this to displace the object + //collision; project delta onto slope and use this to displace the object //(sx,sy)*-dp is the projection vector obj.reportCollisionVsWorld(-sx*dp, -sy*dp, t.sx, t.sy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; } return Phaser.Physics.Ninja.Circle.COL_NONE; @@ -1988,10 +1988,10 @@ Phaser.Physics.Ninja.Circle.prototype = { //collide vs the appropriate vertex var vx = t.pos.x + (oH*t.xw); var vy = t.pos.y + (oV*t.yw); - - var dx = obj.pos.x - vx;//calc vert->circle vector + + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; - + var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; if(0 < pen) @@ -2013,10 +2013,10 @@ Phaser.Physics.Ninja.Circle.prototype = { return Phaser.Physics.Ninja.Circle.COL_OTHER; } - - } + + } } - + return Phaser.Physics.Ninja.Circle.COL_NONE; }, @@ -2062,20 +2062,20 @@ Phaser.Physics.Ninja.Circle.prototype = { //colliding with current tile //we could only be colliding vs the slope OR a vertex //look at the vector form the closest vert to the circle to decide - + var sx = t.sx; var sy = t.sy; - + var r = obj.radius; var ox = obj.pos.x - t.pos.x;//this gives is the coordinates of the innermost - var oy = obj.pos.y - (t.pos.y - (signy*t.yw));//point on the circle, relative to the tile corner - + var oy = obj.pos.y - (t.pos.y - (signy*t.yw));//point on the circle, relative to the tile corner + //if the component of (ox,oy) parallel to the normal's righthand normal //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy) //then we project by the normal or axis, otherwise by the corner/vertex - //note that this is simply a VERY tricky/weird method of determining + //note that this is simply a VERY tricky/weird method of determining //if the circle is in side the slope/face's voronoi region, or that of the vertex. - + var perp = (ox*-sy) + (oy*sx); if((perp*signx*signy) < 0) { @@ -2090,93 +2090,93 @@ Phaser.Physics.Ninja.Circle.prototype = { obj.reportCollisionVsWorld(ox*pen, oy*pen, ox, oy, t); return Phaser.Physics.Ninja.Circle.COL_OTHER; - } + } } else { //collide vs. slope or vs axis - ox -= r*sx;//this gives us the vector from + ox -= r*sx;//this gives us the vector from oy -= r*sy;//a point on the slope to the innermost point on the circle - + //if the dotprod of (ox,oy) and (sx,sy) is negative, the point on the circle 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); - + if(dp < 0) { //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); - + //find the smallest axial projection vector if(x < y) - { + { //penetration in x is smaller lenP = x; - y = 0; - //get sign for projection along x-axis + y = 0; + //get sign for projection along x-axis if((obj.pos.x - t.pos.x) < 0) { x *= -1; } } else - { + { //penetration in y is smaller lenP = y; - x = 0; - //get sign for projection along y-axis + x = 0; + //get sign for projection along y-axis if((obj.pos.y - t.pos.y)< 0) { y *= -1; - } + } } if(lenP < lenN) { obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t); - + return Phaser.Physics.Ninja.Circle.COL_AXIS } else - { + { obj.reportCollisionVsWorld(sx,sy,t.sx,t.sy,t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; - } + } } } - + } else { //colliding vertically - + if((signy*oV) < 0) { //colliding with face/edge OR with corner of wedge, depending on our position vertically - + //collide vs. vertex //get diag vertex position var vx = t.pos.x; var vy = t.pos.y - (signy*t.yw); - - var dx = obj.pos.x - vx;//calc vert->circle vector + + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; - + if((dx*signx) < 0) - { + { //colliding vs face obj.reportCollisionVsWorld(0, y*oV, 0, oV, t); - - return Phaser.Physics.Ninja.Circle.COL_AXIS; + + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else { //colliding vs. vertex - + var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; if(0 < pen) @@ -2193,9 +2193,9 @@ Phaser.Physics.Ninja.Circle.prototype = { dx /= len; dy /= len; } - + obj.reportCollisionVsWorld(dx*pen, dy*pen, dx, dy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; } } @@ -2204,18 +2204,18 @@ Phaser.Physics.Ninja.Circle.prototype = { { //we could only be colliding vs the slope OR a vertex //look at the vector form the closest vert to the circle to decide - + var sx = t.sx; var sy = t.sy; - + var ox = obj.pos.x - (t.pos.x - (signx*t.xw));//this gives is the coordinates of the innermost - var oy = obj.pos.y - (t.pos.y + (oV*t.yw));//point on the circle, relative to the closest tile vert - + var oy = obj.pos.y - (t.pos.y + (oV*t.yw));//point on the circle, relative to the closest tile vert + //if the component of (ox,oy) parallel to the normal's righthand normal //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy) //then we project by the vertex, otherwise by the normal. - //note that this is simply a VERY tricky/weird method of determining - //if the circle is in side the slope/face's voronio region, or that of the vertex. + //note that this is simply a VERY tricky/weird method of determining + //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); if(0 < (perp*signx*signy)) { @@ -2229,31 +2229,31 @@ Phaser.Physics.Ninja.Circle.prototype = { oy /= len; obj.reportCollisionVsWorld(ox*pen, oy*pen, ox, oy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; - } + } } else { //collide vs. slope - + //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're //penetrating the slope. note that this method of penetration calculation doesn't hold //in general (i.e it won't work if the circle is in the slope), but works in this case //because we know the circle is in a neighboring cell var dp = (ox*sx) + (oy*sy); - var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case.. + var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case.. if(0 < pen) { //collision; circle out along normal by penetration amount obj.reportCollisionVsWorld(sx*pen, sy*pen, t.sx, t.sy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; } } } - } + } } else if(oV == 0) { @@ -2261,11 +2261,11 @@ Phaser.Physics.Ninja.Circle.prototype = { //due to the first conditional far above obj.reportCollisionVsWorld(x*oH, 0, oH, 0, t); - + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else - { + { //colliding diagonally; due to the first conditional above, //obj is vertically offset against slope, and offset in either direction horizontally @@ -2273,10 +2273,10 @@ Phaser.Physics.Ninja.Circle.prototype = { //get diag vertex position var vx = t.pos.x + (oH*t.xw); var vy = t.pos.y + (oV*t.yw); - - var dx = obj.pos.x - vx;//calc vert->circle vector + + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; - + var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; if(0 < pen) @@ -2295,7 +2295,7 @@ Phaser.Physics.Ninja.Circle.prototype = { } obj.reportCollisionVsWorld(dx*pen, dy*pen, dx, dy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; } } @@ -2341,66 +2341,66 @@ Phaser.Physics.Ninja.Circle.prototype = { var sx = t.sx; var sy = t.sy; - + var r = obj.radius; var ox = (obj.pos.x - (sx*r)) - (t.pos.x + (signx*t.xw));//this gives is the coordinates of the innermost var oy = (obj.pos.y - (sy*r)) - (t.pos.y - (signy*t.yw));//point on the AABB, relative to a point on the slope - + //if the dotprod of (ox,oy) and (sx,sy) is negative, the point on the circle 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); - + if(dp < 0) { //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); - + //find the smallest axial projection vector if(x < y) - { + { //penetration in x is smaller lenP = x; - y = 0; - //get sign for projection along x-axis + y = 0; + //get sign for projection along x-axis if((obj.pos.x - t.pos.x) < 0) { x *= -1; } } else - { + { //penetration in y is smaller lenP = y; - x = 0; - //get sign for projection along y-axis + x = 0; + //get sign for projection along y-axis if((obj.pos.y - t.pos.y)< 0) { y *= -1; - } + } } - + if(lenP < lenN) { obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t); - + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else { obj.reportCollisionVsWorld(sx, sy, t.sx, t.sy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; } - - } + + } } else { //colliding vertically - + if((signy*oV) < 0) { //colliding with face/edge @@ -2411,16 +2411,16 @@ Phaser.Physics.Ninja.Circle.prototype = { else { //colliding with edge, slope, or vertex - + var ox = obj.pos.x - t.pos.x;//this gives is the coordinates of the innermost - var oy = obj.pos.y - (t.pos.y + (signy*t.yw));//point on the circle, relative to the closest tile vert - + var oy = obj.pos.y - (t.pos.y + (signy*t.yw));//point on the circle, relative to the closest tile vert + if((ox*signx) < 0) { //we're colliding with the halfface obj.reportCollisionVsWorld(0, y*oV, 0, oV, t); - return Phaser.Physics.Ninja.Circle.COL_AXIS; + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else { @@ -2428,12 +2428,12 @@ Phaser.Physics.Ninja.Circle.prototype = { var sx = t.sx; var sy = t.sy; - + //if the component of (ox,oy) parallel to the normal's righthand normal //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy) //then we project by the vertex, otherwise by the slope. - //note that this is simply a VERY tricky/weird method of determining - //if the circle is in side the slope/face's voronio region, or that of the vertex. + //note that this is simply a VERY tricky/weird method of determining + //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); if(0 < (perp*signx*signy)) { @@ -2445,16 +2445,16 @@ Phaser.Physics.Ninja.Circle.prototype = { //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0 ox /= len; oy /= len; - + obj.reportCollisionVsWorld(ox*pen, oy*pen, ox, oy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; - } + } } else { //collide vs. slope - + //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're //penetrating the slope. note that this method of penetration calculation doesn't hold //in general (i.e it won't work if the circle is in the slope), but works in this case @@ -2465,10 +2465,10 @@ Phaser.Physics.Ninja.Circle.prototype = { { //collision; circle out along normal by penetration amount obj.reportCollisionVsWorld(sx*pen, sy*pen, sx, sy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; } - } + } } } } @@ -2476,12 +2476,12 @@ Phaser.Physics.Ninja.Circle.prototype = { else if(oV == 0) { //colliding horizontally - + if((signx*oH) < 0) { //colliding with face/edge obj.reportCollisionVsWorld(x*oH, 0, oH, 0, t); - + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else @@ -2492,15 +2492,15 @@ Phaser.Physics.Ninja.Circle.prototype = { var slen = Math.sqrt(2*2 + 1*1);//the raw slope is (-2,-1) var sx = (signx*2) / slen;//get slope _unit_ normal; var sy = (signy*1) / slen;//raw RH normal is (1,-2) - + var ox = obj.pos.x - (t.pos.x + (signx*t.xw));//this gives is the coordinates of the innermost - var oy = obj.pos.y - (t.pos.y - (signy*t.yw));//point on the circle, relative to the closest tile vert + var oy = obj.pos.y - (t.pos.y - (signy*t.yw));//point on the circle, relative to the closest tile vert //if the component of (ox,oy) parallel to the normal's righthand normal //has the same sign as the slope of the slope (the sign of the slope's slope is signx*signy) //then we project by the slope, otherwise by the vertex. - //note that this is simply a VERY tricky/weird method of determining - //if the circle is in side the slope/face's voronio region, or that of the vertex. + //note that this is simply a VERY tricky/weird method of determining + //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); if((perp*signx*signy) < 0) { @@ -2514,14 +2514,14 @@ Phaser.Physics.Ninja.Circle.prototype = { oy /= len; obj.reportCollisionVsWorld(ox*pen, oy*pen, ox, oy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; - } + } } else { //collide vs. slope - + //if the component of (ox,oy) parallel to the normal is less than the circle radius, we're //penetrating the slope. note that this method of penetration calculation doesn't hold //in general (i.e it won't work if the circle is in the slope), but works in this case @@ -2532,7 +2532,7 @@ Phaser.Physics.Ninja.Circle.prototype = { { //collision; circle out along normal by penetration amount obj.reportCollisionVsWorld(sx*pen, sy*pen, t.sx, t.sy, t); - + return Phaser.Physics.Ninja.Circle.COL_OTHER; } } @@ -2541,27 +2541,27 @@ Phaser.Physics.Ninja.Circle.prototype = { else { //colliding diagonally - if( 0 < ((signx*oH) + (signy*oV)) ) + if( 0 < ((signx*oH) + (signy*oV)) ) { //the dotprod of slope normal and cell offset is strictly positive, //therefore obj is in the diagonal neighb pointed at by the normal. - + //collide vs slope var sx = t.sx; var sy = t.sy; - + var r = obj.radius; var ox = (obj.pos.x - (sx*r)) - (t.pos.x + (signx*t.xw));//this gives is the coordinates of the innermost var oy = (obj.pos.y - (sy*r)) - (t.pos.y - (signy*t.yw));//point on the circle, relative to a point on the slope - + //if the dotprod of (ox,oy) and (sx,sy) is negative, the point on the circle 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); - + if(dp < 0) { - //collision; project delta onto slope and use this to displace the object + //collision; project delta onto slope and use this to displace the object //(sx,sy)*-dp is the projection vector obj.reportCollisionVsWorld(-sx*dp, -sy*dp, t.sx, t.sy, t); @@ -2572,14 +2572,14 @@ Phaser.Physics.Ninja.Circle.prototype = { } else { - + //collide vs the appropriate vertex var vx = t.pos.x + (oH*t.xw); var vy = t.pos.y + (oV*t.yw); - - var dx = obj.pos.x - vx;//calc vert->circle vector + + var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; - + var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; if(0 < pen) @@ -2601,10 +2601,10 @@ Phaser.Physics.Ninja.Circle.prototype = { return Phaser.Physics.Ninja.Circle.COL_OTHER; } - - } + + } } - + return Phaser.Physics.Ninja.Circle.COL_NONE; }, diff --git a/src/physics/ninja/Tile.js b/src/physics/ninja/Tile.js index 138cfc98d..6da2c90f7 100644 --- a/src/physics/ninja/Tile.js +++ b/src/physics/ninja/Tile.js @@ -9,7 +9,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 +23,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; } /** @@ -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 { @@ -672,7 +672,7 @@ Phaser.Physics.Ninja.Tile.prototype = { * @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; } diff --git a/src/physics/ninja/World.js b/src/physics/ninja/World.js index b4e451bc9..3ed240d94 100644 --- a/src/physics/ninja/World.js +++ b/src/physics/ninja/World.js @@ -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. */ diff --git a/src/physics/p2/Body.js b/src/physics/p2/Body.js index 0253987a5..4bab0531e 100644 --- a/src/physics/p2/Body.js +++ b/src/physics/p2/Body.js @@ -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. */ @@ -1080,7 +1080,7 @@ Phaser.Physics.P2.Body.prototype = { } }, - + /** * Updates the debug draw if any body shapes change. * @@ -1279,7 +1279,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 +1331,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 +1364,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 +1397,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 +1423,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 +1448,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 +1474,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 +1494,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 +1514,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 +1535,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 +1552,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 +1578,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 +1595,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 +1622,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 +1643,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 +1668,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 +1688,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 +1708,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 +1729,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 +1743,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); @@ -1774,7 +1774,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; diff --git a/src/physics/p2/BodyDebug.js b/src/physics/p2/BodyDebug.js index 6970461bd..535a26482 100644 --- a/src/physics/p2/BodyDebug.js +++ b/src/physics/p2/BodyDebug.js @@ -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; @@ -109,7 +109,7 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, { 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); @@ -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, { } -}) \ No newline at end of file +}) diff --git a/src/physics/p2/InversePointProxy.js b/src/physics/p2/InversePointProxy.js index 317b5e650..ec0ea0a1f 100644 --- a/src/physics/p2/InversePointProxy.js +++ b/src/physics/p2/InversePointProxy.js @@ -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]; diff --git a/src/physics/p2/PointProxy.js b/src/physics/p2/PointProxy.js index 3261a56d9..39e8f60e1 100644 --- a/src/physics/p2/PointProxy.js +++ b/src/physics/p2/PointProxy.js @@ -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]; diff --git a/src/physics/p2/World.js b/src/physics/p2/World.js index ff47e1cbe..f428c07fb 100644 --- a/src/physics/p2/World.js +++ b/src/physics/p2/World.js @@ -147,7 +147,7 @@ Phaser.Physics.P2 = function (game, config) { * @property {array} _toRemove - Internal var used to hold references to bodies to remove from the world on the next step. */ this._toRemove = []; - + /** * @property {array} collisionGroups - Internal var. */ @@ -1307,12 +1307,12 @@ Phaser.Physics.P2.prototype = { * @param {number} y - The y coordinate of Body. * @param {number} mass - The mass of the Body. A mass of 0 means a 'static' Body is created. * @param {boolean} [addToWorld=false] - Automatically add this Body to the world? (usually false as it won't have any shapes on construction). - * @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 {Phaser.Physics.P2.Body} The body */ @@ -1349,12 +1349,12 @@ Phaser.Physics.P2.prototype = { * @param {number} y - The y coordinate of Body. * @param {number} mass - The mass of the Body. A mass of 0 means a 'static' Body is created. * @param {boolean} [addToWorld=false] - Automatically add this Body to the world? (usually false as it won't have any shapes on construction). - * @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. */ createParticle: function (x, y, mass, addToWorld, options, data) { @@ -1541,7 +1541,7 @@ Phaser.Physics.P2.prototype = { * Convert p2 physics value (meters) to pixel scale. * By default Phaser uses a scale of 20px per meter. * If you need to modify this you can over-ride these functions via the Physics Configuration object. - * + * * @method Phaser.Physics.P2#mpx * @param {number} v - The value to convert. * @return {number} The scaled value. @@ -1556,7 +1556,7 @@ Phaser.Physics.P2.prototype = { * Convert pixel value to p2 physics scale (meters). * By default Phaser uses a scale of 20px per meter. * If you need to modify this you can over-ride these functions via the Physics Configuration object. - * + * * @method Phaser.Physics.P2#pxm * @param {number} v - The value to convert. * @return {number} The scaled value. @@ -1571,7 +1571,7 @@ Phaser.Physics.P2.prototype = { * Convert p2 physics value (meters) to pixel scale and inverses it. * By default Phaser uses a scale of 20px per meter. * If you need to modify this you can over-ride these functions via the Physics Configuration object. - * + * * @method Phaser.Physics.P2#mpxi * @param {number} v - The value to convert. * @return {number} The scaled value. @@ -1586,7 +1586,7 @@ Phaser.Physics.P2.prototype = { * Convert pixel value to p2 physics scale (meters) and inverses it. * By default Phaser uses a scale of 20px per meter. * If you need to modify this you can over-ride these functions via the Physics Configuration object. - * + * * @method Phaser.Physics.P2#pxmi * @param {number} v - The value to convert. * @return {number} The scaled value. @@ -1604,7 +1604,7 @@ Phaser.Physics.P2.prototype = { * @property {number} friction - Friction between colliding bodies. This value is used if no matching ContactMaterial is found for a Material pair. */ Object.defineProperty(Phaser.Physics.P2.prototype, "friction", { - + get: function () { return this.world.defaultFriction; @@ -1624,7 +1624,7 @@ Object.defineProperty(Phaser.Physics.P2.prototype, "friction", { * @property {number} restitution - Default coefficient of restitution between colliding bodies. This value is used if no matching ContactMaterial is found for a Material pair. */ Object.defineProperty(Phaser.Physics.P2.prototype, "restituion", { - + get: function () { return this.world.defaultRestitution; @@ -1644,7 +1644,7 @@ Object.defineProperty(Phaser.Physics.P2.prototype, "restituion", { * @property {boolean} applySpringForces - Enable to automatically apply spring forces each step. */ Object.defineProperty(Phaser.Physics.P2.prototype, "applySpringForces", { - + get: function () { return this.world.applySpringForces; @@ -1664,7 +1664,7 @@ Object.defineProperty(Phaser.Physics.P2.prototype, "applySpringForces", { * @property {boolean} applyDamping - Enable to automatically apply body damping each step. */ Object.defineProperty(Phaser.Physics.P2.prototype, "applyDamping", { - + get: function () { return this.world.applyDamping; @@ -1684,7 +1684,7 @@ Object.defineProperty(Phaser.Physics.P2.prototype, "applyDamping", { * @property {boolean} applyGravity - Enable to automatically apply gravity each step. */ Object.defineProperty(Phaser.Physics.P2.prototype, "applyGravity", { - + get: function () { return this.world.applyGravity; @@ -1704,7 +1704,7 @@ Object.defineProperty(Phaser.Physics.P2.prototype, "applyGravity", { * @property {boolean} solveConstraints - Enable/disable constraint solving in each step. */ Object.defineProperty(Phaser.Physics.P2.prototype, "solveConstraints", { - + get: function () { return this.world.solveConstraints; @@ -1725,7 +1725,7 @@ Object.defineProperty(Phaser.Physics.P2.prototype, "solveConstraints", { * @readonly */ Object.defineProperty(Phaser.Physics.P2.prototype, "time", { - + get: function () { return this.world.time; @@ -1739,7 +1739,7 @@ Object.defineProperty(Phaser.Physics.P2.prototype, "time", { * @property {boolean} emitImpactEvent - Set to true if you want to the world to emit the "impact" event. Turning this off could improve performance. */ Object.defineProperty(Phaser.Physics.P2.prototype, "emitImpactEvent", { - + get: function () { return this.world.emitImpactEvent; @@ -1759,7 +1759,7 @@ Object.defineProperty(Phaser.Physics.P2.prototype, "emitImpactEvent", { * @property {boolean} enableBodySleeping - Enable / disable automatic body sleeping. */ Object.defineProperty(Phaser.Physics.P2.prototype, "enableBodySleeping", { - + get: function () { return this.world.enableBodySleeping; @@ -1780,7 +1780,7 @@ Object.defineProperty(Phaser.Physics.P2.prototype, "enableBodySleeping", { * @readonly */ Object.defineProperty(Phaser.Physics.P2.prototype, "total", { - + get: function () { return this.world.bodies.length; diff --git a/src/physics/p2/p2.js b/src/physics/p2/p2.js index 3b6baeb8b..115bc4498 100644 --- a/src/physics/p2/p2.js +++ b/src/physics/p2/p2.js @@ -1,18 +1,18 @@ /** * The MIT License (MIT) - * + * * Copyright (c) 2013 p2.js authors - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -30,12 +30,12 @@ are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation + this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; @@ -131,7 +131,7 @@ mat2.transpose = function(out, a) { out[2] = a[1]; out[3] = a[3]; } - + return out; }; @@ -152,7 +152,7 @@ mat2.invert = function(out, a) { return null; } det = 1.0 / det; - + out[0] = a3 * det; out[1] = -a1 * det; out[2] = -a2 * det; @@ -273,12 +273,12 @@ are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation + this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; @@ -296,7 +296,7 @@ var vec2 = {}; if(!GLMAT_EPSILON) { var GLMAT_EPSILON = 0.000001; } - + /** * Creates a new, empty vec2 * @@ -667,7 +667,7 @@ vec2.forEach = (function() { if(!offset) { offset = 0; } - + if(count) { l = Math.min((count * stride) + offset, a.length); } else { @@ -679,7 +679,7 @@ vec2.forEach = (function() { fn(vec, vec, arg); a[i] = vec[0]; a[i+1] = vec[1]; } - + return a; }; })(); @@ -10714,4 +10714,4 @@ World.prototype.hitTest = function(worldPoint,bodies,precision){ },{"../../package.json":8,"../collision/Broadphase":10,"../collision/NaiveBroadphase":12,"../collision/Narrowphase":13,"../constraints/DistanceConstraint":17,"../constraints/LockConstraint":19,"../constraints/PrismaticConstraint":20,"../constraints/RevoluteConstraint":21,"../events/EventEmitter":28,"../material/ContactMaterial":29,"../material/Material":30,"../math/vec2":33,"../objects/Body":34,"../objects/Spring":35,"../shapes/Capsule":37,"../shapes/Circle":38,"../shapes/Convex":39,"../shapes/Line":41,"../shapes/Particle":42,"../shapes/Plane":43,"../shapes/Rectangle":44,"../solver/GSSolver":46,"../utils/Utils":50}]},{},[36]) (36) }); -; \ No newline at end of file +; diff --git a/src/pixi/InteractionData.js b/src/pixi/InteractionData.js index 909fcbe2b..cfd7188f8 100644 --- a/src/pixi/InteractionData.js +++ b/src/pixi/InteractionData.js @@ -1,7 +1,7 @@ /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ - + /** * Holds all information related to an Interaction event * @@ -60,4 +60,4 @@ PIXI.InteractionData.prototype.getLocalPosition = function(displayObject) }; // constructor -PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; \ No newline at end of file +PIXI.InteractionData.prototype.constructor = PIXI.InteractionData; diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index c5e446c1b..443d14722 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -41,7 +41,7 @@ PIXI.InteractionManager = function(stage) this.tempPoint = new PIXI.Point(); /** - * + * * @property mouseoverEnabled * @type Boolean * @default @@ -50,7 +50,7 @@ PIXI.InteractionManager = function(stage) /** * tiny little interactiveData pool ! - * + * * @property pool * @type Array */ @@ -165,7 +165,7 @@ PIXI.InteractionManager.prototype.setTarget = function(target) this.setTargetDomElement( target.view ); } - + }; @@ -395,7 +395,7 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event) * * @method onMouseOut * @param event {Event} The DOM event of a mouse button being moved out - * @private + * @private */ PIXI.InteractionManager.prototype.onMouseOut = function() { @@ -484,7 +484,7 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) if( !item.worldVisible )return false; // temp fix for if the element is in a non visible - + var isSprite = (item instanceof PIXI.Sprite), worldTransform = item.worldTransform, a00 = worldTransform.a, a01 = worldTransform.b, a02 = worldTransform.tx, @@ -526,7 +526,7 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) } } } - + var length = item.children.length; for (var i = length-1; i >= 0; i--) @@ -541,7 +541,7 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData) } } - + return false; @@ -597,7 +597,7 @@ PIXI.InteractionManager.prototype.onTouchStart = function(event) var rect = this.interactionDOMElement.getBoundingClientRect(); if(PIXI.AUTO_PREVENT_DEFAULT)event.preventDefault(); - + var changedTouches = event.changedTouches; for (var i=0; i < changedTouches.length; i++) { diff --git a/src/pixi/Outro.js b/src/pixi/Outro.js index b83e9fb54..8f42e2e2d 100644 --- a/src/pixi/Outro.js +++ b/src/pixi/Outro.js @@ -12,4 +12,4 @@ } else { root.PIXI = PIXI; } -}).call(this); \ No newline at end of file +}).call(this); diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 7a3c7b1b9..e8608b39c 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -7,8 +7,8 @@ */ var PIXI = PIXI || {}; -/* -* +/* +* * This file contains a lot of pixi consts which are used across the rendering engine * @class Consts */ @@ -46,9 +46,9 @@ PIXI.scaleModes = { NEAREST:1 }; -// interaction frequency +// interaction frequency PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; PIXI.RAD_TO_DEG = 180 / Math.PI; -PIXI.DEG_TO_RAD = Math.PI / 180; \ No newline at end of file +PIXI.DEG_TO_RAD = Math.PI / 180; diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 74f8c13de..ff133d25e 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -16,8 +16,8 @@ PIXI.Matrix2 = PIXI.determineMatrixArrayType(); /* * @class Matrix -* The Matrix class is now an object, which makes it a lot faster, -* here is a representation of it : +* The Matrix class is now an object, which makes it a lot faster, +* here is a representation of it : * | a | b | tx| * | c | c | ty| * | 0 | 0 | 1 | @@ -89,4 +89,4 @@ PIXI.Matrix.prototype.toArray = function(transpose) return array;//[this.a, this.b, this.tx, this.c, this.d, this.ty, 0, 0, 1]; }; -PIXI.identityMatrix = new PIXI.Matrix(); \ No newline at end of file +PIXI.identityMatrix = new PIXI.Matrix(); diff --git a/src/pixi/core/Rectangle.js b/src/pixi/core/Rectangle.js index b8edfcce7..c2c740836 100644 --- a/src/pixi/core/Rectangle.js +++ b/src/pixi/core/Rectangle.js @@ -84,4 +84,4 @@ PIXI.Rectangle.prototype.contains = function(x, y) // constructor PIXI.Rectangle.prototype.constructor = PIXI.Rectangle; -PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); \ No newline at end of file +PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0); diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 444248191..af87f802a 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -122,7 +122,7 @@ PIXI.DisplayObject = function() /** * This is the cursor that will be used when the mouse is over this object. To enable this the element must have interaction = true and buttonMode = true - * + * * @property defaultCursor * @type String * @@ -162,7 +162,7 @@ PIXI.DisplayObject = function() this._cr = 1; /** - * The area the filter is applied to + * The area the filter is applied to * * @property filterArea * @type Rectangle @@ -516,11 +516,11 @@ PIXI.DisplayObject.prototype._generateCachedSprite = function()//renderSession) { this._cacheAsBitmap = false; var bounds = this.getLocalBounds(); - + if(!this._cachedSprite) { var renderTexture = new PIXI.RenderTexture(bounds.width | 0, bounds.height | 0);//, renderSession.renderer); - + this._cachedSprite = new PIXI.Sprite(renderTexture); this._cachedSprite.worldTransform = this.worldTransform; } @@ -545,7 +545,7 @@ PIXI.DisplayObject.prototype._generateCachedSprite = function()//renderSession) * Renders the object using the WebGL renderer * * @method _renderWebGL -* @param renderSession {RenderSession} +* @param renderSession {RenderSession} * @private */ PIXI.DisplayObject.prototype._destroyCachedSprite = function() @@ -571,7 +571,7 @@ PIXI.DisplayObject.prototype._renderWebGL = function(renderSession) * Renders the object using the Canvas renderer * * @method _renderCanvas -* @param renderSession {RenderSession} +* @param renderSession {RenderSession} * @private */ PIXI.DisplayObject.prototype._renderCanvas = function(renderSession) diff --git a/src/pixi/display/DisplayObjectContainer.js b/src/pixi/display/DisplayObjectContainer.js index 92ae06e69..817828292 100644 --- a/src/pixi/display/DisplayObjectContainer.js +++ b/src/pixi/display/DisplayObjectContainer.js @@ -129,7 +129,7 @@ PIXI.DisplayObjectContainer.prototype.swapChildren = function(child, child2) this.children[index1] = child2; this.children[index2] = child; - + }; /** @@ -175,7 +175,7 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child) /** -* Removes all the children +* Removes all the children * * @method removeAll * NOT tested yet @@ -188,7 +188,7 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child) { this.removeChild(this.children[i]); } - + }; */ /* @@ -247,13 +247,13 @@ PIXI.DisplayObjectContainer.prototype.getBounds = function(matrix) for(var i=0,j=this.children.length; i https://github.com/mattdesl/ * for creating the original pixi version! * @@ -10,7 +10,7 @@ PIXI.WebGLFastSpriteBatch = function(gl) { - + this.vertSize = 10; this.maxSize = 6000;//Math.pow(2, 16) / this.vertSize; @@ -25,7 +25,7 @@ PIXI.WebGLFastSpriteBatch = function(gl) this.vertices = new Float32Array(numVerts); //index data this.indices = new Uint16Array(numIndices); - + this.vertexBuffer = null; this.indexBuffer = null; @@ -44,10 +44,10 @@ PIXI.WebGLFastSpriteBatch = function(gl) this.drawing = false; this.currentBatchSize = 0; this.currentBaseTexture = null; - + this.currentBlendMode = 0; this.renderSession = null; - + this.shader = null; @@ -100,17 +100,17 @@ PIXI.WebGLFastSpriteBatch.prototype.render = function(spriteBatch) var sprite = children[0]; // if the uvs have not updated then no point rendering just yet! - + // check texture. if(!sprite.texture._uvs)return; - + this.currentBaseTexture = sprite.texture.baseTexture; // check blend mode if(sprite.blendMode !== this.currentBlendMode) { this.setBlendMode(sprite.blendMode); } - + for(var i=0,j= children.length; i ( this.size * 0.5 ) ) { gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertices); @@ -284,11 +284,11 @@ PIXI.WebGLFastSpriteBatch.prototype.flush = function() gl.bufferSubData(gl.ARRAY_BUFFER, 0, view); } - - + + // now draw those suckas! gl.drawElements(gl.TRIANGLES, this.currentBatchSize * 6, gl.UNSIGNED_SHORT, 0); - + // then reset the batch! this.currentBatchSize = 0; @@ -342,7 +342,7 @@ PIXI.WebGLFastSpriteBatch.prototype.setBlendMode = function(blendMode) this.flush(); this.currentBlendMode = blendMode; - + var blendModeWebGL = PIXI.blendModesWebGL[this.currentBlendMode]; this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 7503ef547..ae0299b4b 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -14,7 +14,7 @@ PIXI.WebGLFilterManager = function(gl, transparent) this.transparent = transparent; this.filterStack = []; - + this.offsetX = 0; this.offsetY = 0; @@ -24,7 +24,7 @@ PIXI.WebGLFilterManager = function(gl, transparent) // API /** * Initialises the context and the properties -* @method setContext +* @method setContext * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLFilterManager.prototype.setContext = function(gl) @@ -36,10 +36,10 @@ PIXI.WebGLFilterManager.prototype.setContext = function(gl) }; /** -* +* * @method begin -* @param renderSession {RenderSession} -* @param buffer {ArrayBuffer} +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} */ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { @@ -290,7 +290,7 @@ PIXI.WebGLFilterManager.prototype.popFilter = function() // bind the buffer gl.bindFramebuffer(gl.FRAMEBUFFER, buffer ); - // set the blend mode! + // set the blend mode! //gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA) // set texture @@ -439,7 +439,7 @@ PIXI.WebGLFilterManager.prototype.destroy = function() var gl = this.gl; this.filterStack = null; - + this.offsetX = 0; this.offsetY = 0; @@ -447,7 +447,7 @@ PIXI.WebGLFilterManager.prototype.destroy = function() for (var i = 0; i < this.texturePool.length; i++) { this.texturePool.destroy(); } - + this.texturePool = null; //destroy buffers.. diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 6f32b281a..d9ed95782 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -96,7 +96,7 @@ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projectio PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) { var webGL = graphics._webGL[gl.id]; - + for (var i = webGL.lastIndex; i < graphics.graphicsData.length; i++) { var data = graphics.graphicsData[i]; @@ -126,7 +126,7 @@ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) webGL.lastIndex = graphics.graphicsData.length; - + webGL.glPoints = new Float32Array(webGL.points); @@ -219,7 +219,7 @@ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData) */ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData) { - + // need to convert points to a nice regular data var rectData = graphicsData.points; var x = rectData[0]; diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index 545e3ddb3..7db19c070 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -1,7 +1,7 @@ /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ - + /** * @class WebGLMaskManager @@ -19,7 +19,7 @@ PIXI.WebGLMaskManager = function(gl) /** * Sets the drawing context to the one given in parameter -* @method setContext +* @method setContext * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLMaskManager.prototype.setContext = function(gl) @@ -42,11 +42,11 @@ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession) gl.enable(gl.STENCIL_TEST); gl.stencilFunc(gl.ALWAYS,1,1); } - + // maskData.visible = false; this.maskStack.push(maskData); - + gl.colorMask(false, false, false, true); gl.stencilOp(gl.KEEP,gl.KEEP,gl.INCR); @@ -82,7 +82,7 @@ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession) gl.stencilFunc(gl.NOTEQUAL,0,this.maskStack.length); gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); } - + if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; @@ -94,4 +94,4 @@ PIXI.WebGLMaskManager.prototype.destroy = function() { this.maskStack = null; this.gl = null; -}; \ No newline at end of file +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js index d1181beb1..69b0aa8bc 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js @@ -27,14 +27,14 @@ PIXI.WebGLShaderManager = function(gl) /** * Initialises the context and the properties -* @method setContext +* @method setContext * @param gl {WebGLContext} the current WebGL drawing context * @param transparent {Boolean} Whether or not the drawing context should be transparent */ PIXI.WebGLShaderManager.prototype.setContext = function(gl) { this.gl = gl; - + // the next one is used for rendering primatives this.primitiveShader = new PIXI.PrimitiveShader(gl); @@ -50,9 +50,9 @@ PIXI.WebGLShaderManager.prototype.setContext = function(gl) /** -* Takes the attributes given in parameters +* Takes the attributes given in parameters * @method setAttribs -* @param attribs {Array} attribs +* @param attribs {Array} attribs */ PIXI.WebGLShaderManager.prototype.setAttribs = function(attribs) { @@ -94,7 +94,7 @@ PIXI.WebGLShaderManager.prototype.setAttribs = function(attribs) }; /** -* Sets-up the given shader +* Sets-up the given shader * * @method activateShader * @param shader {Object} the shader that is going to be activated @@ -107,7 +107,7 @@ PIXI.WebGLShaderManager.prototype.activateShader = function(shader) this.gl.useProgram(shader.program); this.setAttribs(shader.attributes); - + }; /** @@ -121,7 +121,7 @@ PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function() gl.useProgram(this.primitiveShader.program); this.setAttribs(this.primitiveShader.attributes); - + }; /** diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderUtils.js b/src/pixi/renderers/webgl/utils/WebGLShaderUtils.js index f6cc02467..f962ba876 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderUtils.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderUtils.js @@ -3,11 +3,11 @@ */ // TODO Alvin and Mat -// Should we eventually create a Utils class ? +// Should we eventually create a Utils class ? // Or just move this file to the pixi.js file ? PIXI.initDefaultShaders = function() { - + // PIXI.stripShader = new PIXI.StripShader(); // PIXI.stripShader.init(); diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index 2101cb024..e778beb38 100644 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -1,6 +1,6 @@ /** * @author Mat Groves - * + * * Big thanks to the very clever Matt DesLauriers https://github.com/mattdesl/ * for creating the original pixi version! * @@ -20,7 +20,7 @@ PIXI.WebGLSpriteBatch = function(gl) { /** - * + * * * @property vertSize * @type Number @@ -57,7 +57,7 @@ PIXI.WebGLSpriteBatch = function(gl) * @type Uint16Array */ this.indices = new Uint16Array(numIndices); - + this.lastIndexCount = 0; for (var i=0, j=0; i < numIndices; i += 6, j += 4) @@ -74,12 +74,12 @@ PIXI.WebGLSpriteBatch = function(gl) this.drawing = false; this.currentBatchSize = 0; this.currentBaseTexture = null; - + this.setContext(gl); }; /** -* +* * @method setContext * * @param gl {WebGLContext} the current WebGL drawing context @@ -106,7 +106,7 @@ PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) }; /** -* +* * @method begin * * @param renderSession {RenderSession} the RenderSession @@ -120,7 +120,7 @@ PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession) }; /** -* +* * @method end * */ @@ -130,9 +130,9 @@ PIXI.WebGLSpriteBatch.prototype.end = function() }; /** -* +* * @method render -* +* * @param sprite {Sprite} the sprite to render when using this spritebatch */ PIXI.WebGLSpriteBatch.prototype.render = function(sprite) @@ -170,7 +170,7 @@ PIXI.WebGLSpriteBatch.prototype.render = function(sprite) var aY = sprite.anchor.y; var w0, w1, h0, h1; - + if (sprite.texture.trim) { // if the sprite is trimmed then we need to add the extra space before transforming the sprite coords.. @@ -242,7 +242,7 @@ PIXI.WebGLSpriteBatch.prototype.render = function(sprite) // color verticies[index++] = alpha; verticies[index++] = tint; - + // increment the batchsize this.currentBatchSize++; @@ -252,7 +252,7 @@ PIXI.WebGLSpriteBatch.prototype.render = function(sprite) /** * Renders a tilingSprite using the spriteBatch * @method renderTilingSprite -* +* * @param sprite {TilingSprite} the tilingSprite to render */ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite) @@ -347,7 +347,7 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite) // color verticies[index++] = alpha; verticies[index++] = tint; - + // xy verticies[index++] = a * w0 + c * h0 + tx; verticies[index++] = d * h0 + b * w0 + ty; @@ -377,7 +377,7 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite) * Renders the content and empties the current batch * * @method flush -* +* */ PIXI.WebGLSpriteBatch.prototype.flush = function() { @@ -385,12 +385,12 @@ PIXI.WebGLSpriteBatch.prototype.flush = function() if (this.currentBatchSize===0)return; var gl = this.gl; - + // bind the current texture gl.bindTexture(gl.TEXTURE_2D, this.currentBaseTexture._glTextures[gl.id] || PIXI.createWebGLTexture(this.currentBaseTexture, gl)); // upload the verts to the buffer - + if(this.currentBatchSize > ( this.size * 0.5 ) ) { gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertices); @@ -404,10 +404,10 @@ PIXI.WebGLSpriteBatch.prototype.flush = function() // var view = this.vertices.subarray(0, this.currentBatchSize * 4 * this.vertSize); //gl.bufferSubData(gl.ARRAY_BUFFER, 0, view); - + // now draw those suckas! gl.drawElements(gl.TRIANGLES, this.currentBatchSize * 6, gl.UNSIGNED_SHORT, 0); - + // then reset the batch! this.currentBatchSize = 0; @@ -416,7 +416,7 @@ PIXI.WebGLSpriteBatch.prototype.flush = function() }; /** -* +* * @method stop * */ @@ -426,7 +426,7 @@ PIXI.WebGLSpriteBatch.prototype.stop = function() }; /** -* +* * @method start * */ @@ -460,7 +460,7 @@ PIXI.WebGLSpriteBatch.prototype.start = function() /** * Sets-up the given blendMode from WebGL's point of view -* @method setBlendMode +* @method setBlendMode * * @param blendMode {Number} the blendMode, should be a Pixi const, such as PIXI.BlendModes.ADD */ @@ -469,7 +469,7 @@ PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode) this.flush(); this.currentBlendMode = blendMode; - + var blendModeWebGL = PIXI.blendModesWebGL[this.currentBlendMode]; this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; @@ -483,12 +483,12 @@ PIXI.WebGLSpriteBatch.prototype.destroy = function() this.vertices = null; this.indices = null; - + this.gl.deleteBuffer( this.vertexBuffer ); this.gl.deleteBuffer( this.indexBuffer ); - + this.currentBaseTexture = null; - + this.gl = null; }; diff --git a/src/pixi/text/BitmapText.js b/src/pixi/text/BitmapText.js index cc056c15a..f1840a9dd 100644 --- a/src/pixi/text/BitmapText.js +++ b/src/pixi/text/BitmapText.js @@ -82,7 +82,7 @@ PIXI.BitmapText.prototype.updateText = function() var lineWidths = []; var line = 0; var scale = this.fontSize / data.size; - + for(var i = 0; i < this.text.length; i++) { diff --git a/src/pixi/text/Text.js b/src/pixi/text/Text.js index e569fbc87..574b93cf6 100644 --- a/src/pixi/text/Text.js +++ b/src/pixi/text/Text.js @@ -3,7 +3,7 @@ */ /** - * A Text Object will create a line(s) of text. To split a line you can use '\n' + * A Text Object will create a line(s) of text. To split a line you can use '\n' * or add a wordWrap property set to true and and wordWrapWidth property with a value * in the style object * @@ -125,7 +125,7 @@ PIXI.Text.prototype.updateText = function() this.canvas.height = lineHeight * lines.length; if(navigator.isCocoonJS) 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; @@ -186,7 +186,7 @@ PIXI.Text.prototype.updateTexture = function() * Renders the object using the WebGL renderer * * @method _renderWebGL -* @param renderSession {RenderSession} +* @param renderSession {RenderSession} * @private */ PIXI.Text.prototype._renderWebGL = function(renderSession) diff --git a/src/pixi/textures/BaseTexture.js b/src/pixi/textures/BaseTexture.js index 3d4733414..d48e68305 100644 --- a/src/pixi/textures/BaseTexture.js +++ b/src/pixi/textures/BaseTexture.js @@ -69,7 +69,7 @@ PIXI.BaseTexture = function(source, scaleMode) // used for webGL this._glTextures = []; - + if(!source)return; if(this.source.complete || this.source.getContext) @@ -99,7 +99,7 @@ PIXI.BaseTexture = function(source, scaleMode) this.imageUrl = null; this._powerOf2 = false; - + }; @@ -142,7 +142,7 @@ PIXI.BaseTexture.prototype.updateSourceImage = function(newSrc) * @static * @method fromImage * @param imageUrl {String} The image url of the texture - * @param crossorigin {Boolean} + * @param crossorigin {Boolean} * @param scaleMode {Number} Should be one of the PIXI.scaleMode consts * @return BaseTexture */ diff --git a/src/pixi/textures/RenderTexture.js b/src/pixi/textures/RenderTexture.js index 50b1d5cf5..536947cbe 100644 --- a/src/pixi/textures/RenderTexture.js +++ b/src/pixi/textures/RenderTexture.js @@ -169,7 +169,7 @@ PIXI.RenderTexture.prototype.renderWebGL = function(displayObject, position, cle // update the textures! PIXI.WebGLRenderer.updateTextures(); - // + // this.renderer.renderDisplayObject(displayObject, this.projection, this.textureBuffer.frameBuffer); displayObject.worldTransform = originalWorldTransform; diff --git a/src/pixi/textures/Texture.js b/src/pixi/textures/Texture.js index 8500a6e62..3d4e3580f 100644 --- a/src/pixi/textures/Texture.js +++ b/src/pixi/textures/Texture.js @@ -53,15 +53,15 @@ PIXI.Texture = function(baseTexture, frame) * @type Rectangle */ this.trim = null; - + this.scope = this; this._uvs = null; - + if(baseTexture.hasLoaded) { if(this.noFrame)frame = new PIXI.Rectangle(0,0, baseTexture.width, baseTexture.height); - + this.setFrame(frame); } else @@ -86,7 +86,7 @@ PIXI.Texture.prototype.onBaseTextureLoaded = function() baseTexture.removeEventListener( 'loaded', this.onLoaded ); if(this.noFrame)this.frame = new PIXI.Rectangle(0,0, baseTexture.width, baseTexture.height); - + this.setFrame(this.frame); this.scope.dispatchEvent( { type: 'update', content: this } ); diff --git a/src/pixi/utils/Detector.js b/src/pixi/utils/Detector.js index dea205af0..de8d2100f 100644 --- a/src/pixi/utils/Detector.js +++ b/src/pixi/utils/Detector.js @@ -10,7 +10,7 @@ * @static * @param width=800 {Number} the width of the renderers view * @param height=600 {Number} the height of the renderers view - * @param [view] {Canvas} the canvas to use as a view, optional + * @param [view] {Canvas} the canvas to use as a view, optional * @param [transparent=false] {Boolean} the transparency of the render view, default false * @param [antialias=false] {Boolean} sets antialias (only applicable in webGL chrome at the moment) * diff --git a/src/pixi/utils/EventTarget.js b/src/pixi/utils/EventTarget.js index 300d28770..4857132fc 100644 --- a/src/pixi/utils/EventTarget.js +++ b/src/pixi/utils/EventTarget.js @@ -1,7 +1,7 @@ /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ - + /** * https://github.com/mrdoob/eventtarget.js/ * THankS mr DOob! diff --git a/src/pixi/utils/Polyk.js b/src/pixi/utils/Polyk.js index aaf3bdb49..188534a37 100644 --- a/src/pixi/utils/Polyk.js +++ b/src/pixi/utils/Polyk.js @@ -44,7 +44,7 @@ PIXI.PolyK = {}; * Triangulates shapes for webGL graphic fills * * @method Triangulate - * + * */ PIXI.PolyK.Triangulate = function(p) { @@ -160,7 +160,7 @@ PIXI.PolyK._PointInTriangle = function(px, py, ax, ay, bx, by, cx, cy) * Checks whether a shape is convex * * @method _convex - * + * * @private */ PIXI.PolyK._convex = function(ax, ay, bx, by, cx, cy, sign) diff --git a/src/pixi/utils/Utils.js b/src/pixi/utils/Utils.js index 0b2accd25..908aa155b 100644 --- a/src/pixi/utils/Utils.js +++ b/src/pixi/utils/Utils.js @@ -1,7 +1,7 @@ /** * @author Mat Groves http://matgroves.com/ @Doormat23 */ - + // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating @@ -11,7 +11,7 @@ /** * A polyfill for requestAnimationFrame - * You can actually use both requestAnimationFrame and requestAnimFrame, + * You can actually use both requestAnimationFrame and requestAnimFrame, * you will still benefit from the polyfill * * @method requestAnimationFrame @@ -138,7 +138,7 @@ PIXI.packColorRGBA = function(r, g, b, a)//r, g, b, a) // var g = (i / 4096.0)%64 / 64; // var b = (i / 64.0)%64 / 64; // var a = (i)%64 / 64; - + // console.log(r, g, b, a); // return i; diff --git a/src/sound/Sound.js b/src/sound/Sound.js index a087570a7..c35b4699e 100644 --- a/src/sound/Sound.js +++ b/src/sound/Sound.js @@ -16,7 +16,7 @@ * @param {boolean} [loop=false] - Whether or not the sound will loop. */ Phaser.Sound = function (game, key, volume, loop, connect) { - + if (typeof volume == 'undefined') { volume = 1; } if (typeof loop == 'undefined') { loop = false; } if (typeof connect === 'undefined') { connect = game.sound.connectToMaster; } @@ -52,7 +52,7 @@ Phaser.Sound = function (game, key, volume, loop, connect) { * @property {object} markers - The sound markers. */ this.markers = {}; - + /** * @property {AudioContext} context - Reference to the AudioContext instance. */ @@ -80,34 +80,34 @@ Phaser.Sound = function (game, key, volume, loop, connect) { * @property {number} totalDuration - The total duration of the sound, in milliseconds */ this.totalDuration = 0; - + /** * @property {number} startTime - The time the Sound starts at (typically 0 unless starting from a marker) * @default */ this.startTime = 0; - + /** * @property {number} currentTime - The current time the sound is at. */ this.currentTime = 0; - + /** * @property {number} duration - The duration of the sound. */ this.duration = 0; - + /** * @property {number} stopTime - The time the sound stopped. */ this.stopTime = 0; - + /** * @property {boolean} paused - true if the sound is paused, otherwise false. * @default */ this.paused = false; - + /** * @property {number} pausedPosition - The position the sound had reached when it was paused. */ @@ -123,31 +123,31 @@ Phaser.Sound = function (game, key, volume, loop, connect) { * @default */ this.isPlaying = false; - + /** * @property {string} currentMarker - The string ID of the currently playing marker, if any. * @default */ this.currentMarker = ''; - + /** * @property {boolean} pendingPlayback - true if the sound file is pending playback * @readonly */ this.pendingPlayback = false; - + /** * @property {boolean} override - if true when you play this sound it will always start from the beginning. * @default */ this.override = false; - + /** * @property {boolean} usingWebAudio - true if this sound is being played with Web Audio. * @readonly */ this.usingWebAudio = this.game.sound.usingWebAudio; - + /** * @property {boolean} usingAudioTag - true if the sound is being played via the Audio tag. */ @@ -201,37 +201,37 @@ Phaser.Sound = function (game, key, volume, loop, connect) { * @property {Phaser.Signal} onDecoded - The onDecoded event is dispatched when the sound has finished decoding (typically for mp3 files) */ this.onDecoded = new Phaser.Signal(); - + /** * @property {Phaser.Signal} onPlay - The onPlay event is dispatched each time this sound is played. */ this.onPlay = new Phaser.Signal(); - + /** * @property {Phaser.Signal} onPause - The onPause event is dispatched when this sound is paused. */ this.onPause = new Phaser.Signal(); - + /** * @property {Phaser.Signal} onResume - The onResume event is dispatched when this sound is resumed from a paused state. */ this.onResume = new Phaser.Signal(); - + /** * @property {Phaser.Signal} onLoop - The onLoop event is dispatched when this sound loops during playback. */ this.onLoop = new Phaser.Signal(); - + /** * @property {Phaser.Signal} onStop - The onStop event is dispatched when this sound stops playback. */ this.onStop = new Phaser.Signal(); - + /** * @property {Phaser.Signal} onMute - The onMouse event is dispatched when this sound is muted. */ this.onMute = new Phaser.Signal(); - + /** * @property {Phaser.Signal} onMarkerComplete - The onMarkerComplete event is dispatched when a marker within this sound completes playback. */ @@ -492,7 +492,7 @@ Phaser.Sound.prototype = { this._sound = this.context.createBufferSource(); this._sound.buffer = this._buffer; - + if (this.externalNode) { this._sound.connect(this.externalNode.input); @@ -572,7 +572,7 @@ Phaser.Sound.prototype = { // console.log('playing', this._sound); this._sound.currentTime = this.position; this._sound.muted = this._muted; - + if (this._muted) { this._sound.volume = 0; @@ -713,7 +713,7 @@ Phaser.Sound.prototype = { this.isPlaying = false; var prevMarker = this.currentMarker; - + if (this.currentMarker !== '') { this.onMarkerComplete.dispatch(this.currentMarker, this); @@ -759,11 +759,11 @@ Object.defineProperty(Phaser.Sound.prototype, "isDecoded", { * @property {boolean} mute - Gets or sets the muted state of this sound. */ Object.defineProperty(Phaser.Sound.prototype, "mute", { - + get: function () { return this._muted; }, - + set: function (value) { value = value || null; diff --git a/src/sound/SoundManager.js b/src/sound/SoundManager.js index 35c093d7a..00d21973d 100644 --- a/src/sound/SoundManager.js +++ b/src/sound/SoundManager.js @@ -20,12 +20,12 @@ Phaser.SoundManager = function (game) { * @property {Phaser.Game} game - Local reference to game. */ this.game = game; - + /** * @property {Phaser.Signal} onSoundDecode - The event dispatched when a sound decodes (typically only for mp3 files) */ this.onSoundDecode = new Phaser.Signal(); - + /** * @property {boolean} _codeMuted - Internal mute tracking var. * @private @@ -39,7 +39,7 @@ Phaser.SoundManager = function (game) { * @default */ this._muted = false; - + /** * @property {Description} _unlockSource - Internal unlock tracking var. * @private @@ -50,12 +50,12 @@ Phaser.SoundManager = function (game) { /** * @property {number} _volume - The global audio volume. A value between 0 (silence) and 1 (full volume). * @private - * @default + * @default */ this._volume = 1; /** - * @property {array} _sounds - An array containing all the sounds + * @property {array} _sounds - An array containing all the sounds * @private * @default The empty array. */ @@ -66,19 +66,19 @@ Phaser.SoundManager = function (game) { * @default */ this.context = null; - + /** * @property {boolean} usingWebAudio - true if this sound is being played with Web Audio. * @readonly */ this.usingWebAudio = true; - + /** * @property {boolean} usingAudioTag - true if the sound is being played via the Audio tag. * @readonly */ this.usingAudioTag = false; - + /** * @property {boolean} noAudio - Has audio been disabled via the PhaserGlobal object? Useful if you need to use a 3rd party audio library instead. * @default @@ -102,7 +102,7 @@ Phaser.SoundManager = function (game) { * @default */ this.channels = 32; - + }; Phaser.SoundManager.prototype = { @@ -268,7 +268,7 @@ Phaser.SoundManager.prototype = { this._sounds[i].resume(); } } - + }, /** @@ -483,7 +483,7 @@ Object.defineProperty(Phaser.SoundManager.prototype, "mute", { * @property {number} volume - Gets or sets the global volume of the SoundManager, a value between 0 and 1. */ Object.defineProperty(Phaser.SoundManager.prototype, "volume", { - + get: function () { if (this.usingWebAudio) @@ -516,7 +516,7 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", { } } } - + } }); diff --git a/src/system/Canvas.js b/src/system/Canvas.js index f5387f0c3..c99fce99e 100644 --- a/src/system/Canvas.js +++ b/src/system/Canvas.js @@ -114,7 +114,7 @@ Phaser.Canvas = { color = color || 'rgb(0,0,0)'; canvas.style.backgroundColor = color; - + return canvas; }, diff --git a/src/system/Device.js b/src/system/Device.js index bfdd9df4d..6761abee7 100644 --- a/src/system/Device.js +++ b/src/system/Device.js @@ -136,7 +136,7 @@ Phaser.Device = function (game) { */ this.css3D = false; - /** + /** * @property {boolean} pointerLock - Is Pointer Lock available? * @default */ @@ -317,7 +317,7 @@ Phaser.Device = function (game) { */ this.iPhone4 = false; - /** + /** * @property {boolean} iPad - Is running on iPad? * @default */ @@ -366,7 +366,7 @@ Phaser.Device = function (game) { this._checkDevice(); this._checkFeatures(); this._checkOS(); - + }; Phaser.Device.prototype = { @@ -452,7 +452,7 @@ Phaser.Device.prototype = { } this.worker = !!window['Worker']; - + if ('ontouchstart' in document.documentElement || (window.navigator.maxTouchPoints && window.navigator.maxTouchPoints > 1)) { this.touch = true; @@ -462,7 +462,7 @@ Phaser.Device.prototype = { { this.mspointer = true; } - + this.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document; this.quirksMode = (document.compatMode === 'CSS1Compat') ? false : true; @@ -618,7 +618,7 @@ Phaser.Device.prototype = { try { if (result = !!audioElement.canPlayType) { - + if (audioElement.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) { this.ogg = true; } @@ -675,7 +675,7 @@ Phaser.Device.prototype = { } navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate; - + if (navigator.vibrate) { this.vibration = true; @@ -711,7 +711,7 @@ Phaser.Device.prototype = { has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]); } } - + document.body.removeChild(el); this.css3D = (has3d !== undefined && has3d.length > 0 && has3d !== "none"); diff --git a/src/system/RequestAnimationFrame.js b/src/system/RequestAnimationFrame.js index c63b95d88..4f6625b9a 100644 --- a/src/system/RequestAnimationFrame.js +++ b/src/system/RequestAnimationFrame.js @@ -7,13 +7,13 @@ /** * Abstracts away the use of RAF or setTimeOut for the core game update loop. * -* @class Phaser.RequestAnimationFrame +* @class Phaser.RequestAnimationFrame * @constructor * @param {Phaser.Game} game - A reference to the currently running game. * @param {boolean} [forceSetTimeOut=false] - Tell Phaser to use setTimeOut even if raf is available. */ Phaser.RequestAnimationFrame = function(game, forceSetTimeOut) { - + if (typeof forceSetTimeOut === 'undefined') { forceSetTimeOut = false; } /** @@ -102,7 +102,7 @@ Phaser.RequestAnimationFrame.prototype = { /** * The update method for the requestAnimationFrame - * @method Phaser.RequestAnimationFrame#updateRAF + * @method Phaser.RequestAnimationFrame#updateRAF */ updateRAF: function () { diff --git a/src/tilemap/Tile.js b/src/tilemap/Tile.js index 3d6f20f16..d2e8943ed 100644 --- a/src/tilemap/Tile.js +++ b/src/tilemap/Tile.js @@ -28,12 +28,12 @@ Phaser.Tile = function (layer, index, x, y, width, height) { * @property {number} index - The index of this tile within the map data corresponding to the tileset. */ this.index = index; - + /** * @property {number} x - The x map coordinate of this tile. */ this.x = x; - + /** * @property {number} y - The y map coordinate of this tile. */ @@ -43,7 +43,7 @@ Phaser.Tile = function (layer, index, x, y, width, height) { * @property {number} x - The x map coordinate of this tile. */ this.worldX = x * width; - + /** * @property {number} y - The y map coordinate of this tile. */ @@ -53,7 +53,7 @@ Phaser.Tile = function (layer, index, x, y, width, height) { * @property {number} width - The width of the tile in pixels. */ this.width = width; - + /** * @property {number} height - The height of the tile in pixels. */ @@ -63,7 +63,7 @@ Phaser.Tile = function (layer, index, x, y, width, height) { * @property {number} width - The width of the tile in pixels. */ this.centerX = Math.abs(width / 2); - + /** * @property {number} height - The height of the tile in pixels. */ @@ -196,7 +196,7 @@ Phaser.Tile.prototype = { /** * Set a callback to be called when this tile is hit by an object. * The callback must true true for collision processing to take place. - * + * * @method Phaser.Tile#setCollisionCallback * @param {function} callback - Callback function. * @param {object} context - Callback will be called within this context. @@ -218,7 +218,7 @@ Phaser.Tile.prototype = { this.collisionCallback = null; this.collisionCallbackContext = null; this.properties = null; - + }, /** @@ -320,7 +320,7 @@ Phaser.Tile.prototype.constructor = Phaser.Tile; * @readonly */ Object.defineProperty(Phaser.Tile.prototype, "collides", { - + get: function () { return (this.collideLeft || this.collideRight || this.collideUp || this.collideDown); } @@ -333,7 +333,7 @@ Object.defineProperty(Phaser.Tile.prototype, "collides", { * @readonly */ Object.defineProperty(Phaser.Tile.prototype, "canCollide", { - + get: function () { return (this.collideLeft || this.collideRight || this.collideUp || this.collideDown || this.collisionCallback); } @@ -346,7 +346,7 @@ Object.defineProperty(Phaser.Tile.prototype, "canCollide", { * @readonly */ Object.defineProperty(Phaser.Tile.prototype, "left", { - + get: function () { return this.worldX; } @@ -359,7 +359,7 @@ Object.defineProperty(Phaser.Tile.prototype, "left", { * @readonly */ Object.defineProperty(Phaser.Tile.prototype, "right", { - + get: function () { return this.worldX + this.width; } @@ -372,7 +372,7 @@ Object.defineProperty(Phaser.Tile.prototype, "right", { * @readonly */ Object.defineProperty(Phaser.Tile.prototype, "top", { - + get: function () { return this.worldY; } @@ -385,7 +385,7 @@ Object.defineProperty(Phaser.Tile.prototype, "top", { * @readonly */ Object.defineProperty(Phaser.Tile.prototype, "bottom", { - + get: function () { return this.worldY + this.height; } diff --git a/src/tilemap/Tilemap.js b/src/tilemap/Tilemap.js index 9b4fea6a6..cf6770013 100644 --- a/src/tilemap/Tilemap.js +++ b/src/tilemap/Tilemap.js @@ -1207,7 +1207,7 @@ Phaser.Tilemap.prototype = { if (typeof x === "undefined") { x = 0; } if (typeof y === "undefined") { y = 0; } - + layer = this.getLayer(layer); if (!tileblock || tileblock.length < 2) diff --git a/src/tilemap/TilemapLayer.js b/src/tilemap/TilemapLayer.js index 84082949b..068acf47c 100644 --- a/src/tilemap/TilemapLayer.js +++ b/src/tilemap/TilemapLayer.js @@ -46,17 +46,17 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) { * @property {CanvasRenderingContext2D} context - The 2d context of the canvas. */ this.context = this.canvas.getContext('2d'); - + /** * @property {PIXI.BaseTexture} baseTexture - Required Pixi var. */ this.baseTexture = new PIXI.BaseTexture(this.canvas); - + /** * @property {PIXI.Texture} texture - Required Pixi var. */ this.texture = new PIXI.Texture(this.baseTexture); - + /** * @property {Phaser.Frame} textureFrame - Dimensions of the renderable area. */ @@ -158,7 +158,7 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) { /** * @property {object} _mc - Local map data and calculation cache. - * @private + * @private */ this._mc = { @@ -187,7 +187,7 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) { /** * @property {array} _results - Local render loop var to help avoid gc spikes. - * @private + * @private */ this._results = []; @@ -208,8 +208,8 @@ Phaser.TilemapLayer.prototype.postUpdate = function () { // console.log('layer pu'); - Phaser.Image.prototype.postUpdate.call(this); - + Phaser.Image.prototype.postUpdate.call(this); + // Stops you being able to auto-scroll the camera if it's not following a sprite this.scrollX = this.game.camera.x * this.scrollFactorX; this.scrollY = this.game.camera.y * this.scrollFactorY; @@ -244,7 +244,7 @@ Phaser.TilemapLayer.prototype.resizeWorld = function () { } /** -* Take an x coordinate that doesn't account for scrollFactorX and 'fix' it +* Take an x coordinate that doesn't account for scrollFactorX and 'fix' it * into a scrolled local space. Used primarily internally * @method Phaser.TilemapLayer#_fixX * @memberof Phaser.TilemapLayer @@ -269,7 +269,7 @@ Phaser.TilemapLayer.prototype._fixX = function(x) { } /** -* Take an x coordinate that _does_ account for scrollFactorX and 'unfix' it +* Take an x coordinate that _does_ account for scrollFactorX and 'unfix' it * back to camera space. Used primarily internally * @method Phaser.TilemapLayer#_unfixX * @memberof Phaser.TilemapLayer @@ -289,7 +289,7 @@ Phaser.TilemapLayer.prototype._unfixX = function(x) { } /** -* Take a y coordinate that doesn't account for scrollFactorY and 'fix' it +* Take a y coordinate that doesn't account for scrollFactorY and 'fix' it * into a scrolled local space. Used primarily internally * @method Phaser.TilemapLayer#_fixY * @memberof Phaser.TilemapLayer @@ -314,7 +314,7 @@ Phaser.TilemapLayer.prototype._fixY = function(y) { } /** -* Take a y coordinate that _does_ account for scrollFactorY and 'unfix' it +* Take a y coordinate that _does_ account for scrollFactorY and 'unfix' it * back to camera space. Used primarily internally * @method Phaser.TilemapLayer#_unfixY * @memberof Phaser.TilemapLayer @@ -594,7 +594,7 @@ Phaser.TilemapLayer.prototype.render = function () { if (this.game.renderType === Phaser.WEBGL) { - // PIXI.updateWebGLTexture(this.baseTexture, renderSession.gl); + // PIXI.updateWebGLTexture(this.baseTexture, renderSession.gl); PIXI.updateWebGLTexture(this.baseTexture, this.game.renderer.gl); } @@ -680,7 +680,7 @@ Phaser.TilemapLayer.prototype.renderDebug = function () { * @property {number} scrollX - Scrolls the map horizontally or returns the current x position. */ Object.defineProperty(Phaser.TilemapLayer.prototype, "scrollX", { - + get: function () { return this._mc.x; }, @@ -690,7 +690,7 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, "scrollX", { if (value !== this._mc.x && value >= 0 && this.layer.widthInPixels > this.width) { this._mc.x = value; - + if (this._mc.x > (this.layer.widthInPixels - this.width)) { this._mc.x = this.layer.widthInPixels - this.width; @@ -720,7 +720,7 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, "scrollX", { * @property {number} scrollY - Scrolls the map vertically or returns the current y position. */ Object.defineProperty(Phaser.TilemapLayer.prototype, "scrollY", { - + get: function () { return this._mc.y; }, @@ -760,7 +760,7 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, "scrollY", { * @property {number} collisionWidth - The width of the collision tiles. */ Object.defineProperty(Phaser.TilemapLayer.prototype, "collisionWidth", { - + get: function () { return this._mc.cw; }, @@ -780,7 +780,7 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, "collisionWidth", { * @property {number} collisionHeight - The height of the collision tiles. */ Object.defineProperty(Phaser.TilemapLayer.prototype, "collisionHeight", { - + get: function () { return this._mc.ch; }, diff --git a/src/tilemap/TilemapParser.js b/src/tilemap/TilemapParser.js index 1f45d8b00..c559a49d6 100644 --- a/src/tilemap/TilemapParser.js +++ b/src/tilemap/TilemapParser.js @@ -368,7 +368,7 @@ Phaser.TilemapParser = { properties: json.layers[i].objects[v].properties }; - + objects[json.layers[i].name].push(object); } else if (json.layers[i].objects[v].polyline) @@ -409,7 +409,7 @@ Phaser.TilemapParser = { for (var i = 0; i < map.tilesets.length; i++) { var set = map.tilesets[i]; - + var x = set.tileMargin; var y = set.tileMargin; diff --git a/src/time/Time.js b/src/time/Time.js index 17ca7b35e..a4a4056ac 100644 --- a/src/time/Time.js +++ b/src/time/Time.js @@ -222,7 +222,7 @@ Phaser.Time.prototype = { { this.time = this.now; this._justResumed = false; - + this.events.resume(); for (var i = 0; i < this._timers.length; i++) @@ -295,7 +295,7 @@ Phaser.Time.prototype = { * @private */ gamePaused: function () { - + this._pauseStarted = this.now; this.events.pause(); diff --git a/src/time/Timer.js b/src/time/Timer.js index f953ffd24..b7806a19e 100644 --- a/src/time/Timer.js +++ b/src/time/Timer.js @@ -427,7 +427,7 @@ Phaser.Timer.prototype = { * @method Phaser.Timer#pause */ pause: function () { - + if (this.running && !this.expired) { this._pauseStarted = this.game.time.now; @@ -444,7 +444,7 @@ Phaser.Timer.prototype = { * @private */ _pause: function () { - + if (this.running && !this.expired) { this._pauseStarted = this.game.time.now; @@ -551,7 +551,7 @@ Object.defineProperty(Phaser.Timer.prototype, "next", { Object.defineProperty(Phaser.Timer.prototype, "duration", { get: function () { - + if (this.running && this.nextTick > this._now) { return this.nextTick - this._now; diff --git a/src/tween/Easing.js b/src/tween/Easing.js index de9ece6b2..753eb4814 100644 --- a/src/tween/Easing.js +++ b/src/tween/Easing.js @@ -23,7 +23,7 @@ Phaser.Easing = { /** * Ease-in. * - * @method Phaser.Easing.Linear#In + * @method Phaser.Easing.Linear#In * @param {number} k - The value to be tweened. * @returns {number} k^2. */ @@ -45,8 +45,8 @@ Phaser.Easing = { /** * Ease-in. * - * @method Phaser.Easing.Quadratic#In - * @param {number} k - The value to be tweened. + * @method Phaser.Easing.Quadratic#In + * @param {number} k - The value to be tweened. * @returns {number} k^2. */ In: function ( k ) { @@ -58,8 +58,8 @@ Phaser.Easing = { /** * Ease-out. * - * @method Phaser.Easing.Quadratic#Out - * @param {number} k - The value to be tweened. + * @method Phaser.Easing.Quadratic#Out + * @param {number} k - The value to be tweened. * @returns {number} k* (2-k). */ Out: function ( k ) { @@ -72,7 +72,7 @@ Phaser.Easing = { * Ease-in/out. * * @method Phaser.Easing.Quadratic#InOut - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ InOut: function ( k ) { @@ -94,8 +94,8 @@ Phaser.Easing = { /** * Cubic ease-in. * - * @method Phaser.Easing.Cubic#In - * @param {number} k - The value to be tweened. + * @method Phaser.Easing.Cubic#In + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ In: function ( k ) { @@ -108,7 +108,7 @@ Phaser.Easing = { * Cubic ease-out. * * @method Phaser.Easing.Cubic#Out - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ Out: function ( k ) { @@ -121,7 +121,7 @@ Phaser.Easing = { * Cubic ease-in/out. * * @method Phaser.Easing.Cubic#InOut - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ InOut: function ( k ) { @@ -143,8 +143,8 @@ Phaser.Easing = { /** * Quartic ease-in. * - * @method Phaser.Easing.Quartic#In - * @param {number} k - The value to be tweened. + * @method Phaser.Easing.Quartic#In + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ In: function ( k ) { @@ -157,7 +157,7 @@ Phaser.Easing = { * Quartic ease-out. * * @method Phaser.Easing.Quartic#Out - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ Out: function ( k ) { @@ -170,7 +170,7 @@ Phaser.Easing = { * Quartic ease-in/out. * * @method Phaser.Easing.Quartic#InOut - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ InOut: function ( k ) { @@ -192,8 +192,8 @@ Phaser.Easing = { /** * Quintic ease-in. * - * @method Phaser.Easing.Quintic#In - * @param {number} k - The value to be tweened. + * @method Phaser.Easing.Quintic#In + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ In: function ( k ) { @@ -206,7 +206,7 @@ Phaser.Easing = { * Quintic ease-out. * * @method Phaser.Easing.Quintic#Out - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ Out: function ( k ) { @@ -219,7 +219,7 @@ Phaser.Easing = { * Quintic ease-in/out. * * @method Phaser.Easing.Quintic#InOut - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ InOut: function ( k ) { @@ -241,8 +241,8 @@ Phaser.Easing = { /** * Sinusoidal ease-in. * - * @method Phaser.Easing.Sinusoidal#In - * @param {number} k - The value to be tweened. + * @method Phaser.Easing.Sinusoidal#In + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ In: function ( k ) { @@ -255,7 +255,7 @@ Phaser.Easing = { * Sinusoidal ease-out. * * @method Phaser.Easing.Sinusoidal#Out - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ Out: function ( k ) { @@ -268,7 +268,7 @@ Phaser.Easing = { * Sinusoidal ease-in/out. * * @method Phaser.Easing.Sinusoidal#InOut - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ InOut: function ( k ) { @@ -289,8 +289,8 @@ Phaser.Easing = { /** * Exponential ease-in. * - * @method Phaser.Easing.Exponential#In - * @param {number} k - The value to be tweened. + * @method Phaser.Easing.Exponential#In + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ In: function ( k ) { @@ -303,7 +303,7 @@ Phaser.Easing = { * Exponential ease-out. * * @method Phaser.Easing.Exponential#Out - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ Out: function ( k ) { @@ -316,7 +316,7 @@ Phaser.Easing = { * Exponential ease-in/out. * * @method Phaser.Easing.Exponential#InOut - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ InOut: function ( k ) { @@ -340,8 +340,8 @@ Phaser.Easing = { /** * Circular ease-in. * - * @method Phaser.Easing.Circular#In - * @param {number} k - The value to be tweened. + * @method Phaser.Easing.Circular#In + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ In: function ( k ) { @@ -354,7 +354,7 @@ Phaser.Easing = { * Circular ease-out. * * @method Phaser.Easing.Circular#Out - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ Out: function ( k ) { @@ -367,7 +367,7 @@ Phaser.Easing = { * Circular ease-in/out. * * @method Phaser.Easing.Circular#InOut - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ InOut: function ( k ) { @@ -389,8 +389,8 @@ Phaser.Easing = { /** * Elastic ease-in. * - * @method Phaser.Easing.Elastic#In - * @param {number} k - The value to be tweened. + * @method Phaser.Easing.Elastic#In + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ In: function ( k ) { @@ -408,7 +408,7 @@ Phaser.Easing = { * Elastic ease-out. * * @method Phaser.Easing.Elastic#Out - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ Out: function ( k ) { @@ -426,7 +426,7 @@ Phaser.Easing = { * Elastic ease-in/out. * * @method Phaser.Easing.Elastic#InOut - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ InOut: function ( k ) { @@ -453,8 +453,8 @@ Phaser.Easing = { /** * Back ease-in. * - * @method Phaser.Easing.Back#In - * @param {number} k - The value to be tweened. + * @method Phaser.Easing.Back#In + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ In: function ( k ) { @@ -468,7 +468,7 @@ Phaser.Easing = { * Back ease-out. * * @method Phaser.Easing.Back#Out - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ Out: function ( k ) { @@ -482,7 +482,7 @@ Phaser.Easing = { * Back ease-in/out. * * @method Phaser.Easing.Back#InOut - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ InOut: function ( k ) { @@ -505,8 +505,8 @@ Phaser.Easing = { /** * Bounce ease-in. * - * @method Phaser.Easing.Bounce#In - * @param {number} k - The value to be tweened. + * @method Phaser.Easing.Bounce#In + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ In: function ( k ) { @@ -519,7 +519,7 @@ Phaser.Easing = { * Bounce ease-out. * * @method Phaser.Easing.Bounce#Out - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ Out: function ( k ) { @@ -548,7 +548,7 @@ Phaser.Easing = { * Bounce ease-in/out. * * @method Phaser.Easing.Bounce#InOut - * @param {number} k - The value to be tweened. + * @param {number} k - The value to be tweened. * @returns {number} The tweened value. */ InOut: function ( k ) { diff --git a/src/tween/Tween.js b/src/tween/Tween.js index 7a210e1ea..b9fa5a02a 100644 --- a/src/tween/Tween.js +++ b/src/tween/Tween.js @@ -125,7 +125,7 @@ Phaser.Tween = function (object, game, manager) { * @default null */ this._onUpdateCallback = null; - + /** * @property {object} _onUpdateCallbackContext - The context in which to call the onUpdate callback. * @private @@ -164,7 +164,7 @@ Phaser.Tween = function (object, game, manager) { // { // this._valuesStart[field] = parseFloat(object[field], 10); // } - + /** * @property {Phaser.Signal} onStart - The onStart event is fired when the Tween begins. */ @@ -476,7 +476,7 @@ Phaser.Tween.prototype = { }, /** - * Set easing function this tween will use, i.e. Phaser.Easing.Linear.None. + * Set easing function this tween will use, i.e. Phaser.Easing.Linear.None. * * @method Phaser.Tween#easing * @param {function} easing - The easing function this tween will use, i.e. Phaser.Easing.Linear.None. @@ -520,7 +520,7 @@ Phaser.Tween.prototype = { /** * Loop a chain of tweens - * + * * Usage: * game.add.tween(p).to({ x: 700 }, 1000, Phaser.Easing.Linear.None, true) * .to({ y: 300 }, 1000, Phaser.Easing.Linear.None) @@ -554,7 +554,7 @@ Phaser.Tween.prototype = { }, /** - * Pauses the tween. + * Pauses the tween. * * @method Phaser.Tween#pause */ @@ -572,7 +572,7 @@ Phaser.Tween.prototype = { * @private */ _pause: function () { - + if (!this._codePaused) { this._paused = true; @@ -737,7 +737,7 @@ Phaser.Tween.prototype = { return true; } - + }; Phaser.Tween.prototype.constructor = Phaser.Tween; diff --git a/src/tween/TweenManager.js b/src/tween/TweenManager.js index b326d23b8..b76c78788 100644 --- a/src/tween/TweenManager.js +++ b/src/tween/TweenManager.js @@ -6,9 +6,9 @@ /** * Phaser - TweenManager -* +* * @class Phaser.TweenManager -* @classdesc +* @classdesc * Phaser.Game has a single instance of the TweenManager through which all Tween objects are created and updated. * Tweens are hooked into the game clock and pause system, adjusting based on the game state. * @@ -26,13 +26,13 @@ Phaser.TweenManager = function (game) { * @property {Phaser.Game} game - Local reference to game. */ this.game = game; - + /** * @property {array} _tweens - All of the currently running tweens. * @private */ this._tweens = []; - + /** * @property {array} _add - All of the tweens queued to be added in the next update. * @private @@ -87,7 +87,7 @@ Phaser.TweenManager.prototype = { }, /** - * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. + * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. * * @method Phaser.TweenManager#create * @param {Object} object - Object the tween will be run on. diff --git a/src/utils/Color.js b/src/utils/Color.js index 83406df71..5d1804c0d 100644 --- a/src/utils/Color.js +++ b/src/utils/Color.js @@ -52,7 +52,7 @@ Phaser.Color = { var hex16 = (h.charAt(0) == "#") ? h.substring(1, 7) : h; - if (hex16.length==3) + if (hex16.length == 3) { hex16 = hex16.charAt(0) + hex16.charAt(0) + hex16.charAt(1) + hex16.charAt(1) + hex16.charAt(2) + hex16.charAt(2); } @@ -62,7 +62,7 @@ Phaser.Color = { var blue = parseInt(hex16.substring(4, 6), 16); return red << 16 | green << 8 | blue; - + }, /** @@ -78,13 +78,13 @@ Phaser.Color = { var argb = Phaser.Color.getRGB(color); var hsl = Phaser.Color.RGBtoHSV(color); - + // Hex format var result = Phaser.Color.RGBtoHexstring(color) + "\n"; - + // RGB format result = result.concat("Alpha: " + argb.alpha + " Red: " + argb.red + " Green: " + argb.green + " Blue: " + argb.blue) + "\n"; - + // HSL info result = result.concat("Hue: " + hsl.hue + " Saturation: " + hsl.saturation + " Lightnes: " + hsl.lightness); @@ -285,7 +285,7 @@ Phaser.Color = { var blue = color & 0xFF; return 'rgba(' + red.toString() + ',' + green.toString() + ',' + blue.toString() + ',' + alpha.toString() + ')'; - + }, /** @@ -347,5 +347,5 @@ Phaser.Color = { getBlue: function (color) { return color & 0xFF; } - + }; diff --git a/src/utils/Debug.js b/src/utils/Debug.js index 2482af038..9216ec3be 100644 --- a/src/utils/Debug.js +++ b/src/utils/Debug.js @@ -20,7 +20,7 @@ Phaser.Utils.Debug = function (game) { * @property {Phaser.Game} game - A reference to the currently running Game. */ this.game = game; - + /** * @property {PIXI.Sprite} sprite - If debugging in WebGL mode we need this. */ @@ -35,7 +35,7 @@ Phaser.Utils.Debug = function (game) { * @property {PIXI.BaseTexture} baseTexture - Required Pixi var. */ this.baseTexture = null; - + /** * @property {PIXI.Texture} texture - Required Pixi var. */ @@ -56,7 +56,7 @@ Phaser.Utils.Debug = function (game) { * @default '14px Courier' */ this.font = '14px Courier'; - + /** * @property {number} columnWidth - The spacing between columns. */ @@ -66,24 +66,24 @@ Phaser.Utils.Debug = function (game) { * @property {number} lineHeight - The line height between the debug text. */ this.lineHeight = 16; - + /** * @property {boolean} renderShadow - Should the text be rendered with a slight shadow? Makes it easier to read on different types of background. */ this.renderShadow = true; - + /** * @property {Context} currentX - The current X position the debug information will be rendered at. * @default */ this.currentX = 0; - + /** * @property {number} currentY - The current Y position the debug information will be rendered at. * @default */ this.currentY = 0; - + /** * @property {number} currentAlpha - The current alpha the debug information will be rendered at. * @default @@ -270,7 +270,7 @@ Phaser.Utils.Debug.prototype = { this.line('Bounds x: ' + camera.bounds.x + ' Y: ' + camera.bounds.y + ' w: ' + camera.bounds.width + ' h: ' + camera.bounds.height); this.line('View x: ' + camera.view.x + ' Y: ' + camera.view.y + ' w: ' + camera.view.width + ' h: ' + camera.view.height); this.stop(); - + }, /** @@ -563,7 +563,7 @@ Phaser.Utils.Debug.prototype = { } this.stop(); - + }, /** diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 95dec9773..733ae8ac1 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -11,7 +11,7 @@ * @static */ Phaser.Utils = { - + /** * Get a unit dimension from a string. * @@ -72,7 +72,7 @@ Phaser.Utils = { } return array; - + }, /** @@ -80,7 +80,7 @@ Phaser.Utils = { * pad = the string to pad it out with (defaults to a space) * dir = 1 (left), 2 (right), 3 (both) * @method Phaser.Utils.pad - * @param {string} str - The target string. + * @param {string} str - The target string. * @param {number} len - The number of characters to be added. * @param {number} pad - The string to pad it out with (defaults to a space). * @param {number} [dir=3] The direction dir = 1 (left), 2 (right), 3 (both). @@ -191,7 +191,7 @@ Phaser.Utils = { --i; } - for ( ; i < length; i++ ) + for (; i < length; i++) { // Only deal with non-null/undefined values if ((options = arguments[i]) != null) @@ -252,17 +252,17 @@ if (typeof Function.prototype.bind != 'function') { return function (thisArg) { var target = this, boundArgs = slice.call(arguments, 1); - + if (typeof target != 'function') { throw new TypeError(); } - + function bound() { var args = boundArgs.concat(slice.call(arguments)); target.apply(this instanceof bound ? this : thisArg, args); } - + bound.prototype = (function F(proto) { proto && (F.prototype = proto); @@ -271,7 +271,7 @@ if (typeof Function.prototype.bind != 'function') { return new F; } })(target.prototype); - + return bound; }; })(); From 89a16399526f60e720bf2f1119f2b66b717cda7a Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sat, 22 Mar 2014 23:31:02 -0700 Subject: [PATCH 06/23] Fix jshint issues in src/tilemap --- src/tilemap/Tilemap.js | 8 ++++---- src/tilemap/TilemapLayer.js | 28 ++++++++++++++-------------- src/tilemap/TilemapParser.js | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/tilemap/Tilemap.js b/src/tilemap/Tilemap.js index cf6770013..550d98c8c 100644 --- a/src/tilemap/Tilemap.js +++ b/src/tilemap/Tilemap.js @@ -177,7 +177,7 @@ Phaser.Tilemap.prototype = { * @param {Phaser.Group} [group] - Optional Group to add the layer to. If not specified it will be added to the World group. * @return {Phaser.TilemapLayer} The TilemapLayer object. This is an extension of Phaser.Image and can be moved around the display list accordingly. */ - create: function (name, width, height, tileWidth, tileHeight) { + create: function (name, width, height, tileWidth, tileHeight, group) { if (typeof group === 'undefined') { group = this.game.world; } @@ -758,7 +758,7 @@ Phaser.Tilemap.prototype = { } } - for (var y = 0; y < this.layers[layer].height ; y++) + for (var y = 0; y < this.layers[layer].height; y++) { for (var x = 0; x < this.layers[layer].width; x++) { @@ -1057,7 +1057,7 @@ Phaser.Tilemap.prototype = { this.layers[layer].dirty = true; this.calculateFaces(layer); - + return this.layers[layer].data[y][x]; } @@ -1180,7 +1180,7 @@ Phaser.Tilemap.prototype = { this._results.length = 0; - this._results.push( { x: x, y: y, width: width, height: height, layer: layer }); + this._results.push({ x: x, y: y, width: width, height: height, layer: layer }); for (var ty = y; ty < y + height; ty++) { diff --git a/src/tilemap/TilemapLayer.js b/src/tilemap/TilemapLayer.js index 068acf47c..23f283583 100644 --- a/src/tilemap/TilemapLayer.js +++ b/src/tilemap/TilemapLayer.js @@ -229,7 +229,7 @@ Phaser.TilemapLayer.prototype.postUpdate = function () { // this.children[i].postUpdate(); // } -} +}; /** * Sets the world size to match the size of this layer. @@ -241,7 +241,7 @@ Phaser.TilemapLayer.prototype.resizeWorld = function () { this.game.world.setBounds(0, 0, this.layer.widthInPixels, this.layer.heightInPixels); -} +}; /** * Take an x coordinate that doesn't account for scrollFactorX and 'fix' it @@ -266,7 +266,7 @@ Phaser.TilemapLayer.prototype._fixX = function(x) { return this._mc.x + (x - (this._mc.x / this.scrollFactorX)); -} +}; /** * Take an x coordinate that _does_ account for scrollFactorX and 'unfix' it @@ -286,7 +286,7 @@ Phaser.TilemapLayer.prototype._unfixX = function(x) { return (this._mc.x / this.scrollFactorX) + (x - this._mc.x); -} +}; /** * Take a y coordinate that doesn't account for scrollFactorY and 'fix' it @@ -311,7 +311,7 @@ Phaser.TilemapLayer.prototype._fixY = function(y) { return this._mc.y + (y - (this._mc.y / this.scrollFactorY)); -} +}; /** * Take a y coordinate that _does_ account for scrollFactorY and 'unfix' it @@ -331,7 +331,7 @@ Phaser.TilemapLayer.prototype._unfixY = function(y) { return (this._mc.y / this.scrollFactorY) + (y - this._mc.y); -} +}; /** * Convert a pixel value to a tile coordinate. @@ -346,7 +346,7 @@ Phaser.TilemapLayer.prototype.getTileX = function (x) { return this.game.math.snapToFloor(this._fixX(x), this.map.tileWidth) / this.map.tileWidth; -} +}; /** * Convert a pixel value to a tile coordinate. @@ -361,7 +361,7 @@ Phaser.TilemapLayer.prototype.getTileY = function (y) { return this.game.math.snapToFloor(this._fixY(y), this.map.tileHeight) / this.map.tileHeight; -} +}; /** * Convert a pixel value to a tile coordinate. @@ -379,7 +379,7 @@ Phaser.TilemapLayer.prototype.getTileXY = function (x, y, point) { return point; -} +}; /** * Gets all tiles that intersect with the given line. @@ -425,7 +425,7 @@ Phaser.TilemapLayer.prototype.getRayCastTiles = function (line, stepRate, collid return results; -} +}; /** * Get all tiles that exist within the given area, defined by the top-left corner, width and height. Values given are in pixels, not tiles. @@ -484,7 +484,7 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides return this._results; -} +}; /** * Internal function to update maximum values. @@ -511,7 +511,7 @@ Phaser.TilemapLayer.prototype.updateMax = function () { this.dirty = true; -} +}; /** * Renders the tiles to the layer canvas and pushes to the display. @@ -603,7 +603,7 @@ Phaser.TilemapLayer.prototype.render = function () { return true; -} +}; /** * Renders a collision debug overlay on-top of the canvas. Called automatically by render when debug = true. @@ -673,7 +673,7 @@ Phaser.TilemapLayer.prototype.renderDebug = function () { } -} +}; /** * @name Phaser.TilemapLayer#scrollX diff --git a/src/tilemap/TilemapParser.js b/src/tilemap/TilemapParser.js index c559a49d6..4d48631df 100644 --- a/src/tilemap/TilemapParser.js +++ b/src/tilemap/TilemapParser.js @@ -454,4 +454,4 @@ Phaser.TilemapParser = { } -} +}; From 0b08877f7673be71ca995b82cea85b7794bfca70 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 01:26:06 -0700 Subject: [PATCH 07/23] Fix jshint issues in src/particles/arcade --- src/particles/arcade/ArcadeParticles.js | 2 +- src/particles/arcade/Emitter.js | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/particles/arcade/ArcadeParticles.js b/src/particles/arcade/ArcadeParticles.js index 29202324e..cc3241b82 100644 --- a/src/particles/arcade/ArcadeParticles.js +++ b/src/particles/arcade/ArcadeParticles.js @@ -1 +1 @@ -Phaser.Particles.Arcade = {} +Phaser.Particles.Arcade = {}; diff --git a/src/particles/arcade/Emitter.js b/src/particles/arcade/Emitter.js index 772005866..fffce8143 100644 --- a/src/particles/arcade/Emitter.js +++ b/src/particles/arcade/Emitter.js @@ -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 From 5f267baeb058d8826bb737648c2eda28d790f3a0 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 01:31:39 -0700 Subject: [PATCH 08/23] Fix jshint issues in src/physics/arcade --- src/physics/arcade/Body.js | 4 ++-- src/physics/arcade/World.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index a98232508..18d02656b 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -747,7 +747,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. @@ -768,6 +768,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; diff --git a/src/physics/arcade/World.js b/src/physics/arcade/World.js index 93d4b98e6..f6582995d 100644 --- a/src/physics/arcade/World.js +++ b/src/physics/arcade/World.js @@ -1280,7 +1280,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) { From b375daa3f6d7c56e2f8ff5266b61c976b1f7374b Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sat, 22 Mar 2014 23:31:41 -0700 Subject: [PATCH 09/23] Fix jshint issues in src/physics/ninja --- src/physics/ninja/AABB.js | 13 +- src/physics/ninja/Circle.js | 265 ++++++++++++++++++------------------ src/physics/ninja/Tile.js | 6 +- src/physics/ninja/World.js | 9 +- 4 files changed, 141 insertions(+), 152 deletions(-) diff --git a/src/physics/ninja/AABB.js b/src/physics/ninja/AABB.js index 262f59c17..4c833f1c1 100644 --- a/src/physics/ninja/AABB.js +++ b/src/physics/ninja/AABB.js @@ -1,3 +1,4 @@ +/* jshint camelcase: false */ /** * @author Richard Davey * @copyright 2014 Photon Storm Ltd. @@ -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) @@ -1014,4 +1005,4 @@ Phaser.Physics.Ninja.AABB.prototype = { this.system = null; } -} +}; diff --git a/src/physics/ninja/Circle.js b/src/physics/ninja/Circle.js index 3f9aee118..ba3b8f8c3 100644 --- a/src/physics/ninja/Circle.js +++ b/src/physics/ninja/Circle.js @@ -1,3 +1,4 @@ +/* jshint camelcase: false */ /** * @author Richard Davey * @copyright 2014 Photon Storm Ltd. @@ -99,7 +100,7 @@ Phaser.Physics.Ninja.Circle = function (body, x, y, radius) { this.circleTileProjections[Phaser.Physics.Ninja.Tile.TYPE_67DEGb] = this.projCircle_67DegB; this.circleTileProjections[Phaser.Physics.Ninja.Tile.TYPE_HALF] = this.projCircle_Half; -} +}; Phaser.Physics.Ninja.Circle.prototype.constructor = Phaser.Physics.Ninja.Circle; @@ -352,9 +353,9 @@ Phaser.Physics.Ninja.Circle.prototype = { //if we're colliding vs. horiz. or vert. neighb, we simply project horiz/vert //if we're colliding diagonally, we need to collide vs. tile corner - if (oH == 0) + if (oH === 0) { - if (oV == 0) + if (oV === 0) { //collision with current cell if (x < y) @@ -362,7 +363,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //penetration in x is smaller; project in x var dx = obj.pos.x - t.pos.x;//get sign for projection along x-axis - //NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?) + //NOTE: should we handle the delta === 0 case?! and how? (project towards oldpos?) if (dx < 0) { obj.reportCollisionVsWorld(-x, 0, -1, 0, t); @@ -379,7 +380,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //penetration in y is smaller; project in y var dy = obj.pos.y - t.pos.y;//get sign for projection along y-axis - //NOTE: should we handle the delta == 0 case?! and how? (project towards oldpos?) + //NOTE: should we handle the delta === 0 case?! and how? (project towards oldpos?) if (dy < 0) { obj.reportCollisionVsWorld(0, -y, 0, -1, t); @@ -400,7 +401,7 @@ Phaser.Physics.Ninja.Circle.prototype = { return Phaser.Physics.Ninja.Circle.COL_AXIS; } } - else if (oV == 0) + else if (oV === 0) { //collision with horizontal neighbor obj.reportCollisionVsWorld(x * oH, 0, oH, 0, t); @@ -423,7 +424,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if (0 < pen) { //vertex is in the circle; project outward - if (len == 0) + if (len === 0) { //project out by 45deg dx = oH / Math.SQRT2; @@ -470,9 +471,9 @@ Phaser.Physics.Ninja.Circle.prototype = { var signy = t.signy; var lenP; - if (oH == 0) + if (oH === 0) { - if (oV == 0) + if (oV === 0) { //colliding with current tile @@ -599,7 +600,7 @@ Phaser.Physics.Ninja.Circle.prototype = { } } } - else if (oV == 0) + else if (oV === 0) { //colliding horizontally if ((signx * oH) < 0) @@ -692,7 +693,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if (0 < pen) { //vertex is in the circle; project outward - if (len == 0) + if (len === 0) { //project out by 45deg dx = oH / Math.SQRT2; @@ -740,9 +741,9 @@ Phaser.Physics.Ninja.Circle.prototype = { var signy = t.signy; var lenP; - if (oH == 0) + if (oH === 0) { - if (oV == 0) + if (oV === 0) { //colliding with current tile @@ -836,7 +837,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if (0 < pen) { //vertex is in the circle; project outward - if (len == 0) + if (len === 0) { //project out vertically dx = 0; @@ -855,7 +856,7 @@ Phaser.Physics.Ninja.Circle.prototype = { } } } - else if (oV == 0) + else if (oV === 0) { //colliding horizontally if ((signx * oH) < 0) @@ -881,7 +882,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if (0 < pen) { //vertex is in the circle; project outward - if (len == 0) + if (len === 0) { //project out horizontally dx = oH; @@ -924,7 +925,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if (0 < pen) { //vertex is in the circle; project outward - if (len == 0) + if (len === 0) { //project out by 45deg dx = oH / Math.SQRT2; @@ -974,9 +975,9 @@ Phaser.Physics.Ninja.Circle.prototype = { var signy = t.signy; var lenP; - if (oH == 0) + if (oH === 0) { - if (oV == 0) + if (oV === 0) { //colliding with current tile @@ -1028,7 +1029,7 @@ Phaser.Physics.Ninja.Circle.prototype = { } else { - //note: len should NEVER be == 0, because if it is, + //note: len should NEVER be === 0, because if it is, //projeciton by an axis shoudl always be shorter, and we should //never arrive here ox /= len; @@ -1069,7 +1070,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if (0 < pen) { - //note: len should NEVER be == 0, because if it is, + //note: len should NEVER be === 0, because if it is, //obj is not in a neighboring cell! ox /= len; oy /= len; @@ -1081,7 +1082,7 @@ Phaser.Physics.Ninja.Circle.prototype = { } } } - else if (oV == 0) + else if (oV === 0) { //colliding horizontally if ((signx * oH) < 0) @@ -1109,7 +1110,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if (0 < pen) { - //note: len should NEVER be == 0, because if it is, + //note: len should NEVER be === 0, because if it is, //obj is not in a neighboring cell! ox /= len; oy /= len; @@ -1141,7 +1142,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if (0 < pen) { - //note: len should NEVER be == 0, because if it is, + //note: len should NEVER be === 0, because if it is, //obj is not in a neighboring cell! ox /= len; oy /= len; @@ -1166,7 +1167,7 @@ Phaser.Physics.Ninja.Circle.prototype = { if (0 < pen) { //vertex is in the circle; project outward - if (len == 0) + if (len === 0) { //project out by 45deg dx = oH / Math.SQRT2; @@ -1221,14 +1222,14 @@ Phaser.Physics.Ninja.Circle.prototype = { var signy = t.signy; var celldp = (oH*signx + oV*signy);//this tells us about the configuration of cell-offset relative to tile normal - if(0 < celldp) + if (0 < celldp) { //obj is in "far" (pointed-at-by-normal) neighbor of halffull tile, and will never hit return Phaser.Physics.Ninja.Circle.COL_NONE; } - else if(oH == 0) + else if (oH === 0) { - if(oV == 0) + if (oV === 0) { //colliding with current tile var r = obj.radius; @@ -1244,7 +1245,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //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); - if(dp < 0) + if (dp < 0) { //collision; project delta onto slope and use this to displace the object sx *= -dp;//(sx,sy) is now the projection vector @@ -1254,7 +1255,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var lenN = Math.sqrt(sx*sx + sy*sy); var lenP = Math.sqrt(x*x + y*y); - if(lenP < lenN) + if (lenP < lenN) { obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP,t); @@ -1274,15 +1275,14 @@ Phaser.Physics.Ninja.Circle.prototype = { { //colliding vertically - if(celldp == 0) + if (celldp === 0) { - var r = obj.radius; var dx = obj.pos.x - t.pos.x; //we're in a cell perpendicular to the normal, and can collide vs. halfedge vertex //or halfedge side - if((dx*signx) < 0) + if ((dx*signx) < 0) { //collision with halfedge side obj.reportCollisionVsWorld(0,y*oV,0,oV,t); @@ -1296,10 +1296,10 @@ Phaser.Physics.Ninja.Circle.prototype = { var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //vertex is in the circle; project outward - if(len == 0) + if (len === 0) { //project out by 45deg dx = signx / Math.SQRT2; @@ -1330,18 +1330,17 @@ Phaser.Physics.Ninja.Circle.prototype = { } } - else if(oV == 0) + else if (oV === 0) { //colliding horizontally - if(celldp == 0) + if (celldp === 0) { - var r = obj.radius; var dy = obj.pos.y - t.pos.y; //we're in a cell perpendicular to the normal, and can collide vs. halfedge vertex //or halfedge side - if((dy*signy) < 0) + if ((dy*signy) < 0) { //collision with halfedge side obj.reportCollisionVsWorld(x*oH,0,oH,0,t); @@ -1355,10 +1354,10 @@ Phaser.Physics.Ninja.Circle.prototype = { var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //vertex is in the circle; project outward - if(len == 0) + if (len === 0) { //project out by 45deg dx = signx / Math.SQRT2; @@ -1401,10 +1400,10 @@ Phaser.Physics.Ninja.Circle.prototype = { var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //vertex is in the circle; project outward - if(len == 0) + if (len === 0) { //project out by 45deg dx = oH / Math.SQRT2; @@ -1449,22 +1448,23 @@ Phaser.Physics.Ninja.Circle.prototype = { //if obj is in this tile: collide vs slope or vertex //if obj is horiz neighb in direction of slope: collide vs. slope or vertex //if obj is horiz neighb against the slope: - // if(distance in y from circle to 90deg corner of tile < 1/2 tileheight, collide vs. face) + // if (distance in y from circle to 90deg corner of tile < 1/2 tileheight, collide vs. face) // else(collide vs. corner of slope) (vert collision with a non-grid-aligned vert) //if obj is vert neighb against direction of slope: collide vs. face + var lenP; var signx = t.signx; var signy = t.signy; - if(0 < (signy*oV)) + if (0 < (signy*oV)) { //object will never collide vs tile, it can't reach that far return Phaser.Physics.Ninja.Circle.COL_NONE; } - else if(oH == 0) + else if (oH === 0) { - if(oV == 0) + if (oV === 0) { //colliding with current tile //we could only be colliding vs the slope OR a vertex @@ -1484,12 +1484,12 @@ Phaser.Physics.Ninja.Circle.prototype = { //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); - if(0 < (perp*signx*signy)) + if (0 < (perp*signx*signy)) { //collide vs. vertex var len = Math.sqrt(ox*ox + oy*oy); var pen = r - len; - if(0 < pen) + if (0 < pen) { //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0 ox /= len; @@ -1510,7 +1510,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy) var dp = (ox*sx) + (oy*sy); - if(dp < 0) + if (dp < 0) { //collision; project delta onto slope and use this to displace the object sx *= -dp;//(sx,sy) is now the projection vector @@ -1519,13 +1519,13 @@ Phaser.Physics.Ninja.Circle.prototype = { var lenN = Math.sqrt(sx*sx + sy*sy); //find the smallest axial projection vector - if(x < y) + if (x < y) { //penetration in x is smaller lenP = x; y = 0; //get sign for projection along x-axis - if((obj.pos.x - t.pos.x) < 0) + if ((obj.pos.x - t.pos.x) < 0) { x *= -1; } @@ -1536,13 +1536,13 @@ Phaser.Physics.Ninja.Circle.prototype = { lenP = y; x = 0; //get sign for projection along y-axis - if((obj.pos.y - t.pos.y)< 0) + if ((obj.pos.y - t.pos.y)< 0) { y *= -1; } } - if(lenP < lenN) + if (lenP < lenN) { obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t); @@ -1569,10 +1569,10 @@ Phaser.Physics.Ninja.Circle.prototype = { return Phaser.Physics.Ninja.Circle.COL_AXIS; } } - else if(oV == 0) + else if (oV === 0) { //colliding horizontally - if((signx*oH) < 0) + if ((signx*oH) < 0) { //colliding with face/edge OR with corner of wedge, depending on our position vertically @@ -1584,7 +1584,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; - if((dy*signy) < 0) + if ((dy*signy) < 0) { //colliding vs face obj.reportCollisionVsWorld(x*oH, 0, oH, 0, t); @@ -1597,10 +1597,10 @@ Phaser.Physics.Ninja.Circle.prototype = { var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //vertex is in the circle; project outward - if(len == 0) + if (len === 0) { //project out by 45deg dx = oH / Math.SQRT2; @@ -1640,12 +1640,12 @@ Phaser.Physics.Ninja.Circle.prototype = { //note that this is simply a VERY tricky/weird method of determining //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); - if((perp*signx*signy) < 0) + if ((perp*signx*signy) < 0) { //collide vs. vertex var len = Math.sqrt(ox*ox + oy*oy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0 ox /= len; @@ -1667,7 +1667,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var dp = (ox*sx) + (oy*sy); var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case.. - if(0 < pen) + if (0 < pen) { //collision; circle out along normal by penetration amount obj.reportCollisionVsWorld(sx*pen, sy*pen, sx, sy, t); @@ -1693,10 +1693,10 @@ Phaser.Physics.Ninja.Circle.prototype = { var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //vertex is in the circle; project outward - if(len == 0) + if (len === 0) { //project out by 45deg dx = oH / Math.SQRT2; @@ -1744,12 +1744,13 @@ Phaser.Physics.Ninja.Circle.prototype = { // //if obj is vert neighb in direction of slope: collide vs. slope or vertex + var lenP; var signx = t.signx; var signy = t.signy; - if(oH == 0) + if (oH === 0) { - if(oV == 0) + if (oV === 0) { //colliding with current cell @@ -1764,7 +1765,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy) var dp = (ox*sx) + (oy*sy); - if(dp < 0) + if (dp < 0) { //collision; project delta onto slope and use this to displace the object sx *= -dp;//(sx,sy) is now the projection vector @@ -1773,13 +1774,13 @@ Phaser.Physics.Ninja.Circle.prototype = { var lenN = Math.sqrt(sx*sx + sy*sy); //find the smallest axial projection vector - if(x < y) + if (x < y) { //penetration in x is smaller lenP = x; y = 0; //get sign for projection along x-axis - if((obj.pos.x - t.pos.x) < 0) + if ((obj.pos.x - t.pos.x) < 0) { x *= -1; } @@ -1790,13 +1791,13 @@ Phaser.Physics.Ninja.Circle.prototype = { lenP = y; x = 0; //get sign for projection along y-axis - if((obj.pos.y - t.pos.y)< 0) + if ((obj.pos.y - t.pos.y)< 0) { y *= -1; } } - if(lenP < lenN) + if (lenP < lenN) { obj.reportCollisionVsWorld(x, y, x/lenP, y/lenP, t); @@ -1814,7 +1815,7 @@ Phaser.Physics.Ninja.Circle.prototype = { { //colliding vertically - if((signy*oV) < 0) + if ((signy*oV) < 0) { //colliding with face/edge obj.reportCollisionVsWorld(0, y*oV, 0, oV, t); @@ -1838,12 +1839,12 @@ Phaser.Physics.Ninja.Circle.prototype = { //note that this is simply a VERY tricky/weird method of determining //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); - if(0 < (perp*signx*signy)) + if (0 < (perp*signx*signy)) { //collide vs. vertex var len = Math.sqrt(ox*ox + oy*oy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0 ox /= len; @@ -1864,7 +1865,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //because we know the circle is in a neighboring cell var dp = (ox*sx) + (oy*sy); var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case.. - if(0 < pen) + if (0 < pen) { //collision; circle out along normal by penetration amount obj.reportCollisionVsWorld(sx*pen, sy*pen,sx, sy, t); @@ -1875,11 +1876,11 @@ Phaser.Physics.Ninja.Circle.prototype = { } } } - else if(oV == 0) + else if (oV === 0) { //colliding horizontally - if((signx*oH) < 0) + if ((signx*oH) < 0) { //colliding with face/edge obj.reportCollisionVsWorld(x*oH, 0, oH, 0, t); @@ -1893,7 +1894,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var ox = obj.pos.x - (t.pos.x + (signx*t.xw));//this gives is the coordinates of the innermost var oy = obj.pos.y - t.pos.y;//point on the circle, relative to the closest tile vert - if((oy*signy) < 0) + if ((oy*signy) < 0) { //we're colliding with the halfface obj.reportCollisionVsWorld(x*oH, 0, oH, 0, t); @@ -1913,12 +1914,12 @@ Phaser.Physics.Ninja.Circle.prototype = { //note that this is simply a VERY tricky/weird method of determining //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); - if((perp*signx*signy) < 0) + if ((perp*signx*signy) < 0) { //collide vs. vertex var len = Math.sqrt(ox*ox + oy*oy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0 ox /= len; @@ -1939,7 +1940,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //because we know the circle is in a neighboring cell var dp = (ox*sx) + (oy*sy); var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case.. - if(0 < pen) + if (0 < pen) { //collision; circle out along normal by penetration amount obj.reportCollisionVsWorld(sx*pen, sy*pen, t.sx, t.sy, t); @@ -1953,7 +1954,7 @@ Phaser.Physics.Ninja.Circle.prototype = { else { //colliding diagonally - if( 0 < ((signx*oH) + (signy*oV)) ) + if ( 0 < ((signx*oH) + (signy*oV)) ) { //the dotprod of slope normal and cell offset is strictly positive, //therefore obj is in the diagonal neighb pointed at by the normal. @@ -1973,7 +1974,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy) var dp = (ox*sx) + (oy*sy); - if(dp < 0) + if (dp < 0) { //collision; project delta onto slope and use this to displace the object //(sx,sy)*-dp is the projection vector @@ -1994,10 +1995,10 @@ Phaser.Physics.Ninja.Circle.prototype = { var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //vertex is in the circle; project outward - if(len == 0) + if (len === 0) { //project out by 45deg dx = oH / Math.SQRT2; @@ -2042,27 +2043,28 @@ Phaser.Physics.Ninja.Circle.prototype = { //if obj is in this tile: collide vs slope or vertex or axis //if obj is vert neighb in direction of slope: collide vs. slope or vertex //if obj is vert neighb against the slope: - // if(distance in y from circle to 90deg corner of tile < 1/2 tileheight, collide vs. face) + // if (distance in y from circle to 90deg corner of tile < 1/2 tileheight, collide vs. face) // else(collide vs. corner of slope) (vert collision with a non-grid-aligned vert) //if obj is horiz neighb against direction of slope: collide vs. face var signx = t.signx; var signy = t.signy; - if(0 < (signx*oH)) + if (0 < (signx*oH)) { //object will never collide vs tile, it can't reach that far return Phaser.Physics.Ninja.Circle.COL_NONE; } - else if(oH == 0) + else if (oH === 0) { - if(oV == 0) + if (oV === 0) { //colliding with current tile //we could only be colliding vs the slope OR a vertex //look at the vector form the closest vert to the circle to decide + var lenP; var sx = t.sx; var sy = t.sy; @@ -2077,12 +2079,12 @@ Phaser.Physics.Ninja.Circle.prototype = { //if the circle is in side the slope/face's voronoi region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); - if((perp*signx*signy) < 0) + if ((perp*signx*signy) < 0) { //collide vs. vertex var len = Math.sqrt(ox*ox + oy*oy); var pen = r - len; - if(0 < pen) + if (0 < pen) { //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0 ox /= len; @@ -2102,7 +2104,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy) var dp = (ox*sx) + (oy*sy); - if(dp < 0) + if (dp < 0) { //collision; project delta onto slope and use this to displace the object sx *= -dp;//(sx,sy) is now the projection vector @@ -2111,13 +2113,13 @@ Phaser.Physics.Ninja.Circle.prototype = { var lenN = Math.sqrt(sx*sx + sy*sy); //find the smallest axial projection vector - if(x < y) + if (x < y) { //penetration in x is smaller lenP = x; y = 0; //get sign for projection along x-axis - if((obj.pos.x - t.pos.x) < 0) + if ((obj.pos.x - t.pos.x) < 0) { x *= -1; } @@ -2128,17 +2130,17 @@ Phaser.Physics.Ninja.Circle.prototype = { lenP = y; x = 0; //get sign for projection along y-axis - if((obj.pos.y - t.pos.y)< 0) + if ((obj.pos.y - t.pos.y)< 0) { y *= -1; } } - if(lenP < lenN) + if (lenP < lenN) { obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t); - return Phaser.Physics.Ninja.Circle.COL_AXIS + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else { @@ -2154,7 +2156,7 @@ Phaser.Physics.Ninja.Circle.prototype = { { //colliding vertically - if((signy*oV) < 0) + if ((signy*oV) < 0) { //colliding with face/edge OR with corner of wedge, depending on our position vertically @@ -2166,7 +2168,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var dx = obj.pos.x - vx;//calc vert->circle vector var dy = obj.pos.y - vy; - if((dx*signx) < 0) + if ((dx*signx) < 0) { //colliding vs face obj.reportCollisionVsWorld(0, y*oV, 0, oV, t); @@ -2179,10 +2181,10 @@ Phaser.Physics.Ninja.Circle.prototype = { var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //vertex is in the circle; project outward - if(len == 0) + if (len === 0) { //project out by 45deg dx = oH / Math.SQRT2; @@ -2217,12 +2219,12 @@ Phaser.Physics.Ninja.Circle.prototype = { //note that this is simply a VERY tricky/weird method of determining //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); - if(0 < (perp*signx*signy)) + if (0 < (perp*signx*signy)) { //collide vs. vertex var len = Math.sqrt(ox*ox + oy*oy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0 ox /= len; @@ -2244,7 +2246,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var dp = (ox*sx) + (oy*sy); var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case.. - if(0 < pen) + if (0 < pen) { //collision; circle out along normal by penetration amount obj.reportCollisionVsWorld(sx*pen, sy*pen, t.sx, t.sy, t); @@ -2255,14 +2257,14 @@ Phaser.Physics.Ninja.Circle.prototype = { } } } - else if(oV == 0) + else if (oV === 0) { //colliding horizontally; we can assume that (signy*oV) < 0 //due to the first conditional far above - obj.reportCollisionVsWorld(x*oH, 0, oH, 0, t); + obj.reportCollisionVsWorld(x*oH, 0, oH, 0, t); - return Phaser.Physics.Ninja.Circle.COL_AXIS; + return Phaser.Physics.Ninja.Circle.COL_AXIS; } else { @@ -2279,10 +2281,10 @@ Phaser.Physics.Ninja.Circle.prototype = { var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //vertex is in the circle; project outward - if(len == 0) + if (len === 0) { //project out by 45deg dx = oH / Math.SQRT2; @@ -2333,12 +2335,13 @@ Phaser.Physics.Ninja.Circle.prototype = { var signx = t.signx; var signy = t.signy; - if(oH == 0) + if (oH === 0) { - if(oV == 0) + if (oV === 0) { //colliding with current cell + var lenP; var sx = t.sx; var sy = t.sy; @@ -2350,7 +2353,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy) var dp = (ox*sx) + (oy*sy); - if(dp < 0) + if (dp < 0) { //collision; project delta onto slope and use this to displace the object sx *= -dp;//(sx,sy) is now the projection vector @@ -2359,13 +2362,13 @@ Phaser.Physics.Ninja.Circle.prototype = { var lenN = Math.sqrt(sx*sx + sy*sy); //find the smallest axial projection vector - if(x < y) + if (x < y) { //penetration in x is smaller lenP = x; y = 0; //get sign for projection along x-axis - if((obj.pos.x - t.pos.x) < 0) + if ((obj.pos.x - t.pos.x) < 0) { x *= -1; } @@ -2376,13 +2379,13 @@ Phaser.Physics.Ninja.Circle.prototype = { lenP = y; x = 0; //get sign for projection along y-axis - if((obj.pos.y - t.pos.y)< 0) + if ((obj.pos.y - t.pos.y)< 0) { y *= -1; } } - if(lenP < lenN) + if (lenP < lenN) { obj.reportCollisionVsWorld(x,y,x/lenP, y/lenP, t); @@ -2401,7 +2404,7 @@ Phaser.Physics.Ninja.Circle.prototype = { { //colliding vertically - if((signy*oV) < 0) + if ((signy*oV) < 0) { //colliding with face/edge obj.reportCollisionVsWorld(0, y*oV, 0, oV, t); @@ -2415,7 +2418,7 @@ Phaser.Physics.Ninja.Circle.prototype = { var ox = obj.pos.x - t.pos.x;//this gives is the coordinates of the innermost var oy = obj.pos.y - (t.pos.y + (signy*t.yw));//point on the circle, relative to the closest tile vert - if((ox*signx) < 0) + if ((ox*signx) < 0) { //we're colliding with the halfface obj.reportCollisionVsWorld(0, y*oV, 0, oV, t); @@ -2435,12 +2438,12 @@ Phaser.Physics.Ninja.Circle.prototype = { //note that this is simply a VERY tricky/weird method of determining //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); - if(0 < (perp*signx*signy)) + if (0 < (perp*signx*signy)) { //collide vs. vertex var len = Math.sqrt(ox*ox + oy*oy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0 ox /= len; @@ -2461,7 +2464,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //because we know the circle is in a neighboring cell var dp = (ox*sx) + (oy*sy); var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case.. - if(0 < pen) + if (0 < pen) { //collision; circle out along normal by penetration amount obj.reportCollisionVsWorld(sx*pen, sy*pen, sx, sy, t); @@ -2473,11 +2476,11 @@ Phaser.Physics.Ninja.Circle.prototype = { } } } - else if(oV == 0) + else if (oV === 0) { //colliding horizontally - if((signx*oH) < 0) + if ((signx*oH) < 0) { //colliding with face/edge obj.reportCollisionVsWorld(x*oH, 0, oH, 0, t); @@ -2502,12 +2505,12 @@ Phaser.Physics.Ninja.Circle.prototype = { //note that this is simply a VERY tricky/weird method of determining //if the circle is in side the slope/face's voronio region, or that of the vertex. var perp = (ox*-sy) + (oy*sx); - if((perp*signx*signy) < 0) + if ((perp*signx*signy) < 0) { //collide vs. vertex var len = Math.sqrt(ox*ox + oy*oy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //note: if len=0, then perp=0 and we'll never reach here, so don't worry about div-by-0 ox /= len; @@ -2528,7 +2531,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //because we know the circle is in a neighboring cell var dp = (ox*sx) + (oy*sy); var pen = obj.radius - Math.abs(dp);//note: we don't need the abs because we know the dp will be positive, but just in case.. - if(0 < pen) + if (0 < pen) { //collision; circle out along normal by penetration amount obj.reportCollisionVsWorld(sx*pen, sy*pen, t.sx, t.sy, t); @@ -2541,7 +2544,7 @@ Phaser.Physics.Ninja.Circle.prototype = { else { //colliding diagonally - if( 0 < ((signx*oH) + (signy*oV)) ) + if ( 0 < ((signx*oH) + (signy*oV)) ) { //the dotprod of slope normal and cell offset is strictly positive, //therefore obj is in the diagonal neighb pointed at by the normal. @@ -2559,7 +2562,7 @@ Phaser.Physics.Ninja.Circle.prototype = { //and we need toproject it out by the magnitude of the projection of (ox,oy) onto (sx,sy) var dp = (ox*sx) + (oy*sy); - if(dp < 0) + if (dp < 0) { //collision; project delta onto slope and use this to displace the object //(sx,sy)*-dp is the projection vector @@ -2582,10 +2585,10 @@ Phaser.Physics.Ninja.Circle.prototype = { var len = Math.sqrt(dx*dx + dy*dy); var pen = obj.radius - len; - if(0 < pen) + if (0 < pen) { //vertex is in the circle; project outward - if(len == 0) + if (len === 0) { //project out by 45deg dx = oH / Math.SQRT2; @@ -2618,4 +2621,4 @@ Phaser.Physics.Ninja.Circle.prototype = { this.system = null; } -} +}; diff --git a/src/physics/ninja/Tile.js b/src/physics/ninja/Tile.js index 6da2c90f7..4d1609a90 100644 --- a/src/physics/ninja/Tile.js +++ b/src/physics/ninja/Tile.js @@ -1,3 +1,4 @@ +/* jshint camelcase: false */ /** * @author Richard Davey * @copyright 2014 Photon Storm Ltd. @@ -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; @@ -665,7 +665,7 @@ Phaser.Physics.Ninja.Tile.prototype = { } } -} +}; /** * @name Phaser.Physics.Ninja.Tile#x diff --git a/src/physics/ninja/World.js b/src/physics/ninja/World.js index 3ed240d94..6a2ab0176 100644 --- a/src/physics/ninja/World.js +++ b/src/physics/ninja/World.js @@ -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) { From 1c286c1ae5676d17a8adede35fcb84fadde00fe9 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sat, 22 Mar 2014 23:31:26 -0700 Subject: [PATCH 10/23] Fix jshint issues in src/physics/p2 --- src/physics/p2/Body.js | 32 +++++++++++++-------------- src/physics/p2/BodyDebug.js | 16 +++++++------- src/physics/p2/CollisionGroup.js | 2 +- src/physics/p2/ContactMaterial.js | 2 +- src/physics/p2/DistanceConstraint.js | 2 +- src/physics/p2/GearConstraint.js | 2 +- src/physics/p2/LockConstraint.js | 2 +- src/physics/p2/Material.js | 2 +- src/physics/p2/PrismaticConstraint.js | 2 +- src/physics/p2/RevoluteConstraint.js | 2 +- src/physics/p2/Spring.js | 2 +- src/physics/p2/World.js | 14 ++++++------ 12 files changed, 39 insertions(+), 41 deletions(-) diff --git a/src/physics/p2/Body.js b/src/physics/p2/Body.js index 4bab0531e..6710aa54c 100644 --- a/src/physics/p2/Body.js +++ b/src/physics/p2/Body.js @@ -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; @@ -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(); } @@ -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) @@ -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) { diff --git a/src/physics/p2/BodyDebug.js b/src/physics/p2/BodyDebug.js index 535a26482..85281d048 100644 --- a/src/physics/p2/BodyDebug.js +++ b/src/physics/p2/BodyDebug.js @@ -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, { @@ -106,7 +106,7 @@ 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; @@ -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++; } } @@ -424,4 +424,4 @@ Phaser.Utils.extend(Phaser.Physics.P2.BodyDebug.prototype, { } -}) +}); diff --git a/src/physics/p2/CollisionGroup.js b/src/physics/p2/CollisionGroup.js index f4270d3c4..8101915c4 100644 --- a/src/physics/p2/CollisionGroup.js +++ b/src/physics/p2/CollisionGroup.js @@ -18,4 +18,4 @@ Phaser.Physics.P2.CollisionGroup = function (bitmask) { */ this.mask = bitmask; -} +}; diff --git a/src/physics/p2/ContactMaterial.js b/src/physics/p2/ContactMaterial.js index 4f1328e78..230ad87ad 100644 --- a/src/physics/p2/ContactMaterial.js +++ b/src/physics/p2/ContactMaterial.js @@ -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; diff --git a/src/physics/p2/DistanceConstraint.js b/src/physics/p2/DistanceConstraint.js index 45f8b0f7b..46d9f0b48 100644 --- a/src/physics/p2/DistanceConstraint.js +++ b/src/physics/p2/DistanceConstraint.js @@ -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; diff --git a/src/physics/p2/GearConstraint.js b/src/physics/p2/GearConstraint.js index b13fa5a7a..5cd131bf4 100644 --- a/src/physics/p2/GearConstraint.js +++ b/src/physics/p2/GearConstraint.js @@ -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; diff --git a/src/physics/p2/LockConstraint.js b/src/physics/p2/LockConstraint.js index cd8c3abba..0400d89d3 100644 --- a/src/physics/p2/LockConstraint.js +++ b/src/physics/p2/LockConstraint.js @@ -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; diff --git a/src/physics/p2/Material.js b/src/physics/p2/Material.js index 08209361e..fd9bc1951 100644 --- a/src/physics/p2/Material.js +++ b/src/physics/p2/Material.js @@ -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; diff --git a/src/physics/p2/PrismaticConstraint.js b/src/physics/p2/PrismaticConstraint.js index d6002ceee..ba48e1029 100644 --- a/src/physics/p2/PrismaticConstraint.js +++ b/src/physics/p2/PrismaticConstraint.js @@ -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; diff --git a/src/physics/p2/RevoluteConstraint.js b/src/physics/p2/RevoluteConstraint.js index 97f874815..327aea10a 100644 --- a/src/physics/p2/RevoluteConstraint.js +++ b/src/physics/p2/RevoluteConstraint.js @@ -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; diff --git a/src/physics/p2/Spring.js b/src/physics/p2/Spring.js index 22da2b6ec..47e20e12e 100644 --- a/src/physics/p2/Spring.js +++ b/src/physics/p2/Spring.js @@ -67,7 +67,7 @@ Phaser.Physics.P2.Spring = function (world, bodyA, bodyB, restLength, stiffness, p2.Spring.call(this, bodyA, bodyB, options); -} +}; Phaser.Physics.P2.Spring.prototype = Object.create(p2.Spring.prototype); Phaser.Physics.P2.Spring.prototype.constructor = Phaser.Physics.P2.Spring; diff --git a/src/physics/p2/World.js b/src/physics/p2/World.js index f428c07fb..4d2603e4d 100644 --- a/src/physics/p2/World.js +++ b/src/physics/p2/World.js @@ -37,7 +37,7 @@ Phaser.Physics.P2 = function (game, config) { * @property {number} frameRate - The frame rate the world will be stepped at. Defaults to 1 / 60, but you can change here. Also see useElapsedTime property. * @default */ - this.frameRate = 1 / 60; + this.frameRate = 1 / 60; /** * @property {boolean} useElapsedTime - If true the frameRate value will be ignored and instead p2 will step with the value of Game.Time.physicsElapsed, which is a delta time value. @@ -279,7 +279,7 @@ Phaser.Physics.P2.prototype = { if (object.hasOwnProperty('body') && object.body === null) { object.body = new Phaser.Physics.P2.Body(this.game, object, object.x, object.y, 1); - object.body.debug = debug + object.body.debug = debug; object.anchor.set(0.5); } @@ -579,7 +579,7 @@ Phaser.Physics.P2.prototype = { } else { - this.bounds = new p2.Body({ mass: 0, position:[this.pxmi(cx), this.pxmi(cy)] }); + this.bounds = new p2.Body({ mass: 0, position: [this.pxmi(cx), this.pxmi(cy)] }); } if (left) @@ -591,7 +591,7 @@ Phaser.Physics.P2.prototype = { this._wallShapes[0].collisionGroup = this.boundsCollisionGroup.mask; } - this.bounds.addShape(this._wallShapes[0], [this.pxmi(-hw), 0], 1.5707963267948966 ); + this.bounds.addShape(this._wallShapes[0], [this.pxmi(-hw), 0], 1.5707963267948966); } if (right) @@ -603,7 +603,7 @@ Phaser.Physics.P2.prototype = { this._wallShapes[1].collisionGroup = this.boundsCollisionGroup.mask; } - this.bounds.addShape(this._wallShapes[1], [this.pxmi(hw), 0], -1.5707963267948966 ); + this.bounds.addShape(this._wallShapes[1], [this.pxmi(hw), 0], -1.5707963267948966); } if (top) @@ -615,7 +615,7 @@ Phaser.Physics.P2.prototype = { this._wallShapes[2].collisionGroup = this.boundsCollisionGroup.mask; } - this.bounds.addShape(this._wallShapes[2], [0, this.pxmi(-hh)], -3.141592653589793 ); + this.bounds.addShape(this._wallShapes[2], [0, this.pxmi(-hh)], -3.141592653589793); } if (bottom) @@ -627,7 +627,7 @@ Phaser.Physics.P2.prototype = { this._wallShapes[3].collisionGroup = this.boundsCollisionGroup.mask; } - this.bounds.addShape(this._wallShapes[3], [0, this.pxmi(hh)] ); + this.bounds.addShape(this._wallShapes[3], [0, this.pxmi(hh)]); } this.world.addBody(this.bounds); From 35c24f4ec36a3d757afd8bbc3fc89b9782df2edf Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sat, 22 Mar 2014 23:31:51 -0700 Subject: [PATCH 11/23] Fix jshint issues in src/utils --- src/utils/Utils.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 733ae8ac1..3cd1a3f11 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -99,17 +99,17 @@ Phaser.Utils = { switch (dir) { case 1: - str = Array(len + 1 - str.length).join(pad) + str; + str = new Array(len + 1 - str.length).join(pad) + str; break; case 3: var right = Math.ceil((padlen = len - str.length) / 2); var left = padlen - right; - str = Array(left+1).join(pad) + str + Array(right+1).join(pad); + str = new Array(left+1).join(pad) + str + new Array(right+1).join(pad); break; default: - str = str + Array(len + 1 - str.length).join(pad); + str = str + new Array(len + 1 - str.length).join(pad); break; } } @@ -140,7 +140,7 @@ Phaser.Utils = { // the "constructor" property of certain host objects, ie. |window.location| // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 try { - if (obj.constructor && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) + if (obj.constructor && !({}).hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf")) { return false; } @@ -245,6 +245,7 @@ Phaser.Utils = { */ if (typeof Function.prototype.bind != 'function') { + /* jshint freeze: false */ Function.prototype.bind = (function () { var slice = Array.prototype.slice; @@ -264,7 +265,10 @@ if (typeof Function.prototype.bind != 'function') { } bound.prototype = (function F(proto) { - proto && (F.prototype = proto); + if (proto) + { + F.prototype = proto; + } if (!(this instanceof F)) { @@ -285,5 +289,5 @@ if (!Array.isArray) Array.isArray = function (arg) { return Object.prototype.toString.call(arg) == '[object Array]'; - } + }; } From 9faa27ce4fc3dd8212a0c91c3ca3ec49d74a602a Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 01:10:01 -0700 Subject: [PATCH 12/23] Fix jshint issues in src/animation --- src/animation/Animation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/animation/Animation.js b/src/animation/Animation.js index da0e6fbbb..dd774166e 100644 --- a/src/animation/Animation.js +++ b/src/animation/Animation.js @@ -586,4 +586,4 @@ Phaser.Animation.generateFrameNames = function (prefix, start, stop, suffix, zer return output; -} +}; From debb6bdcf9619f0bc986fa90871a81cea54b9eff Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 01:29:04 -0700 Subject: [PATCH 13/23] Fix jshint issues in src/core --- src/core/Filter.js | 2 +- src/core/Game.js | 2 +- src/core/Group.js | 102 +++++++++++++++++++------------------- src/core/LinkedList.js | 2 +- src/core/ScaleManager.js | 2 +- src/core/Signal.js | 6 +-- src/core/SignalBinding.js | 4 +- src/core/Stage.js | 18 +++---- src/core/World.js | 8 +-- 9 files changed, 73 insertions(+), 73 deletions(-) diff --git a/src/core/Filter.js b/src/core/Filter.js index a2ea6d397..621a5f335 100644 --- a/src/core/Filter.js +++ b/src/core/Filter.js @@ -25,7 +25,7 @@ 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. diff --git a/src/core/Game.js b/src/core/Game.js index dccc74e7f..81fa101ab 100644 --- a/src/core/Game.js +++ b/src/core/Game.js @@ -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') { diff --git a/src/core/Group.js b/src/core/Group.js index 5ee54cd38..4f0590a62 100644 --- a/src/core/Group.js +++ b/src/core/Group.js @@ -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. @@ -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. @@ -420,7 +420,7 @@ 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. @@ -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,7 +811,7 @@ 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. @@ -834,7 +834,7 @@ 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. @@ -887,7 +887,7 @@ 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) @@ -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,7 +1010,7 @@ 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. @@ -1042,7 +1042,7 @@ 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. @@ -1060,7 +1060,7 @@ 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. @@ -1078,7 +1078,7 @@ 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. @@ -1096,7 +1096,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. @@ -1130,7 +1130,7 @@ Phaser.Group.prototype.sort = function (index, order) { this.updateZ(); -} +}; /** * An internal helper function for the sort process. @@ -1161,7 +1161,7 @@ Phaser.Group.prototype.ascendingSortHandler = function (a, b) { } } -} +}; /** * An internal helper function for the sort process. @@ -1185,7 +1185,7 @@ 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. @@ -1242,7 +1242,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. @@ -1260,7 +1260,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. @@ -1273,7 +1273,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. @@ -1286,7 +1286,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. @@ -1301,7 +1301,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. @@ -1316,7 +1316,7 @@ Phaser.Group.prototype.getBottom = function () { return this.children[0]; } -} +}; /** * Call this function to find out how many members of the group are alive. @@ -1328,7 +1328,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. @@ -1340,7 +1340,7 @@ Phaser.Group.prototype.countDead = function () { return this.iterate('alive', false, Phaser.Group.RETURN_TOTAL); -} +}; /** * Returns a member at random from the group. @@ -1362,7 +1362,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. @@ -1394,7 +1394,7 @@ Phaser.Group.prototype.remove = function (child) { return true; -} +}; /** * Removes all children from this Group, setting all group properties to null. @@ -1422,7 +1422,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. @@ -1460,7 +1460,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. @@ -1506,7 +1506,7 @@ Phaser.Group.prototype.destroy = function (destroyChildren, soft) { this.exists = false; } -} +}; /** * @name Phaser.Group#total diff --git a/src/core/LinkedList.js b/src/core/LinkedList.js index d5f2a9d25..64556349e 100644 --- a/src/core/LinkedList.js +++ b/src/core/LinkedList.js @@ -147,7 +147,7 @@ Phaser.LinkedList.prototype = { entity = entity.next; } - while(entity != this.last.next) + while(entity != this.last.next); } diff --git a/src/core/ScaleManager.js b/src/core/ScaleManager.js index 688a46fc2..cef364361 100644 --- a/src/core/ScaleManager.js +++ b/src/core/ScaleManager.js @@ -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']); } diff --git a/src/core/Signal.js b/src/core/Signal.js index ff4602e6f..823af38db 100644 --- a/src/core/Signal.js +++ b/src/core/Signal.js @@ -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); } diff --git a/src/core/SignalBinding.js b/src/core/SignalBinding.js index 1c607f181..cc5b3e75f 100644 --- a/src/core/SignalBinding.js +++ b/src/core/SignalBinding.js @@ -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) diff --git a/src/core/Stage.js b/src/core/Stage.js index cb2cef498..0e98ebc6e 100644 --- a/src/core/Stage.js +++ b/src/core/Stage.js @@ -111,7 +111,7 @@ Phaser.Stage.prototype.preUpdate = function () { this.children[i].preUpdate(); } -} +}; /** * This is called automatically after the State.update, but before particles or plugins update. @@ -127,7 +127,7 @@ Phaser.Stage.prototype.update = function () { this.children[i].update(); } -} +}; /** * This is called automatically before the renderer runs and after the plugins have updated. @@ -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 diff --git a/src/core/World.js b/src/core/World.js index aacf76ad4..c6d039250 100644 --- a/src/core/World.js +++ b/src/core/World.js @@ -34,7 +34,7 @@ Phaser.World = function (game) { */ 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 From 2ea76d12168e9921f90569424eb923efe57f6984 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 01:33:53 -0700 Subject: [PATCH 14/23] Fix jshint issues in src/loader --- src/loader/Loader.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/loader/Loader.js b/src/loader/Loader.js index df0ec5d5c..dbbbf609a 100644 --- a/src/loader/Loader.js +++ b/src/loader/Loader.js @@ -1163,11 +1163,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) { From ebad4c1d3854de46bfb9e53c9514c11f8cf67168 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 01:34:59 -0700 Subject: [PATCH 15/23] Fix jshint issues in src/input --- src/input/Keyboard.js | 2 +- src/input/Pointer.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/input/Keyboard.js b/src/input/Keyboard.js index 596bfe8ab..631bb86be 100644 --- a/src/input/Keyboard.js +++ b/src/input/Keyboard.js @@ -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) - } + }; }, diff --git a/src/input/Pointer.js b/src/input/Pointer.js index 87ab6b456..e8a019696 100644 --- a/src/input/Pointer.js +++ b/src/input/Pointer.js @@ -378,7 +378,7 @@ Phaser.Pointer.prototype = { } currentNode = currentNode.next; } - while (currentNode != null) + while (currentNode != null); } if (this._highestRenderObject === null) @@ -508,7 +508,7 @@ Phaser.Pointer.prototype = { currentNode = currentNode.next; } - while (currentNode != null) + while (currentNode != null); } if (this.targetObject) From 04d88b6c3551af94e7643ea4b4148742f961a009 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 01:35:53 -0700 Subject: [PATCH 16/23] Fix jshint issues in src/geom --- src/geom/Circle.js | 2 +- src/geom/Point.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/geom/Circle.js b/src/geom/Circle.js index cdea7dc89..d8efd8936 100644 --- a/src/geom/Circle.js +++ b/src/geom/Circle.js @@ -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) { diff --git a/src/geom/Point.js b/src/geom/Point.js index 5136073dc..b8f0b87d7 100644 --- a/src/geom/Point.js +++ b/src/geom/Point.js @@ -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) { From bdbf2783ad62b1077f25f47587364d7f28e16f56 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 01:40:24 -0700 Subject: [PATCH 17/23] Fix jshint issues in src/gameobjects --- src/gameobjects/BitmapData.js | 2 +- src/gameobjects/BitmapText.js | 8 ++++---- src/gameobjects/Button.js | 12 ++++++------ src/gameobjects/Graphics.js | 10 +++++----- src/gameobjects/Image.js | 20 ++++++++++---------- src/gameobjects/RenderTexture.js | 2 +- src/gameobjects/RetroFont.js | 16 ++++++++-------- src/gameobjects/Text.js | 28 ++++++++++++++-------------- src/gameobjects/TileSprite.js | 16 ++++++++-------- 9 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/gameobjects/BitmapData.js b/src/gameobjects/BitmapData.js index fe13ac95c..50204f07e 100644 --- a/src/gameobjects/BitmapData.js +++ b/src/gameobjects/BitmapData.js @@ -106,7 +106,7 @@ Phaser.BitmapData = function (game, key, width, height) { */ this.dirty = false; -} +}; Phaser.BitmapData.prototype = { diff --git a/src/gameobjects/BitmapText.js b/src/gameobjects/BitmapText.js index d29d52f5a..94e82d71e 100644 --- a/src/gameobjects/BitmapText.js +++ b/src/gameobjects/BitmapText.js @@ -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 diff --git a/src/gameobjects/Button.js b/src/gameobjects/Button.js index 98715847d..244d6558c 100644 --- a/src/gameobjects/Button.js +++ b/src/gameobjects/Button.js @@ -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. @@ -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. diff --git a/src/gameobjects/Graphics.js b/src/gameobjects/Graphics.js index 6304d3220..04b1f4bd5 100644 --- a/src/gameobjects/Graphics.js +++ b/src/gameobjects/Graphics.js @@ -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,7 +137,7 @@ 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. @@ -185,7 +185,7 @@ Phaser.Graphics.prototype.destroy = function(destroyChildren) { this.game = null; -} +}; /* * Draws a {Phaser.Polygon} or a {PIXI.Polygon} filled @@ -203,7 +203,7 @@ 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. diff --git a/src/gameobjects/Image.js b/src/gameobjects/Image.js index 52b2918d7..15d6d56f9 100644 --- a/src/gameobjects/Image.js +++ b/src/gameobjects/Image.js @@ -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,7 +326,7 @@ Phaser.Image.prototype.crop = function(rect) { } } -} +}; /** * Brings a 'dead' Image back to life, optionally giving it the health value specified. @@ -350,7 +350,7 @@ Phaser.Image.prototype.revive = function() { return this; -} +}; /** * Kills a Image. A killed Image has its alive, exists and visible properties all set to false. @@ -375,7 +375,7 @@ 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 @@ -438,7 +438,7 @@ 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. @@ -461,7 +461,7 @@ Phaser.Image.prototype.reset = function(x, y) { 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 @@ -480,7 +480,7 @@ 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. diff --git a/src/gameobjects/RenderTexture.js b/src/gameobjects/RenderTexture.js index 1ddf02cef..033d2c307 100644 --- a/src/gameobjects/RenderTexture.js +++ b/src/gameobjects/RenderTexture.js @@ -58,7 +58,7 @@ Phaser.RenderTexture.prototype.renderXY = function (displayObject, x, y, clear) this.render(displayObject, this._temp, clear); -} +}; // Documentation stubs diff --git a/src/gameobjects/RetroFont.js b/src/gameobjects/RetroFont.js index e54577c3c..7a314b0cc 100644 --- a/src/gameobjects/RetroFont.js +++ b/src/gameobjects/RetroFont.js @@ -274,7 +274,7 @@ 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. @@ -309,7 +309,7 @@ Phaser.RetroFont.prototype.setText = function (content, multiLine, characterSpac this.text = content; } -} +}; /** * Over rides the default PIXI.RenderTexture resize event as we need our baseTexture resized as well. @@ -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,7 +344,7 @@ Phaser.RetroFont.prototype.resize = function (width, height) { PIXI.Texture.frameUpdates.push(this); -} +}; /** * Updates the BitmapData of the Sprite with the text @@ -435,7 +435,7 @@ Phaser.RetroFont.prototype.buildRetroFontText = function () { 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. @@ -477,7 +477,7 @@ Phaser.RetroFont.prototype.pasteLine = function (line, x, y, customSpacingX) { } } } -} +}; /** * Works out the longest line of text in _text and returns its length @@ -504,7 +504,7 @@ 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. @@ -531,7 +531,7 @@ Phaser.RetroFont.prototype.removeUnsupportedCharacters = function (stripCR) { } return newString; -} +}; /** * @name Phaser.BitmapText#text diff --git a/src/gameobjects/Text.js b/src/gameobjects/Text.js index 876b0e61d..2ecf424f6 100644 --- a/src/gameobjects/Text.js +++ b/src/gameobjects/Text.js @@ -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,13 +353,13 @@ 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 @@ -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. diff --git a/src/gameobjects/TileSprite.js b/src/gameobjects/TileSprite.js index fd7171ea4..e551d2f7e 100644 --- a/src/gameobjects/TileSprite.js +++ b/src/gameobjects/TileSprite.js @@ -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,7 +390,7 @@ 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 @@ -451,7 +451,7 @@ 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() @@ -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 From f409a735f0e609c70334943fdc44f04f7a54f2b4 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 01:43:27 -0700 Subject: [PATCH 18/23] Fix jshint issues in src/Phaser.js --- src/Phaser.js | 115 ++++++++++++++++++------------------ src/physics/Physics.js | 4 +- src/physics/ninja/AABB.js | 2 +- src/physics/ninja/Circle.js | 2 +- 4 files changed, 62 insertions(+), 61 deletions(-) diff --git a/src/Phaser.js b/src/Phaser.js index 8e8d08d56..2a46ca41d 100644 --- a/src/Phaser.js +++ b/src/Phaser.js @@ -1,3 +1,4 @@ +/* global Phaser:true */ /** * @author Richard Davey * @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. }; diff --git a/src/physics/Physics.js b/src/physics/Physics.js index 9874b532b..e2805a3ad 100644 --- a/src/physics/Physics.js +++ b/src/physics/Physics.js @@ -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.'); } }, diff --git a/src/physics/ninja/AABB.js b/src/physics/ninja/AABB.js index 4c833f1c1..96f88de62 100644 --- a/src/physics/ninja/AABB.js +++ b/src/physics/ninja/AABB.js @@ -136,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; diff --git a/src/physics/ninja/Circle.js b/src/physics/ninja/Circle.js index ba3b8f8c3..494441e3a 100644 --- a/src/physics/ninja/Circle.js +++ b/src/physics/ninja/Circle.js @@ -140,7 +140,7 @@ Phaser.Physics.Ninja.Circle.prototype = { * @param {number} dy - Collision normal * @param {number} obj - Object this Circle collided with */ - reportCollisionVsWorld: function (px, py, dx, dy, obj) { + reportCollisionVsWorld: function (px, py, dx, dy) { var p = this.pos; var o = this.oldpos; From 3b4c0344520541fc25134798dde74393e8d74952 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 09:18:31 -0700 Subject: [PATCH 19/23] Constrain Windows Scripting Host env to Loader.js --- .jshintrc | 1 - src/loader/Loader.js | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.jshintrc b/.jshintrc index 0421ee80f..760605b02 100644 --- a/.jshintrc +++ b/.jshintrc @@ -2,7 +2,6 @@ "globals" : { "Phaser": false, "PIXI": false, "p2": false }, // Ignore Environment Globals "browser" : true, // Standard browser globals e.g. `window`, `document`. - "wsh" : true, // Windows Scripting Host. // Development "devel" : true, // Allow developments statements e.g. `console.log();`. diff --git a/src/loader/Loader.js b/src/loader/Loader.js index dbbbf609a..977fd5398 100644 --- a/src/loader/Loader.js +++ b/src/loader/Loader.js @@ -1,3 +1,4 @@ +/* jshint wsh:true */ /** * @author Richard Davey * @copyright 2014 Photon Storm Ltd. From 428505f6001f0a50dfb6300a2e870d52900f6559 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 09:21:34 -0700 Subject: [PATCH 20/23] Enable jshint `immed` flag. --- .jshintrc | 2 +- src/math/Math.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.jshintrc b/.jshintrc index 760605b02..c46a74e35 100644 --- a/.jshintrc +++ b/.jshintrc @@ -24,7 +24,7 @@ "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(){}() );` + "immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );` "iterator" : true, // This option suppresses warnings about the __iterator__ property. "latedef" : true, // Prohibit variable use before definition. "laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons. diff --git a/src/math/Math.js b/src/math/Math.js index 16a42a868..c95915534 100644 --- a/src/math/Math.js +++ b/src/math/Math.js @@ -995,7 +995,7 @@ Phaser.Math = { if (typeof startIndex === "undefined") { startIndex = 0; } if (typeof length === "undefined") { length = 0; } - + if (objects != null) { var l = length; @@ -1311,7 +1311,7 @@ Phaser.Math = { * @method Phaser.Math#degToRad * @return {function} */ - degToRad: function() { + degToRad: (function() { var degreeToRadiansFactor = Math.PI / 180; @@ -1321,7 +1321,7 @@ Phaser.Math = { }; - }(), + }()), /** * Convert degrees to radians. @@ -1329,7 +1329,7 @@ Phaser.Math = { * @method Phaser.Math#radToDeg * @return {function} */ - radToDeg: function() { + radToDeg: (function() { var radianToDegreesFactor = 180 / Math.PI; @@ -1339,6 +1339,6 @@ Phaser.Math = { }; - }() + }()) }; From d4beaeafb7158e744076f3892144b3248c4d21fc Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 09:25:06 -0700 Subject: [PATCH 21/23] Unsuppress warnings for things that don't appear in the codebase. --- .jshintrc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.jshintrc b/.jshintrc index c46a74e35..9577f250f 100644 --- a/.jshintrc +++ b/.jshintrc @@ -25,22 +25,17 @@ "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(){}() );` - "iterator" : true, // This option suppresses warnings about the __iterator__ property. "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. - "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. // Styling "indent" : 4, // Specify indentation spacing From 7aec06910dd9d95c7cee13b50344ae1d03db47df Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 09:54:20 -0700 Subject: [PATCH 22/23] Add filters to jshint task. --- Gruntfile.js | 5 ++++ filters/.jshintrc | 49 +++++++++++++++++++++++++++++++++++++++ filters/BinarySerpents.js | 2 +- filters/CausticLight.js | 6 ++--- filters/CheckerWave.js | 8 +++---- filters/ColorBars.js | 4 ++-- filters/Fire.js | 6 ++--- filters/HueRotate.js | 4 ++-- filters/LightBeam.js | 14 +++++------ filters/Marble.js | 8 +++---- filters/Plasma.js | 2 +- filters/SampleFilter.js | 6 ++--- filters/Tunnel.js | 8 +++---- 13 files changed, 88 insertions(+), 34 deletions(-) create mode 100644 filters/.jshintrc diff --git a/Gruntfile.js b/Gruntfile.js index 5d885534b..f2d49647c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -394,6 +394,11 @@ module.exports = function (grunt) { options: { jshintrc: '.jshintrc' } }, + filters: { + src: ['filters/**/*.js'], + options: { jshintrc: 'filters/.jshintrc', } + }, + tooling: { src: [ 'Gruntfile.js', diff --git a/filters/.jshintrc b/filters/.jshintrc new file mode 100644 index 000000000..ec8189515 --- /dev/null +++ b/filters/.jshintrc @@ -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. +} diff --git a/filters/BinarySerpents.js b/filters/BinarySerpents.js index c8e51b84c..e8d9c59f4 100644 --- a/filters/BinarySerpents.js +++ b/filters/BinarySerpents.js @@ -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', { diff --git a/filters/CausticLight.js b/filters/CausticLight.js index d909ab39c..8e4c5c373 100644 --- a/filters/CausticLight.js +++ b/filters/CausticLight.js @@ -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; -} +}; diff --git a/filters/CheckerWave.js b/filters/CheckerWave.js index 93221c5ba..fd586cc54 100644 --- a/filters/CheckerWave.js +++ b/filters/CheckerWave.js @@ -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', { diff --git a/filters/ColorBars.js b/filters/ColorBars.js index fd13e20de..8677caac7 100644 --- a/filters/ColorBars.js +++ b/filters/ColorBars.js @@ -6,7 +6,7 @@ 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 = [ @@ -70,7 +70,7 @@ Phaser.Filter.ColorBars.prototype.init = function (width, height) { this.setResolution(width, height); -} +}; Object.defineProperty(Phaser.Filter.ColorBars.prototype, 'alpha', { diff --git a/filters/Fire.js b/filters/Fire.js index dfcb13a4d..3c3a84faf 100644 --- a/filters/Fire.js +++ b/filters/Fire.js @@ -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 = [ @@ -73,7 +73,7 @@ Phaser.Filter.Fire.prototype.init = function (width, height, alpha, shift) { this.uniforms.shift.value = shift; } -} +}; Object.defineProperty(Phaser.Filter.Fire.prototype, 'alpha', { diff --git a/filters/HueRotate.js b/filters/HueRotate.js index 2312a295f..3d41927e7 100644 --- a/filters/HueRotate.js +++ b/filters/HueRotate.js @@ -8,7 +8,7 @@ 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 = [ @@ -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', { diff --git a/filters/LightBeam.js b/filters/LightBeam.js index 988301932..d4f5b03a3 100644 --- a/filters/LightBeam.js +++ b/filters/LightBeam.js @@ -6,12 +6,12 @@ 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 = [ @@ -55,7 +55,7 @@ Phaser.Filter.LightBeam.prototype.init = function (width, height) { this.setResolution(width, height); -} +}; Object.defineProperty(Phaser.Filter.LightBeam.prototype, 'alpha', { diff --git a/filters/Marble.js b/filters/Marble.js index a960a0e7b..b8be8b6d8 100644 --- a/filters/Marble.js +++ b/filters/Marble.js @@ -6,12 +6,12 @@ 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', { diff --git a/filters/Plasma.js b/filters/Plasma.js index 638515db7..000d2114f 100644 --- a/filters/Plasma.js +++ b/filters/Plasma.js @@ -60,7 +60,7 @@ Phaser.Filter.Plasma.prototype.init = function (width, height, alpha, size) { this.uniforms.size.value = size; } -} +}; Object.defineProperty(Phaser.Filter.Plasma.prototype, 'alpha', { diff --git a/filters/SampleFilter.js b/filters/SampleFilter.js index a621da718..0e8878ba6 100644 --- a/filters/SampleFilter.js +++ b/filters/SampleFilter.js @@ -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; -} +}; diff --git a/filters/Tunnel.js b/filters/Tunnel.js index 113792969..abc3751f2 100644 --- a/filters/Tunnel.js +++ b/filters/Tunnel.js @@ -6,9 +6,9 @@ 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 = [ @@ -44,7 +44,7 @@ Phaser.Filter.Tunnel.prototype.init = function (width, height, texture) { texture.baseTexture._powerOf2 = true; -} +}; Object.defineProperty(Phaser.Filter.Tunnel.prototype, 'alpha', { From 0841f77bc8ae591e1777fa6cf621e47c0caa1b20 Mon Sep 17 00:00:00 2001 From: Christian Wesselhoeft Date: Sun, 23 Mar 2014 10:08:20 -0700 Subject: [PATCH 23/23] Add plugins to jshint task. --- Gruntfile.js | 1 + plugins/ColorHarmony.js | 33 +++---- plugins/ProTracker.js | 205 +++++++++++++++++++++------------------- plugins/Webcam.js | 64 ++++++------- 4 files changed, 159 insertions(+), 144 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index f2d49647c..555bc4b54 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -385,6 +385,7 @@ module.exports = function (grunt) { jshint: { src: { src: [ + 'plugins/**/*.js', 'src/**/*.js', '!src/Intro.js', '!src/Outro.js', diff --git a/plugins/ColorHarmony.js b/plugins/ColorHarmony.js index 4b973b654..fb3a13937 100644 --- a/plugins/ColorHarmony.js +++ b/plugins/ColorHarmony.js @@ -1,7 +1,8 @@ +/* jshint camelcase:false */ /** * A collection of methods useful for manipulating and comparing colors. * -* @class ColorHarmony +* @class ColorHarmony * @author Richard Davey * @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. *

A complementary hue is one directly opposite the color given on the color wheel

*

Value returned in 0xAARRGGBB format with Alpha set to 255.

@@ -27,7 +28,7 @@ Phaser.Plugins.ColorHarmony.prototype = { }, - /** + /** * Returns an Analogous Color Harmony for the given color. *

An Analogous harmony are hues adjacent to each other on the color wheel

*

Values returned in 0xAARRGGBB format with Alpha set to 255.

@@ -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. *

A Split Complement harmony are the two hues on either side of the color's Complement

*

Values returned in 0xAARRGGBB format with Alpha set to 255.

@@ -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. *

A Triadic harmony are 3 hues equidistant from each other on the color wheel

*

Values returned in 0xAARRGGBB format with Alpha set to 255.

@@ -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 = { }; } -} +}; diff --git a/plugins/ProTracker.js b/plugins/ProTracker.js index 007fa11fa..3fb0452ad 100644 --- a/plugins/ProTracker.js +++ b/plugins/ProTracker.js @@ -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;i0x1f) && (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=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 diff --git a/plugins/Webcam.js b/plugins/Webcam.js index 00f3cd24d..ce87e372f 100644 --- a/plugins/Webcam.js +++ b/plugins/Webcam.js @@ -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); + } };