Skip to content

Commit d26f937

Browse files
committed
RetroFont has a new property called frameData which contains the Frame objects for each of the letters in the font, which can be used by Sprites.
1 parent 152335f commit d26f937

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Version 2.1.0 - "Cairhien" - -in development-
104104
* Game.destroy now removes the games canvas element from the DOM.
105105
* ScaleManager.setMinMax(minWidth, minHeight, maxWidth, maxHeight) is a handy function to allow you to set all the min/max dimensions in one call.
106106
* ArcadePhysics.collide and overlap can now accept 2 Arrays of objects to be used in the collision checks (thanks @ctmartinez1992 #1158)
107+
* RetroFont has a new property called frameData which contains the Frame objects for each of the letters in the font, which can be used by Sprites.
107108

108109
### Updates
109110

src/gameobjects/RetroFont.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,21 @@ Phaser.RetroFont = function (game, key, characterWidth, characterHeight, chars,
121121
*/
122122
this.grabData = [];
123123

124+
/**
125+
* @property {Phaser.FrameData} frameData - The FrameData representing this Retro Font.
126+
*/
127+
this.frameData = new Phaser.FrameData();
128+
124129
// Now generate our rects for faster copying later on
125130
var currentX = this.offsetX;
126131
var currentY = this.offsetY;
127132
var r = 0;
128-
var data = new Phaser.FrameData();
129133

130134
for (var c = 0; c < chars.length; c++)
131135
{
132136
var uuid = game.rnd.uuid();
133137

134-
var frame = data.addFrame(new Phaser.Frame(c, currentX, currentY, this.characterWidth, this.characterHeight, '', uuid));
138+
var frame = this.frameData.addFrame(new Phaser.Frame(c, currentX, currentY, this.characterWidth, this.characterHeight, '', uuid));
135139

136140
this.grabData[chars.charCodeAt(c)] = frame.index;
137141

@@ -156,7 +160,7 @@ Phaser.RetroFont = function (game, key, characterWidth, characterHeight, chars,
156160
}
157161
}
158162

159-
game.cache.updateFrameData(key, data);
163+
game.cache.updateFrameData(key, this.frameData);
160164

161165
/**
162166
* @property {Phaser.Image} stamp - The image that is stamped to the RenderTexture for each character in the font.

0 commit comments

Comments
 (0)