Skip to content

Commit ee42432

Browse files
committed
Texture.get has been optimized to fail first, then error, with a new falsey check. This allows you to skip out specifying animation frames in the animation config without generating a console warning.
1 parent 9a561ff commit ee42432

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@
2929
* BitmapText.setText will not change the text via `setText` unless the new text is different to the old one.
3030
* If you set `transparent` in the Game Config but didn't provide a `backgroundColor` then it would render as black. It will now be properly transparent. If you do provide a color value then it must include an alpha component.
3131
* You can now pass normal Groups to Arcade Physics collide / overlap, as well as Physics Groups. Fix #3277 (thanks @nkholski)
32+
* Texture.get has been optimized to fail first, then error, with a new falsey check. This allows you to skip out specifying animation frames in the animation config without generating a console warning.
33+
3234
* Documentation updates: thanks to @melissaelopez @samme
3335

36+
3437
## Version 3.1.2 - 23rd February 2018
3538

3639
### Updates

src/textures/Texture.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,23 +193,22 @@ var Texture = new Class({
193193
*/
194194
get: function (name)
195195
{
196-
if (name === undefined || name === null || (typeof name !== 'string' && typeof name !== 'number'))
196+
// null, undefined, empty string, zero
197+
if (!name)
197198
{
198-
name = (this.frameTotal === 1) ? '__BASE' : this.firstFrame;
199+
name = this.firstFrame;
199200
}
200201

201202
var frame = this.frames[name];
202203

203204
if (!frame)
204205
{
205206
console.warn('No Texture.frame found with name ' + name);
206-
207-
return this.frames['__BASE'];
208-
}
209-
else
210-
{
211-
return frame;
207+
208+
frame = this.frames[this.firstFrame];
212209
}
210+
211+
return frame;
213212
},
214213

215214
/**

0 commit comments

Comments
 (0)