Ferenc Dajka
Ferenc Dajka

Reputation: 1052

Set transparency of a quad in starling

OK, so it blows my mind, so help me please, I'd like to use a transparent quad in my starling project, it has a property: color of ARGB, so I set the alpha to 90 for example, but it just doesn't seem to work like that. now I've changed it's blend mode to MULTIPLY, so it works, but I'm not sure it's the good solution, maybe with other colored background, it won't look like, as I want, I want it a bit grey, so the user knows, he can't acces the stage, at the minute. So is there any other, better solution than this? Thank you, here's my code

package screens 
{
    import starling.display.Image;
    import starling.display.Quad;
    import starling.display.BlendMode

public class TransparentScr extends AbstractScr{
    private var trpImg:Image;

    public function TransparentScr() {
        super();
    }

    override protected function init():void {
        super.init();
        var quad:Quad = new Quad(Main.STAGE_WIDTH / 2, Main.STAGE_HEIGHT / 2, 0x90cccccc, true);
        quad.blendMode = BlendMode.MULTIPLY;
        addChild(quad);
    }

}

}

Upvotes: 2

Views: 3303

Answers (2)

Josh Tynjala
Josh Tynjala

Reputation: 5242

so I set the alpha to 90

In Starling, alpha values go from 0.0 to 1.0. Assuming that you want 90% opacity, you should use 0.9.

Upvotes: 2

AturSams
AturSams

Reputation: 7942

I think you can only use the Quad to make it transparent. As far as making it monochrome, I I would recommend a ColorMatrixFilter:

var mat:Array = [ 
          .33,.33,.33,0,0,
          .33,.33,.33,0,0,
          .33,.33,.33,0,0,
          .33,.33,.33,1,0 ];
var colorMat:ColorMatrixFilter = new ColorMatrixFilter(mat);
this.filters = [colorMat];

Upvotes: 1

Related Questions