Game Development Reference
In-Depth Information
Take your time and play with the rest of the filters and see how you can apply them.
Choosing the right filters or a combination of them is what makes a game visually
more appealing. Further, note that each filter comes with a bunch of little knobs
(properties) that lets you create unique filters as your game demands.
Transparency: Playing with the alpha
channel
With Flash and AS3, one can easily control the transparency of an image and UI
elements like buttons and text fields. This is a great way to create a cool-looking
interface for your game. In the graphics world, transparency is usually controlled
by what is called the alpha channel.
The alpha channel value in Flash is a number and its value may range from 0 to 1. 0.
Being completely transparent, you would not see the sprite with an alpha of 0 and
a value of 1 is opaque, which means that anything directly behind the sprite will be
invisible. A value of 0.5 is 50 percent transparent or opaque.
The following example shows how you can create one. It is quite simple. During the
creation of a sprite in the method call beginFill , you simply specify the value for
alpha (default value 1) something other than 1.
package {
import flash.display.Sprite;
public class AlphaTest extends Sprite
{
public function AlphaTest()
{
var s:Sprite = new Sprite();
s.graphics.beginFill(0xFFFF00, 1);
s.graphics.drawCircle(0, 0, 10);
s.graphics.endFill();
s.x = s.y = 20;
addChild(s);
var s1:Sprite = new Sprite();
s1.graphics.beginFill(0xFF0000, 0.5);
s1.graphics.drawCircle(0, 0, 10);
s1.graphics.endFill();
s1.x = s1.y = 25;
addChild(s1);
}
}
}
 
Search WWH ::




Custom Search