diff --git a/CHANGELOG.md b/CHANGELOG.md index 14c10ac4f..ea4dddb42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,22 +2,68 @@ ## Version 3.11.0 - Leafa - in development +### Camera - New Features, Updates and Fixes + +* All of the 2D Camera classes are now 100% covered by JSDocs! +* `Camera.alpha` (and its related method `Camera.setAlpha`) allows you to set an alpha level for the entire camera. This impacts everything it is rendering, even if those objects also have their own alpha values too. You can tween the property to make the camera contents fade in / out, or otherwise set it as needed in your game. +* `Camera.deadzone` (and its related method `Camera.setDeadzone`) allows you to specify the deadzone for a camera. The deadzone is a rectangular region used when a camera is following a target. If the target is within the deadzone then the camera will not scroll. As soon as the target leaves the deadzone, the camera will begin tracking it (applying lerp if needed.) It allows you to set a region of the camera in which a player can move freely before tracking begins. The deadzone is re-centered on the camera mid point every frame, meaning you can also use the rectangle for other in-game checks as needed. +* `Camera.pan` is a new Camera Effect that allows you to control automatic camera pans between points in your game world. You can specify a duration and ease type for the pan, and it'll emit events just like all other camera effects, so you can hook into the start, update and completion of the pan. See the examples and docs for more details. +* `Camera.zoom` is a new Camera Effect that allows you to control automatic camera zooming. You can specify a duration and ease type for the zoom, as well as the zoom factor of course, and it'll emit events just like all other camera effects, so you can hook into the start, update and completion of the zoom. Used in combination with the new Pan effect you can zoom and pan around with ease. See the examples and docs for more details. +* `Camera.midPoint` is a new Vec2 property that is updated every frame. Use it to obtain exactly where in the world the center of the camera is currently looking. +* `Camera.displayWidth` is a new property that returns the display width of the camera, factoring in the current zoom level. +* `Camera.displayHeight` is a new property that returns the display height of the camera, factoring in the current zoom level. +* `Camera.centerOn` is a new method that will move the camera so its viewport is centered on the given coordinates. A handy way of jumping to different points around a map without needing to calculate the scroll offsets. +* The Camera bounds didn't factor in the camera zoom properly, meaning you would often not be able to reach the corners of a camera bound world at a zoom level other than 1. The bounds are now calculated each frame to ensure they match the zoom level and it will no longer allow you to scroll off the edge of the bounds. Fix #3547 (thanks @nkholski) +* `Camera.centerToBounds` didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706 (thanks @cyantree) +* `Camera.setBounds` has a new optional argument `centerOn`. If specified it will automatically center the camera on the new bounds given. +* The Camera will no longer stutter when following Game Objects at high zoom levels. +* `Camera._id` has been renamed to `Camera.id`, a read-only bitmask used for camera exclusion from Game Objects. +* The Camera Manager `cameraPool` has been removed entirely. It was mostly pointless in practice as Cameras are not regenerated frequently enough to need pooling. It also didn't maintain the bitmask list correctly before. +* `CameraManager.resetAll` now destroys all current Cameras, resets the camera ID marker to 1 and adds a single new Camera. +* `CameraManager.currentCameraId` has been removed. IDs are assigned more intelligently now, via the `getNextID` internal method. +* `CameraManager.addExisting` no longer needs to be passed a Camera that already exists in the pool (as the pool has been removed), meaning you can now create your own Cameras and pass them to `addExisting` and have them treated as normal cameras and not be ignored by the manager. They are also assigned a proper ID when added. +* `CameraManager.addExisting` has a new boolean argument `makeMain` which will make the new camera the main one. +* `CameraManager.getTotal` is a new method that will return the total number of Cameras being managed, with an optional `isVisible` argument, that only counts visible cameras if set. +* `CameraManager.remove` can now take an array of cameras to be removed from the manager, as well as a single camera. +* `CameraManager.remove` would previously not allow you to remove a camera if it meant there would be no cameras left in the Camera Manager. This restriction has been removed. A Camera Manager can now run even with zero cameras. Your game obviously won't display anything, but it's still now possible. +* `CameraManager.remove` will now return the total number of Cameras removed. + +### Round Pixels Changes + +Before explaining the changes it's worth covering what the three different game config properties do: + +`roundPixels` - this will cause the renderer to draw most Game Objects at whole integer positions. Their actual positions can be anything, but the renderer will floor the values to ensure they are integers immediately before drawing. It only works on texture based Game Objects. Graphics objects, for instance, ignore this property. + +`antialias` - when set to `true` WebGL textures are created using `gl.LINEAR`, which allows WebGL to try its best to interpolate the texture when rendered at non-texture frame sizes. This can happen if you scale a Game Object, or zoom a Camera. In both cases it will need to interpolate the pixel values to accommodate the new size. If this property is set to `false` then it will use `gl.NEAREST` instead. This uses a nearest neighbor method of interpolation, and is nearly always the better option if you need to keep the textures crisp, such as when using scaled pixel art. Disabling `antialias` invokes nearest-neighbor interpolation on the game canvas itself as well. If you need a mixture of aliased and anti-aliased textures in your game, then you can change them on a per-texture basis by using `Texture.setFilter`. + +There is a third game config property called `pixelArt`. If set to `true` it's the same thing as enabling `roundPixels` and disabling `antialias`. This is the optimum setting for pixel art games. + +* Both renderers will now check for `pixelArt` OR `antialias` before setting the canvas scale mode. Both values are checked during texture creation as well. +* If in your game config you have enabled either pixel art mode or roundPixels, then all Cameras will have their `roundPixels` values set to `true` by default. You can toggle this by changing the `CameraManager.roundPixels` property, or change it on a camera-by-camera basis, as needed. +* `Camera.roundPixels` is now used across all rendering code for both Canvas and WebGL. Previously, it would check the renderer config value, but now all renderer code uses the camera value to decide if it should floor the drawing position or not. + ### New Features * `Graphics.fillRoundedRect` will draw a stroked rounded rectangle to a Graphics object. The radius of the corners can be either a number, or an object, allowing you to specify different radius per corner (thanks @TadejZupancic) * `Graphics.strokeRoundedRect` will draw a filled rounded rectangle to a Graphics object. The radius of the corners can be either a number, or an object, allowing you to specify different radius per corner (thanks @TadejZupancic) -* `Camera.deadzone` (and its related method `Camera.setDeadzone`) allows you to specify the deadzone for a camera. The deadzone is a rectangular region used when a camera is following a target. If the target is within the deadzone then the camera will not scroll. As soon as the target leaves the deadzone, the camera will begin tracking it (applying lerp if needed.) It allows you to set a region of the camera in which a player can move freely before tracking begins. The deadzone is re-centered on the camera mid point every frame, meaning you can also use the rectangle for other in-game chcecks as needed. -* `Camera.midPoint` is a new Vec2 property that is updated every frame. Use it to obtain exactly where in the world the center of the camera is currently looking. -* `Camera.displayWidth` is a new property that returns the display width of the camera, factoring in the current zoom level. -* `Camera.displayHeight` is a new property that returns the display height of the camera, factoring in the current zoom level. -* `Camera.centerOn` is a new method that will move the camera so its viewport is centered on the given coordinates. A handy way of jumping to different points around a map without needing to calculate the scroll offsets. +* `ParticleEmitter.stop` is a new chainable method to stop a particle emitter. It's the same as setting `on` to `false` but means you don't have to break the method flow to do so (thanks @samme) +* `ScenePlugin.pause` (and the corresponding methods in Scene Systems and the Scene Manager) now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'pause' event. +* `ScenePlugin.resume` (and the corresponding methods in Scene Systems and the Scene Manager) now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'resume' event. +* `ScenePlugin.sleep` (and the corresponding methods in Scene Systems and the Scene Manager) now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'sleep' event. +* `ScenePlugin.wake` (and the corresponding methods in Scene Systems and the Scene Manager) now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'wake' event. +* `ScenePlugin.setActive` now has a new optional `data` argument, which is passed to the target Scene and emitted in its 'pause' or 'resume' events. +* `TileSprite.tileScaleX` and `tileScaleY` are two new properties that allow you to control the scale of the texture within the Tile Sprite. This impacts the way the repeating texture is scaled, and is independent to scaling the Tile Sprite itself. It works in both Canvas and WebGL mode. ### Updates * DataManager.removeValue (and by extension the `remove` method too) will not emit the parent of the DataManager as the 2nd argument in the `removedata` event, to keep it consistent with the set events (thanks @rexrainbow) * The docs for the Loader `filecomplete` event said that you could listen for a specific file using its type and key, i.e.: `filecomplete-image-monster`, however, the code used an underscore instead of a hyphen. We feel the hyphen looks cleaner, so the Loader code has been updated, meaning you can now use the hyphen version of the event properly (thanks @NokFrt) * If a Game Object is already being dragged, it cannot be dragged by another pointer (in multi-touch mode) until the original pointer has released it (thanks @rexrainbow) -* Calling `Tween.play` on a tween created via `TweenManager.create` wouldn't actually start playback until the tween was first added to the Tween Manager. Now, calling `play` will have it automatically add itself to the Tween Manager if it's not already in there. Fix #3763 (thanks @pantoninho) +* Calling `Tween.play` on a tween created via `TweenManager.create` wouldn't actually start playback until the tween was first added to the Tween Manager. Now, calling `play` will have it automatically add itself to the Tween Manager if it's not already in there. Fix #3763 (thanks @pantoninho) +* If the Blitter object has no Bob's to render it will now abort immediately, avoiding several context calls in Canvas mode. +* `Scene.run` will now pass the optional `data` object in all cases, no matter if it's waking, resuming or starting a Scene (thanks @rook2pawn) +* `ScenePlugin.start` and `ScenePlugin.restart` will now always queue the op with the Scene Manager, regardless of the state of the Scene, in order to avoid issues where plugins carry on running for a frame before closing down. Fix #3776 (thanks @jjalonso) +* The `batchTileSprite` method has been removed from the `TextureTintPipeline` class, because it is now handled internally by the Tile Sprite object itself. ### Bug Fixes @@ -25,17 +71,25 @@ * The LoaderPlugin didn't emit the `filecomplete` event if any of files failed to load, causing it to fail to run the Scene `create` function as well. Fix #3750 (thanks @NokFrt) * Fix setter calls in BuildGameObjectAnimation so it will now properly set the delay, repeat, repeat delay and yoyo of a config based animation (thanks @DannyT) * The Arcade Body `blocked.none` property is now set to `false` after separation with static bodies or tiles. Previously, the blocked direction was set correctly, but the `none` remained `true` (thanks @samme) -* The Camera bounds didn't factor in the camera zoom properly, meaning you would often not be able to reach the corners of a camera bound world at a zoom level other than 1. The bounds are now calculated each frame to ensure they match the zoom level and it will no longer allow you to scroll off the edge of the bounds. Fix #3547 (thanks @nkholski) * `Bob.setFrame` didn't actually set the frame on the Bob, now it does. Fix #3774 (thanks @NokFrt) -* `Camera.centerToBounds` didn't take the bounds offset into account, so bounds at non-zero positions wouldn't center properly. All bounds now center correctly. Fix #3706 (thanks @cyantree) +* `Bob.alpha` was ignored by the canvas renderer, only working in WebGL. This has now been fixed. +* Although the Blitter object had the Alpha component, setting it made no difference. Setting Blitter alpha now impacts the rendering of all children, in both Canvas and WebGL, and you can also specify an alpha per Bob as well. +* `SceneManager.run` would ignore scenes that are currently in the queue of scenes pending to be added. This has now been fixed so that the scene is queued to be started once it's ready (thanks @rook2pawn) +* `GameObject.disableInteractive` was toggling input. Every second call would turn the input back on (thanks @TadejZupancic) +* The position of the TilemapLayer wasn't taken into account when culling tiles for the Camera. It's now calculated as part of the cull flow (thanks @Upperfoot) +* Fix extra argument passing in Array.Each (thanks @samme) +* TileSprite was using the Size component instead of ComputedSize, meaning its `getBounds` and `displayWidth` and `displayHeight` results were incorrect. Fix #3789 (thanks @jjalonso) +* `ArrayUtils.AddAt` didn't calculate the array offset correctly if you passed an array in to be merged with an existing array. This also caused Container.addAt to fail if an array was passed to it. Fix #3788 (thanks @jjalonso) +* The `Pointer.camera` property would only be set if there was a viable Game Object in the camera view. Now it is set regardless, to always be the Camera the Pointer interacted with. +* Added the Mask component to Container. It worked without it, but this brings it in-line with the documentation and other Game Objects. Fix #3797 (thanks @zilbuz) ### Examples, Documentation and TypeScript My thanks to the following for helping with the Phaser 3 Examples, Docs and TypeScript definitions, either by reporting errors, fixing them or helping author the docs: -@DannyT @squilibob @dvdbrink @t1gu1 @cyantree @DrevanTonder +@DannyT @squilibob @dvdbrink @t1gu1 @cyantree @DrevanTonder @mikewesthad -Also, a special mention to @andygroff for his excellent work enhancing the search box on the examples site. +Also, a special mention to @andygroff for his excellent work enhancing the search box on the examples site, and @hexus for his assistance completing the documentation for the Game Objects. ## Version 3.10.1 - Hayashi - 13th June 2018 diff --git a/src/animations/Animation.js b/src/animations/Animation.js index cf2107c0f..c6f83bf8b 100644 --- a/src/animations/Animation.js +++ b/src/animations/Animation.js @@ -32,7 +32,7 @@ var GetValue = require('../utils/object/GetValue'); * * @property {string} key - The key that the animation will be associated with. i.e. sprite.animations.play(key) * @property {(string|number)} frame - [description] - * @property {float} [duration=0] - [description] + * @property {number} [duration=0] - [description] * @property {boolean} [visible] - [description] */ @@ -545,7 +545,7 @@ var Animation = new Class({ * @method Phaser.Animations.Animation#getFrameByProgress * @since 3.4.0 * - * @param {float} value - A value between 0 and 1. + * @param {number} value - A value between 0 and 1. * * @return {Phaser.Animations.AnimationFrame} The frame closest to the given progress value. */ diff --git a/src/boot/Config.js b/src/boot/Config.js index b05667951..7211a1756 100644 --- a/src/boot/Config.js +++ b/src/boot/Config.js @@ -323,25 +323,31 @@ var Config = new Class({ var renderConfig = GetValue(config, 'render', config); + /** + * @const {boolean} Phaser.Boot.Config#autoResize - [description] + */ + this.autoResize = GetValue(renderConfig, 'autoResize', false); + /** * @const {boolean} Phaser.Boot.Config#antialias - [description] */ this.antialias = GetValue(renderConfig, 'antialias', true); + /** + * @const {boolean} Phaser.Boot.Config#roundPixels - [description] + */ + this.roundPixels = GetValue(renderConfig, 'roundPixels', false); + /** * @const {boolean} Phaser.Boot.Config#pixelArt - [description] */ this.pixelArt = GetValue(renderConfig, 'pixelArt', false); - /** - * @const {boolean} Phaser.Boot.Config#autoResize - [description] - */ - this.autoResize = GetValue(renderConfig, 'autoResize', false); - - /** - * @const {boolean} Phaser.Boot.Config#roundPixels - [description] - */ - this.roundPixels = GetValue(renderConfig, 'roundPixels', false); + if (this.pixelArt) + { + this.antialias = false; + this.roundPixels = true; + } /** * @const {boolean} Phaser.Boot.Config#transparent - [description] diff --git a/src/boot/CreateRenderer.js b/src/boot/CreateRenderer.js index 908fbe834..b45ab8de3 100644 --- a/src/boot/CreateRenderer.js +++ b/src/boot/CreateRenderer.js @@ -48,7 +48,7 @@ var CreateRenderer = function (game) } // Pixel Art mode? - if (config.pixelArt) + if (!config.antialias) { CanvasPool.disableSmoothing(); } @@ -70,7 +70,7 @@ var CreateRenderer = function (game) } // Pixel Art mode? - if (config.pixelArt) + if (!config.antialias) { CanvasInterpolation.setCrisp(game.canvas); } diff --git a/src/cameras/2d/Camera.js b/src/cameras/2d/Camera.js index a822f7253..980be2549 100644 --- a/src/cameras/2d/Camera.js +++ b/src/cameras/2d/Camera.js @@ -94,6 +94,17 @@ var Camera = new Class({ */ this.scene; + /** + * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. + * This value is a bitmask. + * + * @name Phaser.Cameras.Scene2D.Camera#id + * @type {integer} + * @readOnly + * @since 3.11.0 + */ + this.id = 0; + /** * The name of the Camera. This is left empty for your own use. * @@ -251,7 +262,7 @@ var Camera = new Class({ * Be careful to never set this value to zero. * * @name Phaser.Cameras.Scene2D.Camera#zoom - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -302,6 +313,18 @@ var Camera = new Class({ */ this.backgroundColor = ValueToColor('rgba(0,0,0,0)'); + /** + * The Camera alpha value. Setting this property impacts every single object that this Camera + * renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out, + * or via the chainable `setAlpha` method instead. + * + * @name Phaser.Cameras.Scene2D.Camera#alpha + * @type {number} + * @default 1 + * @since 3.11.0 + */ + this.alpha = 1; + /** * The Camera Fade effect handler. * To fade this camera see the `Camera.fade` methods. @@ -429,7 +452,7 @@ var Camera = new Class({ * See `setOrigin` to set both origins in a single, chainable call. * * @name Phaser.Cameras.Scene2D.Camera#originX - * @type {float} + * @type {number} * @default 0.5 * @since 3.11.0 */ @@ -446,7 +469,7 @@ var Camera = new Class({ * See `setOrigin` to set both origins in a single, chainable call. * * @name Phaser.Cameras.Scene2D.Camera#originY - * @type {float} + * @type {number} * @default 0.5 * @since 3.11.0 */ @@ -487,17 +510,26 @@ var Camera = new Class({ * @since 3.0.0 */ this._follow = null; + }, - /** - * Internal camera ID. Assigned by the Camera Manager and used in the camera pool. - * - * @name Phaser.Cameras.Scene2D.Camera#_id - * @type {integer} - * @private - * @default 0 - * @since 3.0.0 - */ - this._id = 0; + /** + * Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * @method Phaser.GameObjects.Components.Origin#setAlpha + * @since 3.11.0 + * + * @param {number} [value=1] - The Camera alpha value. + * + * @return {this} This Camera instance. + */ + setAlpha: function (value) + { + if (value === undefined) { value = 1; } + + this.alpha = value; + + return this; }, /** @@ -1029,7 +1061,7 @@ var Camera = new Class({ */ ignore: function (gameObject) { - var id = this._id; + var id = this.id; if (Array.isArray(gameObject)) { @@ -1317,10 +1349,23 @@ var Camera = new Class({ }, /** - * Set the world bounds for this Camera. - * - * A Camera bounds controls where the camera can scroll to within the world. It does not limit - * rendering of the camera, or placement of the viewport within your game. + * Set the bounds of the Camera. The bounds are an axis-aligned rectangle. + * + * The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the + * edges and into blank space. It does not limit the placement of Game Objects, or where + * the Camera viewport can be positioned. + * + * Temporarily disable the bounds by changing the boolean `Camera.useBounds`. + * + * Clear the bounds entirely by calling `Camera.removeBounds`. + * + * If you set bounds that are smaller than the viewport it will stop the Camera from being + * able to scroll. The bounds can be positioned where-ever you wish. By default they are from + * 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of + * the Camera bounds. However, you can position them anywhere. So if you wanted a game world + * that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y + * to be -1024, -1024, with a width and height of 2048. Depending on your game you may find + * it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle. * * @method Phaser.Cameras.Scene2D.Camera#setBounds * @since 3.0.0 @@ -1329,15 +1374,26 @@ var Camera = new Class({ * @param {integer} y - The top-left y coordinate of the bounds. * @param {integer} width - The width of the bounds, in pixels. * @param {integer} height - The height of the bounds, in pixels. + * @param {boolean} [centerOn] - If `true` the Camera will automatically be centered on the new bounds. * * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. */ - setBounds: function (x, y, width, height) + setBounds: function (x, y, width, height, centerOn) { this._bounds.setTo(x, y, width, height); this.useBounds = true; + if (centerOn) + { + this.centerToBounds(); + } + else + { + this.scrollX = this.clampX(this.scrollX); + this.scrollY = this.clampY(this.scrollY); + } + return this; }, @@ -1406,8 +1462,9 @@ var Camera = new Class({ }, /** - * Should the Camera round pixel values to whole integers when scrolling? - * In some types of game this is required to prevent sub-pixel aliasing. + * Should the Camera round pixel values to whole integers when rendering Game Objects? + * + * In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing. * * @method Phaser.Cameras.Scene2D.Camera#setRoundPixels * @since 3.0.0 @@ -1534,7 +1591,7 @@ var Camera = new Class({ * @method Phaser.Cameras.Scene2D.Camera#setZoom * @since 3.0.0 * - * @param {float} [value=1] - The zoom value of the Camera. The minimum it can be is 0.001. + * @param {number} [value=1] - The zoom value of the Camera. The minimum it can be is 0.001. * * @return {Phaser.Cameras.Scene2D.Camera} This Camera instance. */ @@ -1590,8 +1647,8 @@ var Camera = new Class({ * * @param {(Phaser.GameObjects.GameObject|object)} target - The target for the Camera to follow. * @param {boolean} [roundPixels=false] - Round the camera position to whole integers to avoid sub-pixel rendering? - * @param {float} [lerpX=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. - * @param {float} [lerpY=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. + * @param {number} [lerpX=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. + * @param {number} [lerpY=1] - A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. * @param {number} [offsetX=0] - The horizontal offset from the camera follow target.x position. * @param {number} [offsetY=0] - The vertical offset from the camera follow target.y position. * diff --git a/src/cameras/2d/CameraManager.js b/src/cameras/2d/CameraManager.js index 5c6dc3d16..45d19824b 100644 --- a/src/cameras/2d/CameraManager.js +++ b/src/cameras/2d/CameraManager.js @@ -13,27 +13,54 @@ var RectangleContains = require('../../geom/rectangle/Contains'); /** * @typedef {object} InputJSONCameraObject * - * @property {string} [name=''] - [description] - * @property {integer} [x=0] - [description] - * @property {integer} [y=0] - [description] - * @property {integer} [width] - [description] - * @property {integer} [height] - [description] - * @property {float} [zoom=1] - [description] - * @property {float} [rotation=0] - [description] - * @property {boolean} [roundPixels=false] - [description] - * @property {float} [scrollX=0] - [description] - * @property {float} [scrollY=0] - [description] - * @property {(false|string)} [backgroundColor=false] - [description] - * @property {?object} [bounds] - [description] - * @property {number} [bounds.x=0] - [description] - * @property {number} [bounds.y=0] - [description] - * @property {number} [bounds.width] - [description] - * @property {number} [bounds.height] - [description] + * @property {string} [name=''] - The name of the Camera. + * @property {integer} [x=0] - The horizontal position of the Camera viewport. + * @property {integer} [y=0] - The vertical position of the Camera viewport. + * @property {integer} [width] - The width of the Camera viewport. + * @property {integer} [height] - The height of the Camera viewport. + * @property {number} [zoom=1] - The default zoom level of the Camera. + * @property {number} [rotation=0] - The rotation of the Camera, in radians. + * @property {boolean} [roundPixels=false] - Should the Camera round pixels before rendering? + * @property {number} [scrollX=0] - The horizontal scroll position of the Camera. + * @property {number} [scrollY=0] - The vertical scroll position of the Camera. + * @property {(false|string)} [backgroundColor=false] - A CSS color string controlling the Camera background color. + * @property {?object} [bounds] - Defines the Camera bounds. + * @property {number} [bounds.x=0] - The top-left extent of the Camera bounds. + * @property {number} [bounds.y=0] - The top-left extent of the Camera bounds. + * @property {number} [bounds.width] - The width of the Camera bounds. + * @property {number} [bounds.height] - The height of the Camera bounds. */ /** * @classdesc - * [description] + * The Camera Manager is a plugin that belongs to a Scene and is responsible for managing all of the Scene Cameras. + * + * By default you can access the Camera Manager from within a Scene using `this.cameras`, although this can be changed + * in your game config. + * + * Create new Cameras using the `add` method. Or extend the Camera class with your own addition code and then add + * the new Camera in using the `addExisting` method. + * + * Cameras provide a view into your game world, and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. The Camera Manager can manage up to 31 unique + * 'Game Object ignore capable' Cameras. Any Cameras beyond 31 that you create will all be given a Camera ID of + * zero, meaning that they cannot be used for Game Object exclusion. This means if you need your Camera to ignore + * Game Objects, make sure it's one of the first 31 created. + * + * A Camera also has built-in special effects including Fade, Flash, Camera Shake, Pan and Zoom. * * @class CameraManager * @memberOf Phaser.Cameras.Scene2D @@ -67,18 +94,22 @@ var CameraManager = new Class({ this.systems = scene.sys; /** - * The current Camera ID. + * All Cameras created by, or added to, this Camera Manager, will have their `roundPixels` + * property set to match this value. By default it is set to match the value set in the + * game configuration, but can be changed at any point. Equally, individual cameras can + * also be changed as needed. * - * @name Phaser.Cameras.Scene2D.CameraManager#currentCameraId - * @type {number} - * @default 1 - * @readOnly - * @since 3.0.0 + * @name Phaser.Cameras.Scene2D.CameraManager#roundPixels + * @type {boolean} + * @since 3.11.0 */ - this.currentCameraId = 1; + this.roundPixels = scene.sys.game.config.roundPixels; /** * An Array of the Camera objects being managed by this Camera Manager. + * The Cameras are updated and rendered in the same order in which they appear in this array. + * Do not directly add or remove entries to this array. However, you can move the contents + * around the array should you wish to adjust the display order. * * @name Phaser.Cameras.Scene2D.CameraManager#cameras * @type {Phaser.Cameras.Scene2D.Camera[]} @@ -87,16 +118,15 @@ var CameraManager = new Class({ this.cameras = []; /** - * A pool of Camera objects available to be used by the Camera Manager. - * - * @name Phaser.Cameras.Scene2D.CameraManager#cameraPool - * @type {Phaser.Cameras.Scene2D.Camera[]} - * @since 3.0.0 - */ - this.cameraPool = []; - - /** - * The default Camera in the Camera Manager. + * A handy reference to the 'main' camera. By default this is the first Camera the + * Camera Manager creates. You can also set it directly, or use the `makeMain` argument + * in the `add` and `addExisting` methods. It allows you to access it from your game: + * + * ```javascript + * var cam = this.cameras.main; + * ``` + * + * Also see the properties `camera1`, `camera2` and so on. * * @name Phaser.Cameras.Scene2D.CameraManager#main * @type {Phaser.Cameras.Scene2D.Camera} @@ -105,7 +135,7 @@ var CameraManager = new Class({ this.main; /** - * This scale affects all cameras. It's used by Scale Manager. + * This scale affects all cameras. It's used by the Scale Manager. * * @name Phaser.Cameras.Scene2D.CameraManager#baseScale * @type {number} @@ -168,19 +198,33 @@ var CameraManager = new Class({ }, /** - * [description] + * Adds a new Camera into the Camera Manager. The Camera Manager can support up to 31 different Cameras. + * + * Each Camera has its own viewport, which controls the size of the Camera and its position within the canvas. + * + * Use the `Camera.scrollX` and `Camera.scrollY` properties to change where the Camera is looking, or the + * Camera methods such as `centerOn`. Cameras also have built in special effects, such as fade, flash, shake, + * pan and zoom. + * + * By default Cameras are transparent and will render anything that they can see based on their `scrollX` + * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. + * + * The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change + * it after creation if required. + * + * See the Camera class documentation for more details. * * @method Phaser.Cameras.Scene2D.CameraManager#add * @since 3.0.0 * - * @param {number} [x=0] - [description] - * @param {number} [y=0] - [description] - * @param {number} [width] - [description] - * @param {number} [height] - [description] - * @param {boolean} [makeMain=false] - [description] - * @param {string} [name=''] - [description] + * @param {integer} [x=0] - The horizontal position of the Camera viewport. + * @param {integer} [y=0] - The vertical position of the Camera viewport. + * @param {integer} [width] - The width of the Camera viewport. If not given it'll be the game config size. + * @param {integer} [height] - The height of the Camera viewport. If not given it'll be the game config size. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. + * @param {string} [name=''] - The name of the Camera. * - * @return {Phaser.Cameras.Scene2D.Camera} [description] + * @return {Phaser.Cameras.Scene2D.Camera} The newly created Camera. */ add: function (x, y, width, height, makeMain, name) { @@ -191,21 +235,13 @@ var CameraManager = new Class({ if (makeMain === undefined) { makeMain = false; } if (name === undefined) { name = ''; } - var camera = null; - - if (this.cameraPool.length > 0) - { - camera = this.cameraPool.pop(); - - camera.setViewport(x, y, width, height); - } - else - { - camera = new Camera(x, y, width, height); - } + var camera = new Camera(x, y, width, height); camera.setName(name); camera.setScene(this.scene); + camera.setRoundPixels(this.roundPixels); + + camera.id = this.getNextID(); this.cameras.push(camera); @@ -214,33 +250,49 @@ var CameraManager = new Class({ this.main = camera; } - camera._id = this.currentCameraId; - - this.currentCameraId = this.currentCameraId << 1; - return camera; }, /** - * [description] + * Adds an existing Camera into the Camera Manager. + * + * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. + * + * The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change + * it after addition if required. + * + * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the + * manager. As long as it doesn't already exist in the manager it will be added then returned. + * + * If this method returns `null` then the Camera already exists in this Camera Manager. * * @method Phaser.Cameras.Scene2D.CameraManager#addExisting * @since 3.0.0 * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera to be added to the Camera Manager. + * @param {boolean} [makeMain=false] - Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. * - * @return {Phaser.Cameras.Scene2D.Camera} [description] + * @return {?Phaser.Cameras.Scene2D.Camera} The Camera that was added to the Camera Manager, or `null` if it couldn't be added. */ - addExisting: function (camera) + addExisting: function (camera, makeMain) { + if (makeMain === undefined) { makeMain = false; } + var index = this.cameras.indexOf(camera); - var poolIndex = this.cameraPool.indexOf(camera); - if (index < 0 && poolIndex >= 0) + if (index === -1) { - this.cameras.push(camera); - this.cameraPool.slice(poolIndex, 1); + camera.id = this.getNextID(); + camera.setRoundPixels(this.roundPixels); + + this.cameras.push(camera); + + if (makeMain) + { + this.main = camera; + } + return camera; } @@ -248,14 +300,97 @@ var CameraManager = new Class({ }, /** - * [description] + * Gets the next available Camera ID number. + * + * The Camera Manager supports up to 31 unique cameras, after which the ID returned will always be zero. + * You can create additional cameras beyond 31, but they cannot be used for Game Object exclusion. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getNextID + * @private + * @since 3.11.0 + * + * @return {number} The next available Camera ID, or 0 if they're all already in use. + */ + getNextID: function () + { + var cameras = this.cameras; + + var testID = 1; + + // Find the first free camera ID we can use + + for (var t = 0; t < 32; t++) + { + var found = false; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (camera && camera.id === testID) + { + found = true; + continue; + } + } + + if (found) + { + testID = testID << 1; + } + else + { + return testID; + } + } + + return 0; + }, + + /** + * Gets the total number of Cameras in this Camera Manager. + * + * If the optional `isVisible` argument is set it will only count Cameras that are currently visible. + * + * @method Phaser.Cameras.Scene2D.CameraManager#getTotal + * @since 3.11.0 + * + * @param {boolean} [isVisible=false] - Set the `true` to only include visible Cameras in the total. + * + * @return {integer} The total number of Cameras in this Camera Manager. + */ + getTotal: function (isVisible) + { + if (isVisible === undefined) { isVisible = false; } + + var total = 0; + + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) + { + var camera = cameras[i]; + + if (!isVisible || (isVisible && camera.visible)) + { + total++; + } + } + + return total; + }, + + /** + * Populates this Camera Manager based on the given configuration object, or an array of config objects. + * + * See the `InputJSONCameraObject` documentation for details of the object structure. * * @method Phaser.Cameras.Scene2D.CameraManager#fromJSON * @since 3.0.0 * - * @param {(InputJSONCameraObject|InputJSONCameraObject[])} config - [description] + * @param {(InputJSONCameraObject|InputJSONCameraObject[])} config - A Camera configuration object, or an array of them, to be added to this Camera Manager. * - * @return {Phaser.Cameras.Scene2D.CameraManager} [description] + * @return {Phaser.Cameras.Scene2D.CameraManager} This Camera Manager instance. */ fromJSON: function (config) { @@ -315,22 +450,27 @@ var CameraManager = new Class({ }, /** - * [description] + * Gets a Camera based on its name. + * + * Camera names are optional and don't have to be set, so this method is only of any use if you + * have given your Cameras unique names. * * @method Phaser.Cameras.Scene2D.CameraManager#getCamera * @since 3.0.0 * - * @param {string} name - [description] + * @param {string} name - The name of the Camera. * - * @return {Phaser.Cameras.Scene2D.Camera} [description] + * @return {?Phaser.Cameras.Scene2D.Camera} The first Camera with a name matching the given string, otherwise `null`. */ getCamera: function (name) { - for (var i = 0; i < this.cameras.length; i++) + var cameras = this.cameras; + + for (var i = 0; i < cameras.length; i++) { - if (this.cameras[i].name === name) + if (cameras[i].name === name) { - return this.cameras[i]; + return cameras[i]; } } @@ -373,33 +513,58 @@ var CameraManager = new Class({ }, /** - * [description] + * Removes the given Camera, or an array of Cameras, from this Camera Manager. + * + * If found in the Camera Manager it will be immediately removed from the local cameras array. + * If also currently the 'main' camera, 'main' will be reset to be camera 0. + * + * The removed Camera is not destroyed. If you also wish to destroy the Camera, you should call + * `Camera.destroy` on it, so that it clears all references to the Camera Manager. * * @method Phaser.Cameras.Scene2D.CameraManager#remove * @since 3.0.0 * - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] + * @param {(Phaser.Cameras.Scene2D.Camera|Phaser.Cameras.Scene2D.Camera[])} camera - The Camera, or an array of Cameras, to be removed from this Camera Manager. + * + * @return {integer} The total number of Cameras removed. */ remove: function (camera) { - var cameraIndex = this.cameras.indexOf(camera); - - if (cameraIndex >= 0 && this.cameras.length > 1) + if (!Array.isArray(camera)) { - this.cameraPool.push(this.cameras[cameraIndex]); - this.cameras.splice(cameraIndex, 1); + camera = [ camera ]; + } - if (this.main === camera) + var total = 0; + var cameras = this.cameras; + + for (var i = 0; i < camera.length; i++) + { + var index = cameras.indexOf(camera[i]); + + if (index !== -1) { - this.main = this.cameras[0]; + cameras.splice(index, 1); + total++; } } + + if (!this.main) + { + this.main = cameras[0]; + } + + return total; }, /** - * [description] + * The internal render method. This is called automatically by the Scene and should not be invoked directly. + * + * It will iterate through all local cameras and render them in turn, as long as they're visible and have + * an alpha level > 0. * * @method Phaser.Cameras.Scene2D.CameraManager#render + * @protected * @since 3.0.0 * * @param {(Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer)} renderer - The Renderer that will render the children to this camera. @@ -408,54 +573,62 @@ var CameraManager = new Class({ */ render: function (renderer, children, interpolation) { + var scene = this.scene; var cameras = this.cameras; var baseScale = this.baseScale; + var resolution = renderer.config.resolution; - for (var i = 0, l = cameras.length; i < l; ++i) + for (var i = 0; i < this.cameras.length; i++) { var camera = cameras[i]; - if (camera.visible) + if (camera.visible && camera.alpha > 0) { - camera.preRender(baseScale, renderer.config.resolution); + camera.preRender(baseScale, resolution); - renderer.render(this.scene, children, interpolation, camera); + renderer.render(scene, children, interpolation, camera); } } }, /** - * [description] + * Resets this Camera Manager. + * + * This will iterate through all current Cameras, destroying them all, then it will reset the + * cameras array, reset the ID counter and create 1 new single camera using the default values. * * @method Phaser.Cameras.Scene2D.CameraManager#resetAll * @since 3.0.0 * - * @return {Phaser.Cameras.Scene2D.Camera} [description] + * @return {Phaser.Cameras.Scene2D.Camera} The freshly created main Camera. */ resetAll: function () { - while (this.cameras.length > 0) + for (var i = 0; i < this.cameras.length; i++) { - this.cameraPool.push(this.cameras.pop()); + this.cameras[i].destroy(); } + this.cameras = []; + this.main = this.add(); return this.main; }, /** - * [description] + * The main update loop. Called automatically when the Scene steps. * * @method Phaser.Cameras.Scene2D.CameraManager#update + * @protected * @since 3.0.0 * - * @param {number} timestep - [description] - * @param {number} delta - [description] + * @param {number} timestep - The timestep value. + * @param {number} delta - The delta value since the last frame. */ update: function (timestep, delta) { - for (var i = 0, l = this.cameras.length; i < l; ++i) + for (var i = 0; i < this.cameras.length; i++) { this.cameras[i].update(timestep, delta); } @@ -472,7 +645,7 @@ var CameraManager = new Class({ */ resize: function (width, height) { - for (var i = 0, l = this.cameras.length; i < l; ++i) + for (var i = 0; i < this.cameras.length; i++) { this.cameras[i].setSize(width, height); } @@ -495,13 +668,7 @@ var CameraManager = new Class({ this.cameras[i].destroy(); } - for (i = 0; i < this.cameraPool.length; i++) - { - this.cameraPool[i].destroy(); - } - this.cameras = []; - this.cameraPool = []; var eventEmitter = this.systems.events; diff --git a/src/cameras/2d/effects/Fade.js b/src/cameras/2d/effects/Fade.js index 40c9e4e55..d4ecc44d3 100644 --- a/src/cameras/2d/effects/Fade.js +++ b/src/cameras/2d/effects/Fade.js @@ -127,7 +127,7 @@ var Fade = new Class({ * A value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Fade#alpha - * @type {float} + * @type {number} * @private * @since 3.5.0 */ @@ -137,7 +137,7 @@ var Fade = new Class({ * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Fade#progress - * @type {float} + * @type {number} * @since 3.5.0 */ this.progress = 0; @@ -156,7 +156,7 @@ var Fade = new Class({ * @callback CameraFadeCallback * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. - * @param {float} progress - The progress of the effect. A value between 0 and 1. + * @param {number} progress - The progress of the effect. A value between 0 and 1. */ /** diff --git a/src/cameras/2d/effects/Flash.js b/src/cameras/2d/effects/Flash.js index a6abe6c83..f314e5bee 100644 --- a/src/cameras/2d/effects/Flash.js +++ b/src/cameras/2d/effects/Flash.js @@ -102,7 +102,7 @@ var Flash = new Class({ * A value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Flash#alpha - * @type {float} + * @type {number} * @private * @since 3.5.0 */ @@ -112,7 +112,7 @@ var Flash = new Class({ * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Flash#progress - * @type {float} + * @type {number} * @since 3.5.0 */ this.progress = 0; @@ -131,7 +131,7 @@ var Flash = new Class({ * @callback CameraFlashCallback * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. - * @param {float} progress - The progress of the effect. A value between 0 and 1. + * @param {number} progress - The progress of the effect. A value between 0 and 1. */ /** diff --git a/src/cameras/2d/effects/Pan.js b/src/cameras/2d/effects/Pan.js index a9c3140cd..a55bdd690 100644 --- a/src/cameras/2d/effects/Pan.js +++ b/src/cameras/2d/effects/Pan.js @@ -107,7 +107,7 @@ var Pan = new Class({ * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Pan#progress - * @type {float} + * @type {number} * @since 3.11.0 */ this.progress = 0; @@ -126,7 +126,7 @@ var Pan = new Class({ * @callback CameraPanCallback * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. - * @param {float} progress - The progress of the effect. A value between 0 and 1. + * @param {number} progress - The progress of the effect. A value between 0 and 1. * @param {number} x - The Camera's new scrollX coordinate. * @param {number} y - The Camera's new scrollY coordinate. */ diff --git a/src/cameras/2d/effects/Shake.js b/src/cameras/2d/effects/Shake.js index 930afeb4d..d809f69f1 100644 --- a/src/cameras/2d/effects/Shake.js +++ b/src/cameras/2d/effects/Shake.js @@ -80,7 +80,7 @@ var Shake = new Class({ * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. * * @name Phaser.Cameras.Scene2D.Effects.Shake#progress - * @type {float} + * @type {number} * @since 3.5.0 */ this.progress = 0; @@ -121,7 +121,7 @@ var Shake = new Class({ * @callback CameraShakeCallback * * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera on which the effect is running. - * @param {float} progress - The progress of the effect. A value between 0 and 1. + * @param {number} progress - The progress of the effect. A value between 0 and 1. */ /** @@ -153,7 +153,7 @@ var Shake = new Class({ * @param {Phaser.Cameras.Scene2D.Camera} camera - The camera that the effect began on. * @param {Phaser.Cameras.Scene2D.Effects.Shake} effect - A reference to the effect instance. * @param {integer} duration - The duration of the effect. - * @param {float} intensity - The intensity of the effect. + * @param {number} intensity - The intensity of the effect. */ /** diff --git a/src/cameras/controls/FixedKeyControl.js b/src/cameras/controls/FixedKeyControl.js index d7fc82c63..cb2ec29db 100644 --- a/src/cameras/controls/FixedKeyControl.js +++ b/src/cameras/controls/FixedKeyControl.js @@ -23,8 +23,8 @@ var GetValue = require('../../utils/object/GetValue'); * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. - * @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - * @property {(float|{x:float,y:float})} [speed=0] - The horizontal and vertical speed the camera will move. + * @property {number} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(number|{x:number,y:number})} [speed=0] - The horizontal and vertical speed the camera will move. */ /** @@ -118,7 +118,7 @@ var FixedKeyControl = new Class({ * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. * * @name Phaser.Cameras.Controls.FixedKeyControl#zoomSpeed - * @type {float} + * @type {number} * @default 0.01 * @since 3.0.0 */ @@ -128,7 +128,7 @@ var FixedKeyControl = new Class({ * The horizontal speed the camera will move. * * @name Phaser.Cameras.Controls.FixedKeyControl#speedX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -138,7 +138,7 @@ var FixedKeyControl = new Class({ * The vertical speed the camera will move. * * @name Phaser.Cameras.Controls.FixedKeyControl#speedY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ diff --git a/src/cameras/controls/SmoothedKeyControl.js b/src/cameras/controls/SmoothedKeyControl.js index b211f7c63..b3724b581 100644 --- a/src/cameras/controls/SmoothedKeyControl.js +++ b/src/cameras/controls/SmoothedKeyControl.js @@ -30,10 +30,10 @@ var GetValue = require('../../utils/object/GetValue'); * @property {Phaser.Input.Keyboard.Key} [up] - The Key to be pressed that will move the Camera up. * @property {Phaser.Input.Keyboard.Key} [zoomIn] - The Key to be pressed that will zoom the Camera in. * @property {Phaser.Input.Keyboard.Key} [zoomOut] - The Key to be pressed that will zoom the Camera out. - * @property {float} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - * @property {(float|{x:float,y:float})} [acceleration=0] - The horizontal and vertical acceleration the camera will move. - * @property {(float|{x:float,y:float})} [drag=0] - The horizontal and vertical drag applied to the camera when it is moving. - * @property {(float|{x:float,y:float})} [maxSpeed=0] - The maximum horizontal and vertical speed the camera will move. + * @property {number} [zoomSpeed=0.01] - The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + * @property {(number|{x:number,y:number})} [acceleration=0] - The horizontal and vertical acceleration the camera will move. + * @property {(number|{x:number,y:number})} [drag=0] - The horizontal and vertical drag applied to the camera when it is moving. + * @property {(number|{x:number,y:number})} [maxSpeed=0] - The maximum horizontal and vertical speed the camera will move. */ /** @@ -127,7 +127,7 @@ var SmoothedKeyControl = new Class({ * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#zoomSpeed - * @type {float} + * @type {number} * @default 0.01 * @since 3.0.0 */ @@ -137,7 +137,7 @@ var SmoothedKeyControl = new Class({ * The horizontal acceleration the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -147,7 +147,7 @@ var SmoothedKeyControl = new Class({ * The vertical acceleration the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#accelY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -170,7 +170,7 @@ var SmoothedKeyControl = new Class({ * The horizontal drag applied to the camera when it is moving. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -180,7 +180,7 @@ var SmoothedKeyControl = new Class({ * The vertical drag applied to the camera when it is moving. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#dragY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -203,7 +203,7 @@ var SmoothedKeyControl = new Class({ * The maximum horizontal speed the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedX - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -213,7 +213,7 @@ var SmoothedKeyControl = new Class({ * The maximum vertical speed the camera will move. * * @name Phaser.Cameras.Controls.SmoothedKeyControl#maxSpeedY - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ diff --git a/src/cameras/sprite3d/Camera.js b/src/cameras/sprite3d/Camera.js index 735349ad6..58a909b56 100644 --- a/src/cameras/sprite3d/Camera.js +++ b/src/cameras/sprite3d/Camera.js @@ -504,7 +504,7 @@ var Camera = new Class({ * @method Phaser.Cameras.Sprite3D.Camera#randomCube * @since 3.0.0 * - * @param {float} [scale=1] - [description] + * @param {number} [scale=1] - [description] * @param {Phaser.GameObjects.Sprite3D[]} [sprites] - [description] * * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. @@ -662,7 +662,7 @@ var Camera = new Class({ * @method Phaser.Cameras.Sprite3D.Camera#rotate * @since 3.0.0 * - * @param {float} radians - [description] + * @param {number} radians - [description] * @param {Phaser.Math.Vector3} axis - [description] * * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. @@ -682,7 +682,7 @@ var Camera = new Class({ * @since 3.0.0 * * @param {Phaser.Math.Vector3} point - [description] - * @param {float} radians - [description] + * @param {number} radians - [description] * @param {Phaser.Math.Vector3} axis - [description] * * @return {Phaser.Cameras.Sprite3D.Camera} This Camera object. diff --git a/src/cameras/sprite3d/OrthographicCamera.js b/src/cameras/sprite3d/OrthographicCamera.js index 7b8db4d18..0727ba9ba 100644 --- a/src/cameras/sprite3d/OrthographicCamera.js +++ b/src/cameras/sprite3d/OrthographicCamera.js @@ -60,7 +60,7 @@ var OrthographicCamera = new Class({ * [description] * * @name Phaser.Cameras.Sprite3D.OrthographicCamera#_zoom - * @type {float} + * @type {number} * @private * @since 3.0.0 */ diff --git a/src/curves/CubicBezierCurve.js b/src/curves/CubicBezierCurve.js index 7d575ba78..d4ae536f2 100644 --- a/src/curves/CubicBezierCurve.js +++ b/src/curves/CubicBezierCurve.js @@ -123,7 +123,7 @@ var CubicBezierCurve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. diff --git a/src/curves/Curve.js b/src/curves/Curve.js index 908cc672f..66115a756 100644 --- a/src/curves/Curve.js +++ b/src/curves/Curve.js @@ -278,7 +278,7 @@ var Curve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - [description] + * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] @@ -434,7 +434,7 @@ var Curve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - [description] + * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] @@ -456,7 +456,7 @@ var Curve = new Class({ * @param {integer} distance - [description] * @param {integer} [divisions] - [description] * - * @return {float} [description] + * @return {number} [description] */ getTFromDistance: function (distance, divisions) { @@ -476,7 +476,7 @@ var Curve = new Class({ * @method Phaser.Curves.Curve#getUtoTmapping * @since 3.0.0 * - * @param {float} u - [description] + * @param {number} u - [description] * @param {integer} distance - [description] * @param {integer} [divisions] - [description] * diff --git a/src/curves/EllipseCurve.js b/src/curves/EllipseCurve.js index d036941e7..352843775 100644 --- a/src/curves/EllipseCurve.js +++ b/src/curves/EllipseCurve.js @@ -207,7 +207,7 @@ var EllipseCurve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. diff --git a/src/curves/LineCurve.js b/src/curves/LineCurve.js index 2ba95ef9e..2d8a874b4 100644 --- a/src/curves/LineCurve.js +++ b/src/curves/LineCurve.js @@ -126,7 +126,7 @@ var LineCurve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. @@ -155,7 +155,7 @@ var LineCurve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} u - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. diff --git a/src/curves/QuadraticBezierCurve.js b/src/curves/QuadraticBezierCurve.js index f4d312f49..3028330b7 100644 --- a/src/curves/QuadraticBezierCurve.js +++ b/src/curves/QuadraticBezierCurve.js @@ -110,7 +110,7 @@ var QuadraticBezier = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. diff --git a/src/curves/SplineCurve.js b/src/curves/SplineCurve.js index 067e5e5da..55cf98b64 100644 --- a/src/curves/SplineCurve.js +++ b/src/curves/SplineCurve.js @@ -150,7 +150,7 @@ var SplineCurve = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. diff --git a/src/curves/path/MoveTo.js b/src/curves/path/MoveTo.js index f35dbd430..50388b23a 100644 --- a/src/curves/path/MoveTo.js +++ b/src/curves/path/MoveTo.js @@ -55,7 +55,7 @@ var MoveTo = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} t - The position along the curve to return. Where 0 is the start and 1 is the end. + * @param {number} t - The position along the curve to return. Where 0 is the start and 1 is the end. * @param {Phaser.Math.Vector2} [out] - A Vector2 object to store the result in. If not given will be created. * * @return {Phaser.Math.Vector2} The coordinates of the point on the curve. If an `out` object was given this will be returned. @@ -75,7 +75,7 @@ var MoveTo = new Class({ * * @generic {Phaser.Math.Vector2} O - [out,$return] * - * @param {float} u - [description] + * @param {number} u - [description] * @param {Phaser.Math.Vector2} [out] - [description] * * @return {Phaser.Math.Vector2} [description] diff --git a/src/display/color/Color.js b/src/display/color/Color.js index fe5dec751..827c38620 100644 --- a/src/display/color/Color.js +++ b/src/display/color/Color.js @@ -171,10 +171,10 @@ var Color = new Class({ * @method Phaser.Display.Color#setGLTo * @since 3.0.0 * - * @param {float} red - The red color value. A number between 0 and 1. - * @param {float} green - The green color value. A number between 0 and 1. - * @param {float} blue - The blue color value. A number between 0 and 1. - * @param {float} [alpha=1] - The alpha value. A number between 0 and 1. + * @param {number} red - The red color value. A number between 0 and 1. + * @param {number} green - The green color value. A number between 0 and 1. + * @param {number} blue - The blue color value. A number between 0 and 1. + * @param {number} [alpha=1] - The alpha value. A number between 0 and 1. * * @return {Phaser.Display.Color} This Color object. */ @@ -299,7 +299,7 @@ var Color = new Class({ * The red color value, normalized to the range 0 to 1. * * @name Phaser.Display.Color#redGL - * @type {float} + * @type {number} * @since 3.0.0 */ redGL: { @@ -324,7 +324,7 @@ var Color = new Class({ * The green color value, normalized to the range 0 to 1. * * @name Phaser.Display.Color#greenGL - * @type {float} + * @type {number} * @since 3.0.0 */ greenGL: { @@ -349,7 +349,7 @@ var Color = new Class({ * The blue color value, normalized to the range 0 to 1. * * @name Phaser.Display.Color#blueGL - * @type {float} + * @type {number} * @since 3.0.0 */ blueGL: { @@ -374,7 +374,7 @@ var Color = new Class({ * The alpha color value, normalized to the range 0 to 1. * * @name Phaser.Display.Color#alphaGL - * @type {float} + * @type {number} * @since 3.0.0 */ alphaGL: { diff --git a/src/gameobjects/GameObject.js b/src/gameobjects/GameObject.js index 05497d236..64eb7f726 100644 --- a/src/gameobjects/GameObject.js +++ b/src/gameobjects/GameObject.js @@ -124,7 +124,11 @@ var GameObject = new Class({ /** * A bitmask that controls if this Game Object is drawn by a Camera or not. - * Not usually set directly. Instead call `Camera.ignore`. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: + * + * @example + * this.cameraFilter |= camera.id * * @name Phaser.GameObjects.GameObject#cameraFilter * @type {number} @@ -374,7 +378,7 @@ var GameObject = new Class({ { if (this.input) { - this.input.enabled = (this.input.enabled) ? false : true; + this.input.enabled = false; } return this; diff --git a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js index 6f7075003..31874a262 100644 --- a/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js +++ b/src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js @@ -26,7 +26,7 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc var text = src.text; var textLength = text.length; - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } @@ -68,6 +68,21 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc var rotation = 0; var scale = (src.fontSize / src.fontData.size); + // Alpha + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + // Blend Mode if (renderer.currentBlendMode !== src.blendMode) { @@ -112,8 +127,6 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc ctx.clip(); } - var roundPixels = renderer.config.roundPixels; - for (var index = 0; index < textLength; ++index) { // Reset the scale (in case the callback changed it) @@ -171,7 +184,7 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc x -= cameraScrollX; y -= cameraScrollY; - if (roundPixels) + if (camera.roundPixels) { x |= 0; y |= 0; diff --git a/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js b/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js index 2921c96a8..047054bc9 100644 --- a/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js +++ b/src/gameobjects/bitmaptext/static/BitmapTextCanvasRenderer.js @@ -26,7 +26,7 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, var text = src.text; var textLength = text.length; - if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || textLength === 0 || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } @@ -63,6 +63,21 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, var scale = (src.fontSize / src.fontData.size); + // Alpha + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + // Blend Mode if (renderer.currentBlendMode !== src.blendMode) { @@ -70,25 +85,16 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; } - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - // Smoothing if (renderer.currentScaleMode !== src.scaleMode) { renderer.currentScaleMode = src.scaleMode; } - var roundPixels = renderer.config.roundPixels; - var tx = (src.x - camera.scrollX * src.scrollFactorX) + src.frame.x; var ty = (src.y - camera.scrollY * src.scrollFactorY) + src.frame.y; - if (roundPixels) + if (camera.roundPixels) { tx |= 0; ty |= 0; @@ -159,7 +165,7 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage, continue; } - if (roundPixels) + if (camera.roundPixels) { x |= 0; y |= 0; diff --git a/src/gameobjects/blitter/BlitterCanvasRenderer.js b/src/gameobjects/blitter/BlitterCanvasRenderer.js index ed2cd2172..515e54c3d 100644 --- a/src/gameobjects/blitter/BlitterCanvasRenderer.js +++ b/src/gameobjects/blitter/BlitterCanvasRenderer.js @@ -23,16 +23,34 @@ var GameObject = require('../GameObject'); */ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + var list = src.getRenderList(); + + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id)) || list.length === 0) { return; } - var list = src.getRenderList(); + var ctx = renderer.gameContext; + + // Alpha + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + + // Blend Mode renderer.setBlendMode(src.blendMode); - var ctx = renderer.gameContext; var cameraScrollX = src.x - camera.scrollX * src.scrollFactorX; var cameraScrollY = src.y - camera.scrollY * src.scrollFactorY; @@ -56,6 +74,18 @@ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, ca var fx = 1; var fy = 1; + var bobAlpha = bob.alpha * alpha; + + if (bobAlpha === 0) + { + continue; + } + else if (renderer.currentAlpha !== bobAlpha) + { + renderer.currentAlpha = bobAlpha; + ctx.globalAlpha = bobAlpha; + } + if (!flip) { renderer.blitImage(dx + bob.x + cameraScrollX, dy + bob.y + cameraScrollY, bob.frame); diff --git a/src/gameobjects/blitter/Bob.js b/src/gameobjects/blitter/Bob.js index a92b9f84b..d4dd9cab5 100644 --- a/src/gameobjects/blitter/Bob.js +++ b/src/gameobjects/blitter/Bob.js @@ -291,7 +291,7 @@ var Bob = new Class({ * @method Phaser.GameObjects.Blitter.Bob#setAlpha * @since 3.0.0 * - * @param {float} value - The alpha value used for this Bob. Between 0 and 1. + * @param {number} value - The alpha value used for this Bob. Between 0 and 1. * * @return {Phaser.GameObjects.Blitter.Bob} This Bob Game Object. */ diff --git a/src/gameobjects/components/Alpha.js b/src/gameobjects/components/Alpha.js index e53928112..0f32a9173 100644 --- a/src/gameobjects/components/Alpha.js +++ b/src/gameobjects/components/Alpha.js @@ -23,7 +23,7 @@ var Alpha = { * Private internal value. Holds the global alpha value. * * @name Phaser.GameObjects.Components.Alpha#_alpha - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -34,7 +34,7 @@ var Alpha = { * Private internal value. Holds the top-left alpha value. * * @name Phaser.GameObjects.Components.Alpha#_alphaTL - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -45,7 +45,7 @@ var Alpha = { * Private internal value. Holds the top-right alpha value. * * @name Phaser.GameObjects.Components.Alpha#_alphaTR - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -56,7 +56,7 @@ var Alpha = { * Private internal value. Holds the bottom-left alpha value. * * @name Phaser.GameObjects.Components.Alpha#_alphaBL - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -67,7 +67,7 @@ var Alpha = { * Private internal value. Holds the bottom-right alpha value. * * @name Phaser.GameObjects.Components.Alpha#_alphaBR - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -99,10 +99,10 @@ var Alpha = { * @method Phaser.GameObjects.Components.Alpha#setAlpha * @since 3.0.0 * - * @param {float} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. - * @param {float} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. - * @param {float} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param {float} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. + * @param {number} [topLeft=1] - The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. + * @param {number} [topRight] - The alpha value used for the top-right of the Game Object. WebGL only. + * @param {number} [bottomLeft] - The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param {number} [bottomRight] - The alpha value used for the bottom-right of the Game Object. WebGL only. * * @return {this} This Game Object instance. */ @@ -132,7 +132,7 @@ var Alpha = { * This is a global value, impacting the entire Game Object, not just a region of it. * * @name Phaser.GameObjects.Components.Alpha#alpha - * @type {float} + * @type {number} * @since 3.0.0 */ alpha: { @@ -169,7 +169,7 @@ var Alpha = { * This value is interpolated from the corner to the center of the Game Object. * * @name Phaser.GameObjects.Components.Alpha#alphaTopLeft - * @type {float} + * @type {number} * @webglOnly * @since 3.0.0 */ @@ -199,7 +199,7 @@ var Alpha = { * This value is interpolated from the corner to the center of the Game Object. * * @name Phaser.GameObjects.Components.Alpha#alphaTopRight - * @type {float} + * @type {number} * @webglOnly * @since 3.0.0 */ @@ -229,7 +229,7 @@ var Alpha = { * This value is interpolated from the corner to the center of the Game Object. * * @name Phaser.GameObjects.Components.Alpha#alphaBottomLeft - * @type {float} + * @type {number} * @webglOnly * @since 3.0.0 */ @@ -259,7 +259,7 @@ var Alpha = { * This value is interpolated from the corner to the center of the Game Object. * * @name Phaser.GameObjects.Components.Alpha#alphaBottomRight - * @type {float} + * @type {number} * @webglOnly * @since 3.0.0 */ diff --git a/src/gameobjects/components/Animation.js b/src/gameobjects/components/Animation.js index e059381b2..97285362e 100644 --- a/src/gameobjects/components/Animation.js +++ b/src/gameobjects/components/Animation.js @@ -528,7 +528,7 @@ var Animation = new Class({ * @method Phaser.GameObjects.Components.Animation#getProgress * @since 3.4.0 * - * @return {float} The progress of the current animation, between 0 and 1. + * @return {number} The progress of the current animation, between 0 and 1. */ getProgress: function () { @@ -549,7 +549,7 @@ var Animation = new Class({ * @method Phaser.GameObjects.Components.Animation#setProgress * @since 3.4.0 * - * @param {float} [value=0] - The progress value, between 0 and 1. + * @param {number} [value=0] - The progress value, between 0 and 1. * * @return {Phaser.GameObjects.GameObject} The Game Object that owns this Animation Component. */ diff --git a/src/gameobjects/components/Origin.js b/src/gameobjects/components/Origin.js index a672db568..75fc1a7db 100644 --- a/src/gameobjects/components/Origin.js +++ b/src/gameobjects/components/Origin.js @@ -34,7 +34,7 @@ var Origin = { * Setting the value to 0 means the position now relates to the left of the Game Object. * * @name Phaser.GameObjects.Components.Origin#originX - * @type {float} + * @type {number} * @default 0.5 * @since 3.0.0 */ @@ -47,7 +47,7 @@ var Origin = { * Setting the value to 0 means the position now relates to the top of the Game Object. * * @name Phaser.GameObjects.Components.Origin#originY - * @type {float} + * @type {number} * @default 0.5 * @since 3.0.0 */ @@ -63,7 +63,7 @@ var Origin = { * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. * * @name Phaser.GameObjects.Components.Origin#displayOriginX - * @type {float} + * @type {number} * @since 3.0.0 */ displayOriginX: { @@ -87,7 +87,7 @@ var Origin = { * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. * * @name Phaser.GameObjects.Components.Origin#displayOriginY - * @type {float} + * @type {number} * @since 3.0.0 */ displayOriginY: { diff --git a/src/gameobjects/components/ToJSON.js b/src/gameobjects/components/ToJSON.js index 4b360a22d..3391a43bb 100644 --- a/src/gameobjects/components/ToJSON.js +++ b/src/gameobjects/components/ToJSON.js @@ -15,12 +15,12 @@ * @property {number} scale.x - The horizontal scale of this Game Object. * @property {number} scale.y - The vertical scale of this Game Object. * @property {object} origin - The origin of this Game Object. - * @property {float} origin.x - The horizontal origin of this Game Object. - * @property {float} origin.y - The vertical origin of this Game Object. + * @property {number} origin.x - The horizontal origin of this Game Object. + * @property {number} origin.y - The vertical origin of this Game Object. * @property {boolean} flipX - The horizontally flipped state of the Game Object. * @property {boolean} flipY - The vertically flipped state of the Game Object. * @property {number} rotation - The angle of this Game Object in radians. - * @property {float} alpha - The alpha value of the Game Object. + * @property {number} alpha - The alpha value of the Game Object. * @property {boolean} visible - The visible state of the Game Object. * @property {integer} scaleMode - The Scale Mode being used by this Game Object. * @property {(integer|string)} blendMode - Sets the Blend Mode being used by this Game Object. diff --git a/src/gameobjects/components/Transform.js b/src/gameobjects/components/Transform.js index 4db4f9427..b974c203b 100644 --- a/src/gameobjects/components/Transform.js +++ b/src/gameobjects/components/Transform.js @@ -25,7 +25,7 @@ var Transform = { * Private internal value. Holds the horizontal scale value. * * @name Phaser.GameObjects.Components.Transform#_scaleX - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -36,7 +36,7 @@ var Transform = { * Private internal value. Holds the vertical scale value. * * @name Phaser.GameObjects.Components.Transform#_scaleY - * @type {float} + * @type {number} * @private * @default 1 * @since 3.0.0 @@ -47,7 +47,7 @@ var Transform = { * Private internal value. Holds the rotation value in radians. * * @name Phaser.GameObjects.Components.Transform#_rotation - * @type {float} + * @type {number} * @private * @default 0 * @since 3.0.0 diff --git a/src/gameobjects/container/Container.js b/src/gameobjects/container/Container.js index b89ad5180..67b2de884 100644 --- a/src/gameobjects/container/Container.js +++ b/src/gameobjects/container/Container.js @@ -79,6 +79,7 @@ var Container = new Class({ Components.BlendMode, Components.ComputedSize, Components.Depth, + Components.Mask, Components.ScrollFactor, Components.Transform, Components.Visible, diff --git a/src/gameobjects/graphics/GraphicsCanvasRenderer.js b/src/gameobjects/graphics/GraphicsCanvasRenderer.js index 311831079..01a49c430 100644 --- a/src/gameobjects/graphics/GraphicsCanvasRenderer.js +++ b/src/gameobjects/graphics/GraphicsCanvasRenderer.js @@ -26,7 +26,7 @@ var GameObject = require('../GameObject'); */ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix, renderTargetCtx, allowClip) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } @@ -49,6 +49,21 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c var green = 0; var blue = 0; + // Alpha + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + // Blend Mode if (renderer.currentBlendMode !== src.blendMode) { @@ -56,13 +71,6 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; } - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - // Smoothing if (renderer.currentScaleMode !== src.scaleMode) { @@ -70,11 +78,14 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c } ctx.save(); + if (parentMatrix) { var matrix = parentMatrix.matrix; + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } + ctx.translate(srcX - cameraScrollX, srcY - cameraScrollY); ctx.rotate(srcRotation); ctx.scale(srcScaleX, srcScaleY); @@ -253,10 +264,6 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c ); index += 1; break; - - default: - // console.error('Phaser: Invalid Graphics Command ID ' + commandID); - break; } } diff --git a/src/gameobjects/image/ImageCanvasRenderer.js b/src/gameobjects/image/ImageCanvasRenderer.js index 95968f19f..269c78129 100644 --- a/src/gameobjects/image/ImageCanvasRenderer.js +++ b/src/gameobjects/image/ImageCanvasRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var ImageCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/image/ImageWebGLRenderer.js b/src/gameobjects/image/ImageWebGLRenderer.js index 82c7d26d2..99c12f2fc 100644 --- a/src/gameobjects/image/ImageWebGLRenderer.js +++ b/src/gameobjects/image/ImageWebGLRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/lights/LightsManager.js b/src/gameobjects/lights/LightsManager.js index ce9a64a23..788439f39 100644 --- a/src/gameobjects/lights/LightsManager.js +++ b/src/gameobjects/lights/LightsManager.js @@ -70,7 +70,7 @@ var LightsManager = new Class({ * The ambient color. * * @name Phaser.GameObjects.LightsManager#ambientColor - * @type {{ r: float, g: float, b: float }} + * @type {{ r: number, g: number, b: number }} * @since 3.0.0 */ this.ambientColor = { r: 0.1, g: 0.1, b: 0.1 }; diff --git a/src/gameobjects/mesh/MeshFactory.js b/src/gameobjects/mesh/MeshFactory.js index ee7eac382..aa021e351 100644 --- a/src/gameobjects/mesh/MeshFactory.js +++ b/src/gameobjects/mesh/MeshFactory.js @@ -18,10 +18,10 @@ var GameObjectFactory = require('../GameObjectFactory'); * * @param {number} x - The horizontal position of this Game Object in the world. * @param {number} y - The vertical position of this Game Object in the world. - * @param {float[]} vertices - An array containing the vertices data for this Mesh. - * @param {float[]} uv - An array containing the uv data for this Mesh. - * @param {float[]} colors - An array containing the color data for this Mesh. - * @param {float[]} alphas - An array containing the alpha data for this Mesh. + * @param {number[]} vertices - An array containing the vertices data for this Mesh. + * @param {number[]} uv - An array containing the uv data for this Mesh. + * @param {number[]} colors - An array containing the color data for this Mesh. + * @param {number[]} alphas - An array containing the alpha data for this Mesh. * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. * diff --git a/src/gameobjects/mesh/MeshWebGLRenderer.js b/src/gameobjects/mesh/MeshWebGLRenderer.js index ab71120d3..9f815ecc8 100644 --- a/src/gameobjects/mesh/MeshWebGLRenderer.js +++ b/src/gameobjects/mesh/MeshWebGLRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/particles/GravityWell.js b/src/gameobjects/particles/GravityWell.js index 0dc575be9..82b5818e2 100644 --- a/src/gameobjects/particles/GravityWell.js +++ b/src/gameobjects/particles/GravityWell.js @@ -144,7 +144,7 @@ var GravityWell = new Class({ * * @param {Phaser.GameObjects.Particles.Particle} particle - The Particle to update. * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. + * @param {number} step - The delta value divided by 1000. */ update: function (particle, delta) { diff --git a/src/gameobjects/particles/Particle.js b/src/gameobjects/particles/Particle.js index f5c8c7e70..538fd1055 100644 --- a/src/gameobjects/particles/Particle.js +++ b/src/gameobjects/particles/Particle.js @@ -156,7 +156,7 @@ var Particle = new Class({ * The horizontal scale of this Particle. * * @name Phaser.GameObjects.Particles.Particle#scaleX - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -166,7 +166,7 @@ var Particle = new Class({ * The vertical scale of this Particle. * * @name Phaser.GameObjects.Particles.Particle#scaleY - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -176,7 +176,7 @@ var Particle = new Class({ * The alpha value of this Particle. * * @name Phaser.GameObjects.Particles.Particle#alpha - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ @@ -255,7 +255,7 @@ var Particle = new Class({ * The normalized lifespan T value, where 0 is the start and 1 is the end. * * @name Phaser.GameObjects.Particles.Particle#lifeT - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -412,7 +412,7 @@ var Particle = new Class({ * * @param {Phaser.GameObjects.Particles.ParticleEmitter} emitter - The Emitter that is updating this Particle. * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. + * @param {number} step - The delta value divided by 1000. * @param {array} processors - Particle processors (gravity wells). */ computeVelocity: function (emitter, delta, step, processors) @@ -514,7 +514,7 @@ var Particle = new Class({ * @since 3.0.0 * * @param {number} delta - The delta time in ms. - * @param {float} step - The delta value divided by 1000. + * @param {number} step - The delta value divided by 1000. * @param {array} processors - An optional array of update processors. * * @return {boolean} Returns `true` if this Particle has now expired and should be removed, otherwise `false` if still active. diff --git a/src/gameobjects/particles/ParticleEmitter.js b/src/gameobjects/particles/ParticleEmitter.js index 6b139a9fc..585eb181b 100644 --- a/src/gameobjects/particles/ParticleEmitter.js +++ b/src/gameobjects/particles/ParticleEmitter.js @@ -625,7 +625,7 @@ var ParticleEmitter = new Class({ * Calling {@link Phaser.GameObjects.Particles.ParticleEmitter#explode} also puts the emitter in explode mode (frequency = -1). * * @name Phaser.GameObjects.Particles.ParticleEmitter#frequency - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 * @see Phaser.GameObjects.Particles.ParticleEmitter#setFrequency @@ -635,7 +635,7 @@ var ParticleEmitter = new Class({ /** * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). * Already alive particles will continue to update until they expire. - * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start}. + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start} and {@link Phaser.GameObjects.Particles.ParticleEmitter#stop}. * * @name Phaser.GameObjects.Particles.ParticleEmitter#on * @type {boolean} @@ -1207,8 +1207,8 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setPosition * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} x - The x-coordinate of the particle origin. - * @param {float|float[]|EmitterOpOnEmitCallback|object} y - The y-coordinate of the particle origin. + * @param {number|float[]|EmitterOpOnEmitCallback|object} x - The x-coordinate of the particle origin. + * @param {number|float[]|EmitterOpOnEmitCallback|object} y - The y-coordinate of the particle origin. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1229,9 +1229,9 @@ var ParticleEmitter = new Class({ * @since 3.0.0 * * @param {(number|ParticleEmitterBounds|ParticleEmitterBoundsAlt)} x - The x-coordinate of the left edge of the boundary, or an object representing a rectangle. - * @param {float} y - The y-coordinate of the top edge of the boundary. - * @param {float} width - The width of the boundary. - * @param {float} height - The height of the boundary. + * @param {number} y - The y-coordinate of the top edge of the boundary. + * @param {number} width - The width of the boundary. + * @param {number} height - The height of the boundary. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1266,7 +1266,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedX * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1287,7 +1287,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeedY * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1311,7 +1311,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setSpeed * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The speed, in pixels per second. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1332,7 +1332,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleX * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1349,7 +1349,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setScaleY * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1366,7 +1366,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setScale * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - The scale, relative to 1. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1384,7 +1384,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityX * @since 3.0.0 * - * @param {float} value - Acceleration due to gravity, in pixels per second squared. + * @param {number} value - Acceleration due to gravity, in pixels per second squared. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1401,7 +1401,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravityY * @since 3.0.0 * - * @param {float} value - Acceleration due to gravity, in pixels per second squared. + * @param {number} value - Acceleration due to gravity, in pixels per second squared. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1418,8 +1418,8 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setGravity * @since 3.0.0 * - * @param {float} x - Horizontal acceleration due to gravity, in pixels per second squared. - * @param {float} y - Vertical acceleration due to gravity, in pixels per second squared. + * @param {number} x - Horizontal acceleration due to gravity, in pixels per second squared. + * @param {number} y - Vertical acceleration due to gravity, in pixels per second squared. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1437,7 +1437,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setAlpha * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnUpdateCallback|object} value - A value between 0 (transparent) and 1 (opaque). + * @param {number|float[]|EmitterOpOnUpdateCallback|object} value - A value between 0 (transparent) and 1 (opaque). * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1454,7 +1454,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setEmitterAngle * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1471,7 +1471,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setAngle * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The angle of the initial velocity of emitted particles. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1488,7 +1488,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setLifespan * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} value - The particle lifespan, in ms. + * @param {number|float[]|EmitterOpOnEmitCallback|object} value - The particle lifespan, in ms. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1505,7 +1505,7 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setQuantity * @since 3.0.0 * - * @param {float|float[]|EmitterOpOnEmitCallback|object} quantity - The number of particles to release at each flow cycle or explosion. + * @param {number|float[]|EmitterOpOnEmitCallback|object} quantity - The number of particles to release at each flow cycle or explosion. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1523,8 +1523,8 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#setFrequency * @since 3.0.0 * - * @param {float} frequency - The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. - * @param {float|float[]|EmitterOpOnEmitCallback|object} [quantity] - The number of particles to release at each flow cycle or explosion. + * @param {number} frequency - The time interval (>= 0) of each flow cycle, in ms; or -1 to put the emitter in explosion mode. + * @param {number|float[]|EmitterOpOnEmitCallback|object} [quantity] - The number of particles to release at each flow cycle or explosion. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1862,6 +1862,21 @@ var ParticleEmitter = new Class({ return this; }, + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on off} the emitter. + * + * @method Phaser.GameObjects.Particles.ParticleEmitter#stop + * @since 3.11.0 + * + * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. + */ + stop: function () + { + this.on = false; + + return this; + }, + /** * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. * @@ -1915,8 +1930,8 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#flow * @since 3.0.0 * - * @param {float} frequency - The time interval (>= 0) of each flow cycle, in ms. - * @param {float|float[]|EmitterOpOnEmitCallback|object} [count=1] - The number of particles to emit at each flow cycle. + * @param {number} frequency - The time interval (>= 0) of each flow cycle, in ms. + * @param {number|float[]|EmitterOpOnEmitCallback|object} [count=1] - The number of particles to emit at each flow cycle. * * @return {Phaser.GameObjects.Particles.ParticleEmitter} This Particle Emitter. */ @@ -1938,8 +1953,8 @@ var ParticleEmitter = new Class({ * @since 3.0.0 * * @param {integer} count - The amount of Particles to emit. - * @param {float} x - The x coordinate to emit the Particles from. - * @param {float} y - The y coordinate to emit the Particles from. + * @param {number} x - The x coordinate to emit the Particles from. + * @param {number} y - The y coordinate to emit the Particles from. * * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. */ @@ -1956,8 +1971,8 @@ var ParticleEmitter = new Class({ * @method Phaser.GameObjects.Particles.ParticleEmitter#emitParticleAt * @since 3.0.0 * - * @param {float} [x=this.x] - The x coordinate to emit the Particles from. - * @param {float} [y=this.x] - The y coordinate to emit the Particles from. + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.x] - The y coordinate to emit the Particles from. * @param {integer} [count=this.quantity] - The number of Particles to emit. * * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. @@ -1974,8 +1989,8 @@ var ParticleEmitter = new Class({ * @since 3.0.0 * * @param {integer} [count=this.quantity] - The number of Particles to emit. - * @param {float} [x=this.x] - The x coordinate to emit the Particles from. - * @param {float} [y=this.x] - The y coordinate to emit the Particles from. + * @param {number} [x=this.x] - The x coordinate to emit the Particles from. + * @param {number} [y=this.x] - The y coordinate to emit the Particles from. * * @return {Phaser.GameObjects.Particles.Particle} The most recently emitted Particle. * @@ -2040,7 +2055,7 @@ var ParticleEmitter = new Class({ * @since 3.0.0 * * @param {integer} time - The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param {float} delta - The delta time, in ms, elapsed since the last frame. + * @param {number} delta - The delta time, in ms, elapsed since the last frame. */ preUpdate: function (time, delta) { diff --git a/src/gameobjects/particles/ParticleManagerCanvasRenderer.js b/src/gameobjects/particles/ParticleManagerCanvasRenderer.js index a5103614d..1a8df0b35 100644 --- a/src/gameobjects/particles/ParticleManagerCanvasRenderer.js +++ b/src/gameobjects/particles/ParticleManagerCanvasRenderer.js @@ -33,9 +33,11 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol var ctx = renderer.currentContext; ctx.save(); + if (parentMatrix !== undefined) { var matrix = parentMatrix.matrix; + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } @@ -51,8 +53,8 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol continue; } - var lastAlpha = ctx.globalAlpha; + var cameraScrollX = camera.scrollX * emitter.scrollFactorX; var cameraScrollY = camera.scrollY * emitter.scrollFactorY; @@ -62,15 +64,13 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol ctx.globalCompositeOperation = renderer.blendModes[emitter.blendMode]; } - var roundPixels = renderer.config.roundPixels; - for (var index = 0; index < length; ++index) { var particle = particles[index]; - var alpha = ((particle.color >> 24) & 0xFF) / 255.0; + var particleAlpha = camera.alpha * ((particle.color >> 24) & 0xFF) / 255; - if (alpha <= 0) + if (particleAlpha <= 0) { continue; } @@ -88,13 +88,13 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol var tx = particle.x - cameraScrollX; var ty = particle.y - cameraScrollY; - if (roundPixels) + if (camera.roundPixels) { tx |= 0; ty |= 0; } - ctx.globalAlpha = alpha; + ctx.globalAlpha = particleAlpha; ctx.save(); diff --git a/src/gameobjects/quad/Quad.js b/src/gameobjects/quad/Quad.js index 41ae8d4a4..5d9e3b009 100644 --- a/src/gameobjects/quad/Quad.js +++ b/src/gameobjects/quad/Quad.js @@ -260,7 +260,7 @@ var Quad = new Class({ * The top-left alpha value of this Quad. * * @name Phaser.GameObjects.Quad#topLeftAlpha - * @type {float} + * @type {number} * @since 3.0.0 */ topLeftAlpha: { @@ -282,7 +282,7 @@ var Quad = new Class({ * The top-right alpha value of this Quad. * * @name Phaser.GameObjects.Quad#topRightAlpha - * @type {float} + * @type {number} * @since 3.0.0 */ topRightAlpha: { @@ -303,7 +303,7 @@ var Quad = new Class({ * The bottom-left alpha value of this Quad. * * @name Phaser.GameObjects.Quad#bottomLeftAlpha - * @type {float} + * @type {number} * @since 3.0.0 */ bottomLeftAlpha: { @@ -324,7 +324,7 @@ var Quad = new Class({ * The bottom-right alpha value of this Quad. * * @name Phaser.GameObjects.Quad#bottomRightAlpha - * @type {float} + * @type {number} * @since 3.0.0 */ bottomRightAlpha: { diff --git a/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js b/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js index a8c63af01..3e77d0352 100644 --- a/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js +++ b/src/gameobjects/rendertexture/RenderTextureCanvasRenderer.js @@ -30,17 +30,30 @@ var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolati var ctx = renderer.currentContext; + // Alpha + + var alpha = camera.alpha * renderTexture.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + + // Blend Mode + if (renderer.currentBlendMode !== renderTexture.blendMode) { renderer.currentBlendMode = renderTexture.blendMode; ctx.globalCompositeOperation = renderer.blendModes[renderTexture.blendMode]; } - if (renderer.currentAlpha !== renderTexture.alpha) - { - renderer.currentAlpha = renderTexture.alpha; - ctx.globalAlpha = renderTexture.alpha; - } + // Scale Mode if (renderer.currentScaleMode !== renderTexture.scaleMode) { @@ -74,11 +87,14 @@ var RenderTextureCanvasRenderer = function (renderer, renderTexture, interpolati } ctx.save(); + if (parentMatrix !== undefined) { var matrix = parentMatrix.matrix; + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } + ctx.translate(renderTexture.x - camera.scrollX * renderTexture.scrollFactorX, renderTexture.y - camera.scrollY * renderTexture.scrollFactorY); ctx.rotate(renderTexture.rotation); ctx.scale(renderTexture.scaleX, renderTexture.scaleY); diff --git a/src/gameobjects/sprite/SpriteCanvasRenderer.js b/src/gameobjects/sprite/SpriteCanvasRenderer.js index 2f3e392b1..9263ef104 100644 --- a/src/gameobjects/sprite/SpriteCanvasRenderer.js +++ b/src/gameobjects/sprite/SpriteCanvasRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var SpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/sprite/SpriteWebGLRenderer.js b/src/gameobjects/sprite/SpriteWebGLRenderer.js index bdf7501cf..a9c850fba 100644 --- a/src/gameobjects/sprite/SpriteWebGLRenderer.js +++ b/src/gameobjects/sprite/SpriteWebGLRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/gameobjects/text/static/TextCanvasRenderer.js b/src/gameobjects/text/static/TextCanvasRenderer.js index 92ab7928f..1fb2b37a3 100644 --- a/src/gameobjects/text/static/TextCanvasRenderer.js +++ b/src/gameobjects/text/static/TextCanvasRenderer.js @@ -23,30 +23,38 @@ var GameObject = require('../../GameObject'); */ var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id)) || src.text === '') { return; } var ctx = renderer.currentContext; - // var resolution = src.resolution; + // Alpha + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + // Blend Mode + if (renderer.currentBlendMode !== src.blendMode) { renderer.currentBlendMode = src.blendMode; ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; } - // Alpha - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - // Smoothing + if (renderer.currentScaleMode !== src.scaleMode) { renderer.currentScaleMode = src.scaleMode; @@ -65,7 +73,7 @@ var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camer var tx = src.x - camera.scrollX * src.scrollFactorX; var ty = src.y - camera.scrollY * src.scrollFactorY; - if (renderer.config.roundPixels) + if (camera.roundPixels) { tx |= 0; ty |= 0; diff --git a/src/gameobjects/text/static/TextWebGLRenderer.js b/src/gameobjects/text/static/TextWebGLRenderer.js index d4def862c..eaad5be48 100644 --- a/src/gameobjects/text/static/TextWebGLRenderer.js +++ b/src/gameobjects/text/static/TextWebGLRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../../GameObject'); */ var TextWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id)) || src.text === '') + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id)) || src.text === '') { return; } diff --git a/src/gameobjects/tilesprite/TileSprite.js b/src/gameobjects/tilesprite/TileSprite.js index 7a18f27a6..2ae4734e2 100644 --- a/src/gameobjects/tilesprite/TileSprite.js +++ b/src/gameobjects/tilesprite/TileSprite.js @@ -19,7 +19,21 @@ var TileSpriteRender = require('./TileSpriteRender'); * The texture can be scrolled and scaled independently of the TileSprite itself. Textures will automatically wrap and * are designed so that you can create game backdrops using seamless textures as a source. * - * [description] + * You shouldn't ever create a TileSprite any larger than your actual screen size. If you want to create a large repeating background + * that scrolls across the whole map of your game, then you create a TileSprite that fits the screen size and then use the `tilePosition` + * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will + * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to + * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. + * + * An important note about Tile Sprites and NPOT textures: Internally, TileSprite textures use GL_REPEAT to provide + * seamless repeating of the textures. This, combined with the way in which the textures are handled in WebGL, means + * they need to be POT (power-of-two) sizes in order to wrap. If you provide a NPOT (non power-of-two) texture to a + * TileSprite it will generate a POT sized canvas and draw your texture to it, scaled up to the POT size. It's then + * scaled back down again during rendering to the original dimensions. While this works, in that it allows you to use + * any size texture for a Tile Sprite, it does mean that NPOT textures are going to appear anti-aliased when rendered, + * due to the interpolation that took place when it was resized into a POT texture. This is especially visible in + * pixel art graphics. If you notice it and it becomes an issue, the only way to avoid it is to ensure that you + * provide POT textures for Tile Sprites. * * @class TileSprite * @extends Phaser.GameObjects.GameObject @@ -29,6 +43,7 @@ var TileSpriteRender = require('./TileSpriteRender'); * * @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.BlendMode + * @extends Phaser.GameObjects.Components.ComputedSize * @extends Phaser.GameObjects.Components.Depth * @extends Phaser.GameObjects.Components.Flip * @extends Phaser.GameObjects.Components.GetBounds @@ -37,7 +52,6 @@ var TileSpriteRender = require('./TileSpriteRender'); * @extends Phaser.GameObjects.Components.Pipeline * @extends Phaser.GameObjects.Components.ScaleMode * @extends Phaser.GameObjects.Components.ScrollFactor - * @extends Phaser.GameObjects.Components.Size * @extends Phaser.GameObjects.Components.Texture * @extends Phaser.GameObjects.Components.Tint * @extends Phaser.GameObjects.Components.Transform @@ -58,6 +72,7 @@ var TileSprite = new Class({ Mixins: [ Components.Alpha, Components.BlendMode, + Components.ComputedSize, Components.Depth, Components.Flip, Components.GetBounds, @@ -66,7 +81,6 @@ var TileSprite = new Class({ Components.Pipeline, Components.ScaleMode, Components.ScrollFactor, - Components.Size, Components.Texture, Components.Tint, Components.Transform, @@ -102,6 +116,26 @@ var TileSprite = new Class({ */ this.tilePositionY = 0; + /** + * The horizontal scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleX + * @type {number} + * @default 1 + * @since 3.11.0 + */ + this.tileScaleX = 1; + + /** + * The vertical scale of the Tile Sprite texture. + * + * @name Phaser.GameObjects.TileSprite#tileScaleY + * @type {number} + * @default 1 + * @since 3.11.0 + */ + this.tileScaleY = 1; + /** * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. * @@ -116,9 +150,10 @@ var TileSprite = new Class({ /** * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. + * In WebGL this is a WebGLTexture. In Canvas it's a Canvas Fill Pattern. * * @name Phaser.GameObjects.TileSprite#tileTexture - * @type {?WebGLTexture} + * @type {?(WebGLTexture|CanvasPattern)} * @default null * @since 3.0.0 */ @@ -165,7 +200,7 @@ var TileSprite = new Class({ * @default null * @since 3.0.0 */ - this.canvasPattern = null; + // this.canvasPattern = null; /** * The Canvas that the TileSprite's texture is rendered to. @@ -185,6 +220,14 @@ var TileSprite = new Class({ */ this.canvasBufferCtx = this.canvasBuffer.getContext('2d'); + /** + * The previous Texture Frame being used. + * + * @name Phaser.GameObjects.Components.Texture#oldFrame + * @type {Phaser.Textures.Frame} + * @private + * @since 3.0.0 + */ this.oldFrame = null; this.updateTileTexture(); @@ -236,41 +279,41 @@ var TileSprite = new Class({ */ updateTileTexture: function () { - if (!this.dirty && this.oldFrame === this.frame) + var frame = this.frame; + + if (!this.dirty && this.oldFrame === frame) { return; } - this.oldFrame = this.frame; + this.oldFrame = frame; - this.canvasBufferCtx.clearRect(0, 0, this.canvasBuffer.width, this.canvasBuffer.height); + var ctx = this.canvasBufferCtx; + var canvas = this.canvasBuffer; - if (this.renderer.gl) + var fw = this.potWidth; + var fh = this.potHeight; + + if (!this.renderer.gl) { - this.canvasBufferCtx.drawImage( - this.frame.source.image, - this.frame.cutX, this.frame.cutY, - this.frame.cutWidth, this.frame.cutHeight, - 0, 0, - this.potWidth, this.potHeight - ); - - this.tileTexture = this.renderer.canvasToTexture(this.canvasBuffer, this.tileTexture); + fw = frame.cutWidth; + fh = frame.cutHeight; } - else - { - this.canvasBuffer.width = this.frame.cutWidth; - this.canvasBuffer.height = this.frame.cutHeight; - this.canvasBufferCtx.drawImage( - this.frame.source.image, - this.frame.cutX, this.frame.cutY, - this.frame.cutWidth, this.frame.cutHeight, - 0, 0, - this.frame.cutWidth, this.frame.cutHeight - ); - this.canvasPattern = this.canvasBufferCtx.createPattern(this.canvasBuffer, 'repeat'); - } + ctx.clearRect(0, 0, canvas.width, canvas.height); + + canvas.width = fw; + canvas.height = fh; + + ctx.drawImage( + frame.source.image, + frame.cutX, frame.cutY, + frame.cutWidth, frame.cutHeight, + 0, 0, + fw, fh + ); + + this.tileTexture = (this.renderer.gl) ? this.renderer.canvasToTexture(canvas, this.tileTexture) : ctx.createPattern(canvas, 'repeat'); this.dirty = false; }, @@ -291,7 +334,7 @@ var TileSprite = new Class({ CanvasPool.remove(this.canvasBuffer); - this.canvasPattern = null; + this.tileTexture = null; this.canvasBufferCtx = null; this.canvasBuffer = null; diff --git a/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js b/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js index 4949a4577..c744a5504 100644 --- a/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js +++ b/src/gameobjects/tilesprite/TileSpriteCanvasRenderer.js @@ -23,7 +23,7 @@ var GameObject = require('../GameObject'); */ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } @@ -33,6 +33,21 @@ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, src.updateTileTexture(); + // Alpha + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + else if (renderer.currentAlpha !== alpha) + { + renderer.currentAlpha = alpha; + ctx.globalAlpha = alpha; + } + // Blend Mode if (renderer.currentBlendMode !== src.blendMode) @@ -41,14 +56,6 @@ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, ctx.globalCompositeOperation = renderer.blendModes[src.blendMode]; } - // Alpha - - if (renderer.currentAlpha !== src.alpha) - { - renderer.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - // Smoothing if (renderer.currentScaleMode !== src.scaleMode) @@ -79,7 +86,7 @@ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, dy += src.height; } - if (renderer.config.roundPixels) + if (camera.roundPixels) { dx |= 0; dy |= 0; @@ -92,6 +99,7 @@ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, if (parentMatrix !== undefined) { var matrix = parentMatrix.matrix; + ctx.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } @@ -109,9 +117,12 @@ var TileSpriteCanvasRenderer = function (renderer, src, interpolationPercentage, ctx.translate(-(src.originX * src.width), -(src.originY * src.height)); // Draw + + ctx.scale(src.tileScaleX, src.tileScaleY); + ctx.translate(-this.tilePositionX, -this.tilePositionY); - ctx.fillStyle = src.canvasPattern; - ctx.fillRect(this.tilePositionX, this.tilePositionY, src.width, src.height); + ctx.fillStyle = src.tileTexture; + ctx.fillRect(this.tilePositionX, this.tilePositionY, src.width / src.tileScaleX, src.height / src.tileScaleY); ctx.restore(); }; diff --git a/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js b/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js index 79108698a..a73ed4f51 100644 --- a/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js +++ b/src/gameobjects/tilesprite/TileSpriteWebGLRenderer.js @@ -5,6 +5,7 @@ */ var GameObject = require('../GameObject'); +var Utils = require('../../renderer/webgl/Utils'); /** * Renders this Game Object with the WebGL Renderer to the given Camera. @@ -23,14 +24,36 @@ var GameObject = require('../GameObject'); */ var TileSpriteWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } src.updateTileTexture(); - this.pipeline.batchTileSprite(this, camera, parentMatrix); + var getTint = Utils.getTintAppendFloatAlpha; + + this.pipeline.batchTexture( + src, + src.tileTexture, + src.frame.width * src.tileScaleX, src.frame.height * src.tileScaleY, + src.x, src.y, + src.width, src.height, + src.scaleX, src.scaleY, + src.rotation, + src.flipX, src.flipY, + src.scrollFactorX, src.scrollFactorY, + src.originX * src.width, src.originY * src.height, + 0, 0, src.width, src.height, + getTint(src._tintTL, camera.alpha * src._alphaTL), + getTint(src._tintTR, camera.alpha * src._alphaTR), + getTint(src._tintBL, camera.alpha * src._alphaBL), + getTint(src._tintBR, camera.alpha * src._alphaBR), + (src.tilePositionX % src.frame.width) / src.frame.width, + (src.tilePositionY % src.frame.height) / src.frame.height, + camera, + parentMatrix + ); }; module.exports = TileSpriteWebGLRenderer; diff --git a/src/geom/circle/Circle.js b/src/geom/circle/Circle.js index 6a8e2b4d3..6c147dc35 100644 --- a/src/geom/circle/Circle.js +++ b/src/geom/circle/Circle.js @@ -104,7 +104,7 @@ var Circle = new Class({ * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. diff --git a/src/geom/circle/GetPoint.js b/src/geom/circle/GetPoint.js index 863736275..424847bb6 100644 --- a/src/geom/circle/GetPoint.js +++ b/src/geom/circle/GetPoint.js @@ -20,7 +20,7 @@ var Point = require('../point/Point'); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Circle} circle - The Circle to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the circle. diff --git a/src/geom/ellipse/Ellipse.js b/src/geom/ellipse/Ellipse.js index 23a803a43..5dd277b94 100644 --- a/src/geom/ellipse/Ellipse.js +++ b/src/geom/ellipse/Ellipse.js @@ -106,7 +106,7 @@ var Ellipse = new Class({ * * @generic {Phaser.Geom.Point} O - [out,$return] * - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. diff --git a/src/geom/ellipse/GetPoint.js b/src/geom/ellipse/GetPoint.js index 5392d7228..e840f1a45 100644 --- a/src/geom/ellipse/GetPoint.js +++ b/src/geom/ellipse/GetPoint.js @@ -20,7 +20,7 @@ var Point = require('../point/Point'); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to get the circumference point on. - * @param {float} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. + * @param {number} position - A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the ellipse. * @param {(Phaser.Geom.Point|object)} [out] - An object to store the return values in. If not given a Point object will be created. * * @return {(Phaser.Geom.Point|object)} A Point, or point-like object, containing the coordinates of the point around the ellipse. diff --git a/src/geom/intersects/RectangleToValues.js b/src/geom/intersects/RectangleToValues.js index 2f8ef64b0..7409f15d5 100644 --- a/src/geom/intersects/RectangleToValues.js +++ b/src/geom/intersects/RectangleToValues.js @@ -15,7 +15,7 @@ * @param {number} right - [description] * @param {number} top - [description] * @param {number} bottom - [description] - * @param {float} [tolerance=0] - [description] + * @param {number} [tolerance=0] - [description] * * @return {boolean} [description] */ diff --git a/src/geom/line/Line.js b/src/geom/line/Line.js index 2b1dd9940..fd0038254 100644 --- a/src/geom/line/Line.js +++ b/src/geom/line/Line.js @@ -182,7 +182,7 @@ var Line = new Class({ }, /** - * Returns a Vector2 object that corresponds to the start of this Line. + * Returns a Vector2 object that corresponds to the end of this Line. * * @method Phaser.Geom.Line#getPointB * @since 3.0.0 @@ -191,7 +191,7 @@ var Line = new Class({ * * @param {Phaser.Math.Vector2} [vec2] - A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. * - * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the start of this Line. + * @return {Phaser.Math.Vector2} A Vector2 object that corresponds to the end of this Line. */ getPointB: function (vec2) { diff --git a/src/geom/point/Interpolate.js b/src/geom/point/Interpolate.js index a4369eb51..2b7fa5893 100644 --- a/src/geom/point/Interpolate.js +++ b/src/geom/point/Interpolate.js @@ -16,7 +16,7 @@ var Point = require('./Point'); * * @param {Phaser.Geom.Point} pointA - [description] * @param {Phaser.Geom.Point} pointB - [description] - * @param {float} [t=0] - [description] + * @param {number} [t=0] - [description] * @param {(Phaser.Geom.Point|object)} [out] - [description] * * @return {(Phaser.Geom.Point|object)} [description] diff --git a/src/geom/rectangle/GetPoint.js b/src/geom/rectangle/GetPoint.js index d272345c8..c02b57f6c 100644 --- a/src/geom/rectangle/GetPoint.js +++ b/src/geom/rectangle/GetPoint.js @@ -16,7 +16,7 @@ var Point = require('../point/Point'); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Rectangle} rectangle - [description] - * @param {float} position - [description] + * @param {number} position - [description] * @param {(Phaser.Geom.Point|object)} [out] - [description] * * @return {Phaser.Geom.Point} [description] diff --git a/src/geom/rectangle/Rectangle.js b/src/geom/rectangle/Rectangle.js index 37ca57448..13f714c36 100644 --- a/src/geom/rectangle/Rectangle.js +++ b/src/geom/rectangle/Rectangle.js @@ -101,7 +101,7 @@ var Rectangle = new Class({ * * @generic {Phaser.Geom.Point} O - [output,$return] * - * @param {float} position - [description] + * @param {number} position - [description] * @param {(Phaser.Geom.Point|object)} [output] - [description] * * @return {(Phaser.Geom.Point|object)} [description] diff --git a/src/geom/triangle/BuildFromPolygon.js b/src/geom/triangle/BuildFromPolygon.js index 0beaba06d..60b10cfa5 100644 --- a/src/geom/triangle/BuildFromPolygon.js +++ b/src/geom/triangle/BuildFromPolygon.js @@ -17,8 +17,8 @@ var Triangle = require('./Triangle'); * * @param {array} data - A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...] * @param {array} [holes=null] - An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11). - * @param {float} [scaleX=1] - [description] - * @param {float} [scaleY=1] - [description] + * @param {number} [scaleX=1] - [description] + * @param {number} [scaleY=1] - [description] * @param {(array|Phaser.Geom.Triangle[])} [out] - [description] * * @return {(array|Phaser.Geom.Triangle[])} [description] diff --git a/src/geom/triangle/GetPoint.js b/src/geom/triangle/GetPoint.js index ce9bfa9bc..6e25faed8 100644 --- a/src/geom/triangle/GetPoint.js +++ b/src/geom/triangle/GetPoint.js @@ -17,7 +17,7 @@ var Length = require('../line/Length'); * @generic {Phaser.Geom.Point} O - [out,$return] * * @param {Phaser.Geom.Triangle} triangle - [description] - * @param {float} position - [description] + * @param {number} position - [description] * @param {(Phaser.Geom.Point|object)} [out] - [description] * * @return {(Phaser.Geom.Point|object)} [description] diff --git a/src/geom/triangle/Triangle.js b/src/geom/triangle/Triangle.js index c63f73b8c..643c6494e 100644 --- a/src/geom/triangle/Triangle.js +++ b/src/geom/triangle/Triangle.js @@ -127,7 +127,7 @@ var Triangle = new Class({ * * @generic {Phaser.Geom.Point} O - [output,$return] * - * @param {float} position - [description] + * @param {number} position - [description] * @param {(Phaser.Geom.Point|object)} [output] - [description] * * @return {(Phaser.Geom.Point|object)} [description] diff --git a/src/input/InputPlugin.js b/src/input/InputPlugin.js index 922874cf6..497cc981f 100644 --- a/src/input/InputPlugin.js +++ b/src/input/InputPlugin.js @@ -683,7 +683,7 @@ var InputPlugin = new Class({ { var camera = cameras[c]; - // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'output' array. + // Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'over' array. // All objects in this array are input enabled, as checked by the hitTest method, so we don't need to check later on as well. var over = this.manager.hitTest(pointer, this._list, camera); @@ -706,6 +706,11 @@ var InputPlugin = new Class({ } } + // If we got this far then there were no Game Objects below the pointer, but it was still over + // a camera, so set that the top-most one into the pointer + + pointer.camera = cameras[0]; + return []; }, diff --git a/src/input/gamepad/Axis.js b/src/input/gamepad/Axis.js index 1dc257b7e..2d4fcb616 100644 --- a/src/input/gamepad/Axis.js +++ b/src/input/gamepad/Axis.js @@ -57,7 +57,7 @@ var Axis = new Class({ * Use the method `getValue` to get a normalized value with the threshold applied. * * @name Phaser.Input.Gamepad.Axis#value - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -67,7 +67,7 @@ var Axis = new Class({ * Movement tolerance threshold below which axis values are ignored in `getValue`. * * @name Phaser.Input.Gamepad.Axis#threshold - * @type {float} + * @type {number} * @default 0.1 * @since 3.0.0 */ @@ -82,7 +82,7 @@ var Axis = new Class({ * @private * @since 3.0.0 * - * @param {float} value - The value of the axis movement. + * @param {number} value - The value of the axis movement. */ update: function (value) { @@ -95,7 +95,7 @@ var Axis = new Class({ * @method Phaser.Input.Gamepad.Axis#getValue * @since 3.0.0 * - * @return {float} The axis value, adjusted for the movement threshold. + * @return {number} The axis value, adjusted for the movement threshold. */ getValue: function () { diff --git a/src/input/gamepad/Button.js b/src/input/gamepad/Button.js index 78712e504..9a1682bcf 100644 --- a/src/input/gamepad/Button.js +++ b/src/input/gamepad/Button.js @@ -56,7 +56,7 @@ var Button = new Class({ * Between 0 and 1. * * @name Phaser.Input.Gamepad.Button#value - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -67,7 +67,7 @@ var Button = new Class({ * before a button is considered as being 'pressed'. * * @name Phaser.Input.Gamepad.Button#threshold - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ diff --git a/src/loader/File.js b/src/loader/File.js index 5f14aa611..e2daa724e 100644 --- a/src/loader/File.js +++ b/src/loader/File.js @@ -180,7 +180,7 @@ var File = new Class({ * Only set if loading via XHR. * * @name Phaser.Loader.File#percentComplete - * @type {float} + * @type {number} * @default -1 * @since 3.0.0 */ diff --git a/src/loader/LoaderPlugin.js b/src/loader/LoaderPlugin.js index 68cf46da4..167bc9ead 100644 --- a/src/loader/LoaderPlugin.js +++ b/src/loader/LoaderPlugin.js @@ -215,7 +215,7 @@ var LoaderPlugin = new Class({ * Note that it is possible for this value to go down again if you add content to the current load queue during a load. * * @name Phaser.Loader.LoaderPlugin#progress - * @type {float} + * @type {number} * @default 0 * @since 3.0.0 */ @@ -724,7 +724,7 @@ var LoaderPlugin = new Class({ * a file having completed loading. * * @event Phaser.Loader.LoaderPlugin#progressEvent - * @param {float} progress - The current progress of the load. A value between 0 and 1. + * @param {number} progress - The current progress of the load. A value between 0 and 1. */ /** diff --git a/src/math/DegToRad.js b/src/math/DegToRad.js index 7436d90c4..21c0e75c6 100644 --- a/src/math/DegToRad.js +++ b/src/math/DegToRad.js @@ -14,7 +14,7 @@ var CONST = require('./const'); * * @param {integer} degrees - The angle (in degrees) to convert to radians. * - * @return {float} The given angle converted to radians. + * @return {number} The given angle converted to radians. */ var DegToRad = function (degrees) { diff --git a/src/math/FloatBetween.js b/src/math/FloatBetween.js index 78943ddc4..95f938e5f 100644 --- a/src/math/FloatBetween.js +++ b/src/math/FloatBetween.js @@ -10,10 +10,10 @@ * @function Phaser.Math.FloatBetween * @since 3.0.0 * - * @param {float} min - The lower bound for the float, inclusive. - * @param {float} max - The upper bound for the float exclusive. + * @param {number} min - The lower bound for the float, inclusive. + * @param {number} max - The upper bound for the float exclusive. * - * @return {float} A random float within the given range. + * @return {number} A random float within the given range. */ var FloatBetween = function (min, max) { diff --git a/src/math/FromPercent.js b/src/math/FromPercent.js index 47793b962..6e7d61465 100644 --- a/src/math/FromPercent.js +++ b/src/math/FromPercent.js @@ -12,7 +12,7 @@ var Clamp = require('./Clamp'); * @function Phaser.Math.FromPercent * @since 3.0.0 * - * @param {float} percent - A value between 0 and 1 representing the percentage. + * @param {number} percent - A value between 0 and 1 representing the percentage. * @param {number} min - The minimum value. * @param {number} [max] - The maximum value. * diff --git a/src/math/Linear.js b/src/math/Linear.js index 5ef9ced14..b891f6803 100644 --- a/src/math/Linear.js +++ b/src/math/Linear.js @@ -12,7 +12,7 @@ * * @param {number} p0 - The first point. * @param {number} p1 - The second point. - * @param {float} t - The percentage between p0 and p1 to return, represented as a number between 0 and 1. + * @param {number} t - The percentage between p0 and p1 to return, represented as a number between 0 and 1. * * @return {number} The step t% of the way between p0 and p1. */ diff --git a/src/math/Matrix4.js b/src/math/Matrix4.js index 202bfebd8..e4338ec17 100644 --- a/src/math/Matrix4.js +++ b/src/math/Matrix4.js @@ -666,7 +666,7 @@ var Matrix4 = new Class({ * @since 3.0.0 * * @param {(Phaser.Math.Vector3|Phaser.Math.Vector4)} axis - The rotation axis. - * @param {float} angle - The rotation angle in radians. + * @param {number} angle - The rotation angle in radians. * * @return {Phaser.Math.Matrix4} This Matrix4. */ @@ -699,7 +699,7 @@ var Matrix4 = new Class({ * @method Phaser.Math.Matrix4#rotate * @since 3.0.0 * - * @param {float} rad - The angle in radians to rotate by. + * @param {number} rad - The angle in radians to rotate by. * @param {Phaser.Math.Vector3} axis - The axis to rotate upon. * * @return {Phaser.Math.Matrix4} This Matrix4. @@ -777,7 +777,7 @@ var Matrix4 = new Class({ * @method Phaser.Math.Matrix4#rotateX * @since 3.0.0 * - * @param {float} rad - The angle in radians to rotate by. + * @param {number} rad - The angle in radians to rotate by. * * @return {Phaser.Math.Matrix4} This Matrix4. */ @@ -816,7 +816,7 @@ var Matrix4 = new Class({ * @method Phaser.Math.Matrix4#rotateY * @since 3.0.0 * - * @param {float} rad - The angle to rotate by, in radians. + * @param {number} rad - The angle to rotate by, in radians. * * @return {Phaser.Math.Matrix4} This Matrix4. */ @@ -855,7 +855,7 @@ var Matrix4 = new Class({ * @method Phaser.Math.Matrix4#rotateZ * @since 3.0.0 * - * @param {float} rad - The angle to rotate by, in radians. + * @param {number} rad - The angle to rotate by, in radians. * * @return {Phaser.Math.Matrix4} This Matrix4. */ diff --git a/src/math/Percent.js b/src/math/Percent.js index 5e1db799f..15421e701 100644 --- a/src/math/Percent.js +++ b/src/math/Percent.js @@ -18,7 +18,7 @@ * @param {number} [max] - The maximum value. * @param {number} [upperMax] - The mid-way point in the range that represents 100%. * - * @return {float} A value between 0 and 1 representing the percentage. + * @return {number} A value between 0 and 1 representing the percentage. */ var Percent = function (value, min, max, upperMax) { diff --git a/src/math/RadToDeg.js b/src/math/RadToDeg.js index c991e15f4..1bde46d4c 100644 --- a/src/math/RadToDeg.js +++ b/src/math/RadToDeg.js @@ -12,7 +12,7 @@ var CONST = require('./const'); * @function Phaser.Math.RadToDeg * @since 3.0.0 * - * @param {float} radians - The angle in radians to convert ot degrees. + * @param {number} radians - The angle in radians to convert ot degrees. * * @return {integer} The given angle converted to degrees. */ diff --git a/src/math/RandomXY.js b/src/math/RandomXY.js index d58bf5df1..9c523c75c 100644 --- a/src/math/RandomXY.js +++ b/src/math/RandomXY.js @@ -15,7 +15,7 @@ * @since 3.0.0 * * @param {Phaser.Math.Vector2} vector - The Vector to compute random values for. - * @param {float} [scale=1] - The scale of the random values. + * @param {number} [scale=1] - The scale of the random values. * * @return {Phaser.Math.Vector2} The given Vector. */ diff --git a/src/math/RandomXYZW.js b/src/math/RandomXYZW.js index bf44c29b0..2a6e61e6d 100644 --- a/src/math/RandomXYZW.js +++ b/src/math/RandomXYZW.js @@ -11,7 +11,7 @@ * @since 3.0.0 * * @param {Phaser.Math.Vector4} vec4 - The Vector to compute random values for. - * @param {float} [scale=1] - The scale of the random values. + * @param {number} [scale=1] - The scale of the random values. * * @return {Phaser.Math.Vector4} The given Vector. */ diff --git a/src/math/Vector2.js b/src/math/Vector2.js index 5fb099ccc..54aa8efd7 100644 --- a/src/math/Vector2.js +++ b/src/math/Vector2.js @@ -162,8 +162,8 @@ var Vector2 = new Class({ * @method Phaser.Math.Vector2#setToPolar * @since 3.0.0 * - * @param {float} azimuth - The angular coordinate, in radians. - * @param {float} [radius=1] - The radial coordinate (length). + * @param {number} azimuth - The angular coordinate, in radians. + * @param {number} [radius=1] - The radial coordinate (length). * * @return {Phaser.Math.Vector2} This Vector2. */ diff --git a/src/math/easing/elastic/In.js b/src/math/easing/elastic/In.js index ea1a4d28b..8e095c437 100644 --- a/src/math/easing/elastic/In.js +++ b/src/math/easing/elastic/In.js @@ -11,8 +11,8 @@ * @since 3.0.0 * * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] * * @return {number} The tweened value. */ diff --git a/src/math/easing/elastic/InOut.js b/src/math/easing/elastic/InOut.js index a29849c4d..3de98c6f1 100644 --- a/src/math/easing/elastic/InOut.js +++ b/src/math/easing/elastic/InOut.js @@ -11,8 +11,8 @@ * @since 3.0.0 * * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] * * @return {number} The tweened value. */ diff --git a/src/math/easing/elastic/Out.js b/src/math/easing/elastic/Out.js index 2b33921ab..c30596d3f 100644 --- a/src/math/easing/elastic/Out.js +++ b/src/math/easing/elastic/Out.js @@ -11,8 +11,8 @@ * @since 3.0.0 * * @param {number} v - The value to be tweened. - * @param {float} [amplitude=0.1] - The amplitude of the elastic ease. - * @param {float} [period=0.1] - [description] + * @param {number} [amplitude=0.1] - The amplitude of the elastic ease. + * @param {number} [period=0.1] - [description] * * @return {number} The tweened value. */ diff --git a/src/math/fuzzy/Ceil.js b/src/math/fuzzy/Ceil.js index 96f4df163..dd5921bae 100644 --- a/src/math/fuzzy/Ceil.js +++ b/src/math/fuzzy/Ceil.js @@ -11,7 +11,7 @@ * @since 3.0.0 * * @param {number} value - The value. - * @param {float} [epsilon=0.0001] - The epsilon. + * @param {number} [epsilon=0.0001] - The epsilon. * * @return {number} The fuzzy ceiling of the value. */ diff --git a/src/math/fuzzy/Equal.js b/src/math/fuzzy/Equal.js index 67d2d362b..cbfd7cd6d 100644 --- a/src/math/fuzzy/Equal.js +++ b/src/math/fuzzy/Equal.js @@ -14,7 +14,7 @@ * * @param {number} a - The first value. * @param {number} b - The second value. - * @param {float} [epsilon=0.0001] - The epsilon. + * @param {number} [epsilon=0.0001] - The epsilon. * * @return {boolean} `true` if the values are fuzzily equal, otherwise `false`. */ diff --git a/src/math/fuzzy/Floor.js b/src/math/fuzzy/Floor.js index fb662a110..a9f3e7582 100644 --- a/src/math/fuzzy/Floor.js +++ b/src/math/fuzzy/Floor.js @@ -11,7 +11,7 @@ * @since 3.0.0 * * @param {number} value - The value. - * @param {float} [epsilon=0.0001] - The epsilon. + * @param {number} [epsilon=0.0001] - The epsilon. * * @return {number} The floor of the value. */ diff --git a/src/math/fuzzy/GreaterThan.js b/src/math/fuzzy/GreaterThan.js index cf28754df..f67c97539 100644 --- a/src/math/fuzzy/GreaterThan.js +++ b/src/math/fuzzy/GreaterThan.js @@ -14,7 +14,7 @@ * * @param {number} a - The first value. * @param {number} b - The second value. - * @param {float} [epsilon=0.0001] - The epsilon. + * @param {number} [epsilon=0.0001] - The epsilon. * * @return {boolean} `true` if `a` is fuzzily greater than than `b`, otherwise `false`. */ diff --git a/src/math/fuzzy/LessThan.js b/src/math/fuzzy/LessThan.js index f03d8cf1d..22810fe95 100644 --- a/src/math/fuzzy/LessThan.js +++ b/src/math/fuzzy/LessThan.js @@ -14,7 +14,7 @@ * * @param {number} a - The first value. * @param {number} b - The second value. - * @param {float} [epsilon=0.0001] - The epsilon. + * @param {number} [epsilon=0.0001] - The epsilon. * * @return {boolean} `true` if `a` is fuzzily less than `b`, otherwise `false`. */ diff --git a/src/math/interpolation/CubicBezierInterpolation.js b/src/math/interpolation/CubicBezierInterpolation.js index 07721a3db..1bf717c02 100644 --- a/src/math/interpolation/CubicBezierInterpolation.js +++ b/src/math/interpolation/CubicBezierInterpolation.js @@ -41,7 +41,7 @@ function P3 (t, p) * @function Phaser.Math.Interpolation.CubicBezier * @since 3.0.0 * - * @param {float} t - The percentage of interpolation, between 0 and 1. + * @param {number} t - The percentage of interpolation, between 0 and 1. * @param {number} p0 - The start point. * @param {number} p1 - The first control point. * @param {number} p2 - The second control point. diff --git a/src/math/interpolation/QuadraticBezierInterpolation.js b/src/math/interpolation/QuadraticBezierInterpolation.js index c9a67eb2b..177097ee7 100644 --- a/src/math/interpolation/QuadraticBezierInterpolation.js +++ b/src/math/interpolation/QuadraticBezierInterpolation.js @@ -33,7 +33,7 @@ function P2 (t, p) * @function Phaser.Math.Interpolation.QuadraticBezier * @since 3.2.0 * - * @param {float} t - The percentage of interpolation, between 0 and 1. + * @param {number} t - The percentage of interpolation, between 0 and 1. * @param {number} p0 - The start point. * @param {number} p1 - The control point. * @param {number} p2 - The end point. diff --git a/src/physics/impact/World.js b/src/physics/impact/World.js index cc7e70a9e..04af7557a 100644 --- a/src/physics/impact/World.js +++ b/src/physics/impact/World.js @@ -22,7 +22,7 @@ var TYPE = require('./TYPE'); * @property {number} [gravity=0] - [description] * @property {number} [cellSize=64] - [description] * @property {number} [timeScale=1] - [description] - * @property {float} [maxStep=0.05] - [description] + * @property {number} [maxStep=0.05] - [description] * @property {boolean} [debug=false] - [description] * @property {number} [maxVelocity=100] - [description] * @property {boolean} [debugShowBody=true] - [description] @@ -145,7 +145,7 @@ var World = new Class({ * [description] * * @name Phaser.Physics.Impact.World#timeScale - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ diff --git a/src/physics/matter-js/components/Bounce.js b/src/physics/matter-js/components/Bounce.js index 3851a5ea7..9ada1efaf 100644 --- a/src/physics/matter-js/components/Bounce.js +++ b/src/physics/matter-js/components/Bounce.js @@ -18,7 +18,7 @@ var Bounce = { * @method Phaser.Physics.Matter.Components.Bounce#setBounce * @since 3.0.0 * - * @param {float} value - [description] + * @param {number} value - [description] * * @return {Phaser.GameObjects.GameObject} This Game Object. */ diff --git a/src/renderer/canvas/CanvasRenderer.js b/src/renderer/canvas/CanvasRenderer.js index e997962eb..e23d27eb2 100644 --- a/src/renderer/canvas/CanvasRenderer.js +++ b/src/renderer/canvas/CanvasRenderer.js @@ -86,10 +86,10 @@ var CanvasRenderer = new Class({ */ this.config = { clearBeforeRender: game.config.clearBeforeRender, - pixelArt: game.config.pixelArt, backgroundColor: game.config.backgroundColor, resolution: game.config.resolution, autoResize: game.config.autoResize, + antialias: game.config.antialias, roundPixels: game.config.roundPixels }; @@ -100,7 +100,7 @@ var CanvasRenderer = new Class({ * @type {integer} * @since 3.0.0 */ - this.scaleMode = (game.config.pixelArt) ? ScaleModes.NEAREST : ScaleModes.LINEAR; + this.scaleMode = (game.config.antialias) ? ScaleModes.LINEAR : ScaleModes.NEAREST; /** * [description] @@ -136,7 +136,7 @@ var CanvasRenderer = new Class({ * @type {function} * @since 3.0.0 */ - this.drawImage = DrawImage(this.config.roundPixels); + this.drawImage = DrawImage; /** * [description] @@ -324,9 +324,9 @@ var CanvasRenderer = new Class({ * @method Phaser.Renderer.Canvas.CanvasRenderer#setAlpha * @since 3.0.0 * - * @param {float} alpha - [description] + * @param {number} alpha - [description] * - * @return {float} [description] + * @return {number} [description] */ setAlpha: function (alpha) { @@ -375,7 +375,7 @@ var CanvasRenderer = new Class({ * * @param {Phaser.Scene} scene - [description] * @param {Phaser.GameObjects.DisplayList} children - [description] - * @param {float} interpolationPercentage - [description] + * @param {number} interpolationPercentage - [description] * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] */ render: function (scene, children, interpolationPercentage, camera) @@ -395,11 +395,9 @@ var CanvasRenderer = new Class({ ctx.fillRect(camera.x, camera.y, camera.width, camera.height); } - if (this.currentAlpha !== 1) - { - ctx.globalAlpha = 1; - this.currentAlpha = 1; - } + ctx.globalAlpha = camera.alpha; + + this.currentAlpha = camera.alpha; if (this.currentBlendMode !== 0) { @@ -442,6 +440,7 @@ var CanvasRenderer = new Class({ ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.globalCompositeOperation = 'source-over'; + ctx.globalAlpha = 1; camera.flashEffect.postRenderCanvas(ctx); camera.fadeEffect.postRenderCanvas(ctx); diff --git a/src/renderer/canvas/utils/DrawImage.js b/src/renderer/canvas/utils/DrawImage.js index 660fa7eb2..f0d56c27e 100644 --- a/src/renderer/canvas/utils/DrawImage.js +++ b/src/renderer/canvas/utils/DrawImage.js @@ -4,8 +4,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -var roundPixels = false; - /** * [description] * @@ -22,6 +20,18 @@ var DrawImage = function (src, camera, parentMatrix) var frame = src.frame; var cd = frame.canvasData; + // Alpha + + var alpha = camera.alpha * src.alpha; + + if (alpha === 0) + { + // Nothing to see, so abort early + return; + } + + ctx.globalAlpha = alpha; + // Blend Mode if (this.currentBlendMode !== src.blendMode) @@ -30,14 +40,6 @@ var DrawImage = function (src, camera, parentMatrix) ctx.globalCompositeOperation = this.blendModes[src.blendMode]; } - // Alpha - - if (this.currentAlpha !== src.alpha) - { - this.currentAlpha = src.alpha; - ctx.globalAlpha = src.alpha; - } - // Smoothing if (this.currentScaleMode !== src.scaleMode) @@ -76,7 +78,7 @@ var DrawImage = function (src, camera, parentMatrix) var tx = src.x - camera.scrollX * src.scrollFactorX; var ty = src.y - camera.scrollY * src.scrollFactorY; - if (roundPixels) + if (camera.roundPixels) { tx |= 0; ty |= 0; @@ -107,11 +109,4 @@ var DrawImage = function (src, camera, parentMatrix) ctx.restore(); }; -// Special return so we can store the config value locally - -module.exports = function (configRoundPixels) -{ - roundPixels = configRoundPixels; - - return DrawImage; -}; +module.exports = DrawImage; diff --git a/src/renderer/index.js b/src/renderer/index.js index 15b7a53c1..a7b531266 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -8,7 +8,7 @@ * @typedef {object} RendererConfig * * @property {boolean} clearBeforeRender - [description] - * @property {boolean} pixelArt - [description] + * @property {boolean} antialias - [description] * @property {Phaser.Display.Color} backgroundColor - [description] * @property {number} resolution - [description] * @property {boolean} autoResize - [description] diff --git a/src/renderer/snapshot/CanvasSnapshot.js b/src/renderer/snapshot/CanvasSnapshot.js index 9098a15a4..8c5d06ff3 100644 --- a/src/renderer/snapshot/CanvasSnapshot.js +++ b/src/renderer/snapshot/CanvasSnapshot.js @@ -12,7 +12,7 @@ * * @param {HTMLCanvasElement} canvas - [description] * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] + * @param {number} [encoderOptions=0.92] - [description] * * @return {HTMLImageElement} [description] */ diff --git a/src/renderer/snapshot/WebGLSnapshot.js b/src/renderer/snapshot/WebGLSnapshot.js index 2aa5f0030..2d28e951a 100644 --- a/src/renderer/snapshot/WebGLSnapshot.js +++ b/src/renderer/snapshot/WebGLSnapshot.js @@ -12,7 +12,7 @@ * * @param {HTMLCanvasElement} sourceCanvas - [description] * @param {string} [type='image/png'] - [description] - * @param {float} [encoderOptions=0.92] - [description] + * @param {number} [encoderOptions=0.92] - [description] * * @return {HTMLImageElement} [description] */ diff --git a/src/renderer/webgl/WebGLPipeline.js b/src/renderer/webgl/WebGLPipeline.js index c8ae0f425..b15259eff 100644 --- a/src/renderer/webgl/WebGLPipeline.js +++ b/src/renderer/webgl/WebGLPipeline.js @@ -459,7 +459,7 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {float} x - [description] + * @param {number} x - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -476,8 +476,8 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] + * @param {number} x - [description] + * @param {number} y - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -495,9 +495,9 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ @@ -515,10 +515,10 @@ var WebGLPipeline = new Class({ * @since 3.2.0 * * @param {string} name - Name of the uniform - * @param {float} x - X component of the uniform - * @param {float} y - Y component of the uniform - * @param {float} z - Z component of the uniform - * @param {float} w - W component of the uniform + * @param {number} x - X component of the uniform + * @param {number} y - Y component of the uniform + * @param {number} z - Z component of the uniform + * @param {number} w - W component of the uniform * * @return {Phaser.Renderer.WebGL.WebGLPipeline} [description] */ diff --git a/src/renderer/webgl/WebGLRenderer.js b/src/renderer/webgl/WebGLRenderer.js index b18049581..9f3c043b5 100644 --- a/src/renderer/webgl/WebGLRenderer.js +++ b/src/renderer/webgl/WebGLRenderer.js @@ -29,7 +29,7 @@ var TextureTintPipeline = require('./pipelines/TextureTintPipeline'); * * @property {SnapshotCallback} callback - [description] * @property {string} type - [description] - * @property {float} encoder - [description] + * @property {number} encoder - [description] */ /** @@ -80,7 +80,7 @@ var WebGLRenderer = new Class({ */ this.config = { clearBeforeRender: gameConfig.clearBeforeRender, - pixelArt: gameConfig.pixelArt, + antialias: gameConfig.antialias, backgroundColor: gameConfig.backgroundColor, contextCreation: contextCreationConfig, resolution: gameConfig.resolution, @@ -1120,14 +1120,10 @@ var WebGLRenderer = new Class({ wrap = gl.REPEAT; } - if (scaleMode === CONST.ScaleModes.LINEAR) + if (scaleMode === CONST.ScaleModes.LINEAR && this.config.antialias) { filter = gl.LINEAR; } - else if (scaleMode === CONST.ScaleModes.NEAREST || this.config.pixelArt) - { - filter = gl.NEAREST; - } if (!source && typeof width === 'number' && typeof height === 'number') { @@ -1157,7 +1153,7 @@ var WebGLRenderer = new Class({ * @param {object} pixels - pixel data * @param {integer} width - Width of the texture in pixels * @param {integer} height - Height of the texture in pixels - * @param {boolean} pma - Does the texture hace premultiplied alpha. + * @param {boolean} pma - Does the texture have premultiplied alpha? * * @return {WebGLTexture} Raw WebGLTexture */ @@ -1607,7 +1603,7 @@ var WebGLRenderer = new Class({ * * @param {SnapshotCallback} callback - [description] * @param {string} type - [description] - * @param {float} encoderOptions - [description] + * @param {number} encoderOptions - [description] * * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] */ @@ -1695,7 +1691,7 @@ var WebGLRenderer = new Class({ * * @param {WebGLProgram} program - [description] * @param {string} name - [description] - * @param {float} x - [description] + * @param {number} x - [description] * * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] */ @@ -1716,8 +1712,8 @@ var WebGLRenderer = new Class({ * * @param {WebGLProgram} program - [description] * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] + * @param {number} x - [description] + * @param {number} y - [description] * * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] */ @@ -1738,9 +1734,9 @@ var WebGLRenderer = new Class({ * * @param {WebGLProgram} program - [description] * @param {string} name - [description] - * @param {float} x - [description] - * @param {float} y - [description] - * @param {float} z - [description] + * @param {number} x - [description] + * @param {number} y - [description] + * @param {number} z - [description] * * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] */ @@ -1761,10 +1757,10 @@ var WebGLRenderer = new Class({ * * @param {WebGLProgram} program - Target program * @param {string} name - Name of the uniform - * @param {float} x - X component - * @param {float} y - Y component - * @param {float} z - Z component - * @param {float} w - W component + * @param {number} x - X component + * @param {number} y - Y component + * @param {number} z - Z component + * @param {number} w - W component * * @return {Phaser.Renderer.WebGL.WebGLRenderer} [description] */ diff --git a/src/renderer/webgl/pipelines/FlatTintPipeline.js b/src/renderer/webgl/pipelines/FlatTintPipeline.js index 0c50e4b44..9063e3814 100644 --- a/src/renderer/webgl/pipelines/FlatTintPipeline.js +++ b/src/renderer/webgl/pipelines/FlatTintPipeline.js @@ -133,7 +133,7 @@ var FlatTintPipeline = new Class({ ]; /** - * Used internally by for triangulating a polyong + * Used internally for triangulating a polygon * * @name Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#polygonCache * @type {array} @@ -187,23 +187,23 @@ var FlatTintPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillRect * @since 3.0.0 * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x - Horiztonal top left coordinate of the rectangle - * @param {float} y - Vertical top left coordinate of the rectangle - * @param {float} width - Width of the rectangle - * @param {float} height - Height of the rectangle + * @param {number} srcX - Graphics horizontal component for translation + * @param {number} srcY - Graphics vertical component for translation + * @param {number} srcScaleX - Graphics horizontal component for scale + * @param {number} srcScaleY - Graphics vertical component for scale + * @param {number} srcRotation - Graphics rotation + * @param {number} x - Horiztonal top left coordinate of the rectangle + * @param {number} y - Vertical top left coordinate of the rectangle + * @param {number} width - Width of the rectangle + * @param {number} height - Height of the rectangle * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component + * @param {number} fillAlpha - Alpha represented as float + * @param {number} a1 - Matrix stack top a component + * @param {number} b1 - Matrix stack top b component + * @param {number} c1 - Matrix stack top c component + * @param {number} d1 - Matrix stack top d component + * @param {number} e1 - Matrix stack top e component + * @param {number} f1 - Matrix stack top f component * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers */ batchFillRect: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x, y, width, height, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) @@ -245,18 +245,23 @@ var FlatTintPipeline = new Class({ vertexViewF32[vertexOffset + 0] = tx0; vertexViewF32[vertexOffset + 1] = ty0; vertexViewU32[vertexOffset + 2] = tint; + vertexViewF32[vertexOffset + 3] = tx1; vertexViewF32[vertexOffset + 4] = ty1; vertexViewU32[vertexOffset + 5] = tint; + vertexViewF32[vertexOffset + 6] = tx2; vertexViewF32[vertexOffset + 7] = ty2; vertexViewU32[vertexOffset + 8] = tint; + vertexViewF32[vertexOffset + 9] = tx0; vertexViewF32[vertexOffset + 10] = ty0; vertexViewU32[vertexOffset + 11] = tint; + vertexViewF32[vertexOffset + 12] = tx2; vertexViewF32[vertexOffset + 13] = ty2; vertexViewU32[vertexOffset + 14] = tint; + vertexViewF32[vertexOffset + 15] = tx3; vertexViewF32[vertexOffset + 16] = ty3; vertexViewU32[vertexOffset + 17] = tint; @@ -270,25 +275,25 @@ var FlatTintPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillTriangle * @since 3.0.0 * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x0 - Point 0 x coordinate - * @param {float} y0 - Point 0 y coordinate - * @param {float} x1 - Point 1 x coordinate - * @param {float} y1 - Point 1 y coordinate - * @param {float} x2 - Point 2 x coordinate - * @param {float} y2 - Point 2 y coordinate + * @param {number} srcX - Graphics horizontal component for translation + * @param {number} srcY - Graphics vertical component for translation + * @param {number} srcScaleX - Graphics horizontal component for scale + * @param {number} srcScaleY - Graphics vertical component for scale + * @param {number} srcRotation - Graphics rotation + * @param {number} x0 - Point 0 x coordinate + * @param {number} y0 - Point 0 y coordinate + * @param {number} x1 - Point 1 x coordinate + * @param {number} y1 - Point 1 y coordinate + * @param {number} x2 - Point 2 x coordinate + * @param {number} y2 - Point 2 y coordinate * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component + * @param {number} fillAlpha - Alpha represented as float + * @param {number} a1 - Matrix stack top a component + * @param {number} b1 - Matrix stack top b component + * @param {number} c1 - Matrix stack top c component + * @param {number} d1 - Matrix stack top d component + * @param {number} e1 - Matrix stack top e component + * @param {number} f1 - Matrix stack top f component * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers */ batchFillTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) @@ -326,9 +331,11 @@ var FlatTintPipeline = new Class({ vertexViewF32[vertexOffset + 0] = tx0; vertexViewF32[vertexOffset + 1] = ty0; vertexViewU32[vertexOffset + 2] = tint; + vertexViewF32[vertexOffset + 3] = tx1; vertexViewF32[vertexOffset + 4] = ty1; vertexViewU32[vertexOffset + 5] = tint; + vertexViewF32[vertexOffset + 6] = tx2; vertexViewF32[vertexOffset + 7] = ty2; vertexViewU32[vertexOffset + 8] = tint; @@ -342,26 +349,26 @@ var FlatTintPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchStrokeTriangle * @since 3.0.0 * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} x0 - [description] - * @param {float} y0 - [description] - * @param {float} x1 - [description] - * @param {float} y1 - [description] - * @param {float} x2 - [description] - * @param {float} y2 - [description] - * @param {float} lineWidth - Size of the line as a float value + * @param {number} srcX - Graphics horizontal component for translation + * @param {number} srcY - Graphics vertical component for translation + * @param {number} srcScaleX - Graphics horizontal component for scale + * @param {number} srcScaleY - Graphics vertical component for scale + * @param {number} srcRotation - Graphics rotation + * @param {number} x0 - [description] + * @param {number} y0 - [description] + * @param {number} x1 - [description] + * @param {number} y1 - [description] + * @param {number} x2 - [description] + * @param {number} y2 - [description] + * @param {number} lineWidth - Size of the line as a float value * @param {integer} lineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a - Matrix stack top a component - * @param {float} b - Matrix stack top b component - * @param {float} c - Matrix stack top c component - * @param {float} d - Matrix stack top d component - * @param {float} e - Matrix stack top e component - * @param {float} f - Matrix stack top f component + * @param {number} lineAlpha - Alpha represented as float + * @param {number} a - Matrix stack top a component + * @param {number} b - Matrix stack top b component + * @param {number} c - Matrix stack top c component + * @param {number} d - Matrix stack top d component + * @param {number} e - Matrix stack top e component + * @param {number} f - Matrix stack top f component * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers */ batchStrokeTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, currentMatrix) @@ -404,20 +411,20 @@ var FlatTintPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchFillPath * @since 3.0.0 * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} path - Collection of points that represent the path + * @param {number} srcX - Graphics horizontal component for translation + * @param {number} srcY - Graphics vertical component for translation + * @param {number} srcScaleX - Graphics horizontal component for scale + * @param {number} srcScaleY - Graphics vertical component for scale + * @param {number} srcRotation - Graphics rotation + * @param {number} path - Collection of points that represent the path * @param {integer} fillColor - RGB color packed as a uint - * @param {float} fillAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component + * @param {number} fillAlpha - Alpha represented as float + * @param {number} a1 - Matrix stack top a component + * @param {number} b1 - Matrix stack top b component + * @param {number} c1 - Matrix stack top c component + * @param {number} d1 - Matrix stack top d component + * @param {number} e1 - Matrix stack top e component + * @param {number} f1 - Matrix stack top f component * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers */ batchFillPath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) @@ -487,9 +494,11 @@ var FlatTintPipeline = new Class({ vertexViewF32[vertexOffset + 0] = tx0; vertexViewF32[vertexOffset + 1] = ty0; vertexViewU32[vertexOffset + 2] = tint; + vertexViewF32[vertexOffset + 3] = tx1; vertexViewF32[vertexOffset + 4] = ty1; vertexViewU32[vertexOffset + 5] = tint; + vertexViewF32[vertexOffset + 6] = tx2; vertexViewF32[vertexOffset + 7] = ty2; vertexViewU32[vertexOffset + 8] = tint; @@ -506,21 +515,21 @@ var FlatTintPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchStrokePath * @since 3.0.0 * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation + * @param {number} srcX - Graphics horizontal component for translation + * @param {number} srcY - Graphics vertical component for translation + * @param {number} srcScaleX - Graphics horizontal component for scale + * @param {number} srcScaleY - Graphics vertical component for scale + * @param {number} srcRotation - Graphics rotation * @param {array} path - [description] - * @param {float} lineWidth - [description] + * @param {number} lineWidth - [description] * @param {integer} lineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a - Matrix stack top a component - * @param {float} b - Matrix stack top b component - * @param {float} c - Matrix stack top c component - * @param {float} d - Matrix stack top d component - * @param {float} e - Matrix stack top e component - * @param {float} f - Matrix stack top f component + * @param {number} lineAlpha - Alpha represented as float + * @param {number} a - Matrix stack top a component + * @param {number} b - Matrix stack top b component + * @param {number} c - Matrix stack top c component + * @param {number} d - Matrix stack top d component + * @param {number} e - Matrix stack top e component + * @param {number} f - Matrix stack top f component * @param {boolean} isLastPath - Indicates if the path should be closed * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers */ @@ -571,18 +580,23 @@ var FlatTintPipeline = new Class({ vertexViewF32[vertexOffset + 0] = last[3 * 2 + 0]; vertexViewF32[vertexOffset + 1] = last[3 * 2 + 1]; vertexViewU32[vertexOffset + 2] = getTint(last[3 * 2 + 2], lineAlpha); + vertexViewF32[vertexOffset + 3] = last[3 * 0 + 0]; vertexViewF32[vertexOffset + 4] = last[3 * 0 + 1]; vertexViewU32[vertexOffset + 5] = getTint(last[3 * 0 + 2], lineAlpha); + vertexViewF32[vertexOffset + 6] = curr[3 * 3 + 0]; vertexViewF32[vertexOffset + 7] = curr[3 * 3 + 1]; vertexViewU32[vertexOffset + 8] = getTint(curr[3 * 3 + 2], lineAlpha); + vertexViewF32[vertexOffset + 9] = last[3 * 0 + 0]; vertexViewF32[vertexOffset + 10] = last[3 * 0 + 1]; vertexViewU32[vertexOffset + 11] = getTint(last[3 * 0 + 2], lineAlpha); + vertexViewF32[vertexOffset + 12] = last[3 * 2 + 0]; vertexViewF32[vertexOffset + 13] = last[3 * 2 + 1]; vertexViewU32[vertexOffset + 14] = getTint(last[3 * 2 + 2], lineAlpha); + vertexViewF32[vertexOffset + 15] = curr[3 * 1 + 0]; vertexViewF32[vertexOffset + 16] = curr[3 * 1 + 1]; vertexViewU32[vertexOffset + 17] = getTint(curr[3 * 1 + 2], lineAlpha); @@ -599,26 +613,26 @@ var FlatTintPipeline = new Class({ * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchLine * @since 3.0.0 * - * @param {float} srcX - Graphics horizontal component for translation - * @param {float} srcY - Graphics vertical component for translation - * @param {float} srcScaleX - Graphics horizontal component for scale - * @param {float} srcScaleY - Graphics vertical component for scale - * @param {float} srcRotation - Graphics rotation - * @param {float} ax - X coordinate to the start of the line - * @param {float} ay - Y coordinate to the start of the line - * @param {float} bx - X coordinate to the end of the line - * @param {float} by - Y coordinate to the end of the line - * @param {float} aLineWidth - Width of the start of the line - * @param {float} bLineWidth - Width of the end of the line + * @param {number} srcX - Graphics horizontal component for translation + * @param {number} srcY - Graphics vertical component for translation + * @param {number} srcScaleX - Graphics horizontal component for scale + * @param {number} srcScaleY - Graphics vertical component for scale + * @param {number} srcRotation - Graphics rotation + * @param {number} ax - X coordinate to the start of the line + * @param {number} ay - Y coordinate to the start of the line + * @param {number} bx - X coordinate to the end of the line + * @param {number} by - Y coordinate to the end of the line + * @param {number} aLineWidth - Width of the start of the line + * @param {number} bLineWidth - Width of the end of the line * @param {integer} aLineColor - RGB color packed as a uint * @param {integer} bLineColor - RGB color packed as a uint - * @param {float} lineAlpha - Alpha represented as float - * @param {float} a1 - Matrix stack top a component - * @param {float} b1 - Matrix stack top b component - * @param {float} c1 - Matrix stack top c component - * @param {float} d1 - Matrix stack top d component - * @param {float} e1 - Matrix stack top e component - * @param {float} f1 - Matrix stack top f component + * @param {number} lineAlpha - Alpha represented as float + * @param {number} a1 - Matrix stack top a component + * @param {number} b1 - Matrix stack top b component + * @param {number} c1 - Matrix stack top c component + * @param {number} d1 - Matrix stack top d component + * @param {number} e1 - Matrix stack top e component + * @param {number} f1 - Matrix stack top f component * @param {Float32Array} currentMatrix - Parent matrix, generally used by containers */ batchLine: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, ax, ay, bx, by, aLineWidth, bLineWidth, aLineColor, bLineColor, lineAlpha, a1, b1, c1, d1, e1, f1, currentMatrix) @@ -675,18 +689,23 @@ var FlatTintPipeline = new Class({ vertexViewF32[vertexOffset + 0] = x0; vertexViewF32[vertexOffset + 1] = y0; vertexViewU32[vertexOffset + 2] = bTint; + vertexViewF32[vertexOffset + 3] = x1; vertexViewF32[vertexOffset + 4] = y1; vertexViewU32[vertexOffset + 5] = aTint; + vertexViewF32[vertexOffset + 6] = x2; vertexViewF32[vertexOffset + 7] = y2; vertexViewU32[vertexOffset + 8] = bTint; + vertexViewF32[vertexOffset + 9] = x1; vertexViewF32[vertexOffset + 10] = y1; vertexViewU32[vertexOffset + 11] = aTint; + vertexViewF32[vertexOffset + 12] = x3; vertexViewF32[vertexOffset + 13] = y3; vertexViewU32[vertexOffset + 14] = aTint; + vertexViewF32[vertexOffset + 15] = x2; vertexViewF32[vertexOffset + 16] = y2; vertexViewU32[vertexOffset + 17] = bTint; @@ -732,7 +751,7 @@ var FlatTintPipeline = new Class({ var srcScaleY = graphics.scaleY; var srcRotation = graphics.rotation; var commands = graphics.commandBuffer; - var alpha = graphics.alpha; + var alpha = camera.alpha * graphics.alpha; var lineAlpha = 1.0; var fillAlpha = 1.0; var lineColor = 0; @@ -1137,138 +1156,6 @@ var FlatTintPipeline = new Class({ break; } } - }, - - // Stubs - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawStaticTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawStaticTilemapLayer: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawEmitterManager - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawEmitterManager: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#drawBlitter - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Blitter} blitter - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - drawBlitter: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Sprite} sprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchSprite: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchMesh - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Mesh} mesh - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchMesh: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.BitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchBitmapText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchDynamicBitmapText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchDynamicBitmapText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchText - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Text} text - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchText: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchDynamicTilemapLayer - * @since 3.0.0 - * - * @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchDynamicTilemapLayer: function () - { - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchTileSprite: function () - { } }); diff --git a/src/renderer/webgl/pipelines/TextureTintPipeline.js b/src/renderer/webgl/pipelines/TextureTintPipeline.js index fa9a8a059..4f79de15b 100644 --- a/src/renderer/webgl/pipelines/TextureTintPipeline.js +++ b/src/renderer/webgl/pipelines/TextureTintPipeline.js @@ -397,7 +397,7 @@ var TextureTintPipeline = new Class({ this.renderer.setPipeline(this); - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var emitters = emitterManager.emitters.list; var emitterCount = emitters.length; var vertexViewF32 = this.vertexViewF32; @@ -502,18 +502,21 @@ var TextureTintPipeline = new Class({ var yh = y + frame.height; var sr = sin(particle.rotation); var cr = cos(particle.rotation); + var sra = cr * particle.scaleX; var srb = sr * particle.scaleX; var src = -sr * particle.scaleY; var srd = cr * particle.scaleY; var sre = particle.x - scrollX; var srf = particle.y - scrollY; + var mva = sra * cma + srb * cmc; var mvb = sra * cmb + srb * cmd; var mvc = src * cma + srd * cmc; var mvd = src * cmb + srd * cmd; var mve = sre * cma + srf * cmc + cme; var mvf = sre * cmb + srf * cmd + cmf; + var tx0 = x * mva + y * mvc + mve; var ty0 = x * mvb + y * mvd + mvf; var tx1 = x * mva + yh * mvc + mve; @@ -522,6 +525,7 @@ var TextureTintPipeline = new Class({ var ty2 = xw * mvb + yh * mvd + mvf; var tx3 = xw * mva + y * mvc + mve; var ty3 = xw * mvb + y * mvd + mvf; + var vertexOffset = this.vertexCount * vertexComponentCount; if (roundPixels) @@ -541,26 +545,31 @@ var TextureTintPipeline = new Class({ vertexViewF32[vertexOffset + 2] = uvs.x0; vertexViewF32[vertexOffset + 3] = uvs.y0; vertexViewU32[vertexOffset + 4] = color; + vertexViewF32[vertexOffset + 5] = tx1; vertexViewF32[vertexOffset + 6] = ty1; vertexViewF32[vertexOffset + 7] = uvs.x1; vertexViewF32[vertexOffset + 8] = uvs.y1; vertexViewU32[vertexOffset + 9] = color; + vertexViewF32[vertexOffset + 10] = tx2; vertexViewF32[vertexOffset + 11] = ty2; vertexViewF32[vertexOffset + 12] = uvs.x2; vertexViewF32[vertexOffset + 13] = uvs.y2; vertexViewU32[vertexOffset + 14] = color; + vertexViewF32[vertexOffset + 15] = tx0; vertexViewF32[vertexOffset + 16] = ty0; vertexViewF32[vertexOffset + 17] = uvs.x0; vertexViewF32[vertexOffset + 18] = uvs.y0; vertexViewU32[vertexOffset + 19] = color; + vertexViewF32[vertexOffset + 20] = tx2; vertexViewF32[vertexOffset + 21] = ty2; vertexViewF32[vertexOffset + 22] = uvs.x2; vertexViewF32[vertexOffset + 23] = uvs.y2; vertexViewU32[vertexOffset + 24] = color; + vertexViewF32[vertexOffset + 25] = tx3; vertexViewF32[vertexOffset + 26] = ty3; vertexViewF32[vertexOffset + 27] = uvs.x3; @@ -574,7 +583,6 @@ var TextureTintPipeline = new Class({ this.flush(); this.setTexture2D(texture, 0); } - } particleOffset += batchSize; @@ -612,7 +620,7 @@ var TextureTintPipeline = new Class({ this.renderer.setPipeline(this); - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var getTint = Utils.getTintAppendFloatAlpha; var vertexViewF32 = this.vertexViewF32; var vertexViewU32 = this.vertexViewU32; @@ -665,6 +673,8 @@ var TextureTintPipeline = new Class({ var prevTextureSourceIndex; + var alpha = camera.alpha * blitter.alpha; + for (var batchIndex = 0; batchIndex < batchCount; ++batchIndex) { var batchSize = Math.min(length, this.maxQuads); @@ -673,15 +683,15 @@ var TextureTintPipeline = new Class({ { var bob = list[batchOffset + index]; var frame = bob.frame; - var alpha = bob.alpha; + var bobAlpha = bob.alpha * alpha; - if (alpha === 0) + if (bobAlpha === 0) { // Nothing to see here, moving on ... continue; } - var tint = getTint(0xffffff, alpha); + var tint = getTint(0xffffff, bobAlpha); var uvs = frame.uvs; var flipX = bob.flipX; var flipY = bob.flipY; @@ -790,35 +800,37 @@ var TextureTintPipeline = new Class({ { this.flush(); } - - var roundPixels = this.renderer.config.roundPixels; - var getTint = Utils.getTintAppendFloatAlpha; - var vertexViewF32 = this.vertexViewF32; - var vertexViewU32 = this.vertexViewU32; - var cameraMatrix = camera.matrix.matrix; + var frame = sprite.frame; var texture = frame.texture.source[frame.sourceIndex].glTexture; + var getTint = Utils.getTintAppendFloatAlpha; var forceFlipY = (texture.isRenderTexture ? true : false); var flipX = sprite.flipX; var flipY = sprite.flipY ^ forceFlipY; var uvs = frame.uvs; - var width = frame.width * (flipX ? -1.0 : 1.0); - var height = frame.height * (flipY ? -1.0 : 1.0); - var x = -sprite.displayOriginX + frame.x + ((frame.width) * (flipX ? 1.0 : 0.0)); - var y = -sprite.displayOriginY + frame.y + ((frame.height) * (flipY ? 1.0 : 0.0)); - var xw = (roundPixels ? (x|0) : x) + width; - var yh = (roundPixels ? (y|0) : y) + height; + var scaleX = sprite.scaleX; var scaleY = sprite.scaleY; var rotation = sprite.rotation; - var alphaTL = sprite._alphaTL; - var alphaTR = sprite._alphaTR; - var alphaBL = sprite._alphaBL; - var alphaBR = sprite._alphaBR; + var alphaTL = camera.alpha * sprite._alphaTL; + var alphaTR = camera.alpha * sprite._alphaTR; + var alphaBL = camera.alpha * sprite._alphaBL; + var alphaBR = camera.alpha * sprite._alphaBR; var tintTL = sprite._tintTL; var tintTR = sprite._tintTR; var tintBL = sprite._tintBL; var tintBR = sprite._tintBR; + + var roundPixels = camera.roundPixels; + var vertexViewF32 = this.vertexViewF32; + var vertexViewU32 = this.vertexViewU32; + var cameraMatrix = camera.matrix.matrix; + var width = frame.width * (flipX ? -1.0 : 1.0); + var height = frame.height * (flipY ? -1.0 : 1.0); + var x = -sprite.displayOriginX + frame.x + ((frame.width) * (flipX ? 1.0 : 0.0)); + var y = -sprite.displayOriginY + frame.y + ((frame.height) * (flipY ? 1.0 : 0.0)); + var xw = (roundPixels ? (x | 0) : x) + width; + var yh = (roundPixels ? (y | 0) : y) + height; var sr = Math.sin(rotation); var cr = Math.cos(rotation); var sra = cr * scaleX; @@ -886,7 +898,6 @@ var TextureTintPipeline = new Class({ var vTintTR = getTint(tintTR, alphaTR); var vTintBL = getTint(tintBL, alphaBL); var vTintBR = getTint(tintBR, alphaBR); - var vertexOffset = 0; if (roundPixels) { @@ -902,33 +913,38 @@ var TextureTintPipeline = new Class({ this.setTexture2D(texture, 0); - vertexOffset = this.vertexCount * this.vertexComponentCount; + var vertexOffset = this.vertexCount * this.vertexComponentCount; vertexViewF32[vertexOffset + 0] = tx0; vertexViewF32[vertexOffset + 1] = ty0; vertexViewF32[vertexOffset + 2] = uvs.x0; vertexViewF32[vertexOffset + 3] = uvs.y0; vertexViewU32[vertexOffset + 4] = vTintTL; + vertexViewF32[vertexOffset + 5] = tx1; vertexViewF32[vertexOffset + 6] = ty1; vertexViewF32[vertexOffset + 7] = uvs.x1; vertexViewF32[vertexOffset + 8] = uvs.y1; vertexViewU32[vertexOffset + 9] = vTintBL; + vertexViewF32[vertexOffset + 10] = tx2; vertexViewF32[vertexOffset + 11] = ty2; vertexViewF32[vertexOffset + 12] = uvs.x2; vertexViewF32[vertexOffset + 13] = uvs.y2; vertexViewU32[vertexOffset + 14] = vTintBR; + vertexViewF32[vertexOffset + 15] = tx0; vertexViewF32[vertexOffset + 16] = ty0; vertexViewF32[vertexOffset + 17] = uvs.x0; vertexViewF32[vertexOffset + 18] = uvs.y0; vertexViewU32[vertexOffset + 19] = vTintTL; + vertexViewF32[vertexOffset + 20] = tx2; vertexViewF32[vertexOffset + 21] = ty2; vertexViewF32[vertexOffset + 22] = uvs.x2; vertexViewF32[vertexOffset + 23] = uvs.y2; vertexViewU32[vertexOffset + 24] = vTintBR; + vertexViewF32[vertexOffset + 25] = tx3; vertexViewF32[vertexOffset + 26] = ty3; vertexViewF32[vertexOffset + 27] = uvs.x3; @@ -968,7 +984,7 @@ var TextureTintPipeline = new Class({ this.flush(); } - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var getTint = Utils.getTintAppendFloatAlpha; var uvs = mesh.uv; var colors = mesh.colors; @@ -1060,7 +1076,7 @@ var TextureTintPipeline = new Class({ vertexViewF32[vertexOffset + 1] = ty; vertexViewF32[vertexOffset + 2] = uvs[index + 0]; vertexViewF32[vertexOffset + 3] = uvs[index + 1]; - vertexViewU32[vertexOffset + 4] = getTint(colors[index0], alphas[index0]); + vertexViewU32[vertexOffset + 4] = getTint(colors[index0], camera.alpha * alphas[index0]); vertexOffset += 5; index0 += 1; @@ -1095,7 +1111,7 @@ var TextureTintPipeline = new Class({ this.flush(); } - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var text = bitmapText.text; var textLength = text.length; var getTint = Utils.getTintAppendFloatAlpha; @@ -1114,7 +1130,7 @@ var TextureTintPipeline = new Class({ var lineHeight = fontData.lineHeight; var scale = (bitmapText.fontSize / fontData.size); var chars = fontData.chars; - var alpha = bitmapText.alpha; + var alpha = camera.alpha * bitmapText.alpha; var vTintTL = getTint(bitmapText._tintTL, alpha); var vTintTR = getTint(bitmapText._tintTR, alpha); var vTintBL = getTint(bitmapText._tintBL, alpha); @@ -1372,7 +1388,7 @@ var TextureTintPipeline = new Class({ this.flush(); } - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var displayCallback = bitmapText.displayCallback; var text = bitmapText.text; var textLength = text.length; @@ -1391,7 +1407,7 @@ var TextureTintPipeline = new Class({ var lineHeight = fontData.lineHeight; var scale = (bitmapText.fontSize / fontData.size); var chars = fontData.chars; - var alpha = bitmapText.alpha; + var alpha = camera.alpha * bitmapText.alpha; var vTintTL = getTint(bitmapText._tintTL, alpha); var vTintTR = getTint(bitmapText._tintTR, alpha); var vTintBL = getTint(bitmapText._tintBL, alpha); @@ -1722,10 +1738,10 @@ var TextureTintPipeline = new Class({ text.scrollFactorX, text.scrollFactorY, text.displayOriginX, text.displayOriginY, 0, 0, text.canvasTexture.width, text.canvasTexture.height, - getTint(text._tintTL, text._alphaTL), - getTint(text._tintTR, text._alphaTR), - getTint(text._tintBL, text._alphaBL), - getTint(text._tintBR, text._alphaBR), + getTint(text._tintTL, camera.alpha * text._alphaTL), + getTint(text._tintTR, camera.alpha * text._alphaTR), + getTint(text._tintBL, camera.alpha * text._alphaBL), + getTint(text._tintBR, camera.alpha * text._alphaBR), 0, 0, camera, parentTransformMatrix @@ -1750,7 +1766,7 @@ var TextureTintPipeline = new Class({ var tileset = tilemapLayer.tileset; var scrollFactorX = tilemapLayer.scrollFactorX; var scrollFactorY = tilemapLayer.scrollFactorY; - var alpha = tilemapLayer.alpha; + var alpha = camera.alpha * tilemapLayer.alpha; var x = tilemapLayer.x; var y = tilemapLayer.y; var sx = tilemapLayer.scaleX; @@ -1790,43 +1806,6 @@ var TextureTintPipeline = new Class({ } }, - /** - * Batches TileSprite game object - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTileSprite - * @since 3.0.0 - * - * @param {Phaser.GameObjects.TileSprite} tileSprite - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description] - */ - batchTileSprite: function (tileSprite, camera, parentTransformMatrix) - { - var getTint = Utils.getTintAppendFloatAlpha; - - this.batchTexture( - tileSprite, - tileSprite.tileTexture, - tileSprite.frame.width, tileSprite.frame.height, - tileSprite.x, tileSprite.y, - tileSprite.width, tileSprite.height, - tileSprite.scaleX, tileSprite.scaleY, - tileSprite.rotation, - tileSprite.flipX, tileSprite.flipY, - tileSprite.scrollFactorX, tileSprite.scrollFactorY, - tileSprite.originX * tileSprite.width, tileSprite.originY * tileSprite.height, - 0, 0, tileSprite.width, tileSprite.height, - getTint(tileSprite._tintTL, tileSprite._alphaTL), - getTint(tileSprite._tintTR, tileSprite._alphaTR), - getTint(tileSprite._tintBL, tileSprite._alphaBL), - getTint(tileSprite._tintBR, tileSprite._alphaBR), - (tileSprite.tilePositionX % tileSprite.frame.width) / tileSprite.frame.width, - (tileSprite.tilePositionY % tileSprite.frame.height) / tileSprite.frame.height, - camera, - parentTransformMatrix - ); - }, - /** * Generic function for batching a textured quad * @@ -1837,29 +1816,29 @@ var TextureTintPipeline = new Class({ * @param {WebGLTexture} texture - Raw WebGLTexture associated with the quad * @param {integer} textureWidth - Real texture width * @param {integer} textureHeight - Real texture height - * @param {float} srcX - X coordinate of the quad - * @param {float} srcY - Y coordinate of the quad - * @param {float} srcWidth - Width of the quad - * @param {float} srcHeight - Height of the quad - * @param {float} scaleX - X component of scale - * @param {float} scaleY - Y component of scale - * @param {float} rotation - Rotation of the quad + * @param {number} srcX - X coordinate of the quad + * @param {number} srcY - Y coordinate of the quad + * @param {number} srcWidth - Width of the quad + * @param {number} srcHeight - Height of the quad + * @param {number} scaleX - X component of scale + * @param {number} scaleY - Y component of scale + * @param {number} rotation - Rotation of the quad * @param {boolean} flipX - Indicates if the quad is horizontally flipped * @param {boolean} flipY - Indicates if the quad is vertically flipped - * @param {float} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll - * @param {float} scrollFactorY - By which factor is the quad effected by the camera vertical scroll - * @param {float} displayOriginX - Horizontal origin in pixels - * @param {float} displayOriginY - Vertical origin in pixels - * @param {float} frameX - X coordinate of the texture frame - * @param {float} frameY - Y coordinate of the texture frame - * @param {float} frameWidth - Width of the texture frame - * @param {float} frameHeight - Height of the texture frame + * @param {number} scrollFactorX - By which factor is the quad affected by the camera horizontal scroll + * @param {number} scrollFactorY - By which factor is the quad effected by the camera vertical scroll + * @param {number} displayOriginX - Horizontal origin in pixels + * @param {number} displayOriginY - Vertical origin in pixels + * @param {number} frameX - X coordinate of the texture frame + * @param {number} frameY - Y coordinate of the texture frame + * @param {number} frameWidth - Width of the texture frame + * @param {number} frameHeight - Height of the texture frame * @param {integer} tintTL - Tint for top left * @param {integer} tintTR - Tint for top right * @param {integer} tintBL - Tint for bottom left * @param {integer} tintBR - Tint for bottom right - * @param {float} uOffset - Horizontal offset on texture coordinate - * @param {float} vOffset - Vertical offset on texture coordinate + * @param {number} uOffset - Horizontal offset on texture coordinate + * @param {number} vOffset - Vertical offset on texture coordinate * @param {Phaser.Cameras.Scene2D.Camera} camera - Current used camera * @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - Parent container */ @@ -1896,7 +1875,7 @@ var TextureTintPipeline = new Class({ flipY = flipY ^ (texture.isRenderTexture ? 1 : 0); - var roundPixels = this.renderer.config.roundPixels; + var roundPixels = camera.roundPixels; var vertexViewF32 = this.vertexViewF32; var vertexViewU32 = this.vertexViewU32; var cameraMatrix = camera.matrix.matrix; @@ -1904,18 +1883,20 @@ var TextureTintPipeline = new Class({ var height = srcHeight * (flipY ? -1.0 : 1.0); var x = -displayOriginX + ((srcWidth) * (flipX ? 1.0 : 0.0)); var y = -displayOriginY + ((srcHeight) * (flipY ? 1.0 : 0.0)); - var xw = x + width; - var yh = y + height; - var translateX = srcX; - var translateY = srcY; + + // var x = -displayOriginX + frameX + ((frameWidth) * (flipX ? 1.0 : 0.0)); + // var y = -displayOriginY + frameY + ((frameHeight) * (flipY ? 1.0 : 0.0)); + + var xw = (roundPixels ? (x | 0) : x) + width; + var yh = (roundPixels ? (y | 0) : y) + height; var sr = Math.sin(rotation); var cr = Math.cos(rotation); var sra = cr * scaleX; var srb = sr * scaleX; var src = -sr * scaleY; var srd = cr * scaleY; - var sre = translateX; - var srf = translateY; + var sre = srcX; + var srf = srcY; var cma = cameraMatrix[0]; var cmb = cameraMatrix[1]; var cmc = cameraMatrix[2]; @@ -1971,15 +1952,11 @@ var TextureTintPipeline = new Class({ var ty2 = xw * mvb + yh * mvd + mvf; var tx3 = xw * mva + y * mvc + mve; var ty3 = xw * mvb + y * mvd + mvf; - var vertexOffset = 0; + var u0 = (frameX / textureWidth) + uOffset; var v0 = (frameY / textureHeight) + vOffset; var u1 = (frameX + frameWidth) / textureWidth + uOffset; var v1 = (frameY + frameHeight) / textureHeight + vOffset; - - this.setTexture2D(texture, 0); - - vertexOffset = this.vertexCount * this.vertexComponentCount; if (roundPixels) { @@ -1993,31 +1970,40 @@ var TextureTintPipeline = new Class({ ty3 |= 0; } + this.setTexture2D(texture, 0); + + var vertexOffset = this.vertexCount * this.vertexComponentCount; + vertexViewF32[vertexOffset + 0] = tx0; vertexViewF32[vertexOffset + 1] = ty0; vertexViewF32[vertexOffset + 2] = u0; vertexViewF32[vertexOffset + 3] = v0; vertexViewU32[vertexOffset + 4] = tintTL; + vertexViewF32[vertexOffset + 5] = tx1; vertexViewF32[vertexOffset + 6] = ty1; vertexViewF32[vertexOffset + 7] = u0; vertexViewF32[vertexOffset + 8] = v1; vertexViewU32[vertexOffset + 9] = tintTR; + vertexViewF32[vertexOffset + 10] = tx2; vertexViewF32[vertexOffset + 11] = ty2; vertexViewF32[vertexOffset + 12] = u1; vertexViewF32[vertexOffset + 13] = v1; vertexViewU32[vertexOffset + 14] = tintBL; + vertexViewF32[vertexOffset + 15] = tx0; vertexViewF32[vertexOffset + 16] = ty0; vertexViewF32[vertexOffset + 17] = u0; vertexViewF32[vertexOffset + 18] = v0; vertexViewU32[vertexOffset + 19] = tintTL; + vertexViewF32[vertexOffset + 20] = tx2; vertexViewF32[vertexOffset + 21] = ty2; vertexViewF32[vertexOffset + 22] = u1; vertexViewF32[vertexOffset + 23] = v1; vertexViewU32[vertexOffset + 24] = tintBL; + vertexViewF32[vertexOffset + 25] = tx3; vertexViewF32[vertexOffset + 26] = ty3; vertexViewF32[vertexOffset + 27] = u1; @@ -2176,20 +2162,6 @@ var TextureTintPipeline = new Class({ // Force an immediate draw this.flush(); - }, - - /** - * [description] - * - * @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchGraphics - * @since 3.0.0 - * - * @param {Phaser.GameObjects.Graphics} graphics - [description] - * @param {Phaser.Cameras.Scene2D.Camera} camera - [description] - */ - batchGraphics: function () - { - // Stub } }); diff --git a/src/scene/SceneManager.js b/src/scene/SceneManager.js index f4bf67e4d..15afce399 100644 --- a/src/scene/SceneManager.js +++ b/src/scene/SceneManager.js @@ -441,6 +441,8 @@ var SceneManager = new Class({ { scene.init.call(scene, settings.data); + settings.status = CONST.INIT; + if (settings.isTransition) { sys.events.emit('transitioninit', settings.transitionFrom, settings.transitionDuration); @@ -623,10 +625,7 @@ var SceneManager = new Class({ sys.sceneUpdate = scene.update; } - if (settings.status === CONST.CREATING) - { - settings.status = CONST.RUNNING; - } + settings.status = CONST.RUNNING; }, /** @@ -928,16 +927,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to pause. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its pause event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - pause: function (key) + pause: function (key, data) { var scene = this.getScene(key); if (scene) { - scene.sys.pause(); + scene.sys.pause(data); } return this; @@ -950,16 +950,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to resume. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its resume event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - resume: function (key) + resume: function (key, data) { var scene = this.getScene(key); if (scene) { - scene.sys.resume(); + scene.sys.resume(data); } return this; @@ -972,16 +973,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to put to sleep. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its sleep event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - sleep: function (key) + sleep: function (key, data) { var scene = this.getScene(key); if (scene && !scene.sys.isTransitioning()) { - scene.sys.sleep(); + scene.sys.sleep(data); } return this; @@ -994,16 +996,17 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to wake up. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted by its wake event. * * @return {Phaser.Scenes.SceneManager} This SceneManager. */ - wake: function (key) + wake: function (key, data) { var scene = this.getScene(key); if (scene) { - scene.sys.wake(); + scene.sys.wake(data); } return this; @@ -1022,7 +1025,7 @@ var SceneManager = new Class({ * @since 3.10.0 * * @param {string} key - The Scene to run. - * @param {object} [data] - A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_. + * @param {object} [data] - A data object that will be passed to the Scene on start, wake, or resume. * * @return {Phaser.Scenes.SceneManager} This Scene Manager. */ @@ -1046,12 +1049,12 @@ var SceneManager = new Class({ if (scene.sys.isSleeping()) { // Sleeping? - scene.sys.wake(); + scene.sys.wake(data); } else if (scene.sys.isBooted && !scene.sys.isActive()) { // Paused? - scene.sys.resume(); + scene.sys.resume(data); } else { diff --git a/src/scene/ScenePlugin.js b/src/scene/ScenePlugin.js index 2c74110a5..103aa4be8 100644 --- a/src/scene/ScenePlugin.js +++ b/src/scene/ScenePlugin.js @@ -77,7 +77,7 @@ var ScenePlugin = new Class({ * the current percentage of the transition progress, between 0 and 1. * * @name Phaser.Scenes.ScenePlugin#transitionProgress - * @type {float} + * @type {number} * @since 3.5.0 */ this.transitionProgress = 0; @@ -191,7 +191,7 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#start * @since 3.0.0 * - * @param {string} key - The Scene to start. + * @param {string} [key] - The Scene to start. * @param {object} [data] - The Scene data. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. @@ -200,16 +200,8 @@ var ScenePlugin = new Class({ { if (key === undefined) { key = this.key; } - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('stop', this.key); - this.manager.queueOp('start', key, data); - } - else - { - this.manager.stop(this.key); - this.manager.start(key, data); - } + this.manager.queueOp('stop', this.key); + this.manager.queueOp('start', key, data); return this; }, @@ -228,16 +220,8 @@ var ScenePlugin = new Class({ { var key = this.key; - if (this.settings.status !== CONST.RUNNING) - { - this.manager.queueOp('stop', key); - this.manager.queueOp('start', key, data); - } - else - { - this.manager.stop(key); - this.manager.start(key, data); - } + this.manager.queueOp('stop', key); + this.manager.queueOp('start', key, data); return this; }, @@ -511,7 +495,7 @@ var ScenePlugin = new Class({ * @since 3.10.0 * * @param {string} key - The Scene to run. - * @param {object} [data] - A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_. + * @param {object} [data] - A data object that will be passed to the Scene and emitted in its ready, wake, or resume events. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ @@ -535,15 +519,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#pause * @since 3.0.0 * - * @param {string} key - The Scene to pause. + * @param {string} [key] - The Scene to pause. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its pause event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - pause: function (key) + pause: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.pause(key); + this.manager.pause(key, data); return this; }, @@ -554,15 +539,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#resume * @since 3.0.0 * - * @param {string} key - The Scene to resume. + * @param {string} [key] - The Scene to resume. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its resume event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - resume: function (key) + resume: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.resume(key); + this.manager.resume(key, data); return this; }, @@ -573,15 +559,16 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#sleep * @since 3.0.0 * - * @param {string} key - The Scene to put to sleep. + * @param {string} [key] - The Scene to put to sleep. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its sleep event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - sleep: function (key) + sleep: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.sleep(key); + this.manager.sleep(key, data); return this; }, @@ -593,14 +580,15 @@ var ScenePlugin = new Class({ * @since 3.0.0 * * @param {string} key - The Scene to wake up. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted in its wake event. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - wake: function (key) + wake: function (key, data) { if (key === undefined) { key = this.key; } - this.manager.wake(key); + this.manager.wake(key, data); return this; }, @@ -657,12 +645,13 @@ var ScenePlugin = new Class({ * @method Phaser.Scenes.ScenePlugin#setActive * @since 3.0.0 * - * @param {boolean} value - The active value. - * @param {string} [key] - The Scene to set the active state for. + * @param {boolean} value - If `true` the Scene will be resumed. If `false` it will be paused. + * @param {string} [key] - The Scene to set the active state of. + * @param {object} [data] - An optional data object that will be passed to the Scene and emitted with its events. * * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. */ - setActive: function (value, key) + setActive: function (value, key, data) { if (key === undefined) { key = this.key; } @@ -670,7 +659,7 @@ var ScenePlugin = new Class({ if (scene) { - scene.sys.setActive(value); + scene.sys.setActive(value, data); } return this; diff --git a/src/scene/Systems.js b/src/scene/Systems.js index 46e01cf01..512293b22 100644 --- a/src/scene/Systems.js +++ b/src/scene/Systems.js @@ -211,7 +211,7 @@ var Systems = new Class({ /** * The Scene Update function. - * + * * This starts out as NOOP during init, preload and create, and at the end of create * it swaps to be whatever the Scene.update function is. * @@ -345,10 +345,12 @@ var Systems = new Class({ * * @method Phaser.Scenes.Systems#pause * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'pause' event. * * @return {Phaser.Scenes.Systems} This Systems object. */ - pause: function () + pause: function (data) { if (this.settings.active) { @@ -356,7 +358,7 @@ var Systems = new Class({ this.settings.active = false; - this.events.emit('pause', this); + this.events.emit('pause', this, data); } return this; @@ -368,9 +370,11 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#resume * @since 3.0.0 * + * @param {object} [data] - A data object that will be passed in the 'resume' event. + * * @return {Phaser.Scenes.Systems} This Systems object. */ - resume: function () + resume: function (data) { if (!this.settings.active) { @@ -378,7 +382,7 @@ var Systems = new Class({ this.settings.active = true; - this.events.emit('resume', this); + this.events.emit('resume', this, data); } return this; @@ -394,17 +398,19 @@ var Systems = new Class({ * * @method Phaser.Scenes.Systems#sleep * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'sleep' event. * * @return {Phaser.Scenes.Systems} This Systems object. */ - sleep: function () + sleep: function (data) { this.settings.status = CONST.SLEEPING; this.settings.active = false; this.settings.visible = false; - this.events.emit('sleep', this); + this.events.emit('sleep', this, data); return this; }, @@ -415,9 +421,11 @@ var Systems = new Class({ * @method Phaser.Scenes.Systems#wake * @since 3.0.0 * + * @param {object} [data] - A data object that will be passed in the 'wake' event. + * * @return {Phaser.Scenes.Systems} This Systems object. */ - wake: function () + wake: function (data) { var settings = this.settings; @@ -426,7 +434,7 @@ var Systems = new Class({ settings.active = true; settings.visible = true; - this.events.emit('wake', this); + this.events.emit('wake', this, data); if (settings.isTransition) { @@ -534,24 +542,26 @@ var Systems = new Class({ /** * Set the active state of this Scene. + * * An active Scene will run its core update loop. * * @method Phaser.Scenes.Systems#setActive * @since 3.0.0 * * @param {boolean} value - If `true` the Scene will be resumed, if previously paused. If `false` it will be paused. + * @param {object} [data] - A data object that will be passed in the 'resume' or 'pause' events. * * @return {Phaser.Scenes.Systems} This Systems object. */ - setActive: function (value) + setActive: function (value, data) { if (value) { - return this.resume(); + return this.resume(data); } else { - return this.pause(); + return this.pause(data); } }, @@ -580,7 +590,7 @@ var Systems = new Class({ this.events.emit('start', this); // For user-land code to listen out for - this.events.emit('ready', this); + this.events.emit('ready', this, data); }, /** @@ -607,8 +617,10 @@ var Systems = new Class({ * * @method Phaser.Scenes.Systems#shutdown * @since 3.0.0 + * + * @param {object} [data] - A data object that will be passed in the 'shutdown' event. */ - shutdown: function () + shutdown: function (data) { this.events.off('transitioninit'); this.events.off('transitionstart'); @@ -620,7 +632,7 @@ var Systems = new Class({ this.settings.active = false; this.settings.visible = false; - this.events.emit('shutdown', this); + this.events.emit('shutdown', this, data); }, /** diff --git a/src/textures/TextureSource.js b/src/textures/TextureSource.js index 2c8fd1561..93d9710b1 100644 --- a/src/textures/TextureSource.js +++ b/src/textures/TextureSource.js @@ -164,7 +164,7 @@ var TextureSource = new Class({ } } - if (game.config.pixelArt) + if (!game.config.antialias) { this.setFilter(1); } diff --git a/src/tilemaps/Tilemap.js b/src/tilemaps/Tilemap.js index 9fe6fbc6c..a5e61bbed 100644 --- a/src/tilemaps/Tilemap.js +++ b/src/tilemaps/Tilemap.js @@ -372,13 +372,15 @@ var Tilemap = new Class({ * * @param {string} name - The name of this layer. Must be unique within the map. * @param {Phaser.Tilemaps.Tileset} tileset - The tileset the new layer will use. - * @param {integer} width - The width of the layer in tiles. If not specified, it will default + * @param {number} [x=0] - The world x position where the top left of this layer will be placed. + * @param {number} [y=0] - The world y position where the top left of this layer will be placed. + * @param {integer} [width] - The width of the layer in tiles. If not specified, it will default * to the map's width. - * @param {integer} height - The height of the layer in tiles. If not specified, it will default + * @param {integer} [height] - The height of the layer in tiles. If not specified, it will default * to the map's height. - * @param {integer} tileWidth - The width of the tiles the layer uses for calculations. If not + * @param {integer} [tileWidth] - The width of the tiles the layer uses for calculations. If not * specified, it will default to the map's tileWidth. - * @param {integer} tileHeight - The height of the tiles the layer uses for calculations. If not + * @param {integer} [tileHeight] - The height of the tiles the layer uses for calculations. If not * specified, it will default to the map's tileHeight. * @return {?Phaser.Tilemaps.DynamicTilemapLayer} Returns the new layer was created, or null if it failed. */ diff --git a/src/tilemaps/components/CullTiles.js b/src/tilemaps/components/CullTiles.js index a372c371d..6ec3bc118 100644 --- a/src/tilemaps/components/CullTiles.js +++ b/src/tilemaps/components/CullTiles.js @@ -70,8 +70,10 @@ var CullTiles = function (layer, camera, outputArray) continue; } - var tileX = tile.pixelX * a + tile.pixelY * c + e; - var tileY = tile.pixelX * b + tile.pixelY * d + f; + var tilePixelX = (tile.pixelX + tilemapLayer.x); + var tilePixelY = (tile.pixelY + tilemapLayer.y); + var tileX = (tilePixelX * a + tilePixelY * c + e); + var tileY = (tilePixelX * b + tilePixelY * d + f); if (tile.visible && tileX >= tCullX && diff --git a/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js b/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js index 95d92dd01..ab9b5af13 100644 --- a/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js +++ b/src/tilemaps/dynamiclayer/DynamicTilemapLayerCanvasRenderer.js @@ -22,7 +22,7 @@ var GameObject = require('../../gameobjects/GameObject'); */ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } @@ -67,7 +67,7 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, src, interpolationPe ctx.scale(tile.flipX ? -1 : 1, tile.flipY ? -1 : 1); } - ctx.globalAlpha = src.alpha * tile.alpha; + ctx.globalAlpha = camera.alpha * src.alpha * tile.alpha; ctx.drawImage( image, diff --git a/src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js b/src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js index d867e6151..961582c04 100644 --- a/src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js +++ b/src/tilemaps/dynamiclayer/DynamicTilemapLayerWebGLRenderer.js @@ -22,7 +22,7 @@ var GameObject = require('../../gameobjects/GameObject'); */ var DynamicTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/tilemaps/mapdata/LayerData.js b/src/tilemaps/mapdata/LayerData.js index 37a6ef966..f5a6c3c6e 100644 --- a/src/tilemaps/mapdata/LayerData.js +++ b/src/tilemaps/mapdata/LayerData.js @@ -131,7 +131,7 @@ var LayerData = new Class({ * [description] * * @name Phaser.Tilemaps.LayerData#alpha - * @type {float} + * @type {number} * @since 3.0.0 */ this.alpha = GetFastValue(config, 'alpha', 1); diff --git a/src/tilemaps/staticlayer/StaticTilemapLayer.js b/src/tilemaps/staticlayer/StaticTilemapLayer.js index f3d3471d2..0fc087ab4 100644 --- a/src/tilemaps/staticlayer/StaticTilemapLayer.js +++ b/src/tilemaps/staticlayer/StaticTilemapLayer.js @@ -281,7 +281,7 @@ var StaticTilemapLayer = new Class({ var ty2 = tyh; var tx3 = txw; var ty3 = ty; - var tint = Utils.getTintAppendFloatAlpha(0xffffff, this.alpha * tile.alpha); + var tint = Utils.getTintAppendFloatAlpha(0xffffff, camera.alpha * this.alpha * tile.alpha); vertexViewF32[voffset + 0] = tx0; vertexViewF32[voffset + 1] = ty0; diff --git a/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js b/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js index ab8b890ad..c838170f5 100644 --- a/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js +++ b/src/tilemaps/staticlayer/StaticTilemapLayerCanvasRenderer.js @@ -22,7 +22,7 @@ var GameObject = require('../../gameobjects/GameObject'); */ var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPercentage, camera) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } @@ -42,7 +42,7 @@ var StaticTilemapLayerCanvasRenderer = function (renderer, src, interpolationPer ctx.rotate(src.rotation); ctx.scale(src.scaleX, src.scaleY); ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1); - ctx.globalAlpha = src.alpha; + ctx.globalAlpha = camera.alpha * src.alpha; for (var index = 0; index < tileCount; ++index) { diff --git a/src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js b/src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js index 5c8add73d..72f7dc73a 100644 --- a/src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js +++ b/src/tilemaps/staticlayer/StaticTilemapLayerWebGLRenderer.js @@ -22,7 +22,7 @@ var GameObject = require('../../gameobjects/GameObject'); */ var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera) { - if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera._id))) + if (GameObject.RENDER_MASK !== src.renderFlags || (src.cameraFilter > 0 && (src.cameraFilter & camera.id))) { return; } diff --git a/src/time/Clock.js b/src/time/Clock.js index 00249b317..325191380 100644 --- a/src/time/Clock.js +++ b/src/time/Clock.js @@ -59,7 +59,7 @@ var Clock = new Class({ * [description] * * @name Phaser.Time.Clock#timeScale - * @type {float} + * @type {number} * @default 1 * @since 3.0.0 */ diff --git a/src/tweens/TweenManager.js b/src/tweens/TweenManager.js index f3e358699..32ec7feaf 100644 --- a/src/tweens/TweenManager.js +++ b/src/tweens/TweenManager.js @@ -615,7 +615,7 @@ var TweenManager = new Class({ * @method Phaser.Tweens.TweenManager#setGlobalTimeScale * @since 3.0.0 * - * @param {float} value - [description] + * @param {number} value - [description] * * @return {Phaser.Tweens.TweenManager} [description] */ diff --git a/src/tweens/tween/Tween.js b/src/tweens/tween/Tween.js index 30a51b711..92845ac41 100644 --- a/src/tweens/tween/Tween.js +++ b/src/tweens/tween/Tween.js @@ -752,7 +752,7 @@ var Tween = new Class({ * @method Phaser.Tweens.Tween#seek * @since 3.0.0 * - * @param {float} toPosition - A value between 0 and 1. + * @param {number} toPosition - A value between 0 and 1. */ seek: function (toPosition) { @@ -885,7 +885,7 @@ var Tween = new Class({ * @method Phaser.Tweens.Tween#stop * @since 3.0.0 * - * @param {float} [resetTo] - A value between 0 and 1. + * @param {number} [resetTo] - A value between 0 and 1. */ stop: function (resetTo) { diff --git a/src/utils/array/AddAt.js b/src/utils/array/AddAt.js index 320726645..99ebc4517 100644 --- a/src/utils/array/AddAt.js +++ b/src/utils/array/AddAt.js @@ -98,7 +98,7 @@ var AddAt = function (array, item, index, limit, callback, context) itemLength = remaining; } - for (var i = itemLength; i > 0; i--) + for (var i = itemLength - 1; i >= 0; i--) { var entry = item[i]; diff --git a/src/utils/array/Each.js b/src/utils/array/Each.js index 49ecded23..cc980135b 100644 --- a/src/utils/array/Each.js +++ b/src/utils/array/Each.js @@ -13,7 +13,7 @@ * @param {array} array - The array to search. * @param {function} callback - A callback to be invoked for each item in the array. * @param {object} context - The context in which the callback is invoked. - * @param {...*} [args] - Additional arguments that will be passed to the callback, after the child. + * @param {...*} [args] - Additional arguments that will be passed to the callback, after the current array item. * * @return {array} The input array. */ @@ -22,7 +22,7 @@ var Each = function (array, callback, context) var i; var args = [ null ]; - for (i = 2; i < arguments.length; i++) + for (i = 3; i < arguments.length; i++) { args.push(arguments[i]); }