diwil Posted July 2, 2015 Share Posted July 2, 2015 I'm working on a game with dynamic lighting (sprite based), and I've stumbled across a problem with rendering sprites to a RenderTexture. Is there any way to override the default render() method for Phaser.Sprite objects? I'm basically using a camera-fixed sprite called Darkness, rendered in PIXI.blendMode.MULTIPLY, which has a filled rectangle of my ambient color called ambience in it's properties. I also have a group of light sprites, that I render to the darkness' renderTexture. I need to use a Group so renderXY takes rotation into account.function render(){ // Clear the darkness sprite darkness.renderTexture.renderXY(darkness.ambience, 0, 0, true); // Render lights darkness.renderTexture.renderXY(lightGroup, -game.camera.x, -game.camera.y, false);} However, this causes the lights to be drawn to the renderTexture as well as the scene itself. Is there a way to disable rendering of the sprite, while still letting me use renderXY to paint it on a renderTexture, with rotation? I tried changing the renderable and visible properties, but setting either one to false caused the lights to stop rendering altogether. Link to comment Share on other sites More sharing options...
diwil Posted July 3, 2015 Author Share Posted July 3, 2015 I worked it out after all! I had to set the lightGroup.visible to false in the state's preRender() method, and enable visibility in the render() method before the renderXY() call. Link to comment Share on other sites More sharing options...
Recommended Posts