BitmapText.smoothed is a new boolean property that allows you to set texture smoothing on a bitmap font or not. By default smoothing is always on, but you can turn it off which helps for bitmap fonts created from pixel art style character sets.

This commit is contained in:
photonstorm 2015-07-31 15:56:44 +01:00
parent 159f49d5bf
commit d23e5d6eba
4 changed files with 36 additions and 3 deletions

View file

@ -252,6 +252,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
* Loader.images is a new method that allows you to pass an array of image keys, and optionally the urls, to the Loader and have them all added to the load queue in one go.
* Tween.frameBased allows you to control if a Tween updates based on the physics step (i.e. frame based) or the system clock (time based). A frame based tween will use the physics elapsed timer when updating. This means it will retain the same consistent frame rate, regardless of the speed of the device. The duration value given should be given in frames. If the Tween uses a time based update (which is the default) then the duration is given in milliseconds. In this situation a 2000ms tween will last exactly 2 seconds, regardless of the device and how many visual updates the tween has actually been through.
* BitmapText.smoothed is a new boolean property that allows you to set texture smoothing on a bitmap font or not. By default smoothing is always on, but you can turn it off which helps for bitmap fonts created from pixel art style character sets.
### Updates

View file

@ -375,8 +375,6 @@ Phaser.BitmapText.prototype.updateText = function () {
{
// Sprite already exists in the glyphs pool, so we'll reuse it for this letter
g.texture = charData.texture;
// g.name = line.text[c];
// console.log('reusing', g.name, 'as', line.text[c]);
}
else
{
@ -384,7 +382,6 @@ Phaser.BitmapText.prototype.updateText = function () {
g = new PIXI.Sprite(charData.texture);
g.name = line.text[c];
this._glyphs.push(g);
// console.log('new', line.text[c]);
}
g.position.x = (line.chars[c] + align) - ax;
@ -613,3 +610,36 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'maxWidth', {
}
});
/**
* Enable or disable texture smoothing for this BitmapText.
*
* The smoothing is applied to the BaseTexture of this font, which all letters of the text reference.
*
* Smoothing is enabled by default.
*
* @name Phaser.BitmapText#smoothed
* @property {boolean} smoothed
*/
Object.defineProperty(Phaser.BitmapText.prototype, 'smoothed', {
get: function() {
return !this._data.base.scaleMode;
},
set: function(value) {
if (value)
{
this._data.base.scaleMode = 0;
}
else
{
this._data.base.scaleMode = 1;
}
}
});

View file

@ -1293,6 +1293,7 @@ Phaser.Loader.prototype = {
* @return {Phaser.Loader} This Loader instance.
*/
bitmapFont: function (key, textureURL, atlasURL, atlasData, xSpacing, ySpacing) {
if (textureURL === undefined || textureURL === null)
{
textureURL = key + '.png';

View file

@ -328,6 +328,7 @@ declare module Phaser {
renderOrderID: number;
right: number;
text: string;
smoothed: boolean;
textWidth: number;
textHeight: number;
tint: number;