Game Development Reference
In-Depth Information
move at a different speed than the more distant elements. If you have ever travelled
in a train or in a car watching the landscape from the window, you know what we are
talking about. When used correctly, this simple technique grants a very nice looking
illusion of depth for a 2D scrolling game.
Masking
The last technique we would like to describe for the creation of nice 2D assets for
your games is masking. Masking is a technique to edit images that allows the game
engine to display parts of those images as transparent.
It consists of putting your sprites on a homogenous background of some specific col-
or that is not used for any other graphic asset of the game, then setting that color as
transparent in the game engine. The engine will show the sprite, hiding the transpar-
ent part of the image.
There are actually two kinds of transparency which are used in game development.
Full transparency : This means that each part of the image is either visible
or invisible. To use full transparency, it is necessary to reduce the number of
colors of the image to 256 and then set one color as the transparent one in
the game engine. The engine will show all the colors of the image, except the
one you set as transparent.
Alpha transparency : This is a more refined technique that allows having a
full range of transparency for an image, from fully opaque to fully transparent.
For example, it allows representing part of an image as if you were looking at
it through a colored glass. To obtain the effect, a fourth channel, called the al-
pha channel, needs to be added to the already existing channels of an image
(red, green, and blue). A value of zero (black) in the alpha channel means
that that pixel is fully transparent, while a value of one (white) means that it is
fully opaque. Any intermediate value represents semi-transparency. A semi-
transparent pixel is composed partly with the image color and partly with the
background color, depending on the specific value set in the alpha channel
of that pixel.
Both full transparency and alpha transparency are supported by the *.png image
format, so save your graphic assets as *.png when you need part of them to be
transparent.
Search WWH ::




Custom Search