RetroFont charsPerRow paramters is now optional. If not given it will take the image width and divide it by the characterWidth value.

This commit is contained in:
photonstorm 2014-05-27 02:06:16 +01:00
parent f007a77f3d
commit 68f1bbd9a5
2 changed files with 12 additions and 1 deletions

View file

@ -56,6 +56,7 @@ Version 2.0.6 - "Jornhill" - -in development-
* BitmapData.alphaMask now calls BitmapData.update after running.
* BitmapData.draw now has two optional parameters: width and height, to let you stretch the image being drawn if needed.
* Group.destroy now removes any set filters (thanks @Jmaharman fix #844)
* RetroFont charsPerRow paramters is now optional. If not given it will take the image width and divide it by the characterWidth value.
### New Features

View file

@ -13,7 +13,7 @@
* @param {number} characterWidth - The width of each character in the font set.
* @param {number} characterHeight - The height of each character in the font set.
* @param {string} chars - The characters used in the font set, in display order. You can use the TEXT_SET consts for common font set arrangements.
* @param {number} charsPerRow - The number of characters per row in the font set.
* @param {number} [charsPerRow] - The number of characters per row in the font set. If not given charsPerRow will be the image width / characterWidth.
* @param {number} [xSpacing=0] - If the characters in the font set have horizontal spacing between them set the required amount here.
* @param {number} [ySpacing=0] - If the characters in the font set have vertical spacing between them set the required amount here.
* @param {number} [xOffset=0] - If the font set doesn't start at the top left of the given image, specify the X coordinate offset here.
@ -21,6 +21,16 @@
*/
Phaser.RetroFont = function (game, key, characterWidth, characterHeight, chars, charsPerRow, xSpacing, ySpacing, xOffset, yOffset) {
if (!game.cache.checkImageKey(key))
{
return false;
}
if (typeof charsPerRow === 'undefined' || charsPerRow === null)
{
charsPerRow = game.cache.getImage(key).width / characterWidth;
}
/**
* @property {number} characterWidth - The width of each character in the font set.
*/