Jump to content

ParticleContainer Color Glitch


schemagroup
 Share

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,

 

Link to comment
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.

Link to comment
Share on other sites

  • 2 weeks later...

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.

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

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...