Phaser.Component.LoadTexture = function (){ } ; Phaser.Component.LoadTexture.prototype = { customRender: false , _frame: null , loadTexture: function (key, frame, stopAnimation){ frame = frame || 0; if ((stopAnimation || typeof stopAnimation === 'undefined') && this.animations) { this.animations.stop(); } this.key = key; this.customRender = false ; var setFrame = true ; var smoothed = !this.texture.baseTexture.scaleMode; if (Phaser.RenderTexture && key instanceof Phaser.RenderTexture) { this.key = key.key; this.setTexture(key); } else if (Phaser.BitmapData && key instanceof Phaser.BitmapData) { this.customRender = true ; this.setTexture(key.texture); if (this.game.cache.getFrameData(key.key, Phaser.Cache.BITMAPDATA)) { setFrame = !this.animations.loadFrameData(this.game.cache.getFrameData(key.key, Phaser.Cache.BITMAPDATA), frame); } } else if (Phaser.Video && key instanceof Phaser.Video) { this.customRender = true ; var valid = key.texture.valid; this.setTexture(key.texture); this.setFrame(key.texture.frame.clone()); key.onChangeSource.add(this.resizeFrame, this); this.texture.valid = valid; } else if (key instanceof PIXI.Texture) { this.setTexture(key); } else { if (key === null || typeof key === 'undefined') { this.key = '__default'; this.setTexture(PIXI.TextureCache[this.key]); } else if (typeof key === 'string' && !this.game.cache.checkImageKey(key)) { console.warn("Texture with key '" + key + "' not found."); this.key = '__missing'; this.setTexture(PIXI.TextureCache[this.key]); } else { this.setTexture(new PIXI.Texture(PIXI.BaseTextureCache[key])); setFrame = !this.animations.loadFrameData(this.game.cache.getFrameData(key), frame); } } if (setFrame) { this._frame = Phaser.Rectangle.clone(this.texture.frame); } if (!smoothed) { this.texture.baseTexture.scaleMode = 1; } } , setFrame: function (frame){ this._frame = frame; this.texture.frame.x = frame.x; this.texture.frame.y = frame.y; this.texture.frame.width = frame.width; this.texture.frame.height = frame.height; this.texture.crop.x = frame.x; this.texture.crop.y = frame.y; this.texture.crop.width = frame.width; this.texture.crop.height = frame.height; if (frame.trimmed) { if (this.texture.trim) { this.texture.trim.x = frame.spriteSourceSizeX; this.texture.trim.y = frame.spriteSourceSizeY; this.texture.trim.width = frame.sourceSizeW; this.texture.trim.height = frame.sourceSizeH; } else { this.texture.trim = { x: frame.spriteSourceSizeX, y: frame.spriteSourceSizeY, width: frame.sourceSizeW, height: frame.sourceSizeH} ; } this.texture.width = frame.sourceSizeW; this.texture.height = frame.sourceSizeH; this.texture.frame.width = frame.sourceSizeW; this.texture.frame.height = frame.sourceSizeH; } else if (!frame.trimmed && this.texture.trim) { this.texture.trim = null ; } if (this.cropRect) { this.updateCrop(); } this.texture.requiresReTint = true ; this.texture._updateUvs(); if (this.tilingTexture) { this.refreshTexture = true ; } } , resizeFrame: function (parent, width, height){ this.texture.frame.resize(width, height); this.texture.setFrame(this.texture.frame); } , resetFrame: function (){ if (this._frame) { this.setFrame(this._frame); } } , frame: { get: function (){ return this.animations.frame; } , set: function (value){ this.animations.frame = value; } } , frameName: { get: function (){ return this.animations.frameName; } , set: function (value){ this.animations.frameName = value; } } } ;