Wolfos Posted January 1, 2015 Share Posted January 1, 2015 So I got this whole tile renderer, that I think should work (followed the docs pretty closely) but it doesn't. So I put together some minimal code to render an image to a renderTexture and that doesn't work either (nothing in the log, just doesn't work). This code doesn't work:var renderTexture = new PIXI.RenderTexture(1024, 1024);var sprite = new PIXI.Sprite(renderTexture);stage.addChild(sprite); var texture = PIXI.Texture.fromImage("Assets/Sprites/Image.png");var textureSprite = new PIXI.Sprite(texture);renderTexture.render(textureSprite);But rendering text to the RenderTexture (as in this blog post) works just fine, as well as just rendering the image to the stage directly. What am I doing wrong here? EDIT: It seems that the RenderTexture example uses Pixi 1.2.0, which is almost 2 years old. Can anyone confirm RenderTextures being broken in the latest release? Quote Link to comment Share on other sites More sharing options...
alex_h Posted January 1, 2015 Share Posted January 1, 2015 RenderTextures are working fine in the last version I worked with which I think is 2.1.It's possible that the problem you are having might be caused by a timing issue. You might be trying to draw the sprite to the render texture before the png has finished loading. I'm guessing from your rendertexture dimensions of 1024 squared that it is quite a large image which would add credibility to this notion.A quick way of testing this would be moving the call to renderTexture.render into a setTimeout of some arbitrary number of milliseconds, just to be sure there is enough time following your call to Texture.fromImage before you then try to draw the image to your rendertexture. Obviously don't leave the setTimeout in there though, it's just meant as a test! At the end of the day you would probably be better off preloading your images, then you can be sure they are ready to use. Quote Link to comment Share on other sites More sharing options...
Wolfos Posted January 2, 2015 Author Share Posted January 2, 2015 Thanks. That did occur to me once but apparently I didn't verify it. Not used to asset loading being asynchronous. 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.