Hi,
Please view below source code and provide help:
Both color tint and transparency are not currently working?
Jesse
function DrawSprite (spriteName, x, y, scaleX, scaleY, rotation, red, green, blue, alpha)
{
spriteName.x = x;
spriteName.y = y;
spriteName.scaleX = scaleX;
spriteName.scaleY = scaleY;
spriteName.rotation = rotation;
const tint = new Phaser.Display.Color(red, green, blue);
// spriteName.setTint(tint); // Not working?
// spriteName.setAlpha(alpha / 255); // Not working?
}
Sorry, when I draw the sprite(the background) all I get is black?
DrawSprite(sky, 320, 180, 1.0, 1.0, 0, 255, 255, 255, 255);
samme
4
Look in the browser dev tools console for errors.
You did
sky = this.add.image(/*…*/);
before that?
Yes, and no errors in browser console:
samme
6
Did you comment out the setTint
and setAlpha
lines and the sky is still not visible?
The setTint
argument should be tint.color
, not tint
.
That worked, thanks!
Below is the 100% working source code:
function DrawSprite (spriteName, x, y, scaleX, scaleY, rotation, red, green, blue, alpha)
{
spriteName.x = x;
spriteName.y = y;
spriteName.scaleX = scaleX;
spriteName.scaleY = scaleY;
spriteName.rotation = rotation;
const tint = new Phaser.Display.Color(red, green, blue);
spriteName.setTint(tint.color);
spriteName.setAlpha(alpha / 255);
}