drawcall / Proton

Javascript particle animation library
https://drawcall.github.io/Proton/
MIT License
2.42k stars 275 forks source link

Random color not working with Pixi.js render #2

Closed zachdsawyer closed 9 years ago

zachdsawyer commented 11 years ago

I'm using Pixi.js, but I can't get the random color behaviour to work.

http://www.a-jie.cn/proton/example/render/custom/pixijs.html Add this, and it doesn't change the color.
emitter.addBehaviour(new Proton.Color('random'));

I looked at Color.prototype.applyBehaviour, it is executing, but it's not showing up in the render.

I love the framework otherwise, great work!

drawcall commented 11 years ago

Oh, I know the pixi.js engine's Sprite and MovieClip does not support dynamic change color.If I am wrong please tell me.Thank you very much!

shawnsnyder commented 10 years ago

If anyone cares, Pixi has a tint function.

so particleSprite.tint = particle.color should work.

If you are using two colors in the emitter.addBehaviour -

emitter.addBehaviour new Proton.Color("#C97024", "#290000")

You will have to update the tint to the transform color. -

particleSprite.tint = '0x' + colorchange.rgbToHex( particle.transform.rgb.r, particle.transform.rgb.g, particle.transform.rgb.b)

I wrote my own rgbToHex (colorchange.rgbToHex) function, but I think PIXI has a PIXI.rgb2hex function that will probably work.

okartgame commented 9 years ago

shawnsnyder thanks you very much :)