Game Development Community

Making bitmaps translucent

by rwillis · in Torque X 2D · 12/27/2008 (9:15 am) · 2 replies

Has anyone been able to dynamically adjust the translucency of sprites in-game using IsTranslucent = true and Opacity properties? i.e.:

SimpleMaterial ggLogo = new SimpleMaterial();
ggLogo.TextureFilename = @"data/images/GUI/General/GGLogo";              
ggLogo.IsTranslucent = true;
ggLogo.Opacity = 0.5f;

terrainOne = new T2DStaticSprite();
terrainOne.Material = ggLogo;
terrainOne.Position = new Vector2(0, 0);
terrainOne.Size = new Vector2(100, 75);
terrainOne.Visible = true;
terrainOne.Layer = 100;
TorqueObjectDatabase.Instance.Register(terrainOne);

Although the code above doesn't seem to be working (making the image translucent). Am I missing or doing something wrong here?

Edit: Fixed.

#1
12/27/2008 (3:51 pm)
It looks like I found a fix to this. I needed to set ggLogo.IsCopyPass = true.
#2
01/05/2009 (3:51 pm)
You have to set the following properties:

material.IsColorBlended = true;
material.IsTranslucent = true;

It seems like the TX Editor doesn't put "IsColorBlended" as true (only "IsTranslucent" is set), so you have to do it on code for each sprite that needs it.