Skip to content

Commit bf25e67

Browse files
committed
LoadTexture.resizeFrame lets you resize the Frame dimensions that the Game Object uses for rendering. You shouldn't normally need to ever call this, but in the case of special texture types such as Video or BitmapData it can be useful to adjust the dimensions directly in this way.
1 parent ed3e7cd commit bf25e67

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/gameobjects/components/LoadTexture.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ Phaser.Component.LoadTexture.prototype = {
6969
// This works from a reference, which probably isn't what we need here
7070
this.setTexture(key.texture);
7171

72+
key.onChangeSource.add(this.resizeFrame, this);
73+
7274
if (this.game.cache.getFrameData(key.key, Phaser.Cache.VIDEO))
7375
{
7476
setFrame = !this.animations.loadFrameData(this.game.cache.getFrameData(key.key, Phaser.Cache.VIDEO), frame);
@@ -176,6 +178,24 @@ Phaser.Component.LoadTexture.prototype = {
176178

177179
},
178180

181+
/**
182+
* Resizes the Frame dimensions that the Game Object uses for rendering.
183+
*
184+
* You shouldn't normally need to ever call this, but in the case of special texture types such as Video or BitmapData
185+
* it can be useful to adjust the dimensions directly in this way.
186+
*
187+
* @method
188+
* @param {object} parent - The parent texture object that caused the resize, i.e. a Phaser.Video object.
189+
* @param {integer} width - The new width of the texture.
190+
* @param {integer} height - The new height of the texture.
191+
*/
192+
resizeFrame: function (parent, width, height) {
193+
194+
this.texture.frame.resize(width, height);
195+
this.texture.setFrame(this.texture.frame);
196+
197+
},
198+
179199
/**
180200
* Resets the texture frame dimensions that the Game Object uses for rendering.
181201
*

0 commit comments

Comments
 (0)