mirror of
https://github.com/wassname/phaser.git
synced 2026-07-25 13:20:14 +08:00
Stage.smoothed allows you to set if sprites will be smoothed when rendered. Set to false if you're using pixel art in your game. Default is true. Works in Canvas and WebGL. Setting the game anti-aliased parameter now works properly too.
Sprite.smoothed and Image.smoothed allows you to set per-Sprite smoothing, perfect if you just want to keep a few sprites smoothed (or not). Fixes #381.
This commit is contained in:
@@ -698,3 +698,37 @@ Object.defineProperty(Phaser.Image.prototype, "fixedToCamera", {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Enable or disable texture smoothing for this Image. Only works for bitmap/image textures. Smoothing is enabled by default.
|
||||
*
|
||||
* @name Phaser.Image#smoothed
|
||||
* @property {boolean} smoothed - Set to true to smooth the texture of this Image, or false to disable smoothing (great for pixel art)
|
||||
*/
|
||||
Object.defineProperty(Phaser.Image.prototype, "smoothed", {
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this.texture.baseTexture.scaleMode;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
if (value)
|
||||
{
|
||||
if (this.texture)
|
||||
{
|
||||
this.texture.baseTexture.scaleMode = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.texture)
|
||||
{
|
||||
this.texture.baseTexture.scaleMode = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -951,3 +951,37 @@ Object.defineProperty(Phaser.Sprite.prototype, "fixedToCamera", {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Enable or disable texture smoothing for this Sprite. Only works for bitmap/image textures. Smoothing is enabled by default.
|
||||
*
|
||||
* @name Phaser.Sprite#smoothed
|
||||
* @property {boolean} smoothed - Set to true to smooth the texture of this Sprite, or false to disable smoothing (great for pixel art)
|
||||
*/
|
||||
Object.defineProperty(Phaser.Sprite.prototype, "smoothed", {
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this.texture.baseTexture.scaleMode;
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
if (value)
|
||||
{
|
||||
if (this.texture)
|
||||
{
|
||||
this.texture.baseTexture.scaleMode = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.texture)
|
||||
{
|
||||
this.texture.baseTexture.scaleMode = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user