Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Phaser.BitmapData.prototype.generateTexture = function(key) {
- var copyCanvas = PIXI.CanvasPool.create(this, this.width, this.height);
- var copyContext = copyCanvas.getContext('2d', {
- alpha: true
- });
- copyContext.putImageData(this.ctx.getImageData(0, 0, this.width, this.height), 0, 0);
- var texture = PIXI.Texture.fromCanvas(copyCanvas);
- // PIXI.Texture.addTextureToCache(texture, key); //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- return texture;
- };
- Phaser.Component.LoadTexture.prototype.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;
- // This works from a reference, which probably isn't what we need here
- 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.customRender = true;
- this.setTexture(PIXI.Texture.fromCanvas(key.canvas));
- } else if (key instanceof PIXI.Texture) {
- this.setTexture(key);
- } else if (typeof PIXI.TextureCache[key] !== "undefined") //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- {
- this.setTexture(PIXI.TextureCache[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;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement