waltsatan Posted May 27, 2021 Share Posted May 27, 2021 Hi all, I have to rework a large Phaser project and slightly adjust the scale on all the loaded pngs to properly display on a monitor that does not have a square pixel aspect ratio. I could go in and set the scaleX of each sprite, but that would be a chore. I worked out this possible solution instead: (eventually being applied to all the pngs) //scale amount var sx=0.9; var sy=1; //get texture and scale var src = this.textures.get('png').getSourceImage(); var dst = this.textures.createCanvas('png-scaled', src.width * sx, src.height * sy); var context=dst.getContext('2d'); context.scale(sx, sy); dst.draw(0, 0, src); //replace this.textures.remove('png'); this.textures.renameTexture('png-scaled','png'); Is this the best approach to achieve this? Are there any performance loses due to the texture now being a canvas and not the original png image? Thanks! Link to comment Share on other sites More sharing options...
waltsatan Posted June 16, 2021 Author Share Posted June 16, 2021 I found an easy workaround by just using css to set the width and height of the game canvas to the funky aspect ratio I need. Duh! Link to comment Share on other sites More sharing options...
Recommended Posts