Silverlight Game Design Tutorial
| < previous page |
Every game needs graphics. (Actually there are some games that have no graphics, and they usually sucks). Anyway graphics are really important to a game and here we are going to learn how to display graphics.
By the end of this tutorial you will have created a project that looks like this:
Adding Images
1. First of all, you need to find a picture that you want to display on the screen.
2. Click project -> Add existing item, then select the image you want. In this example, I selected the file "hello.png". You'll see this file added in the solution explorer.
3. Simply type these codes into your "Page.xaml.cs" file
using System.Windows.Media.Imaging;
namespace GameExample
{
public partial class Page : UserControl
{
Image img = new Image();
public Page()
{
InitializeComponent();
BitmapImage bmpImg2 = new BitmapImage();
bmpImg2.UriSource = new Uri("hello.png", UriKind.Relative);
img.Source = bmpImg2;
LayoutRoot.Children.Add(img);
}
}
}
4. Hit F5 to see the image displayed on your web browser.
Good job! So here's the explanation to the code above. First we declare an Image called img. To assign actual graphics data into it, we create a BitmapImage, and tell application to get this bitmap source from "hello.png" (which is the file name). After that we assign this BitmapImage to the actual Image component by doing img.Source = bmpImg2. The last important thing though, is that you have to add the following line - "using System.Windows.Media.Imaging;" in order to add images to your application.
| < previous page |
Comments:
2012-01-25 16:07:03 Hhewbkpr wrote:
I've come to collect a parcel |
2012-01-25 15:42:40 Xxjqfxeu wrote:
I'm only getting an answering machine |
2011-09-11 09:09:56 Szwekdgb wrote:
No, I'm not particularly sporty |
2011-09-11 08:52:36 Sbmffjso wrote:
Whereabouts in are you from? |
2011-07-13 23:41:18 Cathleen wrote:
And I thought I was the sensible one. Thanks for setnitg me straight. |
2010-10-30 18:31:59 Rmwpxrtw wrote:
Wonderfull great site |
2010-10-30 18:31:58 Ruadenkr wrote:
Punk not dead |
2010-10-30 18:31:58 Imwlhlmm wrote:
Very interesting tale |
2010-10-30 18:31:57 Vgwntdxl wrote:
This site is crazy :) |
2010-10-30 18:31:56 Mppykqgu wrote:
Good crew it's cool :) |
2010-10-30 18:02:56 Eswezbvv wrote:
Very Good Site |
2010-10-30 18:02:49 Cqwoquii wrote:
2010-10-30 18:02:44 Eaxqfwkp wrote:
this is be cool 8) |
2010-10-30 18:02:38 Tgnsigqn wrote:
Very funny pictures |
2010-10-30 18:02:31 Qjkicshu wrote:
Cool site goodluck :) |
2010-10-30 17:30:25 Skivfmrm wrote:
This site is crazy :) |
2010-10-30 17:30:21 Akstnlvg wrote:
I'm happy very good site |
2010-10-30 17:30:17 Abqrzrtn wrote:
Excellent work, Nice Design |
2010-10-30 17:30:13 Jigrqdca wrote:
Very funny pictures |
2010-10-30 17:29:54 Jybuopiu wrote:
Jonny was here |
2010-10-30 17:01:13 Jcnwziok wrote:
this is be cool 8) |
2010-10-30 17:01:07 Kavpnoho wrote:
Very funny pictures |
2010-10-30 17:00:59 Gwzrhcwl wrote:
Good crew it's cool :) |
2010-10-30 17:00:51 Tmroftdn wrote:
I'm happy very good site |
2010-10-30 17:00:43 Eikgvkza wrote:
real beauty page |
2010-10-11 17:56:18 gfdggdfg wrote:
9lh5qk pepyaka |


