schemagroup

ParticleContainer Color Glitch

Recommended Posts

Hi All,

I'm having this weird issue with the PixiJS ParticleContainer for some reason when I apply a color tint to it using TweenMax it glitches. I've pasted my code for reference if you see any issue in my code.

 

// HERE IS WHERE I CREATE MY PARTICLES USING THE PARTICLE CONTAINER
function createParticles() {
  console.log("createParticles()");

  particleContainer = new PIXI.particles.ParticleContainer(particleData.length, {scale: true,
    position: true,
    tint:true,
    rotation: true,
    alpha: true
  });

  particleContainer.x = app.renderer.width / 2;
  particleContainer.y = app.renderer.height / 2;

  bkg = new PIXI.Graphics().beginFill(0x000000).drawCircle(0, 0, 300);
  bkg.x = app.renderer.width / 2 +10;
  bkg.y = app.renderer.height / 2 +10;

  var graphics = new PIXI.Graphics().beginFill(0x4c9f91).drawCircle(0, 0, 10);
  var texture = graphics.generateCanvasTexture();

  for (var i = 0; i < particleData.length; i++) {
    var particle = new PIXI.Sprite(texture);
    particle.pivot.set(5, 5);
    particleArray.push({particle: particle, xpos: particleData[i].xpos, ypos: particleData[i].ypos});
    particle.alpha = 0;
    particle.x = 0;
    particle.y = 0;
    particle.scale.set(Math.random() * 1 - 0.25);
    particleContainer.addChild(particle);
  }
  contentContainer.addChildAt(bkg, 0);
  contentContainer.addChild(particleContainer);
}

// CHANGES COLOR OF THE PARTICLE CONTAINER, ONCE THIS GETS FIRED IT TURNS BLACK AND THEN CHANGES BACK TO THE COLOR ON WHICH IT APPLIES, LOOKS LIKE A GLITCH.
function cyleColors() {


  tlColor.to(particleContainer, 3, {pixi:{tint:0x4ec7f2}})
         .to(particleContainer, 3, {pixi:{tint:0xe6df36}})
         .to(particleContainer, 3, {pixi:{tint:0x4c9f91}})
         .to(particleContainer, 3, {pixi:{tint:0xf98331}})
         .to(particleContainer, 3, {pixi:{tint:0xde1272}});
}

 

Thanks,

 

Share this post


Link to post
Share on other sites

For TweenMax this is just a number that you are tweening, it can't know if this is a hex color that you are tweening to and from. The common way of tweening hex color in tween engines that support it is by passing a string instead or by the use of specific plugins. If tweenmax supports it try to pass your color as a string, if it doesn't I'm sure there's a plugin that you can activate in there that is meant to do just that.

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

  • Recently Browsing   0 members

    No registered users viewing this page.