lordnoriyuki Posted July 25, 2014 Share Posted July 25, 2014 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 stageThe 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? Thanks - lordnoriyuki Quote Link to comment Share on other sites More sharing options...
Mat Groves Posted July 25, 2014 Share Posted July 25, 2014 here ya goes:var subTexture = new PIXI.Texture( renderTexture.baseTexture, new PIXI.Rectangle(10,10, 20, 20) )var newSprite = new PIXI.Sprite(subTexture)You need to use the RenderTextures baseTexture and it should work fine Quote Link to comment Share on other sites More sharing options...
lordnoriyuki Posted July 25, 2014 Author Share Posted July 25, 2014 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); renderTexture.render(imageSprite); var subTexture = new PIXI.Texture(renderTexture.baseTexture, new PIXI.Rectangle(0, 0, 1024, 1024)); var subSprite = new PIXI.Sprite(subTexture); stage.addChild(subSprite); renderer.render(stage);Nothing appears. If I change renderTexture.baseTexture to imageTexture, then it works fine. -lordnoriyuki Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.