Jump to content

tinting particles to say pink color (any color), always returns black particles


Recommended Posts

So when my player overlaps a coin for example, I have a particle effect. I use 

        this.emitterUp.forEach(function(particle) {          particle.tint = 0xFF0066;        });

to tint particles to no avail. No matter whether hex code is pink, red, green, my particle effect always has black particles. The image I use initially to makeParticles is not even black. Its green. 





In Create(),


    this.emitterUp = this.game.add.emitter(0, 0, 20);    this.emitterUp.makeParticles('explode_green');    this.emitterUp.gravity = 400;

In Update(),


    this.game.physics.arcade.overlap(this.player, this.collectable, this.oneUp, null, this);
oneUp: function(a,b,c,d){   b.kill();     this.emitterUp.x = this.player.x;   this.emitterUp.y = this.player.y;   this.emitterUp.start(true, 1400, null, 20);   this.emitterUp.forEach(function(particle) {          particle.tint = 0xFF0066;   });},


Link to comment
Share on other sites

guys how can i reset the tint of the sprite then, since adding a new color means its additive. Docs mentioned a value of "A value of 0xFFFFFF will remove any tint effect." but its still giving me a pitch black color. 


oneUp: function(a,b,c,d){        b.kill();     this.emitterUp.x = this.player.x;   this.emitterUp.y = this.player.y;this.emitterUp.start(true, 1400, null, 20);        this.emitterUp.forEach(function(particle) {//          particle.tint = 0xFFFFFF;//          particle.reset();          particle.tint = this.chosenColor;        });},
Link to comment
Share on other sites


console.log(this.chosenColor = 0xFFFFFF) 

is it true or false?



What I am trying to do is set tint to 0xFFFFFF and then set the color to chosenColor. ChosenColor is a randomnly chosen color from an array (ie red, greed, etc).  My starting images color is white as well.

Link to comment
Share on other sites

But someone mentioned above they are additive, so I thought setting to white, which according to phaser resets it, (and takes my sprite back to its default white color), and that way any other tint will be red or green and not black??


So how can I tint to a random color from an array of colors?

Link to comment
Share on other sites


did you check you've got this.chosenColor in the right scope? is it = 0xFFFFFF ? or undefined.


and no you don't need to reset it first.

var colors = [0xFF0000, 0x00FF00, 0x0000FF]chosenColor = Phaser.ArrayUtils.getRandomItem(colors)



I have uploaded a really basic prototype at http://icey.site44.com/


Scope seems fine to me. Console.log is not undefined. 

Link to comment
Share on other sites


no.... log here

this.emitterUp.forEach(function(particle) {  // particle.tint = 0xFFFFFF;  // particle.reset();  console.log(this.chosenColor) // <== *** 'this' points to emitter, no? ***  particle.tint = this.chosenColor;});



You are right. By moving the log line, its now giving undefined. FIXED IT!! was missing this at the end. Ashamed.

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...