Sign in to follow this  

"Sub-texture" of a RenderTexture?

Recommended Posts

I want a subset of a RenderTexture, but this doesn't seem to work:

var renderTexture = new PIXI.RenderTexture(1024, 1024);// render something into the renderTexturevar newSprite = new PIXI.Sprite(new PIXI.Texture(renderTexture, new Rectangle(0, 0, 240, 240)))// render this newSprite into a stage

The sprite with the sub-rectangle of the texture doesn't get rendered.


If I do the following it works fine (whole renderTexture on a sprite):

var newSprite = new PIXI.Sprite(renderTexture)

If I do the following it doesn't render either (whole renderTexture, but a new texture from the renderTexture):

var newSprite = new PIXI.Sprite(new PIXI.Texture(renderTexture))

How do I get a sprite which has a sub texture of an existing RenderTexture?




- lordnoriyuki


Share this post

Link to post
Share on other sites
That doesn't seem to work either:

var imageTexture = PIXI.Texture.fromImage("image.png");
var renderTexture = new PIXI.RenderTexture(1024, 1024);

var imageSprite = new PIXI.Sprite(imageTexture);

var subTexture = new PIXI.Texture(renderTexture.baseTexture, new PIXI.Rectangle(0, 0, 1024, 1024));
var subSprite = new PIXI.Sprite(subTexture);



Nothing appears. If I change renderTexture.baseTexture to imageTexture, then it works fine.



Share this post

Link to post
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.

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.