Jump to content

Scale a container with RenderTexture on every frame


Barduck
 Share

Recommended Posts

Hi, I don't like to bother, but I don't sure what I'm doing and I need some guidance if it's possible...

I have two containers, one for map sprites (320x180px) and the other for UI graphics (who it's resized to native resolution, in my case 1920x1080)

My intention is to rescale map_sprites_containter and all its sprites to 1920x1080 in the most efficient way, every frame. So I came up with the idea of render a texture of map_sprites_container, convert it to a sprite and scale it. 

Is this the best way?

Some pseudo code:
var bitmap = new Bitmap(320, 180);
var renderTexture = PIXI.RenderTexture.create(320, 180);
renderer.render(map_sprites_containter, renderTexture);

var canvas = renderer.extract.canvas(renderTexture);
bitmap.context.drawImage(canvas, 0, 0);
canvas.width = 0;
canvas.height = 0;
renderTexture.destroy({ destroyBase: true });
bitmap.baseTexture.update();

var render_map_sprites = new Sprite();
render_map_sprites.bitmap = bitmap;
render_map_sprites.scale.x = 6
render_map_sprites.scale.y = 6
map_sprites_containter.addChild(render_map_sprites);

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...