Skip to content

Commit 3efc800

Browse files
committed
Use global string to cut down on size a little.
1 parent 72d54dd commit 3efc800

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ The process of managing scissors in the WebGLRenderer has been completely rewrit
4949
* Global Plugins now have a new optional `data` object, the contents of which are passed to the plugins `init` method. This allows users to pass data directly into a plugin when added in the config: `{ key: 'BankPlugin', plugin: BankPluginV3, start: true, data: { gold: 5000 } }` or when adding a plugin via the `install` method (thanks @samme)
5050
* You can now play animations in reverse! Use the new `Sprite.anims.playReverse` method to play a pre-defined animation in reverse from its starting frame. Or call `Sprite.anims.reverse` to immediately reverse the flow of an already running animation. Animations running in reverse still count towards the repeat total and respect the yoyo flag (thanks @khaleb85)
5151
* The `ParticleEmitterManager` now has the Transform component. This means you can now set the position, rotation or scale of the Emitter Manager, and it will influence every Emitter it is rendering. The Managers transform is mixed with that of the Camera. This works in both Canvas and WebGL.
52+
* `TextureManager.addRenderTexture` is a new method that will add a Render Texture into the Texture Manager, allowing you to use it as the texture for Game Objects just by using the texture key. Modifying the source Render Texture will immediately modify any Game Objects using it.
5253

5354
### Updates
5455

src/textures/Texture.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ var Class = require('../utils/Class');
88
var Frame = require('./Frame');
99
var TextureSource = require('./TextureSource');
1010

11+
var TEXTURE_MISSING_ERROR = 'Texture.frame missing: ';
12+
1113
/**
1214
* @classdesc
1315
* A Texture consists of a source, usually an Image from the Cache, and a collection of Frames.
@@ -203,7 +205,7 @@ var Texture = new Class({
203205

204206
if (!frame)
205207
{
206-
console.warn('No Texture.frame found with name ' + name);
208+
console.warn(TEXTURE_MISSING_ERROR + name);
207209

208210
frame = this.frames[this.firstFrame];
209211
}
@@ -311,7 +313,7 @@ var Texture = new Class({
311313
*
312314
* @param {(string|integer)} [name] - The string-based name, or integer based index, of the Frame to get from this Texture.
313315
*
314-
* @return {(HTMLImageElement|HTMLCanvasElement)} The DOM Image or Canvas Element.
316+
* @return {(HTMLImageElement|HTMLCanvasElement|Phaser.GameObjects.RenderTexture)} The DOM Image, Canvas Element or Render Texture.
315317
*/
316318
getSourceImage: function (name)
317319
{
@@ -324,14 +326,12 @@ var Texture = new Class({
324326

325327
if (!frame)
326328
{
327-
console.warn('No Texture.frame found with name ' + name);
329+
console.warn(TEXTURE_MISSING_ERROR + name);
328330

329-
return this.frames['__BASE'].source.image;
330-
}
331-
else
332-
{
333-
return frame.source.image;
331+
frame = '__BASE';
334332
}
333+
334+
return this.frames[frame].source.image;
335335
},
336336

337337
/**
@@ -359,7 +359,7 @@ var Texture = new Class({
359359

360360
if (!frame)
361361
{
362-
console.warn('No Texture.frame found with name ' + name);
362+
console.warn(TEXTURE_MISSING_ERROR + name);
363363

364364
idx = this.frames['__BASE'].sourceIndex;
365365
}

0 commit comments

Comments
 (0)