Jump to content

Filter only works on first sprite?


Legomite
 Share

Recommended Posts

I'm using PIXI's ColorMatrixFilter (the older one from https://github.com/photonstorm/phaser/blob/master/v2/filters/pixi/ColorMatrixFilter.js) to increase the brightness of a sprite.

 

I'm also using the Phaser CE v2.7.3, which changed PIXI.AbstractFilter to Phaser.Filter, so I had to do some modding to get it to work.

 

I got the filter to load into the game, and I got it to work on a sprite. The problem is, it only works on the first sprite added to the game, not the second one. It also seems to affect to second sprite. When I add the filter to sprite1, sprite2's texture turns upside down, the scale gets messed up, and the texture, which is a square, gets stretched into a rectangle. If I try to add to filter to sprite2, the sprite disappears entirely.

 

Everything goes back to normal if I remove the filters in the same session.

 

What on earth is going on here? How can I fix it?

 

  sprite1 = game.add.sprite(100, 100, "poop");
  sprite1.scale.set(5);
  
  sprite2 = game.add.sprite(200, 200, "poop");
  sprite2.scale.set(5);
  
  colorMatrix =  [
    1, 0, 0, 0.2,
    0, 1, 0, 0.2,
    0, 0, 1, 0.2,
    0, 0, 0, 1
  ];
  
  filter = new PIXI.ColorMatrixFilter();
  filter.matrix = colorMatrix;

 

Untitled.mov

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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