Sign in to follow this  
Kacper Pietrzak

How does blendModes work in Phaser.Graphics compared to Sprites

Recommended Posts

Hey guys,

Recently I've noticed some strange behaviour while using blendModes on Phaser.Graphics.

I am creating a flashlight by drawing dark rectangle and lighter calculated shape of light from flashlight, I draw that on Phaser.Graphics object. Then I apply this object as a texture to sprite to see the difference between rendered outcomes.

this.shadowTexture = 0, 0 );
this.shadowTexture.blendMode = Phaser.blendModes.MULTIPLY;

this.sprite = 200, 0, this.shadowTexture.generateTexture() );
this.sprite.blendMode = Phaser.blendModes.MULTIPLY;

 // draw on shadowTexture

 this.sprite.texture = this.shadowTexture.generateTexture();
 // just for test purposes

this code results in such situation:


As you can see, blendMode used in Phaser.Graphics resulted with darker flashlight and the one used in Phaser.Sprite in lighter.

Am I getting this all totally wrong ? Or is this some kind of a bug ?

What I would like to achieve is the effect that I get using Sprite just by using Phaser.Graphics.

Please, help guys, I am a bit confused here :)


Share this post

Link to post
Share on other sites

@samme Setting in only on sprite works just fine, but I cannot afford generatingTextue from Phaser.Graphics every frame. Setting it only on Phaser.Graphics and not applying it to sprite but just displaying results in white color not giving a nice transparent flashlight shape, but is not visible at all. Making it darker than pure white results in what you see one the left side of the picture. So, this behaviour is still kind of mystery for me.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.