<< Chapter < Page
  Xna game studio     Page 2 / 9
Chapter >> Page >


  • Listing 1 . Beginning of the class named Game1.
  • Listing 2 . The constructor for the class named Game1.
  • Listing 3 . Beginning of the overridden LoadContent method.
  • Listing 4 . Compute the position of the UFO relative to the game window.
  • Listing 5 . Compute the base scale factor for the background image.
  • Listing 6 . Beginning of the overridden Update method.
  • Listing 7 . Apply dynamic scaling to the background image.
  • Listing 8 . Adjust the origin for the background image.
  • Listing 9 . Beginning of the overridden Game.Draw method.
  • Listing 10 . Draw the UFO.
  • Listing 11 . The class named Game1 for the project named XNA0124Proj.

General background information

Layer depth

When you draw two or more sprites using the SpriteBatch.Draw method, you can specify the z-order as the last ( layerDepth ) parameter to the Draw method. By default, a non-transparent sprite that is drawn with a layerDepth value of 0.0 will hide sprites drawn with greater layerDepth values. The greater the layerDepth value, the further back will be the sprite in the z-order, up to a maximum value of 1.0, which represents the extreme back of thez-order.

Color key transparency

During the design phase of project development, you can cause the program to interpret one specific color as being transparent by setting the Color Key Color property to that color and setting the Color Key Enabled property to true as shown in Figure 1 . Although I have never tried to do it, you can also apparently accomplish this at runtime by settingproperties of the TextureProcessor class.

Figure 1 . Property settings for green transparency.

missing image

Transparent green

Figure 1 shows the property settings required to cause every pixel having a color of pure green (0,255,0) to be replaced with transparent black, regardlessof the actual alpha value of the green pixel.

Store your image in a lossless image file

If you use this capability, you must be careful not to store your image in a file that uses lossy compression, such as a JPEG file. If you do, the pure colorthat went into the file is not likely to be pure when you later extract the image from the file. Instead, you should store your image in a lossless filesuch as a BMP file or a PNG file.

Be aware of the default values

Even if you don't plan to use this capability, you need to be aware of it. It seems that any time you add an existing image file to the content folder, the Color Key Enabled property will be true by default and the Color Key Color property value will be magenta (255,0,255). If you fail to disable the Color Key Enabled property, all of your pure magenta pixels will be replaced by transparent black pixels.

In the early days of computer graphics, magenta was the defacto standard transparency color. It was referred to as "magic pink."


In this module, I will present and explain an animated sequence in which a UFO flies over an alien planet. You will view the action as if the camerais trained on the UFO while maintaining a constant position relative to the UFO.

As the program runs, the planet gets larger and larger creating the illusion that the UFO is getting closer and closer to the surface of the planet. Finally,the program resets and the sequence repeats.

Questions & Answers

what is variations in raman spectra for nanomaterials
Jyoti Reply
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
yes that's correct
I think
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
scanning tunneling microscope
how nano science is used for hydrophobicity
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
what is differents between GO and RGO?
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
analytical skills graphene is prepared to kill any type viruses .
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
The nanotechnology is as new science, to scale nanometric
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
what school?
biomolecules are e building blocks of every organics and inorganic materials.
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
sciencedirect big data base
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, Xna game studio. OpenStax CNX. Feb 28, 2014 Download for free at https://legacy.cnx.org/content/col11634/1.6
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Xna game studio' conversation and receive update notifications?