Updated JSHint configuration, README and started working through source files against JSHint.

This commit is contained in:
photonstorm
2013-11-24 12:51:20 +00:00
parent 16ae7f3cb7
commit d30e2974c4
5 changed files with 33 additions and 46 deletions
+11 -10
View File
@@ -1,4 +1,5 @@
{ {
"globals" : { "Phaser": false, "PIXI": false },
// Ignore Environment Globals // Ignore Environment Globals
"browser" : true, // Standard browser globals e.g. `window`, `document`. "browser" : true, // Standard browser globals e.g. `window`, `document`.
"couch" : false, "couch" : false,
@@ -28,21 +29,21 @@
"asi" : true, // Tolerate Automatic Semicolon Insertion (no semicolons). "asi" : true, // Tolerate Automatic Semicolon Insertion (no semicolons).
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.). "bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments. "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. "camelcase" : true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
"curly" : false, // Require {} for every new block or scope. "curly" : true, // Require {} for every new block or scope.
"eqeqeq" : false, // Require triple equals i.e. `===`. "eqeqeq" : false, // Require triple equals i.e. `===`.
"eqnull" : true, // Tolerate use of `== null`. "eqnull" : true, // Tolerate use of `== null`.
"evil" : true, // Tolerate use of `eval`. "evil" : false, // Tolerate use of `eval`.
"expr" : true, // Tolerate `ExpressionStatement` as Programs. "expr" : false, // Tolerate `ExpressionStatement` as Programs.
"forin" : true, // Tolerate `for in` loops without `hasOwnPrototype`. "forin" : true, // Tolerate `for in` loops without `hasOwnPrototype`.
"freeze" : false, // Prohibits overwriting prototypes of native objects such as Array and Date. "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. "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" : false, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"iterator" : true, // This option suppresses warnings about the __iterator__ property. "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. "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" : false, // Prohipit variable use before definition.
"laxbreak" : true, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons. "laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
"laxcomma" : true, // This option suppresses warnings about comma-first coding style. "laxcomma" : false, // This option suppresses warnings about comma-first coding style.
"loopfunc" : true, // Allow functions to be defined within loops. "loopfunc" : true, // Allow functions to be defined within loops.
// "maxcomplexity" : 10, // This option lets you control cyclomatic complexity throughout your code. // "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. // "maxdepth" : 2, // This option lets you control how nested do you want your blocks to be.
@@ -51,19 +52,19 @@
// "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. // "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. "moz" : false, // This options tells JSHint that your code uses Mozilla JavaScript extensions.
"multistr" : true, // This option suppresses warnings about multi-line strings. "multistr" : true, // This option suppresses warnings about multi-line strings.
"noarg" : false, // Prohibit use of `arguments.caller` and `arguments.callee`. "noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"notypeof" : false, // This option suppresses warnings about invalid typeof operator values. "notypeof" : false, // This option suppresses warnings about invalid typeof operator values.
"proto" : true, // This option suppresses warnings about the __proto__ property. "proto" : true, // This option suppresses warnings about the __proto__ property.
"scripturl" : true, // Tolerate script-targeted URLs. "scripturl" : true, // Tolerate script-targeted URLs.
"shadow" : true, // Allows re-define variables later in code e.g. `var x=1; x=2;`. "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. "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;`. "supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
"undef" : false, // Require all non-global variables be declared before they are used. "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. "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. "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 // Styling
"indent" : 2, // Specify indentation spacing "indent" : 4, // Specify indentation spacing
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`. "newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
"noempty" : true, // Prohibit use of empty blocks. "noempty" : true, // Prohibit use of empty blocks.
"nonew" : true, // Prohibit use of constructors for side-effects. "nonew" : true, // Prohibit use of constructors for side-effects.
+2 -1
View File
@@ -41,6 +41,7 @@ Change Log
Version 1.1.3 - in build Version 1.1.3 - in build
* New: Added a .jshintrc so contributions can be run through JSHint to help retain formatting across the library (thanks kevinthompson)
* New: Added a new in-built texture. Sprites now use __default if no texture was provided (a 32x32 transparent PNG) or __missing if one was given but not found (a 32x32 black box with a green cross through it) * New: Added a new in-built texture. Sprites now use __default if no texture was provided (a 32x32 transparent PNG) or __missing if one was given but not found (a 32x32 black box with a green cross through it)
* New: Added Phaser.Filter. A new way to use the new WebGL shaders/filters that the new version of Pixi supports. * New: Added Phaser.Filter. A new way to use the new WebGL shaders/filters that the new version of Pixi supports.
* New: The object returned by Math.sinCosGenerator now contains a length property. * New: The object returned by Math.sinCosGenerator now contains a length property.
@@ -234,7 +235,7 @@ If you find a bug (highly likely!) then please report it on github or our forum.
If you have a feature request, or have written a small game or demo that shows Phaser in use, then please get in touch. We'd love to hear from you. If you have a feature request, or have written a small game or demo that shows Phaser in use, then please get in touch. We'd love to hear from you.
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`. 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 requirement, 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.
You can do this on the Phaser board that is part of the [HTML5 Game Devs forum](http://www.html5gamedevs.com/forum/14-phaser/) or email: rich@photonstorm.com You can do this on the Phaser board that is part of the [HTML5 Game Devs forum](http://www.html5gamedevs.com/forum/14-phaser/) or email: rich@photonstorm.com
+1 -15
View File
@@ -83,24 +83,10 @@
if (game.renderType === Phaser.WEBGL) if (game.renderType === Phaser.WEBGL)
{ {
sky.visible = false;
var t = game.add.sprite(0, 0);
t.width = 1024;
t.height = 672;
filter2 = game.add.filter('BinarySerpents', 1024, 672);
filter2.alpha = 0.0;
t.filters = [filter2];
var t2 = game.add.sprite(0, 0);
t2.width = 1024;
t2.height = 672;
filter = game.add.filter('Fire', 1024, 672); filter = game.add.filter('Fire', 1024, 672);
filter.shift = 2.0; filter.shift = 2.0;
filter.alpha = 0.0; filter.alpha = 0.0;
t2.filters = [filter]; sky.filters = [filter];
} }
land = game.add.tileSprite(0, 544, 1024, 128, 'land'); land = game.add.tileSprite(0, 544, 1024, 128, 'land');
+16 -16
View File
@@ -23,13 +23,13 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope
/** /**
* @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; this.game = game;
/** /**
* @property {Phaser.Sprite} _parent - A reference to the parent Sprite that owns this Animation. * @property {Phaser.Sprite} _parent - A reference to the parent Sprite that owns this Animation.
* @private * @private
*/ */
this._parent = parent; this._parent = parent;
/** /**
* @property {Phaser.FrameData} _frameData - The FrameData the Animation uses. * @property {Phaser.FrameData} _frameData - The FrameData the Animation uses.
@@ -46,18 +46,18 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope
* @property {object} _frames * @property {object} _frames
* @private * @private
*/ */
this._frames = []; this._frames = [];
this._frames = this._frames.concat(frames); this._frames = this._frames.concat(frames);
/** /**
* @property {number} delay - The delay in ms between each frame of the Animation. * @property {number} delay - The delay in ms between each frame of the Animation.
*/ */
this.delay = 1000 / delay; this.delay = 1000 / delay;
/** /**
* @property {boolean} looped - The loop state of the Animation. * @property {boolean} looped - The loop state of the Animation.
*/ */
this.looped = looped; this.looped = looped;
/** /**
* @property {boolean} looped - The loop state of the Animation. * @property {boolean} looped - The loop state of the Animation.
@@ -68,13 +68,13 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope
* @property {boolean} isFinished - The finished state of the Animation. Set to true once playback completes, false during playback. * @property {boolean} isFinished - The finished state of the Animation. Set to true once playback completes, false during playback.
* @default * @default
*/ */
this.isFinished = false; this.isFinished = false;
/** /**
* @property {boolean} isPlaying - The playing state of the Animation. Set to false once playback completes, true during playback. * @property {boolean} isPlaying - The playing state of the Animation. Set to false once playback completes, true during playback.
* @default * @default
*/ */
this.isPlaying = false; this.isPlaying = false;
/** /**
* @property {boolean} isPaused - The paused state of the Animation. * @property {boolean} isPaused - The paused state of the Animation.
@@ -94,7 +94,7 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope
* @private * @private
* @default * @default
*/ */
this._frameIndex = 0; this._frameIndex = 0;
/** /**
* @property {number} _frameDiff * @property {number} _frameDiff
@@ -113,8 +113,8 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope
/** /**
* @property {Phaser.Frame} currentFrame - The currently displayed frame of the Animation. * @property {Phaser.Frame} currentFrame - The currently displayed frame of the Animation.
*/ */
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
}; };
Phaser.Animation.prototype = { Phaser.Animation.prototype = {
@@ -159,7 +159,7 @@ Phaser.Animation.prototype = {
this._frameIndex = 0; this._frameIndex = 0;
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
if (this._parent.events) if (this._parent.events)
{ {
@@ -226,7 +226,7 @@ Phaser.Animation.prototype = {
return false; return false;
} }
if (this.isPlaying == true && this.game.time.now >= this._timeNextFrame) if (this.isPlaying === true && this.game.time.now >= this._timeNextFrame)
{ {
this._frameSkip = 1; this._frameSkip = 1;
@@ -331,7 +331,7 @@ Phaser.Animation.prototype = {
* @name Phaser.Animation#paused * @name Phaser.Animation#paused
* @property {boolean} paused - Gets and sets the paused state of this Animation. * @property {boolean} paused - Gets and sets the paused state of this Animation.
*/ */
Object.defineProperty(Phaser.Animation.prototype, "paused", { Object.defineProperty(Phaser.Animation.prototype, 'paused', {
get: function () { get: function () {
@@ -366,7 +366,7 @@ Object.defineProperty(Phaser.Animation.prototype, "paused", {
* @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded. * @property {number} frameTotal - The total number of frames in the currently loaded FrameData, or -1 if no FrameData is loaded.
* @readonly * @readonly
*/ */
Object.defineProperty(Phaser.Animation.prototype, "frameTotal", { Object.defineProperty(Phaser.Animation.prototype, 'frameTotal', {
get: function () { get: function () {
return this._frames.length; return this._frames.length;
@@ -378,7 +378,7 @@ Object.defineProperty(Phaser.Animation.prototype, "frameTotal", {
* @name Phaser.Animation#frame * @name Phaser.Animation#frame
* @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display. * @property {number} frame - Gets or sets the current frame index and updates the Texture Cache for display.
*/ */
Object.defineProperty(Phaser.Animation.prototype, "frame", { Object.defineProperty(Phaser.Animation.prototype, 'frame', {
get: function () { get: function () {
@@ -400,7 +400,7 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", {
if (this.currentFrame !== null) if (this.currentFrame !== null)
{ {
this._frameIndex = value; this._frameIndex = value;
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]); this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
} }
} }
+3 -4
View File
@@ -5,14 +5,13 @@
*/ */
/** /**
* An Animation instance contains a single animation and the controls to play it. * The StageScaleMode object is responsible for helping you manage the scaling, resizing and alignment of your game within the browser.
* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
* *
* @class Phaser.StageScaleMode * @class Phaser.StageScaleMode
* @constructor * @constructor
* @param {Phaser.Game} game - A reference to the currently running game. * @param {Phaser.Game} game - A reference to the currently running game.
* @param {number} width - Description. * @param {number} width - The native width of the game.
* @param {number} height - Description. * @param {number} height - The native height of the game.
*/ */
Phaser.StageScaleMode = function (game, width, height) { Phaser.StageScaleMode = function (game, width, height) {