mirror of
https://github.com/photonstorm/phaser
synced 2024-11-15 17:28:18 +00:00
Text.autoRound allows you to control if the text is allowed to render at sub-pixel coordinates or not. Set to true
to round the coordinates, often eliminating anti-aliasing from certain font types (#1867)
This commit is contained in:
parent
ce405acb02
commit
a89d48b9a6
3 changed files with 16 additions and 0 deletions
|
@ -318,6 +318,7 @@ Version 2.4 - "Katar" - in dev
|
|||
* Game Objects that have the Health component (such as Sprites) now have a new method: `heal` which adds the given amount to the health property, i.e. is the opposite of `damage` (thanks @stephandesouza #1794)
|
||||
* maxHealth is a new property that Game Objects with the Health component receive and works in combination with the `heal` method to ensure a health limit cap.
|
||||
* Text.setTextBounds is a rectangular region that allows you to align your text within it, regardless of the number of lines of text or position within the world. For example in an 800x600 sized game if you set the textBounds to be 0,0,800,600 and text alignment to 'left' and vertical alignment to 'bottom' then the text will render in the bottom-right hand corner of the game, regardless of the size of font you're using or the number of lines in the text itself.
|
||||
* Text.autoRound allows you to control if the text is allowed to render at sub-pixel coordinates or not. Set to `true` to round the coordinates, often eliminating anti-aliasing from certain font types (#1867)
|
||||
|
||||
### Updates
|
||||
|
||||
|
|
|
@ -91,6 +91,14 @@ Phaser.Text = function (game, x, y, text, style) {
|
|||
*/
|
||||
this.colors = [];
|
||||
|
||||
/**
|
||||
* Should the linePositionX and Y values be automatically rounded before rendering the Text?
|
||||
* You may wish to enable this if you want to remove the effect of sub-pixel aliasing from text.
|
||||
* @property {boolean} autoRound
|
||||
* @default
|
||||
*/
|
||||
this.autoRound = false;
|
||||
|
||||
/**
|
||||
* @property {string} _text - Internal cache var.
|
||||
* @private
|
||||
|
@ -410,6 +418,12 @@ Phaser.Text.prototype.updateText = function () {
|
|||
linePositionX += (maxLineWidth - lineWidths[i]) / 2;
|
||||
}
|
||||
|
||||
if (this.autoRound)
|
||||
{
|
||||
linePositionX = Math.round(linePositionX);
|
||||
linePositionY = Math.round(linePositionY);
|
||||
}
|
||||
|
||||
if (this.colors.length > 0)
|
||||
{
|
||||
this.updateLine(lines[i], linePositionX, linePositionY);
|
||||
|
|
1
typescript/phaser.d.ts
vendored
1
typescript/phaser.d.ts
vendored
|
@ -4339,6 +4339,7 @@ declare module Phaser {
|
|||
|
||||
align: string;
|
||||
angle: number;
|
||||
autoRound: boolean;
|
||||
boundsAlignH: string;
|
||||
boundsAlignV: string;
|
||||
cameraOffset: Phaser.Point;
|
||||
|
|
Loading…
Reference in a new issue