Jump to content

Overriding Sprite.render?


Recommended Posts

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

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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...