diff --git a/README.md b/README.md index c66f71d2..7fb62753 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Significant API changes: * Loader.tileset has a new method signature. Please use the new format: load.tileset(key, url, tileWidth, tileHeight, tileMargin, tileSpacing, rows, columns, total). * TilemapLayers are now created via the Tilemap object itself: map.createLayer(x, y, width, height, tileset, layer, group) and no longer via the GameObjectFactory. * Tilemap.createFromObjects can now turn a bunch of Tiled objects into Sprites in one single call, and copies across all properties as well. +* Tween.onStartCallback and onCompleteCallback have been removed to avoid confusion. You should use the onStart, onLoop and onComplete events instead. New features: @@ -66,6 +67,7 @@ New features: * Group.set will let you deep set a new propery on a single child of the Group. * Stage.display property added. A direct reference to the root Pixi Stage object (very useful for RenderTexture manipulation) * Added Ejecta detection to Device (thanks endel) +* Tweens can now work with relative + and - values. You can do: `tween(sprite).to( { x: '+400' })` and it will add 400 to the current sprite.x value, or '-400'. New Examples: @@ -104,6 +106,7 @@ Updates: * Input doesn't set the cursor to default if it's already set to none. * You can now collide a group against itself, to have all children collide, and bodies won't check against themselves (thanks cocoademon) * RenderTexture.render / renderXY has a new parameter: renderHidden, a boolean which will allow you to render Sprites even if their visible is set to false. +* Added in prototype.constructor definitions to every class (thanks darkoverlordofdata) Bug Fixes: @@ -119,6 +122,8 @@ Bug Fixes: * Tween.onStart is now called when the tween starts AFTER the delay value, if given (thanks stevenbouma) * Sprites that are fixedToCamera can now be input dragged regardless of world position (thanks RafaelOliveira) * RenderTexture now displays correctly in Canvas games. +* Canvas.addToDOM is now more robust when applying the overflowHidden style. +* Fixed Pixi.StripShader which should stop the weird TileSprite GPU issues some were reporting (thanks GoodboyDigital) You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md @@ -266,6 +271,7 @@ Versions 1.2 ("Saldaea") * Integration with the p2.js physics system. * Enhance the State Management, so you can perform non-destructive State swaps and persistence. +* Update to Pixi 1.5 - currently still in dev branch only, but lots of nice internal changes and new features. Beyond version 1.2 diff --git a/build/phaser.d.ts b/build/phaser.d.ts index ee697f41..33ec8578 100644 --- a/build/phaser.d.ts +++ b/build/phaser.d.ts @@ -212,7 +212,7 @@ declare module Phaser { add(child: any): any; addAt(child: any, index: number): any; getAt(index: number): any; - create(x: number, y: number, key: string, frame: string, exists?: boolean): any; + create(x: number, y: number, key: string, frame?: any, exists?: boolean): Phaser.Sprite; swap(child1: any, child2: any): boolean; bringToTop(child: any): any; getIndex(child: any): number; diff --git a/examples/games/breakout.js b/examples/games/breakout.js index 6c4c6962..79ac2961 100644 --- a/examples/games/breakout.js +++ b/examples/games/breakout.js @@ -135,7 +135,7 @@ function gameOver () { ball.body.velocity.setTo(0, 0); - introText.content = "Game Over!"; + introText.content = 'Game Over!'; introText.visible = true; } @@ -154,7 +154,7 @@ function ballHitBrick (_ball, _brick) { // New level starts score += 1000; scoreText.content = 'score: ' + score; - introText = '- Next Level -'; + introText.content = '- Next Level -'; // Let's move the ball back to the paddle ballOnPaddle = true; diff --git a/examples/tweens/tween relative.js b/examples/tweens/tween relative.js new file mode 100644 index 00000000..38fb243f --- /dev/null +++ b/examples/tweens/tween relative.js @@ -0,0 +1,57 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render }); + +function preload() { + + game.load.image('phaser', 'assets/sprites/phaser1.png'); + game.load.spritesheet('arrows', 'assets/sprites/arrows.png', 23, 31); + +} + +var arrowStart; +var arrowEnd; +var sprite; + +function create() { + + game.stage.backgroundColor = '#2384e7'; + + arrowStart = game.add.sprite(100, 100, 'arrows', 0); + + arrowEnd = game.add.sprite(400, 100, 'arrows', 1); + + sprite = game.add.sprite(100, 164, 'phaser'); + sprite.inputEnabled = true; + + sprite.events.onInputDown.add(move, this); + +} + +function move() { + + if (sprite.x === 100) + { + // Here you'll notice we are using a relative value for the tween. + // You can specify a number as a string with either + or - at the start of it. + // When the tween starts it will take the sprites current X value and add +300 to it. + + game.add.tween(sprite).to( { x: '+300' }, 2000, Phaser.Easing.Linear.None, true); + } + else if (sprite.x === 400) + { + game.add.tween(sprite).to( { x: '-300' }, 2000, Phaser.Easing.Linear.None, true); + } + +} + +function render() { + + if (sprite.x === 100 || sprite.x === 400) + { + game.debug.renderText('Click sprite to tween', 32, 32); + } + + game.debug.renderText('x: ' + arrowStart.x, arrowStart.x, arrowStart.y - 4); + game.debug.renderText('x: ' + arrowEnd.x, arrowEnd.x, arrowEnd.y - 4); + +} diff --git a/examples/wip/tween-relative.js b/examples/wip/tween-relative.js new file mode 100644 index 00000000..38fb243f --- /dev/null +++ b/examples/wip/tween-relative.js @@ -0,0 +1,57 @@ + +var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, render: render }); + +function preload() { + + game.load.image('phaser', 'assets/sprites/phaser1.png'); + game.load.spritesheet('arrows', 'assets/sprites/arrows.png', 23, 31); + +} + +var arrowStart; +var arrowEnd; +var sprite; + +function create() { + + game.stage.backgroundColor = '#2384e7'; + + arrowStart = game.add.sprite(100, 100, 'arrows', 0); + + arrowEnd = game.add.sprite(400, 100, 'arrows', 1); + + sprite = game.add.sprite(100, 164, 'phaser'); + sprite.inputEnabled = true; + + sprite.events.onInputDown.add(move, this); + +} + +function move() { + + if (sprite.x === 100) + { + // Here you'll notice we are using a relative value for the tween. + // You can specify a number as a string with either + or - at the start of it. + // When the tween starts it will take the sprites current X value and add +300 to it. + + game.add.tween(sprite).to( { x: '+300' }, 2000, Phaser.Easing.Linear.None, true); + } + else if (sprite.x === 400) + { + game.add.tween(sprite).to( { x: '-300' }, 2000, Phaser.Easing.Linear.None, true); + } + +} + +function render() { + + if (sprite.x === 100 || sprite.x === 400) + { + game.debug.renderText('Click sprite to tween', 32, 32); + } + + game.debug.renderText('x: ' + arrowStart.x, arrowStart.x, arrowStart.y - 4); + game.debug.renderText('x: ' + arrowEnd.x, arrowEnd.x, arrowEnd.y - 4); + +} diff --git a/src/animation/Animation.js b/src/animation/Animation.js index 0e11dd43..9e61c0df 100644 --- a/src/animation/Animation.js +++ b/src/animation/Animation.js @@ -328,6 +328,8 @@ Phaser.Animation.prototype = { }; +Phaser.Animation.prototype.constructor = Phaser.Animation; + /** * @name Phaser.Animation#paused * @property {boolean} paused - Gets and sets the paused state of this Animation. diff --git a/src/animation/AnimationManager.js b/src/animation/AnimationManager.js index 043ae6c9..1d6878ae 100644 --- a/src/animation/AnimationManager.js +++ b/src/animation/AnimationManager.js @@ -311,6 +311,8 @@ Phaser.AnimationManager.prototype = { }; +Phaser.AnimationManager.prototype.constructor = Phaser.AnimationManager; + /** * @name Phaser.AnimationManager#frameData * @property {Phaser.FrameData} frameData - The current animations FrameData. diff --git a/src/animation/Frame.js b/src/animation/Frame.js index 60f1a2b0..a87bf7dc 100644 --- a/src/animation/Frame.js +++ b/src/animation/Frame.js @@ -158,3 +158,5 @@ Phaser.Frame.prototype = { } }; + +Phaser.Frame.prototype.constructor = Phaser.Frame; diff --git a/src/animation/FrameData.js b/src/animation/FrameData.js index 6588ac21..588c6729 100644 --- a/src/animation/FrameData.js +++ b/src/animation/FrameData.js @@ -223,6 +223,8 @@ Phaser.FrameData.prototype = { }; +Phaser.FrameData.prototype.constructor = Phaser.FrameData; + /** * @name Phaser.FrameData#total * @property {number} total - The total number of frames in this FrameData set. diff --git a/src/core/Camera.js b/src/core/Camera.js index 98b3449e..c69dfdf7 100644 --- a/src/core/Camera.js +++ b/src/core/Camera.js @@ -322,6 +322,8 @@ Phaser.Camera.prototype = { }; +Phaser.Camera.prototype.constructor = Phaser.Camera; + /** * The Cameras x coordinate. This value is automatically clamped if it falls outside of the World bounds. * @name Phaser.Camera#x diff --git a/src/core/Filter.js b/src/core/Filter.js index 6088ba59..8f79611f 100644 --- a/src/core/Filter.js +++ b/src/core/Filter.js @@ -124,6 +124,8 @@ Phaser.Filter.prototype = { }; +Phaser.Filter.prototype.constructor = Phaser.Filter; + /** * @name Phaser.Filter#width * @property {number} width - The width (resolution uniform) diff --git a/src/core/Game.js b/src/core/Game.js index 67ceac99..08e1f7c3 100644 --- a/src/core/Game.js +++ b/src/core/Game.js @@ -635,6 +635,8 @@ Phaser.Game.prototype = { }; +Phaser.Game.prototype.constructor = Phaser.Game; + /** * The paused state of the Game. A paused game doesn't update any of its subsystems. * When a game is paused the onPause event is dispatched. When it is resumed the onResume event is dispatched. diff --git a/src/core/Group.js b/src/core/Group.js index a2f52160..4ea2eb0d 100644 --- a/src/core/Group.js +++ b/src/core/Group.js @@ -1495,6 +1495,8 @@ Phaser.Group.prototype = { }; +Phaser.Group.prototype.constructor = Phaser.Group; + /** * @name Phaser.Group#total * @property {number} total - The total number of children in this Group who have a state of exists = true. diff --git a/src/core/LinkedList.js b/src/core/LinkedList.js index 42358592..e60eaf2f 100644 --- a/src/core/LinkedList.js +++ b/src/core/LinkedList.js @@ -151,4 +151,6 @@ Phaser.LinkedList.prototype = { } -}; \ No newline at end of file +}; + +Phaser.LinkedList.prototype.constructor = Phaser.LinkedList; diff --git a/src/core/Plugin.js b/src/core/Plugin.js index c54933fb..efca2a28 100644 --- a/src/core/Plugin.js +++ b/src/core/Plugin.js @@ -119,3 +119,5 @@ Phaser.Plugin.prototype = { } }; + +Phaser.Plugin.prototype.constructor = Phaser.Plugin; diff --git a/src/core/PluginManager.js b/src/core/PluginManager.js index 2e353890..46b59ebc 100644 --- a/src/core/PluginManager.js +++ b/src/core/PluginManager.js @@ -295,3 +295,5 @@ Phaser.PluginManager.prototype = { } }; + +Phaser.PluginManager.prototype.constructor = Phaser.PluginManager; diff --git a/src/core/Signal.js b/src/core/Signal.js index 4caf87e7..fb80e16b 100644 --- a/src/core/Signal.js +++ b/src/core/Signal.js @@ -300,3 +300,5 @@ Phaser.Signal.prototype = { } }; + +Phaser.Signal.prototype.constructor = Phaser.Signal; diff --git a/src/core/SignalBinding.js b/src/core/SignalBinding.js index cfad9546..9bbf8778 100644 --- a/src/core/SignalBinding.js +++ b/src/core/SignalBinding.js @@ -160,3 +160,5 @@ Phaser.SignalBinding.prototype = { } }; + +Phaser.SignalBinding.prototype.constructor = Phaser.SignalBinding; diff --git a/src/core/Stage.js b/src/core/Stage.js index c1eaf0eb..ad5f0da7 100644 --- a/src/core/Stage.js +++ b/src/core/Stage.js @@ -230,6 +230,8 @@ Phaser.Stage.prototype = { }; +Phaser.Stage.prototype.constructor = Phaser.Stage; + /** * @name Phaser.Stage#backgroundColor * @property {number|string} backgroundColor - Gets and sets the background color of the stage. The color can be given as a number: 0xff0000 or a hex string: '#ff0000' diff --git a/src/core/State.js b/src/core/State.js index 38a99f21..a4187a77 100644 --- a/src/core/State.js +++ b/src/core/State.js @@ -167,3 +167,5 @@ Phaser.State.prototype = { } }; + +Phaser.State.prototype.constructor = Phaser.State; diff --git a/src/core/StateManager.js b/src/core/StateManager.js index dfe3dcf3..6d0d4e31 100644 --- a/src/core/StateManager.js +++ b/src/core/StateManager.js @@ -512,3 +512,5 @@ Phaser.StateManager.prototype = { } }; + +Phaser.StateManager.prototype.constructor = Phaser.StateManager; diff --git a/src/gameobjects/BitmapData.js b/src/gameobjects/BitmapData.js index 1fb08158..68939575 100644 --- a/src/gameobjects/BitmapData.js +++ b/src/gameobjects/BitmapData.js @@ -957,7 +957,9 @@ Phaser.BitmapData.prototype = { } -} +}; + +Phaser.BitmapData.prototype.constructor = Phaser.BitmapData; // EaselJS Tiny API emulation diff --git a/src/gameobjects/Events.js b/src/gameobjects/Events.js index 44c10956..b1caf708 100644 --- a/src/gameobjects/Events.js +++ b/src/gameobjects/Events.js @@ -73,4 +73,6 @@ Phaser.Events.prototype = { } -}; \ No newline at end of file +}; + +Phaser.Events.prototype.constructor = Phaser.Events; diff --git a/src/gameobjects/GameObjectFactory.js b/src/gameobjects/GameObjectFactory.js index e42d1723..547dbb5a 100644 --- a/src/gameobjects/GameObjectFactory.js +++ b/src/gameobjects/GameObjectFactory.js @@ -318,4 +318,6 @@ Phaser.GameObjectFactory.prototype = { } -}; \ No newline at end of file +}; + +Phaser.GameObjectFactory.prototype.constructor = Phaser.GameObjectFactory; diff --git a/src/geom/Circle.js b/src/geom/Circle.js index 78b2765c..3e65334b 100644 --- a/src/geom/Circle.js +++ b/src/geom/Circle.js @@ -195,6 +195,8 @@ Phaser.Circle.prototype = { }; +Phaser.Circle.prototype.constructor = Phaser.Circle; + /** * The largest distance between any two points on the circle. The same as the radius * 2. * @name Phaser.Circle#diameter diff --git a/src/geom/Point.js b/src/geom/Point.js index 3b090b5b..a97ede11 100644 --- a/src/geom/Point.js +++ b/src/geom/Point.js @@ -288,6 +288,8 @@ Phaser.Point.prototype = { }; +Phaser.Point.prototype.constructor = Phaser.Point; + /** * Adds the coordinates of two points together to create a new point. * @method Phaser.Point.add diff --git a/src/geom/Rectangle.js b/src/geom/Rectangle.js index db9c4c79..35104b8d 100644 --- a/src/geom/Rectangle.js +++ b/src/geom/Rectangle.js @@ -266,6 +266,8 @@ Phaser.Rectangle.prototype = { }; +Phaser.Rectangle.prototype.constructor = Phaser.Rectangle; + /** * @name Phaser.Rectangle#halfWidth * @property {number} halfWidth - Half of the width of the Rectangle. diff --git a/src/input/Input.js b/src/input/Input.js index aac7f365..7dfe87c6 100644 --- a/src/input/Input.js +++ b/src/input/Input.js @@ -689,6 +689,8 @@ Phaser.Input.prototype = { }; +Phaser.Input.prototype.constructor = Phaser.Input; + /** * The X coordinate of the most recently active pointer. This value takes game scaling into account automatically. See Pointer.screenX/clientX for source values. * @name Phaser.Input#x diff --git a/src/input/InputHandler.js b/src/input/InputHandler.js index 100ebb1d..d6327ca7 100644 --- a/src/input/InputHandler.js +++ b/src/input/InputHandler.js @@ -1106,4 +1106,6 @@ Phaser.InputHandler.prototype = { } -}; \ No newline at end of file +}; + +Phaser.InputHandler.prototype.constructor = Phaser.InputHandler; diff --git a/src/input/Key.js b/src/input/Key.js index 161829d9..7dc1a407 100644 --- a/src/input/Key.js +++ b/src/input/Key.js @@ -169,3 +169,5 @@ Phaser.Key.prototype = { } }; + +Phaser.Key.prototype.constructor = Phaser.Key; diff --git a/src/input/Keyboard.js b/src/input/Keyboard.js index 37654e9d..57f450b7 100644 --- a/src/input/Keyboard.js +++ b/src/input/Keyboard.js @@ -395,6 +395,8 @@ Phaser.Keyboard.prototype = { }; +Phaser.Keyboard.prototype.constructor = Phaser.Keyboard; + Phaser.Keyboard.A = "A".charCodeAt(0); Phaser.Keyboard.B = "B".charCodeAt(0); Phaser.Keyboard.C = "C".charCodeAt(0); diff --git a/src/input/MSPointer.js b/src/input/MSPointer.js index 80c0f058..11c0ce1d 100644 --- a/src/input/MSPointer.js +++ b/src/input/MSPointer.js @@ -165,4 +165,6 @@ Phaser.MSPointer.prototype = { } -}; \ No newline at end of file +}; + +Phaser.MSPointer.prototype.constructor = Phaser.MSPointer; diff --git a/src/input/Mouse.js b/src/input/Mouse.js index d8f54100..dce9289f 100644 --- a/src/input/Mouse.js +++ b/src/input/Mouse.js @@ -327,3 +327,5 @@ Phaser.Mouse.prototype = { } }; + +Phaser.Mouse.prototype.constructor = Phaser.Mouse; diff --git a/src/input/Pointer.js b/src/input/Pointer.js index 6f77870b..9a9f69b2 100644 --- a/src/input/Pointer.js +++ b/src/input/Pointer.js @@ -583,6 +583,8 @@ Phaser.Pointer.prototype = { }; +Phaser.Pointer.prototype.constructor = Phaser.Pointer; + /** * How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1. * @name Phaser.Pointer#duration diff --git a/src/input/Touch.js b/src/input/Touch.js index ff7e29d8..ffb5645c 100644 --- a/src/input/Touch.js +++ b/src/input/Touch.js @@ -380,4 +380,6 @@ Phaser.Touch.prototype = { } -}; \ No newline at end of file +}; + +Phaser.Touch.prototype.constructor = Phaser.Touch; diff --git a/src/loader/Cache.js b/src/loader/Cache.js index ec5fe2f9..60553472 100644 --- a/src/loader/Cache.js +++ b/src/loader/Cache.js @@ -845,3 +845,5 @@ Phaser.Cache.prototype = { } }; + +Phaser.Cache.prototype.constructor = Phaser.Cache; diff --git a/src/loader/Loader.js b/src/loader/Loader.js index c8cba89e..03c5784c 100644 --- a/src/loader/Loader.js +++ b/src/loader/Loader.js @@ -1300,3 +1300,5 @@ Phaser.Loader.prototype = { } }; + +Phaser.Loader.prototype.constructor = Phaser.Loader; diff --git a/src/math/Math.js b/src/math/Math.js index c0344090..619891fd 100644 --- a/src/math/Math.js +++ b/src/math/Math.js @@ -688,7 +688,7 @@ Phaser.Math = { }, /** - * Description. + * A Linear Interpolation Method, mostly used by Phaser.Tween. * @method Phaser.Math#linearInterpolation * @param {number} v * @param {number} k @@ -715,7 +715,7 @@ Phaser.Math = { }, /** - * Description. + * A Bezier Interpolation Method, mostly used by Phaser.Tween. * @method Phaser.Math#bezierInterpolation * @param {number} v * @param {number} k @@ -736,7 +736,7 @@ Phaser.Math = { }, /** - * Description. + * A Catmull Rom Interpolation Method, mostly used by Phaser.Tween. * @method Phaser.Math#catmullRomInterpolation * @param {number} v * @param {number} k diff --git a/src/math/QuadTree.js b/src/math/QuadTree.js index 5f2bd374..cc97cf99 100644 --- a/src/math/QuadTree.js +++ b/src/math/QuadTree.js @@ -263,3 +263,5 @@ Phaser.QuadTree.prototype = { } }; + +Phaser.QuadTree.prototype.constructor = Phaser.QuadTree; diff --git a/src/math/RandomDataGenerator.js b/src/math/RandomDataGenerator.js index afffa5ce..e3e41882 100644 --- a/src/math/RandomDataGenerator.js +++ b/src/math/RandomDataGenerator.js @@ -245,3 +245,5 @@ Phaser.RandomDataGenerator.prototype = { } }; + +Phaser.RandomDataGenerator.prototype.constructor = Phaser.RandomDataGenerator; diff --git a/src/net/Net.js b/src/net/Net.js index cb412371..f3066e9a 100644 --- a/src/net/Net.js +++ b/src/net/Net.js @@ -162,3 +162,5 @@ Phaser.Net.prototype = { } }; + +Phaser.Net.prototype.constructor = Phaser.Net; diff --git a/src/particles/Particles.js b/src/particles/Particles.js index 9d0f15b1..6238f762 100644 --- a/src/particles/Particles.js +++ b/src/particles/Particles.js @@ -76,4 +76,6 @@ Phaser.Particles.prototype = { } -}; \ No newline at end of file +}; + +Phaser.Particles.prototype.constructor = Phaser.Particles; diff --git a/src/physics/arcade/ArcadePhysics.js b/src/physics/arcade/ArcadePhysics.js index fce8da79..97c27b61 100644 --- a/src/physics/arcade/ArcadePhysics.js +++ b/src/physics/arcade/ArcadePhysics.js @@ -1621,3 +1621,5 @@ Phaser.Physics.Arcade.prototype = { } }; + +Phaser.Physics.Arcade.prototype.constructor = Phaser.Physics.Arcade; diff --git a/src/physics/arcade/Body.js b/src/physics/arcade/Body.js index 145f293d..b0e74a02 100644 --- a/src/physics/arcade/Body.js +++ b/src/physics/arcade/Body.js @@ -626,6 +626,8 @@ Phaser.Physics.Arcade.Body.prototype = { }; +Phaser.Physics.Arcade.Body.prototype.constructor = Phaser.Physics.Arcade.Body; + /** * @name Phaser.Physics.Arcade.Body#bottom * @property {number} bottom - The bottom value of this Body (same as Body.y + Body.height) diff --git a/src/pixi/renderers/webgl/StripShader.js b/src/pixi/renderers/webgl/StripShader.js index e82f33ad..55817b8b 100644 --- a/src/pixi/renderers/webgl/StripShader.js +++ b/src/pixi/renderers/webgl/StripShader.js @@ -27,8 +27,8 @@ PIXI.StripShader = function() 'attribute float aColor;', 'uniform mat3 translationMatrix;', 'uniform vec2 projectionVector;', + 'uniform vec2 offsetVector;', 'varying vec2 vTextureCoord;', - 'varying vec2 offsetVector;', 'varying float vColor;', 'void main(void) {', diff --git a/src/sound/Sound.js b/src/sound/Sound.js index 4fe74531..f3c79d74 100644 --- a/src/sound/Sound.js +++ b/src/sound/Sound.js @@ -703,6 +703,8 @@ Phaser.Sound.prototype = { }; +Phaser.Sound.prototype.constructor = Phaser.Sound; + /** * @name Phaser.Sound#isDecoding * @property {boolean} isDecoding - Returns true if the sound file is still decoding. diff --git a/src/sound/SoundManager.js b/src/sound/SoundManager.js index 0cef0fce..cb64f213 100644 --- a/src/sound/SoundManager.js +++ b/src/sound/SoundManager.js @@ -369,6 +369,8 @@ Phaser.SoundManager.prototype = { }; +Phaser.SoundManager.prototype.constructor = Phaser.SoundManager; + /** * @name Phaser.SoundManager#mute * @property {boolean} mute - Gets or sets the muted state of the SoundManager. This effects all sounds in the game. diff --git a/src/system/Canvas.js b/src/system/Canvas.js index ee4347c2..ded7c813 100644 --- a/src/system/Canvas.js +++ b/src/system/Canvas.js @@ -146,7 +146,7 @@ Phaser.Canvas = { * @method Phaser.Canvas.addToDOM * @param {HTMLCanvasElement} canvas - The canvas to set the touch action on. * @param {string|HTMLElement} parent - The DOM element to add the canvas to. - * @param {boolean} overflowHidden - If set to true it will add the overflow='hidden' style to the parent DOM element. + * @param {boolean} [overflowHidden=true] - If set to true it will add the overflow='hidden' style to the parent DOM element. * @return {HTMLCanvasElement} Returns the source canvas. */ addToDOM: function (canvas, parent, overflowHidden) { @@ -167,11 +167,6 @@ Phaser.Canvas = { // quick test for a HTMLelement target = parent; } - - if (overflowHidden) - { - target.style.overflow = 'hidden'; - } } // Fallback, covers an invalid ID and a non HTMLelement object @@ -180,6 +175,11 @@ Phaser.Canvas = { target = document.body; } + if (overflowHidden && target.style) + { + target.style.overflow = 'hidden'; + } + target.appendChild(canvas); return canvas; diff --git a/src/system/Device.js b/src/system/Device.js index 1e40f7e2..de1bb784 100644 --- a/src/system/Device.js +++ b/src/system/Device.js @@ -667,3 +667,5 @@ Phaser.Device.prototype = { } }; + +Phaser.Device.prototype.constructor = Phaser.Device; diff --git a/src/system/RequestAnimationFrame.js b/src/system/RequestAnimationFrame.js index 2fd35a72..34c02ba5 100644 --- a/src/system/RequestAnimationFrame.js +++ b/src/system/RequestAnimationFrame.js @@ -154,4 +154,6 @@ Phaser.RequestAnimationFrame.prototype = { return (this._isSetTimeOut === false); } -}; \ No newline at end of file +}; + +Phaser.RequestAnimationFrame.prototype.constructor = Phaser.RequestAnimationFrame; diff --git a/src/system/StageScaleMode.js b/src/system/StageScaleMode.js index fd558885..dddea255 100644 --- a/src/system/StageScaleMode.js +++ b/src/system/StageScaleMode.js @@ -734,6 +734,8 @@ Phaser.StageScaleMode.prototype = { }; +Phaser.StageScaleMode.prototype.constructor = Phaser.StageScaleMode; + /** * @name Phaser.StageScaleMode#isFullScreen * @property {boolean} isFullScreen - Returns true if the browser is in full screen mode, otherwise false. diff --git a/src/tilemap/Tile.js b/src/tilemap/Tile.js index e5fd20c5..8d66a471 100644 --- a/src/tilemap/Tile.js +++ b/src/tilemap/Tile.js @@ -204,6 +204,8 @@ Phaser.Tile.prototype = { }; +Phaser.Tile.prototype.constructor = Phaser.Tile; + /** * @name Phaser.Tile#bottom * @property {number} bottom - The sum of the y and height properties. diff --git a/src/tilemap/Tilemap.js b/src/tilemap/Tilemap.js index 098c0ae8..7f775a71 100644 --- a/src/tilemap/Tilemap.js +++ b/src/tilemap/Tilemap.js @@ -1086,3 +1086,5 @@ Phaser.Tilemap.prototype = { } }; + +Phaser.Tilemap.prototype.constructor = Phaser.Tilemap; diff --git a/src/tilemap/Tileset.js b/src/tilemap/Tileset.js index afd2cf27..e25dd331 100644 --- a/src/tilemap/Tileset.js +++ b/src/tilemap/Tileset.js @@ -81,7 +81,7 @@ Phaser.Tileset = function (name, firstgid, width, height, margin, spacing, prope */ this.total = 0; -} +}; Phaser.Tileset.prototype = { @@ -151,4 +151,6 @@ Phaser.Tileset.prototype = { } -} +}; + +Phaser.Tileset.prototype.constructor = Phaser.Tileset; diff --git a/src/time/Time.js b/src/time/Time.js index 7f1ac48c..17b928d9 100644 --- a/src/time/Time.js +++ b/src/time/Time.js @@ -235,4 +235,6 @@ Phaser.Time.prototype = { this._started = this.now; } -}; \ No newline at end of file +}; + +Phaser.Time.prototype.constructor = Phaser.Time; diff --git a/src/time/Timer.js b/src/time/Timer.js index 8677ea46..3e65889e 100644 --- a/src/time/Timer.js +++ b/src/time/Timer.js @@ -43,7 +43,7 @@ Phaser.Timer = function (game) { // Need to add custom FPS rate, for now we'll just use seconds -} +}; Phaser.Timer.prototype = { @@ -114,4 +114,6 @@ Phaser.Timer.prototype = { return (this.game.time.now - this._started) * 0.001; } -} \ No newline at end of file +}; + +Phaser.Timer.prototype.constructor = Phaser.Timer; diff --git a/src/tween/Tween.js b/src/tween/Tween.js index ca0020dc..8d5a4838 100644 --- a/src/tween/Tween.js +++ b/src/tween/Tween.js @@ -112,14 +112,7 @@ Phaser.Tween = function (object, game) { this._chainedTweens = []; /** - * @property {function} _onStartCallback - An onStart callback. - * @private - * @default - */ - this._onStartCallback = null; - - /** - * @property {boolean} _onStartCallbackFired - Private onStart flag. + * @property {boolean} _onStartCallbackFired - Private flag. * @private * @default */ @@ -131,14 +124,7 @@ Phaser.Tween = function (object, game) { * @default null */ this._onUpdateCallback = null; - - /** - * @property {function} _onCompleteCallback - An onComplete callback. - * @private - * @default null - */ - this._onCompleteCallback = null; - + /** * @property {number} _pausedTime - Private pause timer. * @private @@ -196,7 +182,7 @@ Phaser.Tween.prototype = { * @param {boolean} [yoyo=false] - A tween that yoyos will reverse itself when it completes. * @return {Phaser.Tween} This Tween object. */ - to: function ( properties, duration, ease, autoStart, delay, repeat, yoyo ) { + to: function (properties, duration, ease, autoStart, delay, repeat, yoyo) { duration = duration || 1000; ease = ease || null; @@ -236,9 +222,12 @@ Phaser.Tween.prototype = { self._yoyo = yoyo; - if (autoStart) { + if (autoStart) + { return this.start(); - } else { + } + else + { return this; } @@ -252,7 +241,8 @@ Phaser.Tween.prototype = { */ start: function () { - if (this.game === null || this._object === null) { + if (this.game === null || this._object === null) + { return; } @@ -264,29 +254,28 @@ Phaser.Tween.prototype = { this._startTime = this.game.time.now + this._delayTime; - for ( var property in this._valuesEnd ) { - + for (var property in this._valuesEnd) + { // check if an Array was provided as property value - if ( this._valuesEnd[ property ] instanceof Array ) { - - if ( this._valuesEnd[ property ].length === 0 ) { - + if (this._valuesEnd[property] instanceof Array) + { + if (this._valuesEnd[property].length === 0) + { continue; - } // create a local copy of the Array with the start value at the front - this._valuesEnd[ property ] = [ this._object[ property ] ].concat( this._valuesEnd[ property ] ); - + this._valuesEnd[property] = [this._object[property]].concat(this._valuesEnd[property]); } - this._valuesStart[ property ] = this._object[ property ]; + this._valuesStart[property] = this._object[property]; - if ( ( this._valuesStart[ property ] instanceof Array ) === false ) { - this._valuesStart[ property ] *= 1.0; // Ensures we're using numbers, not strings + if ((this._valuesStart[property] instanceof Array) === false) + { + this._valuesStart[property] *= 1.0; // Ensures we're using numbers, not strings } - this._valuesStartRepeat[ property ] = this._valuesStart[ property ] || 0; + this._valuesStartRepeat[property] = this._valuesStart[property] || 0; } @@ -317,7 +306,7 @@ Phaser.Tween.prototype = { * @param {number} amount - The amount of the delay in ms. * @return {Phaser.Tween} Itself. */ - delay: function ( amount ) { + delay: function (amount) { this._delayTime = amount; return this; @@ -331,7 +320,7 @@ Phaser.Tween.prototype = { * @param {number} times - How many times to repeat. * @return {Phaser.Tween} Itself. */ - repeat: function ( times ) { + repeat: function (times) { this._repeat = times; return this; @@ -346,7 +335,7 @@ Phaser.Tween.prototype = { * @param {boolean} yoyo - Set to true to yoyo this tween. * @return {Phaser.Tween} Itself. */ - yoyo: function( yoyo ) { + yoyo: function(yoyo) { this._yoyo = yoyo; return this; @@ -360,7 +349,7 @@ Phaser.Tween.prototype = { * @param {function} easing - The easing function this tween will use, i.e. Phaser.Easing.Linear.None. * @return {Phaser.Tween} Itself. */ - easing: function ( easing ) { + easing: function (easing) { this._easingFunction = easing; return this; @@ -369,12 +358,13 @@ Phaser.Tween.prototype = { /** * Set interpolation function the tween will use, by default it uses Phaser.Math.linearInterpolation. + * Also available: Phaser.Math.bezierInterpolation and Phaser.Math.catmullRomInterpolation. * * @method Phaser.Tween#interpolation * @param {function} interpolation - The interpolation function to use (Phaser.Math.linearInterpolation by default) * @return {Phaser.Tween} Itself. */ - interpolation: function ( interpolation ) { + interpolation: function (interpolation) { this._interpolationFunction = interpolation; return this; @@ -414,20 +404,6 @@ Phaser.Tween.prototype = { }, - /** - * Sets a callback to be fired when the tween starts. Note: callback will be called in the context of the global scope. - * - * @method Phaser.Tween#onStartCallback - * @param {function} callback - The callback to invoke on start. - * @return {Phaser.Tween} Itself. - */ - onStartCallback: function ( callback ) { - - this._onStartCallback = callback; - return this; - - }, - /** * Sets a callback to be fired each time this tween updates. Note: callback will be called in the context of the global scope. * @@ -435,35 +411,23 @@ Phaser.Tween.prototype = { * @param {function} callback - The callback to invoke each time this tween is updated. * @return {Phaser.Tween} Itself. */ - onUpdateCallback: function ( callback ) { + onUpdateCallback: function (callback) { this._onUpdateCallback = callback; return this; }, - /** - * Sets a callback to be fired when the tween completes. Note: callback will be called in the context of the global scope. - * - * @method Phaser.Tween#onCompleteCallback - * @param {function} callback - The callback to invoke on completion. - * @return {Phaser.Tween} Itself. - */ - onCompleteCallback: function ( callback ) { - - this._onCompleteCallback = callback; - return this; - - }, - /** * Pauses the tween. * * @method Phaser.Tween#pause */ pause: function () { + this._paused = true; this._pausedTime = this.game.time.now; + }, /** @@ -472,8 +436,10 @@ Phaser.Tween.prototype = { * @method Phaser.Tween#resume */ resume: function () { + this._paused = false; this._startTime += (this.game.time.now - this._pausedTime); + }, /** @@ -483,7 +449,7 @@ Phaser.Tween.prototype = { * @param {number} time - A timestamp passed in by the TweenManager. * @return {boolean} false if the tween has completed and should be deleted from the manager, otherwise true (still active). */ - update: function ( time ) { + update: function (time) { if (this.pendingDelete) { @@ -505,77 +471,70 @@ Phaser.Tween.prototype = { if (this._onStartCallbackFired === false) { this.onStart.dispatch(this._object); - - if (this._onStartCallback !== null ) - { - this._onStartCallback.call( this._object ); - } - this._onStartCallbackFired = true; } - var elapsed = ( time - this._startTime ) / this._duration; + var elapsed = (time - this._startTime) / this._duration; elapsed = elapsed > 1 ? 1 : elapsed; - var value = this._easingFunction( elapsed ); + var value = this._easingFunction(elapsed); - for ( property in this._valuesEnd ) { - - var start = this._valuesStart[ property ] || 0; - var end = this._valuesEnd[ property ]; - - if ( end instanceof Array ) { - - this._object[ property ] = this._interpolationFunction( end, value ); - - } else { + for (property in this._valuesEnd) + { + var start = this._valuesStart[property] || 0; + var end = this._valuesEnd[property]; + if (end instanceof Array) + { + this._object[property] = this._interpolationFunction(end, value); + } + else + { // Parses relative end values with start as base (e.g.: +10, -3) - if ( typeof(end) === "string" ) { + if (typeof(end) === 'string') + { end = start + parseFloat(end, 10); } // protect against non numeric properties. - if ( typeof(end) === "number" ) { - this._object[ property ] = start + ( end - start ) * value; + if (typeof(end) === 'number') + { + this._object[property] = start + ( end - start ) * value; } - } - } - if ( this._onUpdateCallback !== null ) { - - this._onUpdateCallback.call( this._object, value ); - + if (this._onUpdateCallback !== null) + { + this._onUpdateCallback.call(this._object, value); } - if ( elapsed == 1 ) { - - if ( this._repeat > 0 ) { - - if ( isFinite( this._repeat ) ) { + if (elapsed == 1) + { + if (this._repeat > 0) + { + if (isFinite(this._repeat)) + { this._repeat--; } // reassign starting values, restart by making startTime = now - for ( property in this._valuesStartRepeat ) { - - if ( typeof( this._valuesEnd[ property ] ) === "string" ) + for (property in this._valuesStartRepeat) + { + if (typeof(this._valuesEnd[property]) === 'string') { - this._valuesStartRepeat[ property ] = this._valuesStartRepeat[ property ] + parseFloat(this._valuesEnd[ property ], 10); + this._valuesStartRepeat[property] = this._valuesStartRepeat[property] + parseFloat(this._valuesEnd[property], 10); } if (this._yoyo) { - var tmp = this._valuesStartRepeat[ property ]; - this._valuesStartRepeat[ property ] = this._valuesEnd[ property ]; - this._valuesEnd[ property ] = tmp; + var tmp = this._valuesStartRepeat[property]; + this._valuesStartRepeat[property] = this._valuesEnd[property]; + this._valuesEnd[property] = tmp; this._reversed = !this._reversed; } - this._valuesStart[ property ] = this._valuesStartRepeat[ property ]; - + this._valuesStart[property] = this._valuesStartRepeat[property]; } this._startTime = time + this._delayTime; @@ -584,23 +543,18 @@ Phaser.Tween.prototype = { return true; - } else { - + } + else + { this.isRunning = false; this.onComplete.dispatch(this._object); - if ( this._onCompleteCallback !== null ) { - this._onCompleteCallback.call( this._object ); - } - - for ( var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i ++ ) { - - this._chainedTweens[ i ].start( time ); - + for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i ++) + { + this._chainedTweens[i].start(time); } return false; - } } @@ -610,3 +564,5 @@ Phaser.Tween.prototype = { } }; + +Phaser.Tween.prototype.constructor = Phaser.Tween; diff --git a/src/tween/TweenManager.js b/src/tween/TweenManager.js index 00974bf3..63efdc07 100644 --- a/src/tween/TweenManager.js +++ b/src/tween/TweenManager.js @@ -202,4 +202,6 @@ Phaser.TweenManager.prototype = { } -}; \ No newline at end of file +}; + +Phaser.TweenManager.prototype.constructor = Phaser.TweenManager; diff --git a/src/utils/Debug.js b/src/utils/Debug.js index 1b8ed27a..f89d328a 100644 --- a/src/utils/Debug.js +++ b/src/utils/Debug.js @@ -918,5 +918,6 @@ Phaser.Utils.Debug.prototype = { } - }; + +Phaser.Utils.Debug.prototype.constructor = Phaser.Utils.Debug;