Skip to content

Commit 8c31209

Browse files
committed
Solidified use of pixelArt mode
1 parent 7a23378 commit 8c31209

8 files changed

Lines changed: 25 additions & 23 deletions

File tree

src/boot/Config.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -324,24 +324,30 @@ var Config = new Class({
324324
var renderConfig = GetValue(config, 'render', config);
325325

326326
/**
327-
* @const {boolean} Phaser.Boot.Config#antialias - [description]
327+
* @const {boolean} Phaser.Boot.Config#autoResize - [description]
328328
*/
329-
this.antialias = GetValue(renderConfig, 'antialias', true);
329+
this.autoResize = GetValue(renderConfig, 'autoResize', false);
330330

331331
/**
332-
* @const {boolean} Phaser.Boot.Config#pixelArt - [description]
332+
* @const {boolean} Phaser.Boot.Config#antialias - [description]
333333
*/
334-
this.pixelArt = GetValue(renderConfig, 'pixelArt', false);
334+
this.antialias = GetValue(renderConfig, 'antialias', true);
335335

336336
/**
337-
* @const {boolean} Phaser.Boot.Config#autoResize - [description]
337+
* @const {boolean} Phaser.Boot.Config#roundPixels - [description]
338338
*/
339-
this.autoResize = GetValue(renderConfig, 'autoResize', false);
339+
this.roundPixels = GetValue(renderConfig, 'roundPixels', false);
340340

341341
/**
342-
* @const {boolean} Phaser.Boot.Config#roundPixels - [description]
342+
* @const {boolean} Phaser.Boot.Config#pixelArt - [description]
343343
*/
344-
this.roundPixels = GetValue(renderConfig, 'roundPixels', this.pixelArt);
344+
this.pixelArt = GetValue(renderConfig, 'pixelArt', false);
345+
346+
if (this.pixelArt)
347+
{
348+
this.antialias = false;
349+
this.roundPixels = true;
350+
}
345351

346352
/**
347353
* @const {boolean} Phaser.Boot.Config#transparent - [description]

src/boot/CreateRenderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var CreateRenderer = function (game)
4848
}
4949

5050
// Pixel Art mode?
51-
if (config.pixelArt || !config.antialias)
51+
if (!config.antialias)
5252
{
5353
CanvasPool.disableSmoothing();
5454
}
@@ -70,7 +70,7 @@ var CreateRenderer = function (game)
7070
}
7171

7272
// Pixel Art mode?
73-
if (config.pixelArt || !config.antialias)
73+
if (!config.antialias)
7474
{
7575
CanvasInterpolation.setCrisp(game.canvas);
7676
}

src/cameras/2d/CameraManager.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,8 @@ var CameraManager = new Class({
209209
* By default Cameras are transparent and will render anything that they can see based on their `scrollX`
210210
* and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method.
211211
*
212-
* Please note that it will have its `roundPixels` propery set to whatever is set on the game and renderer
213-
* configuration. So if you've got a game config with `pixelArt: true` in it, then `roundPixels` will always
214-
* be set to `true` on the new Camera.
212+
* The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change
213+
* it after creation if required.
215214
*
216215
* See the Camera class documentation for more details.
217216
*
@@ -259,9 +258,8 @@ var CameraManager = new Class({
259258
*
260259
* The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it.
261260
*
262-
* Please note that it will have its `roundPixels` propery set to whatever is set on the game and renderer
263-
* configuration. So if you've got a game config with `pixelArt: true` in it, then `roundPixels` will always
264-
* be set to `true` on the Camera added to this Camera Manager.
261+
* The Camera will have its `roundPixels` propery set to whatever `CameraManager.roundPixels` is. You can change
262+
* it after addition if required.
265263
*
266264
* The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the
267265
* manager. As long as it doesn't already exist in the manager it will be added then returned.

src/renderer/canvas/CanvasRenderer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ var CanvasRenderer = new Class({
8686
*/
8787
this.config = {
8888
clearBeforeRender: game.config.clearBeforeRender,
89-
pixelArt: game.config.pixelArt,
9089
backgroundColor: game.config.backgroundColor,
9190
resolution: game.config.resolution,
9291
autoResize: game.config.autoResize,
@@ -101,7 +100,7 @@ var CanvasRenderer = new Class({
101100
* @type {integer}
102101
* @since 3.0.0
103102
*/
104-
this.scaleMode = (game.config.pixelArt || !game.config.antialias) ? ScaleModes.NEAREST : ScaleModes.LINEAR;
103+
this.scaleMode = (game.config.antialias) ? ScaleModes.LINEAR : ScaleModes.NEAREST;
105104

106105
/**
107106
* [description]

src/renderer/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @typedef {object} RendererConfig
99
*
1010
* @property {boolean} clearBeforeRender - [description]
11-
* @property {boolean} pixelArt - [description]
11+
* @property {boolean} antialias - [description]
1212
* @property {Phaser.Display.Color} backgroundColor - [description]
1313
* @property {number} resolution - [description]
1414
* @property {boolean} autoResize - [description]

src/renderer/webgl/WebGLRenderer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ var WebGLRenderer = new Class({
8080
*/
8181
this.config = {
8282
clearBeforeRender: gameConfig.clearBeforeRender,
83-
pixelArt: gameConfig.pixelArt,
8483
antialias: gameConfig.antialias,
8584
backgroundColor: gameConfig.backgroundColor,
8685
contextCreation: contextCreationConfig,
@@ -1125,7 +1124,7 @@ var WebGLRenderer = new Class({
11251124
{
11261125
filter = gl.LINEAR;
11271126
}
1128-
else if (scaleMode === CONST.ScaleModes.NEAREST || this.config.pixelArt || !this.config.antialias)
1127+
else if (scaleMode === CONST.ScaleModes.NEAREST || !this.config.antialias)
11291128
{
11301129
filter = gl.NEAREST;
11311130
}

src/renderer/webgl/pipelines/TextureTintPipeline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2080,7 +2080,7 @@ var TextureTintPipeline = new Class({
20802080
this.flush();
20812081
}
20822082

2083-
var roundPixels = camera.roundPixels;
2083+
var roundPixels = this.renderer.config.roundPixels;
20842084
var vertexViewF32 = this.vertexViewF32;
20852085
var vertexViewU32 = this.vertexViewU32;
20862086
var width = frameWidth;

src/textures/TextureSource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ var TextureSource = new Class({
164164
}
165165
}
166166

167-
if (game.config.pixelArt || !game.config.antialias)
167+
if (!game.config.antialias)
168168
{
169169
this.setFilter(1);
170170
}

0 commit comments

Comments
 (0)