v3.86.0 release

This commit is contained in:
Richard Davey 2024-10-11 14:32:30 +01:00
parent c3581595c7
commit f1c4b0fef2
12 changed files with 302605 additions and 302311 deletions

View file

@ -6,6 +6,7 @@ Please select a version to read that specific change log:
| Version | Name | Release Date |
| ------- | ---- | ------------ |
| [3.86](changelog/3.86/CHANGELOG-v3.80.md) | Aoi | 11th October 2024 |
| [3.85.2](changelog/3.85.2/CHANGELOG-v3.85.2.md) | Itsuki | 17th September 2024 |
| [3.85.0](changelog/3.85/CHANGELOG-v3.85.md) | Itsuki | 5th September 2024 |
| [3.80.1](changelog/3.80.1/CHANGELOG-v3.80.1.md) | Nino | 27th February 2024 |

View file

@ -57,15 +57,15 @@ npm install phaser
[Phaser is on jsDelivr](https://www.jsdelivr.com/package/npm/phaser) which is a "super-fast CDN for developers". Include _either_ of the following in your html:
```html
<script src="//cdn.jsdelivr.net/npm/phaser@3.85.2/dist/phaser.js"></script>
<script src="//cdn.jsdelivr.net/npm/phaser@3.85.2/dist/phaser.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/phaser@3.86.0/dist/phaser.js"></script>
<script src="//cdn.jsdelivr.net/npm/phaser@3.86.0/dist/phaser.min.js"></script>
```
It is also available from Cloudflare's [cdnjs](https://cdnjs.com/libraries/phaser):
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/3.85.2/phaser.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/3.85.2/phaser.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/3.86.0/phaser.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/3.86.0/phaser.min.js"></script>
```
## Phaser TypeScript Definitions
@ -115,7 +115,7 @@ Register for a free Phaser account to [download the book](https://phaser.io/news
We have created hundreds of examples and they are all available with full source code and assets.
Browse the examples on the [Phaser 3 Labs](https://labs.phaser.io)
Browse our brand new [Phaser Examples site](https://phaser.io/examples).
## Phaser 3 Plugins
@ -137,8 +137,8 @@ Read more about [Phaser Compressor](https://phaser.io/news/2024/05/phaser-compre
We meticulously keep track of new features, updates and bug fixes in our change logs. Each version of Phaser has its own change log:
* [v3.85.2 Change Log](changelog/3.85.2/CHANGELOG-v3.85.2.md)
* [v3.0.0 to v3.85.0 Change Logs](CHANGELOG.md)
* [v3.86 Change Log](changelog/3.86/CHANGELOG-v3.86.md)
* [v3.0.0 to v3.85.2 Change Logs](CHANGELOG.md)
## Have fun!
@ -158,7 +158,7 @@ Cheers,
**Play** some [amazing games](https://phaser.io/games)<br />
**Learn** By browsing our [API Docs](https://newdocs.phaser.io), [Support Forum](https://phaser.discourse.group/) and [StackOverflow](https://stackoverflow.com/questions/tagged/phaser-framework)<br />
**Code Examples?** We've over 2000 [Examples](https://phaser.io/examples) to learn from<br />
**Read** the weekly [Phaser World](https://phaser.io/newsletter/2024) Newsletter<br />
**Read** the weekly [Phaser World](https://phaser.world) Newsletter<br />
**Be Social:** Join us on [Discord](https://discord.gg/phaser) and [Reddit](https://phaser.io/community/reddit) or follow us on [Twitter](https://twitter.com/phaser_)<br />
Powered by coffee, anime, pixels and love.

View file

@ -8863,6 +8863,22 @@ var BaseCamera = new Class({
* @since 3.60.0
*/
this.isSceneCamera = true;
/**
* Can this Camera render rounded pixel values?
*
* This property is updated during the `preRender` method and should not be
* set directly. It is set based on the `roundPixels` property of the Camera
* combined with the zoom level. If the zoom is an integer then the WebGL
* Renderer can apply rounding during rendering.
*
* @name Phaser.Cameras.Scene2D.BaseCamera#renderRoundPixels
* @type {boolean}
* @readonly
* @default true
* @since 3.86.0
*/
this.renderRoundPixels = true;
},
/**
@ -10799,6 +10815,8 @@ var Camera = new Class({
var zoomY = this.zoomY;
var matrix = this.matrix;
this.renderRoundPixels = (this.roundPixels && Number.isInteger(zoomX) && Number.isInteger(zoomY));
var originX = width * this.originX;
var originY = height * this.originY;
@ -10887,7 +10905,8 @@ var Camera = new Class({
Math.floor(this.x + originX + 0.5),
Math.floor(this.y + originY + 0.5),
this.rotation,
zoomX, zoomY);
zoomX, zoomY
);
matrix.translate(-originX, -originY);
@ -15645,7 +15664,7 @@ var CONST = {
* @type {string}
* @since 3.0.0
*/
VERSION: '3.85.2',
VERSION: '3.86.0',
BlendModes: __webpack_require__(10312),
@ -47643,6 +47662,8 @@ var Render = __webpack_require__(29959);
var Union = __webpack_require__(36899);
var Vector2 = __webpack_require__(26099);
var tempTransformMatrix = new Components.TransformMatrix();
/**
* @classdesc
* A Container Game Object.
@ -47787,16 +47808,6 @@ var Container = new Class({
*/
this.localTransform = new Components.TransformMatrix();
/**
* Internal temporary Transform Matrix used to avoid object creation.
*
* @name Phaser.GameObjects.Container#tempTransformMatrix
* @type {Phaser.GameObjects.Components.TransformMatrix}
* @private
* @since 3.4.0
*/
this.tempTransformMatrix = new Components.TransformMatrix();
/**
* The property key to sort by.
*
@ -48131,7 +48142,7 @@ var Container = new Class({
output.y = source.y;
}
var tempMatrix = this.tempTransformMatrix;
var tempMatrix = tempTransformMatrix;
// No need to loadIdentity because applyITRS overwrites every value anyway
tempMatrix.applyITRS(this.x, this.y, this.rotation, this.scaleX, this.scaleY);
@ -48155,7 +48166,7 @@ var Container = new Class({
*/
getBoundsTransformMatrix: function ()
{
return this.getWorldTransformMatrix(this.tempTransformMatrix, this.localTransform);
return this.getWorldTransformMatrix(tempTransformMatrix, this.localTransform);
},
/**
@ -49078,7 +49089,6 @@ var Container = new Class({
this.removeAll(!!this.exclusive);
this.localTransform.destroy();
this.tempTransformMatrix.destroy();
this.list = [];
},
@ -55043,7 +55053,7 @@ var Group = new Class({
},
/**
* {@link Phaser.GameObjects.Components.Animation#play Plays} an animation for all members of this group.
* {@link Phaser.Animations.AnimationState#play Plays} an animation for all members of this group.
*
* @method Phaser.GameObjects.Group#playAnimation
* @since 3.0.0
@ -65546,7 +65556,7 @@ var ParticleEmitter = new Class({
* or any object with a suitable {@link Phaser.Types.GameObjects.Particles.EdgeZoneSourceCallback getPoints} method.
*
* A {@link Phaser.Types.GameObjects.Particles.ParticleEmitterRandomZoneConfig RandomZone} places the particles randomly within its interior.
* Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback getRandomPoint} method.
* Its {@link Phaser.GameObjects.Particles.Zones.RandomZone#source source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback getRandomPoint} method.
*
* An Emission Zone can only exist once within this Emitter.
*
@ -81098,16 +81108,29 @@ var GetTextSize = function (text, size, lines)
style.syncFont(canvas, context);
// Text Width
var letterSpacing = text.letterSpacing;
for (var i = 0; i < drawnLines; i++)
{
var lineWidth = style.strokeThickness;
lineWidth += context.measureText(lines[i]).width;
if (lines[i].length > 1)
if (letterSpacing === 0)
{
lineWidth += text.letterSpacing * (lines[i].length - 1);
lineWidth += context.measureText(lines[i]).width;
}
else
{
var line = lines[i];
for (var j = 0; j < line.length; j++)
{
lineWidth += context.measureText(line[j]).width;
}
if (line.length > 1)
{
lineWidth += letterSpacing * (line.length - 1);
}
}
// Adjust for wrapped text
@ -118323,7 +118346,7 @@ File.createObjectURL = function (image, blob, defaultType)
/**
* Static method for releasing an existing object URL which was previously created
* by calling {@link File#createObjectURL} method.
* by calling {@link Phaser.Loader.File.createObjectURL} method.
*
* @method Phaser.Loader.File.revokeObjectURL
* @static
@ -155660,6 +155683,12 @@ var CanvasRenderer = new Class({
var gx = sprite.x;
var gy = sprite.y;
if (camera.roundPixels)
{
gx = Math.floor(gx);
gy = Math.floor(gy);
}
spriteMatrix.applyITRS(gx, gy, sprite.rotation, sprite.scaleX * flipX, sprite.scaleY * flipY);
camMatrix.copyFrom(camera.matrix);
@ -155682,10 +155711,10 @@ var CanvasRenderer = new Class({
// Multiply by the Sprite matrix
camMatrix.multiply(spriteMatrix);
if (camera.roundPixels)
if (camera.renderRoundPixels)
{
camMatrix.e = Math.round(camMatrix.e);
camMatrix.f = Math.round(camMatrix.f);
camMatrix.e = Math.floor(camMatrix.e + 0.5);
camMatrix.f = Math.floor(camMatrix.f + 0.5);
}
ctx.save();
@ -155705,26 +155734,24 @@ var CanvasRenderer = new Class({
if (frameWidth > 0 && frameHeight > 0)
{
var fw = frameWidth / res;
var fh = frameHeight / res;
if (camera.roundPixels)
{
ctx.drawImage(
frame.source.image,
frameX, frameY,
frameWidth, frameHeight,
Math.round(x), Math.round(y),
Math.round(frameWidth / res), Math.round(frameHeight / res)
);
}
else
{
ctx.drawImage(
frame.source.image,
frameX, frameY,
frameWidth, frameHeight,
x, y,
frameWidth / res, frameHeight / res
);
x = Math.floor(x + 0.5);
y = Math.floor(y + 0.5);
fw += 0.5;
fh += 0.5;
}
ctx.drawImage(
frame.source.image,
frameX, frameY,
frameWidth, frameHeight,
x, y,
fw, fh
);
}
if (sprite.mask)
@ -158069,7 +158096,7 @@ var RenderTarget = new Class({
*/
this.forceClamp = forceClamp;
this.resize(width, height);
this.init(width, height);
if (autoResize)
{
@ -158082,6 +158109,28 @@ var RenderTarget = new Class({
}
},
/**
* Sets up this Render Target to the given width and height, creating a new
* frame buffer and texture. This method is called automatically by the constructor
* and at no other time.
*
* @method Phaser.Renderer.WebGL.RenderTarget#init
* @since 3.86.0
*
* @param {number} width - The new width of this Render Target.
* @param {number} height - The new height of this Render Target.
*/
init: function (width, height)
{
var renderer = this.renderer;
this.texture = renderer.createTextureFromSource(null, width, height, this.minFilter, this.forceClamp);
this.framebuffer = renderer.createFramebuffer(width, height, this.texture, this.hasDepthBuffer);
this.width = width;
this.height = height;
},
/**
* Sets if this Render Target should automatically resize when the WebGL Renderer
* emits a resize event.
@ -158120,9 +158169,6 @@ var RenderTarget = new Class({
*
* This method is called automatically by the pipeline during its resize handler.
*
* Previous to Phaser v3.85 this method would only run if `autoResize` was `true`,
* it will now run regardless.
*
* @method Phaser.Renderer.WebGL.RenderTarget#resize
* @since 3.50.0
*
@ -158133,7 +158179,7 @@ var RenderTarget = new Class({
*/
resize: function (width, height)
{
if (this.willResize(width, height))
if (this.autoResize && this.willResize(width, height))
{
var renderer = this.renderer;
@ -158165,18 +158211,16 @@ var RenderTarget = new Class({
*/
willResize: function (width, height)
{
if (typeof width !== 'number' || typeof height !== 'number')
{
return false;
}
width = Math.round(width * this.scale);
height = Math.round(height * this.scale);
if (width <= 0)
{
width = 1;
}
if (height <= 0)
{
height = 1;
}
width = Math.max(width, 1);
height = Math.max(height, 1);
return (width !== this.width || height !== this.height);
},
@ -167845,7 +167889,7 @@ var MultiPipeline = new Class({
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(spriteMatrix, calcMatrix);
var quad = calcMatrix.setQuad(x, y, x + frameWidth, y + frameHeight, camera.roundPixels);
var quad = calcMatrix.setQuad(x, y, x + frameWidth, y + frameHeight, camera.renderRoundPixels);
var getTint = Utils.getTintAppendFloatAlpha;
var cameraAlpha = camera.alpha;
@ -168029,7 +168073,7 @@ var MultiPipeline = new Class({
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(spriteMatrix, calcMatrix);
var quad = calcMatrix.setQuad(x, y, x + width, y + height, camera.roundPixels);
var quad = calcMatrix.setQuad(x, y, x + width, y + height, camera.renderRoundPixels);
if (textureUnit === undefined || textureUnit === null)
{
@ -176236,12 +176280,14 @@ var ScaleManager = new Class({
this.fullscreen = game.device.fullscreen;
if ((this.scaleMode !== CONST.SCALE_MODE.RESIZE) && (this.scaleMode !== CONST.SCALE_MODE.EXPAND))
var scaleMode = this.scaleMode;
if (scaleMode !== CONST.SCALE_MODE.RESIZE && scaleMode !== CONST.SCALE_MODE.EXPAND)
{
this.displaySize.setAspectMode(this.scaleMode);
this.displaySize.setAspectMode(scaleMode);
}
if (this.scaleMode === CONST.SCALE_MODE.NONE)
if (scaleMode === CONST.SCALE_MODE.NONE)
{
this.resize(this.width, this.height);
}
@ -176909,18 +176955,16 @@ var ScaleManager = new Class({
style.width = styleWidth + 'px';
style.height = styleHeight + 'px';
// Expand canvas size to fit game size's width or height
var scaleX = this.parentSize.width / baseWidth;
var scaleY = this.parentSize.height / baseHeight;
if (scaleX < scaleY)
if (scaleX < scaleY && scaleX !== 0)
{
this.baseSize.setSize(baseWidth, this.parentSize.height / scaleX);
}
else
else if (scaleY !== 0)
{
this.baseSize.setSize(this.displaySize.width / scaleY, baseHeight);
}
@ -209946,15 +209990,17 @@ var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer)
var x;
var y;
var staggerAxis = layer.staggerAxis;
var staggerIndex = layer.staggerIndex;
if (layer.staggerAxis === 'y')
if (staggerAxis === 'y')
{
x = worldX + (tileWidth * tileX) + tileWidth;
y = worldY + ((1.5 * tileY) * tileHeightHalf) + tileHeightHalf;
if (tileY % 2 === 0)
{
if (this.staggerIndex === 'odd')
if (staggerIndex === 'odd')
{
x -= tileWidthHalf;
}
@ -209964,14 +210010,14 @@ var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer)
}
}
}
else if ((this.staggerAxis === 'x') && (this.staggerIndex === 'odd'))
else if ((staggerAxis === 'x') && (staggerIndex === 'odd'))
{
x = worldX + ((1.5 * tileX) * tileWidthHalf) + tileWidthHalf;
y = worldY + (tileHeight * tileX) + tileHeight;
if (tileX % 2 === 0)
{
if (this.staggerIndex === 'odd')
if (staggerIndex === 'odd')
{
y -= tileHeightHalf;
}
@ -225443,18 +225489,14 @@ var MoveAbove = function (array, item1, item2)
return array;
}
// Remove
// Remove item1 from its current position
array.splice(currentIndex, 1);
// Add in new location
if (baseIndex === array.length - 1)
{
array.push(item1);
}
else
{
array.splice(baseIndex, 0, item1);
}
// Recalculate baseIndex after removal
baseIndex = array.indexOf(item2);
// Insert item1 immediately after item2
array.splice(baseIndex + 1, 0, item1);
return array;
};

File diff suppressed because one or more lines are too long

200
dist/phaser-ie9.js vendored
View file

@ -8863,6 +8863,22 @@ var BaseCamera = new Class({
* @since 3.60.0
*/
this.isSceneCamera = true;
/**
* Can this Camera render rounded pixel values?
*
* This property is updated during the `preRender` method and should not be
* set directly. It is set based on the `roundPixels` property of the Camera
* combined with the zoom level. If the zoom is an integer then the WebGL
* Renderer can apply rounding during rendering.
*
* @name Phaser.Cameras.Scene2D.BaseCamera#renderRoundPixels
* @type {boolean}
* @readonly
* @default true
* @since 3.86.0
*/
this.renderRoundPixels = true;
},
/**
@ -10799,6 +10815,8 @@ var Camera = new Class({
var zoomY = this.zoomY;
var matrix = this.matrix;
this.renderRoundPixels = (this.roundPixels && Number.isInteger(zoomX) && Number.isInteger(zoomY));
var originX = width * this.originX;
var originY = height * this.originY;
@ -10887,7 +10905,8 @@ var Camera = new Class({
Math.floor(this.x + originX + 0.5),
Math.floor(this.y + originY + 0.5),
this.rotation,
zoomX, zoomY);
zoomX, zoomY
);
matrix.translate(-originX, -originY);
@ -15645,7 +15664,7 @@ var CONST = {
* @type {string}
* @since 3.0.0
*/
VERSION: '3.85.2',
VERSION: '3.86.0',
BlendModes: __webpack_require__(10312),
@ -47643,6 +47662,8 @@ var Render = __webpack_require__(29959);
var Union = __webpack_require__(36899);
var Vector2 = __webpack_require__(26099);
var tempTransformMatrix = new Components.TransformMatrix();
/**
* @classdesc
* A Container Game Object.
@ -47787,16 +47808,6 @@ var Container = new Class({
*/
this.localTransform = new Components.TransformMatrix();
/**
* Internal temporary Transform Matrix used to avoid object creation.
*
* @name Phaser.GameObjects.Container#tempTransformMatrix
* @type {Phaser.GameObjects.Components.TransformMatrix}
* @private
* @since 3.4.0
*/
this.tempTransformMatrix = new Components.TransformMatrix();
/**
* The property key to sort by.
*
@ -48131,7 +48142,7 @@ var Container = new Class({
output.y = source.y;
}
var tempMatrix = this.tempTransformMatrix;
var tempMatrix = tempTransformMatrix;
// No need to loadIdentity because applyITRS overwrites every value anyway
tempMatrix.applyITRS(this.x, this.y, this.rotation, this.scaleX, this.scaleY);
@ -48155,7 +48166,7 @@ var Container = new Class({
*/
getBoundsTransformMatrix: function ()
{
return this.getWorldTransformMatrix(this.tempTransformMatrix, this.localTransform);
return this.getWorldTransformMatrix(tempTransformMatrix, this.localTransform);
},
/**
@ -49078,7 +49089,6 @@ var Container = new Class({
this.removeAll(!!this.exclusive);
this.localTransform.destroy();
this.tempTransformMatrix.destroy();
this.list = [];
},
@ -55043,7 +55053,7 @@ var Group = new Class({
},
/**
* {@link Phaser.GameObjects.Components.Animation#play Plays} an animation for all members of this group.
* {@link Phaser.Animations.AnimationState#play Plays} an animation for all members of this group.
*
* @method Phaser.GameObjects.Group#playAnimation
* @since 3.0.0
@ -65546,7 +65556,7 @@ var ParticleEmitter = new Class({
* or any object with a suitable {@link Phaser.Types.GameObjects.Particles.EdgeZoneSourceCallback getPoints} method.
*
* A {@link Phaser.Types.GameObjects.Particles.ParticleEmitterRandomZoneConfig RandomZone} places the particles randomly within its interior.
* Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback getRandomPoint} method.
* Its {@link Phaser.GameObjects.Particles.Zones.RandomZone#source source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback getRandomPoint} method.
*
* An Emission Zone can only exist once within this Emitter.
*
@ -81098,16 +81108,29 @@ var GetTextSize = function (text, size, lines)
style.syncFont(canvas, context);
// Text Width
var letterSpacing = text.letterSpacing;
for (var i = 0; i < drawnLines; i++)
{
var lineWidth = style.strokeThickness;
lineWidth += context.measureText(lines[i]).width;
if (lines[i].length > 1)
if (letterSpacing === 0)
{
lineWidth += text.letterSpacing * (lines[i].length - 1);
lineWidth += context.measureText(lines[i]).width;
}
else
{
var line = lines[i];
for (var j = 0; j < line.length; j++)
{
lineWidth += context.measureText(line[j]).width;
}
if (line.length > 1)
{
lineWidth += letterSpacing * (line.length - 1);
}
}
// Adjust for wrapped text
@ -118323,7 +118346,7 @@ File.createObjectURL = function (image, blob, defaultType)
/**
* Static method for releasing an existing object URL which was previously created
* by calling {@link File#createObjectURL} method.
* by calling {@link Phaser.Loader.File.createObjectURL} method.
*
* @method Phaser.Loader.File.revokeObjectURL
* @static
@ -174206,6 +174229,12 @@ var CanvasRenderer = new Class({
var gx = sprite.x;
var gy = sprite.y;
if (camera.roundPixels)
{
gx = Math.floor(gx);
gy = Math.floor(gy);
}
spriteMatrix.applyITRS(gx, gy, sprite.rotation, sprite.scaleX * flipX, sprite.scaleY * flipY);
camMatrix.copyFrom(camera.matrix);
@ -174228,10 +174257,10 @@ var CanvasRenderer = new Class({
// Multiply by the Sprite matrix
camMatrix.multiply(spriteMatrix);
if (camera.roundPixels)
if (camera.renderRoundPixels)
{
camMatrix.e = Math.round(camMatrix.e);
camMatrix.f = Math.round(camMatrix.f);
camMatrix.e = Math.floor(camMatrix.e + 0.5);
camMatrix.f = Math.floor(camMatrix.f + 0.5);
}
ctx.save();
@ -174251,26 +174280,24 @@ var CanvasRenderer = new Class({
if (frameWidth > 0 && frameHeight > 0)
{
var fw = frameWidth / res;
var fh = frameHeight / res;
if (camera.roundPixels)
{
ctx.drawImage(
frame.source.image,
frameX, frameY,
frameWidth, frameHeight,
Math.round(x), Math.round(y),
Math.round(frameWidth / res), Math.round(frameHeight / res)
);
}
else
{
ctx.drawImage(
frame.source.image,
frameX, frameY,
frameWidth, frameHeight,
x, y,
frameWidth / res, frameHeight / res
);
x = Math.floor(x + 0.5);
y = Math.floor(y + 0.5);
fw += 0.5;
fh += 0.5;
}
ctx.drawImage(
frame.source.image,
frameX, frameY,
frameWidth, frameHeight,
x, y,
fw, fh
);
}
if (sprite.mask)
@ -176615,7 +176642,7 @@ var RenderTarget = new Class({
*/
this.forceClamp = forceClamp;
this.resize(width, height);
this.init(width, height);
if (autoResize)
{
@ -176628,6 +176655,28 @@ var RenderTarget = new Class({
}
},
/**
* Sets up this Render Target to the given width and height, creating a new
* frame buffer and texture. This method is called automatically by the constructor
* and at no other time.
*
* @method Phaser.Renderer.WebGL.RenderTarget#init
* @since 3.86.0
*
* @param {number} width - The new width of this Render Target.
* @param {number} height - The new height of this Render Target.
*/
init: function (width, height)
{
var renderer = this.renderer;
this.texture = renderer.createTextureFromSource(null, width, height, this.minFilter, this.forceClamp);
this.framebuffer = renderer.createFramebuffer(width, height, this.texture, this.hasDepthBuffer);
this.width = width;
this.height = height;
},
/**
* Sets if this Render Target should automatically resize when the WebGL Renderer
* emits a resize event.
@ -176666,9 +176715,6 @@ var RenderTarget = new Class({
*
* This method is called automatically by the pipeline during its resize handler.
*
* Previous to Phaser v3.85 this method would only run if `autoResize` was `true`,
* it will now run regardless.
*
* @method Phaser.Renderer.WebGL.RenderTarget#resize
* @since 3.50.0
*
@ -176679,7 +176725,7 @@ var RenderTarget = new Class({
*/
resize: function (width, height)
{
if (this.willResize(width, height))
if (this.autoResize && this.willResize(width, height))
{
var renderer = this.renderer;
@ -176711,18 +176757,16 @@ var RenderTarget = new Class({
*/
willResize: function (width, height)
{
if (typeof width !== 'number' || typeof height !== 'number')
{
return false;
}
width = Math.round(width * this.scale);
height = Math.round(height * this.scale);
if (width <= 0)
{
width = 1;
}
if (height <= 0)
{
height = 1;
}
width = Math.max(width, 1);
height = Math.max(height, 1);
return (width !== this.width || height !== this.height);
},
@ -186391,7 +186435,7 @@ var MultiPipeline = new Class({
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(spriteMatrix, calcMatrix);
var quad = calcMatrix.setQuad(x, y, x + frameWidth, y + frameHeight, camera.roundPixels);
var quad = calcMatrix.setQuad(x, y, x + frameWidth, y + frameHeight, camera.renderRoundPixels);
var getTint = Utils.getTintAppendFloatAlpha;
var cameraAlpha = camera.alpha;
@ -186575,7 +186619,7 @@ var MultiPipeline = new Class({
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(spriteMatrix, calcMatrix);
var quad = calcMatrix.setQuad(x, y, x + width, y + height, camera.roundPixels);
var quad = calcMatrix.setQuad(x, y, x + width, y + height, camera.renderRoundPixels);
if (textureUnit === undefined || textureUnit === null)
{
@ -194782,12 +194826,14 @@ var ScaleManager = new Class({
this.fullscreen = game.device.fullscreen;
if ((this.scaleMode !== CONST.SCALE_MODE.RESIZE) && (this.scaleMode !== CONST.SCALE_MODE.EXPAND))
var scaleMode = this.scaleMode;
if (scaleMode !== CONST.SCALE_MODE.RESIZE && scaleMode !== CONST.SCALE_MODE.EXPAND)
{
this.displaySize.setAspectMode(this.scaleMode);
this.displaySize.setAspectMode(scaleMode);
}
if (this.scaleMode === CONST.SCALE_MODE.NONE)
if (scaleMode === CONST.SCALE_MODE.NONE)
{
this.resize(this.width, this.height);
}
@ -195455,18 +195501,16 @@ var ScaleManager = new Class({
style.width = styleWidth + 'px';
style.height = styleHeight + 'px';
// Expand canvas size to fit game size's width or height
var scaleX = this.parentSize.width / baseWidth;
var scaleY = this.parentSize.height / baseHeight;
if (scaleX < scaleY)
if (scaleX < scaleY && scaleX !== 0)
{
this.baseSize.setSize(baseWidth, this.parentSize.height / scaleX);
}
else
else if (scaleY !== 0)
{
this.baseSize.setSize(this.displaySize.width / scaleY, baseHeight);
}
@ -228492,15 +228536,17 @@ var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer)
var x;
var y;
var staggerAxis = layer.staggerAxis;
var staggerIndex = layer.staggerIndex;
if (layer.staggerAxis === 'y')
if (staggerAxis === 'y')
{
x = worldX + (tileWidth * tileX) + tileWidth;
y = worldY + ((1.5 * tileY) * tileHeightHalf) + tileHeightHalf;
if (tileY % 2 === 0)
{
if (this.staggerIndex === 'odd')
if (staggerIndex === 'odd')
{
x -= tileWidthHalf;
}
@ -228510,14 +228556,14 @@ var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer)
}
}
}
else if ((this.staggerAxis === 'x') && (this.staggerIndex === 'odd'))
else if ((staggerAxis === 'x') && (staggerIndex === 'odd'))
{
x = worldX + ((1.5 * tileX) * tileWidthHalf) + tileWidthHalf;
y = worldY + (tileHeight * tileX) + tileHeight;
if (tileX % 2 === 0)
{
if (this.staggerIndex === 'odd')
if (staggerIndex === 'odd')
{
y -= tileHeightHalf;
}
@ -243989,18 +244035,14 @@ var MoveAbove = function (array, item1, item2)
return array;
}
// Remove
// Remove item1 from its current position
array.splice(currentIndex, 1);
// Add in new location
if (baseIndex === array.length - 1)
{
array.push(item1);
}
else
{
array.splice(baseIndex, 0, item1);
}
// Recalculate baseIndex after removal
baseIndex = array.indexOf(item2);
// Insert item1 immediately after item2
array.splice(baseIndex + 1, 0, item1);
return array;
};

File diff suppressed because one or more lines are too long

200
dist/phaser.esm.js vendored
View file

@ -8851,6 +8851,22 @@ var BaseCamera = new Class({
* @since 3.60.0
*/
this.isSceneCamera = true;
/**
* Can this Camera render rounded pixel values?
*
* This property is updated during the `preRender` method and should not be
* set directly. It is set based on the `roundPixels` property of the Camera
* combined with the zoom level. If the zoom is an integer then the WebGL
* Renderer can apply rounding during rendering.
*
* @name Phaser.Cameras.Scene2D.BaseCamera#renderRoundPixels
* @type {boolean}
* @readonly
* @default true
* @since 3.86.0
*/
this.renderRoundPixels = true;
},
/**
@ -10787,6 +10803,8 @@ var Camera = new Class({
var zoomY = this.zoomY;
var matrix = this.matrix;
this.renderRoundPixels = (this.roundPixels && Number.isInteger(zoomX) && Number.isInteger(zoomY));
var originX = width * this.originX;
var originY = height * this.originY;
@ -10875,7 +10893,8 @@ var Camera = new Class({
Math.floor(this.x + originX + 0.5),
Math.floor(this.y + originY + 0.5),
this.rotation,
zoomX, zoomY);
zoomX, zoomY
);
matrix.translate(-originX, -originY);
@ -15633,7 +15652,7 @@ var CONST = {
* @type {string}
* @since 3.0.0
*/
VERSION: '3.85.2',
VERSION: '3.86.0',
BlendModes: __webpack_require__(10312),
@ -47631,6 +47650,8 @@ var Render = __webpack_require__(29959);
var Union = __webpack_require__(36899);
var Vector2 = __webpack_require__(26099);
var tempTransformMatrix = new Components.TransformMatrix();
/**
* @classdesc
* A Container Game Object.
@ -47775,16 +47796,6 @@ var Container = new Class({
*/
this.localTransform = new Components.TransformMatrix();
/**
* Internal temporary Transform Matrix used to avoid object creation.
*
* @name Phaser.GameObjects.Container#tempTransformMatrix
* @type {Phaser.GameObjects.Components.TransformMatrix}
* @private
* @since 3.4.0
*/
this.tempTransformMatrix = new Components.TransformMatrix();
/**
* The property key to sort by.
*
@ -48119,7 +48130,7 @@ var Container = new Class({
output.y = source.y;
}
var tempMatrix = this.tempTransformMatrix;
var tempMatrix = tempTransformMatrix;
// No need to loadIdentity because applyITRS overwrites every value anyway
tempMatrix.applyITRS(this.x, this.y, this.rotation, this.scaleX, this.scaleY);
@ -48143,7 +48154,7 @@ var Container = new Class({
*/
getBoundsTransformMatrix: function ()
{
return this.getWorldTransformMatrix(this.tempTransformMatrix, this.localTransform);
return this.getWorldTransformMatrix(tempTransformMatrix, this.localTransform);
},
/**
@ -49066,7 +49077,6 @@ var Container = new Class({
this.removeAll(!!this.exclusive);
this.localTransform.destroy();
this.tempTransformMatrix.destroy();
this.list = [];
},
@ -55031,7 +55041,7 @@ var Group = new Class({
},
/**
* {@link Phaser.GameObjects.Components.Animation#play Plays} an animation for all members of this group.
* {@link Phaser.Animations.AnimationState#play Plays} an animation for all members of this group.
*
* @method Phaser.GameObjects.Group#playAnimation
* @since 3.0.0
@ -65534,7 +65544,7 @@ var ParticleEmitter = new Class({
* or any object with a suitable {@link Phaser.Types.GameObjects.Particles.EdgeZoneSourceCallback getPoints} method.
*
* A {@link Phaser.Types.GameObjects.Particles.ParticleEmitterRandomZoneConfig RandomZone} places the particles randomly within its interior.
* Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback getRandomPoint} method.
* Its {@link Phaser.GameObjects.Particles.Zones.RandomZone#source source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback getRandomPoint} method.
*
* An Emission Zone can only exist once within this Emitter.
*
@ -81086,16 +81096,29 @@ var GetTextSize = function (text, size, lines)
style.syncFont(canvas, context);
// Text Width
var letterSpacing = text.letterSpacing;
for (var i = 0; i < drawnLines; i++)
{
var lineWidth = style.strokeThickness;
lineWidth += context.measureText(lines[i]).width;
if (lines[i].length > 1)
if (letterSpacing === 0)
{
lineWidth += text.letterSpacing * (lines[i].length - 1);
lineWidth += context.measureText(lines[i]).width;
}
else
{
var line = lines[i];
for (var j = 0; j < line.length; j++)
{
lineWidth += context.measureText(line[j]).width;
}
if (line.length > 1)
{
lineWidth += letterSpacing * (line.length - 1);
}
}
// Adjust for wrapped text
@ -118310,7 +118333,7 @@ File.createObjectURL = function (image, blob, defaultType)
/**
* Static method for releasing an existing object URL which was previously created
* by calling {@link File#createObjectURL} method.
* by calling {@link Phaser.Loader.File.createObjectURL} method.
*
* @method Phaser.Loader.File.revokeObjectURL
* @static
@ -173656,6 +173679,12 @@ var CanvasRenderer = new Class({
var gx = sprite.x;
var gy = sprite.y;
if (camera.roundPixels)
{
gx = Math.floor(gx);
gy = Math.floor(gy);
}
spriteMatrix.applyITRS(gx, gy, sprite.rotation, sprite.scaleX * flipX, sprite.scaleY * flipY);
camMatrix.copyFrom(camera.matrix);
@ -173678,10 +173707,10 @@ var CanvasRenderer = new Class({
// Multiply by the Sprite matrix
camMatrix.multiply(spriteMatrix);
if (camera.roundPixels)
if (camera.renderRoundPixels)
{
camMatrix.e = Math.round(camMatrix.e);
camMatrix.f = Math.round(camMatrix.f);
camMatrix.e = Math.floor(camMatrix.e + 0.5);
camMatrix.f = Math.floor(camMatrix.f + 0.5);
}
ctx.save();
@ -173701,26 +173730,24 @@ var CanvasRenderer = new Class({
if (frameWidth > 0 && frameHeight > 0)
{
var fw = frameWidth / res;
var fh = frameHeight / res;
if (camera.roundPixels)
{
ctx.drawImage(
frame.source.image,
frameX, frameY,
frameWidth, frameHeight,
Math.round(x), Math.round(y),
Math.round(frameWidth / res), Math.round(frameHeight / res)
);
}
else
{
ctx.drawImage(
frame.source.image,
frameX, frameY,
frameWidth, frameHeight,
x, y,
frameWidth / res, frameHeight / res
);
x = Math.floor(x + 0.5);
y = Math.floor(y + 0.5);
fw += 0.5;
fh += 0.5;
}
ctx.drawImage(
frame.source.image,
frameX, frameY,
frameWidth, frameHeight,
x, y,
fw, fh
);
}
if (sprite.mask)
@ -176065,7 +176092,7 @@ var RenderTarget = new Class({
*/
this.forceClamp = forceClamp;
this.resize(width, height);
this.init(width, height);
if (autoResize)
{
@ -176078,6 +176105,28 @@ var RenderTarget = new Class({
}
},
/**
* Sets up this Render Target to the given width and height, creating a new
* frame buffer and texture. This method is called automatically by the constructor
* and at no other time.
*
* @method Phaser.Renderer.WebGL.RenderTarget#init
* @since 3.86.0
*
* @param {number} width - The new width of this Render Target.
* @param {number} height - The new height of this Render Target.
*/
init: function (width, height)
{
var renderer = this.renderer;
this.texture = renderer.createTextureFromSource(null, width, height, this.minFilter, this.forceClamp);
this.framebuffer = renderer.createFramebuffer(width, height, this.texture, this.hasDepthBuffer);
this.width = width;
this.height = height;
},
/**
* Sets if this Render Target should automatically resize when the WebGL Renderer
* emits a resize event.
@ -176116,9 +176165,6 @@ var RenderTarget = new Class({
*
* This method is called automatically by the pipeline during its resize handler.
*
* Previous to Phaser v3.85 this method would only run if `autoResize` was `true`,
* it will now run regardless.
*
* @method Phaser.Renderer.WebGL.RenderTarget#resize
* @since 3.50.0
*
@ -176129,7 +176175,7 @@ var RenderTarget = new Class({
*/
resize: function (width, height)
{
if (this.willResize(width, height))
if (this.autoResize && this.willResize(width, height))
{
var renderer = this.renderer;
@ -176161,18 +176207,16 @@ var RenderTarget = new Class({
*/
willResize: function (width, height)
{
if (typeof width !== 'number' || typeof height !== 'number')
{
return false;
}
width = Math.round(width * this.scale);
height = Math.round(height * this.scale);
if (width <= 0)
{
width = 1;
}
if (height <= 0)
{
height = 1;
}
width = Math.max(width, 1);
height = Math.max(height, 1);
return (width !== this.width || height !== this.height);
},
@ -185841,7 +185885,7 @@ var MultiPipeline = new Class({
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(spriteMatrix, calcMatrix);
var quad = calcMatrix.setQuad(x, y, x + frameWidth, y + frameHeight, camera.roundPixels);
var quad = calcMatrix.setQuad(x, y, x + frameWidth, y + frameHeight, camera.renderRoundPixels);
var getTint = Utils.getTintAppendFloatAlpha;
var cameraAlpha = camera.alpha;
@ -186025,7 +186069,7 @@ var MultiPipeline = new Class({
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(spriteMatrix, calcMatrix);
var quad = calcMatrix.setQuad(x, y, x + width, y + height, camera.roundPixels);
var quad = calcMatrix.setQuad(x, y, x + width, y + height, camera.renderRoundPixels);
if (textureUnit === undefined || textureUnit === null)
{
@ -194232,12 +194276,14 @@ var ScaleManager = new Class({
this.fullscreen = game.device.fullscreen;
if ((this.scaleMode !== CONST.SCALE_MODE.RESIZE) && (this.scaleMode !== CONST.SCALE_MODE.EXPAND))
var scaleMode = this.scaleMode;
if (scaleMode !== CONST.SCALE_MODE.RESIZE && scaleMode !== CONST.SCALE_MODE.EXPAND)
{
this.displaySize.setAspectMode(this.scaleMode);
this.displaySize.setAspectMode(scaleMode);
}
if (this.scaleMode === CONST.SCALE_MODE.NONE)
if (scaleMode === CONST.SCALE_MODE.NONE)
{
this.resize(this.width, this.height);
}
@ -194905,18 +194951,16 @@ var ScaleManager = new Class({
style.width = styleWidth + 'px';
style.height = styleHeight + 'px';
// Expand canvas size to fit game size's width or height
var scaleX = this.parentSize.width / baseWidth;
var scaleY = this.parentSize.height / baseHeight;
if (scaleX < scaleY)
if (scaleX < scaleY && scaleX !== 0)
{
this.baseSize.setSize(baseWidth, this.parentSize.height / scaleX);
}
else
else if (scaleY !== 0)
{
this.baseSize.setSize(this.displaySize.width / scaleY, baseHeight);
}
@ -227942,15 +227986,17 @@ var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer)
var x;
var y;
var staggerAxis = layer.staggerAxis;
var staggerIndex = layer.staggerIndex;
if (layer.staggerAxis === 'y')
if (staggerAxis === 'y')
{
x = worldX + (tileWidth * tileX) + tileWidth;
y = worldY + ((1.5 * tileY) * tileHeightHalf) + tileHeightHalf;
if (tileY % 2 === 0)
{
if (this.staggerIndex === 'odd')
if (staggerIndex === 'odd')
{
x -= tileWidthHalf;
}
@ -227960,14 +228006,14 @@ var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer)
}
}
}
else if ((this.staggerAxis === 'x') && (this.staggerIndex === 'odd'))
else if ((staggerAxis === 'x') && (staggerIndex === 'odd'))
{
x = worldX + ((1.5 * tileX) * tileWidthHalf) + tileWidthHalf;
y = worldY + (tileHeight * tileX) + tileHeight;
if (tileX % 2 === 0)
{
if (this.staggerIndex === 'odd')
if (staggerIndex === 'odd')
{
y -= tileHeightHalf;
}
@ -243439,18 +243485,14 @@ var MoveAbove = function (array, item1, item2)
return array;
}
// Remove
// Remove item1 from its current position
array.splice(currentIndex, 1);
// Add in new location
if (baseIndex === array.length - 1)
{
array.push(item1);
}
else
{
array.splice(baseIndex, 0, item1);
}
// Recalculate baseIndex after removal
baseIndex = array.indexOf(item2);
// Insert item1 immediately after item2
array.splice(baseIndex + 1, 0, item1);
return array;
};

File diff suppressed because one or more lines are too long

200
dist/phaser.js vendored
View file

@ -8863,6 +8863,22 @@ var BaseCamera = new Class({
* @since 3.60.0
*/
this.isSceneCamera = true;
/**
* Can this Camera render rounded pixel values?
*
* This property is updated during the `preRender` method and should not be
* set directly. It is set based on the `roundPixels` property of the Camera
* combined with the zoom level. If the zoom is an integer then the WebGL
* Renderer can apply rounding during rendering.
*
* @name Phaser.Cameras.Scene2D.BaseCamera#renderRoundPixels
* @type {boolean}
* @readonly
* @default true
* @since 3.86.0
*/
this.renderRoundPixels = true;
},
/**
@ -10799,6 +10815,8 @@ var Camera = new Class({
var zoomY = this.zoomY;
var matrix = this.matrix;
this.renderRoundPixels = (this.roundPixels && Number.isInteger(zoomX) && Number.isInteger(zoomY));
var originX = width * this.originX;
var originY = height * this.originY;
@ -10887,7 +10905,8 @@ var Camera = new Class({
Math.floor(this.x + originX + 0.5),
Math.floor(this.y + originY + 0.5),
this.rotation,
zoomX, zoomY);
zoomX, zoomY
);
matrix.translate(-originX, -originY);
@ -15645,7 +15664,7 @@ var CONST = {
* @type {string}
* @since 3.0.0
*/
VERSION: '3.85.2',
VERSION: '3.86.0',
BlendModes: __webpack_require__(10312),
@ -47643,6 +47662,8 @@ var Render = __webpack_require__(29959);
var Union = __webpack_require__(36899);
var Vector2 = __webpack_require__(26099);
var tempTransformMatrix = new Components.TransformMatrix();
/**
* @classdesc
* A Container Game Object.
@ -47787,16 +47808,6 @@ var Container = new Class({
*/
this.localTransform = new Components.TransformMatrix();
/**
* Internal temporary Transform Matrix used to avoid object creation.
*
* @name Phaser.GameObjects.Container#tempTransformMatrix
* @type {Phaser.GameObjects.Components.TransformMatrix}
* @private
* @since 3.4.0
*/
this.tempTransformMatrix = new Components.TransformMatrix();
/**
* The property key to sort by.
*
@ -48131,7 +48142,7 @@ var Container = new Class({
output.y = source.y;
}
var tempMatrix = this.tempTransformMatrix;
var tempMatrix = tempTransformMatrix;
// No need to loadIdentity because applyITRS overwrites every value anyway
tempMatrix.applyITRS(this.x, this.y, this.rotation, this.scaleX, this.scaleY);
@ -48155,7 +48166,7 @@ var Container = new Class({
*/
getBoundsTransformMatrix: function ()
{
return this.getWorldTransformMatrix(this.tempTransformMatrix, this.localTransform);
return this.getWorldTransformMatrix(tempTransformMatrix, this.localTransform);
},
/**
@ -49078,7 +49089,6 @@ var Container = new Class({
this.removeAll(!!this.exclusive);
this.localTransform.destroy();
this.tempTransformMatrix.destroy();
this.list = [];
},
@ -55043,7 +55053,7 @@ var Group = new Class({
},
/**
* {@link Phaser.GameObjects.Components.Animation#play Plays} an animation for all members of this group.
* {@link Phaser.Animations.AnimationState#play Plays} an animation for all members of this group.
*
* @method Phaser.GameObjects.Group#playAnimation
* @since 3.0.0
@ -65546,7 +65556,7 @@ var ParticleEmitter = new Class({
* or any object with a suitable {@link Phaser.Types.GameObjects.Particles.EdgeZoneSourceCallback getPoints} method.
*
* A {@link Phaser.Types.GameObjects.Particles.ParticleEmitterRandomZoneConfig RandomZone} places the particles randomly within its interior.
* Its {@link RandomZoneSource source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback getRandomPoint} method.
* Its {@link Phaser.GameObjects.Particles.Zones.RandomZone#source source} can be a Circle, Ellipse, Line, Polygon, Rectangle, or Triangle; or any object with a suitable {@link Phaser.Types.GameObjects.Particles.RandomZoneSourceCallback getRandomPoint} method.
*
* An Emission Zone can only exist once within this Emitter.
*
@ -81098,16 +81108,29 @@ var GetTextSize = function (text, size, lines)
style.syncFont(canvas, context);
// Text Width
var letterSpacing = text.letterSpacing;
for (var i = 0; i < drawnLines; i++)
{
var lineWidth = style.strokeThickness;
lineWidth += context.measureText(lines[i]).width;
if (lines[i].length > 1)
if (letterSpacing === 0)
{
lineWidth += text.letterSpacing * (lines[i].length - 1);
lineWidth += context.measureText(lines[i]).width;
}
else
{
var line = lines[i];
for (var j = 0; j < line.length; j++)
{
lineWidth += context.measureText(line[j]).width;
}
if (line.length > 1)
{
lineWidth += letterSpacing * (line.length - 1);
}
}
// Adjust for wrapped text
@ -118323,7 +118346,7 @@ File.createObjectURL = function (image, blob, defaultType)
/**
* Static method for releasing an existing object URL which was previously created
* by calling {@link File#createObjectURL} method.
* by calling {@link Phaser.Loader.File.createObjectURL} method.
*
* @method Phaser.Loader.File.revokeObjectURL
* @static
@ -173764,6 +173787,12 @@ var CanvasRenderer = new Class({
var gx = sprite.x;
var gy = sprite.y;
if (camera.roundPixels)
{
gx = Math.floor(gx);
gy = Math.floor(gy);
}
spriteMatrix.applyITRS(gx, gy, sprite.rotation, sprite.scaleX * flipX, sprite.scaleY * flipY);
camMatrix.copyFrom(camera.matrix);
@ -173786,10 +173815,10 @@ var CanvasRenderer = new Class({
// Multiply by the Sprite matrix
camMatrix.multiply(spriteMatrix);
if (camera.roundPixels)
if (camera.renderRoundPixels)
{
camMatrix.e = Math.round(camMatrix.e);
camMatrix.f = Math.round(camMatrix.f);
camMatrix.e = Math.floor(camMatrix.e + 0.5);
camMatrix.f = Math.floor(camMatrix.f + 0.5);
}
ctx.save();
@ -173809,26 +173838,24 @@ var CanvasRenderer = new Class({
if (frameWidth > 0 && frameHeight > 0)
{
var fw = frameWidth / res;
var fh = frameHeight / res;
if (camera.roundPixels)
{
ctx.drawImage(
frame.source.image,
frameX, frameY,
frameWidth, frameHeight,
Math.round(x), Math.round(y),
Math.round(frameWidth / res), Math.round(frameHeight / res)
);
}
else
{
ctx.drawImage(
frame.source.image,
frameX, frameY,
frameWidth, frameHeight,
x, y,
frameWidth / res, frameHeight / res
);
x = Math.floor(x + 0.5);
y = Math.floor(y + 0.5);
fw += 0.5;
fh += 0.5;
}
ctx.drawImage(
frame.source.image,
frameX, frameY,
frameWidth, frameHeight,
x, y,
fw, fh
);
}
if (sprite.mask)
@ -176173,7 +176200,7 @@ var RenderTarget = new Class({
*/
this.forceClamp = forceClamp;
this.resize(width, height);
this.init(width, height);
if (autoResize)
{
@ -176186,6 +176213,28 @@ var RenderTarget = new Class({
}
},
/**
* Sets up this Render Target to the given width and height, creating a new
* frame buffer and texture. This method is called automatically by the constructor
* and at no other time.
*
* @method Phaser.Renderer.WebGL.RenderTarget#init
* @since 3.86.0
*
* @param {number} width - The new width of this Render Target.
* @param {number} height - The new height of this Render Target.
*/
init: function (width, height)
{
var renderer = this.renderer;
this.texture = renderer.createTextureFromSource(null, width, height, this.minFilter, this.forceClamp);
this.framebuffer = renderer.createFramebuffer(width, height, this.texture, this.hasDepthBuffer);
this.width = width;
this.height = height;
},
/**
* Sets if this Render Target should automatically resize when the WebGL Renderer
* emits a resize event.
@ -176224,9 +176273,6 @@ var RenderTarget = new Class({
*
* This method is called automatically by the pipeline during its resize handler.
*
* Previous to Phaser v3.85 this method would only run if `autoResize` was `true`,
* it will now run regardless.
*
* @method Phaser.Renderer.WebGL.RenderTarget#resize
* @since 3.50.0
*
@ -176237,7 +176283,7 @@ var RenderTarget = new Class({
*/
resize: function (width, height)
{
if (this.willResize(width, height))
if (this.autoResize && this.willResize(width, height))
{
var renderer = this.renderer;
@ -176269,18 +176315,16 @@ var RenderTarget = new Class({
*/
willResize: function (width, height)
{
if (typeof width !== 'number' || typeof height !== 'number')
{
return false;
}
width = Math.round(width * this.scale);
height = Math.round(height * this.scale);
if (width <= 0)
{
width = 1;
}
if (height <= 0)
{
height = 1;
}
width = Math.max(width, 1);
height = Math.max(height, 1);
return (width !== this.width || height !== this.height);
},
@ -185949,7 +185993,7 @@ var MultiPipeline = new Class({
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(spriteMatrix, calcMatrix);
var quad = calcMatrix.setQuad(x, y, x + frameWidth, y + frameHeight, camera.roundPixels);
var quad = calcMatrix.setQuad(x, y, x + frameWidth, y + frameHeight, camera.renderRoundPixels);
var getTint = Utils.getTintAppendFloatAlpha;
var cameraAlpha = camera.alpha;
@ -186133,7 +186177,7 @@ var MultiPipeline = new Class({
// Multiply by the Sprite matrix, store result in calcMatrix
camMatrix.multiply(spriteMatrix, calcMatrix);
var quad = calcMatrix.setQuad(x, y, x + width, y + height, camera.roundPixels);
var quad = calcMatrix.setQuad(x, y, x + width, y + height, camera.renderRoundPixels);
if (textureUnit === undefined || textureUnit === null)
{
@ -194340,12 +194384,14 @@ var ScaleManager = new Class({
this.fullscreen = game.device.fullscreen;
if ((this.scaleMode !== CONST.SCALE_MODE.RESIZE) && (this.scaleMode !== CONST.SCALE_MODE.EXPAND))
var scaleMode = this.scaleMode;
if (scaleMode !== CONST.SCALE_MODE.RESIZE && scaleMode !== CONST.SCALE_MODE.EXPAND)
{
this.displaySize.setAspectMode(this.scaleMode);
this.displaySize.setAspectMode(scaleMode);
}
if (this.scaleMode === CONST.SCALE_MODE.NONE)
if (scaleMode === CONST.SCALE_MODE.NONE)
{
this.resize(this.width, this.height);
}
@ -195013,18 +195059,16 @@ var ScaleManager = new Class({
style.width = styleWidth + 'px';
style.height = styleHeight + 'px';
// Expand canvas size to fit game size's width or height
var scaleX = this.parentSize.width / baseWidth;
var scaleY = this.parentSize.height / baseHeight;
if (scaleX < scaleY)
if (scaleX < scaleY && scaleX !== 0)
{
this.baseSize.setSize(baseWidth, this.parentSize.height / scaleX);
}
else
else if (scaleY !== 0)
{
this.baseSize.setSize(this.displaySize.width / scaleY, baseHeight);
}
@ -228050,15 +228094,17 @@ var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer)
var x;
var y;
var staggerAxis = layer.staggerAxis;
var staggerIndex = layer.staggerIndex;
if (layer.staggerAxis === 'y')
if (staggerAxis === 'y')
{
x = worldX + (tileWidth * tileX) + tileWidth;
y = worldY + ((1.5 * tileY) * tileHeightHalf) + tileHeightHalf;
if (tileY % 2 === 0)
{
if (this.staggerIndex === 'odd')
if (staggerIndex === 'odd')
{
x -= tileWidthHalf;
}
@ -228068,14 +228114,14 @@ var HexagonalTileToWorldXY = function (tileX, tileY, point, camera, layer)
}
}
}
else if ((this.staggerAxis === 'x') && (this.staggerIndex === 'odd'))
else if ((staggerAxis === 'x') && (staggerIndex === 'odd'))
{
x = worldX + ((1.5 * tileX) * tileWidthHalf) + tileWidthHalf;
y = worldY + (tileHeight * tileX) + tileHeight;
if (tileX % 2 === 0)
{
if (this.staggerIndex === 'odd')
if (staggerIndex === 'odd')
{
y -= tileHeightHalf;
}
@ -243547,18 +243593,14 @@ var MoveAbove = function (array, item1, item2)
return array;
}
// Remove
// Remove item1 from its current position
array.splice(currentIndex, 1);
// Add in new location
if (baseIndex === array.length - 1)
{
array.push(item1);
}
else
{
array.splice(baseIndex, 0, item1);
}
// Recalculate baseIndex after removal
baseIndex = array.indexOf(item2);
// Insert item1 immediately after item2
array.splice(baseIndex + 1, 0, item1);
return array;
};

2
dist/phaser.min.js vendored

File diff suppressed because one or more lines are too long

33482
types/phaser.d.ts vendored

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long