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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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