kriket Posted November 3, 2015 Share Posted November 3, 2015 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. FULL CODE: 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 More sharing options...
jmp909 Posted November 3, 2015 Share Posted November 3, 2015 according to this it should workhttp://phaser.io/sandbox/KqTqXLUy/play Link to comment Share on other sites More sharing options...
chongdashu Posted November 3, 2015 Share Posted November 3, 2015 Could be the fact that their sprite is green. The tint is additive, and would end up making the entire sprite dark. @jmp909, could you try with a greenish sprite? kriket 1 Link to comment Share on other sites More sharing options...
jmp909 Posted November 3, 2015 Share Posted November 3, 2015 try link again.. yes it is quite darkhttp://phaser.io/sandbox/KqTqXLUy/play Link to comment Share on other sites More sharing options...
kriket Posted November 3, 2015 Author Share Posted November 3, 2015 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 More sharing options...
chongdashu Posted November 3, 2015 Share Posted November 3, 2015 0xFFFFFF should reset it back to normal. Link to comment Share on other sites More sharing options...
kriket Posted November 3, 2015 Author Share Posted November 3, 2015 0xFFFFFF should reset it back to normal. It does. but not in my game. Let me check again pls Link to comment Share on other sites More sharing options...
jmp909 Posted November 3, 2015 Share Posted November 3, 2015 try console.log(this.chosenColor == 0xFFFFFF) is it true or false? Link to comment Share on other sites More sharing options...
jmp909 Posted November 3, 2015 Share Posted November 3, 2015 you're only calling it once and that's set to red i put it in the update loop here.. not ideal but you can see it workshttp://phaser.io/sandbox/KqTqXLUy/play (wrong link) Link to comment Share on other sites More sharing options...
kriket Posted November 3, 2015 Author Share Posted November 3, 2015 try 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 More sharing options...
jmp909 Posted November 3, 2015 Share Posted November 3, 2015 sorry that should have been an == anyway, tints aren't cumulative. you don't need to set it to white then the new colour Link to comment Share on other sites More sharing options...
kriket Posted November 3, 2015 Author Share Posted November 3, 2015 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 More sharing options...
jmp909 Posted November 3, 2015 Share Posted November 3, 2015 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) Link to comment Share on other sites More sharing options...
kriket Posted November 3, 2015 Author Share Posted November 3, 2015 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 More sharing options...
jmp909 Posted November 3, 2015 Share Posted November 3, 2015 no.... log herethis.emitterUp.forEach(function(particle) { // particle.tint = 0xFFFFFF; // particle.reset(); console.log(this.chosenColor) // <== *** 'this' points to emitter, no? *** particle.tint = this.chosenColor;});well i'm not sure what 'this' points to actually. Tilde and drhayes 2 Link to comment Share on other sites More sharing options...
kriket Posted November 3, 2015 Author Share Posted November 3, 2015 no.... log herethis.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. Tilde 1 Link to comment Share on other sites More sharing options...
jmp909 Posted November 3, 2015 Share Posted November 3, 2015 Tilde 1 Link to comment Share on other sites More sharing options...
Recommended Posts