Phaser.Component.LoadTexture = function (){ } ; Phaser.Component.LoadTexture.prototype = { customRender: false , _frame: null , loadTexture: function (key, frame, stopAnimation){ if (key === Phaser.PENDING_ATLAS) { key = frame; frame = 0; } else { frame = frame || 0; } if ((stopAnimation || stopAnimation === undefined) && this.animations) { this.animations.stop(); } this.key = key; this.customRender = false ; var cache = this.game.cache; 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 (cache.hasFrameData(key.key, Phaser.Cache.BITMAPDATA)) { setFrame = !this.animations.loadFrameData(cache.getFrameData(key.key, Phaser.Cache.BITMAPDATA), frame); } else { setFrame = !this.animations.loadFrameData(key.frameData, 0); } } 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 (Phaser.Tilemap && key instanceof Phaser.TilemapLayer) { this.setTexture(PIXI.Texture.fromCanvas(key.canvas)); } else if (key instanceof PIXI.Texture) { this.setTexture(key); } else { var img = cache.getImage(key, true ); this.key = img.key; this.setTexture(new PIXI.Texture(img.base)); if (key === '__default') { this.texture.baseTexture.skipRender = true ; } else { this.texture.baseTexture.skipRender = false ; } setFrame = !this.animations.loadFrameData(img.frameData, 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 (frame.rotated) { this.texture.rotated = true ; } 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; } } } ;