Jump to content

Drawing resized frames into a texture


Euler
 Share

Recommended Posts

Hello. I ran into a problem... I need to take three frames from a multi-atlas, scale them and write to a new texture. In pseudo code, it should look something like this:

const texture = this.textures.createCanvas("new-texture", 100, 300);

const t1 = this.textures.getFrame("atlas", "t1").getSourceImage().setSize (100, 100);
const t2 = this.textures.getFrame("atlas", "t2").getSourceImage().setSize (100, 100);
const t3 = this.textures.getFrame("atlas", "t3").getSourceImage().setSize (100, 100);

texture.draw(0, 0, t1);
texture.draw(0, 100, t2);
texture.draw(0, 200, t3);

But I still didn't found proper way to solve this. I will be grateful for any help.

Link to comment
Share on other sites

  • 2 weeks later...

Have you tried using a RenderTexture? https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.RenderTexture.html

I have not tested this but you might be able to create an Image from a Texture Frame and then draw it into the RenderTexture. You might be able to skip creating an Image first if you can resize the Texture Frame but I'm not sure if you can

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...