azerion / phaser-nineslice

NineSlice plugin for Phaser!
MIT License
53 stars 20 forks source link

Tint property causes nineslice to bug out #8

Open shibekin69 opened 7 years ago

shibekin69 commented 7 years ago

Hi,

When I try using tint, it works along with the resize function, but the nineslice graphic gets messed up. The edges (in my case, the right and the bottom) disappears. I'm on Phaser 2.8.1, canvas mode btw.

shibekin69 commented 7 years ago

Ok, I was fiddling around with your nineslice sprite object. After resizing, I can do this:

nineslicegraphic.texture.requiresReTint = true;

That will fix up the graphic after the resize.

shibekin69 commented 7 years ago

I modified the phaser-nineslice.js source.

Adding the ff:

this.texture.requiresReTint = true;

After this for loop:

        for (var yi = 0; yi < 3; yi++) {
            for (var xi = 0; xi < 3; xi++) {
                var s = this.createTexturePart(textureXs[xi], textureYs[yi], textureXs[xi + 1] - textureXs[xi], textureYs[yi + 1] - textureYs[yi]);
                s.width = finalXs[xi + 1] - finalXs[xi];
                s.height = finalYs[yi + 1] - finalYs[yi];
                this.texture.renderXY(s, finalXs[xi], finalYs[yi]);
            }
        }