Jun
26
2011

Affordable RIA development USA- Silverlight development USA

Affordable RIA development USA- Silverlight development USA

Article by Softlogic







A Silverlight development tutorial that shows you how to create your own 2D web based games. This series attempts to recreate a game originally developed with Flash, and can be used to highlight the differences between the two platforms.

When it has come to displaying rich content on the web Flash was king. Its widespread deployment on Internet connected devices and the lack of any real competition made it the only choice for taking a web page beyond a static collection of pictures and text. The playing field is changing though. As web services start to take over from traditional desktop applications (you only need to look at Google Docs, Zoho and Buzzword for an example of this) some major players like Microsoft and Sun, not wanting to be left out of this Web 2.0 revolution, have introduced their own RIA (Rich Internet Application) platforms in the form of Silveright and JavaFX respectively.The series Flash Game Development with Flex and Actionscript looked at using Adobe Flex to create a Flash game in Actionscript that could be played in a web browser. In the interests of fairness this series will focus on recreating that same game with Silverlight using C#.To begin with we first need to set up a base for creating a game. This will involve creating a render loop, embedding and loading some resources, and finally displaying them to the screen. Let us start with the render loop.

When you create a new Silverlight project the Page.xaml and Page.xaml.cs files are created automatically. We will implement the render loop in the Page.xaml.cs file.

Page.xaml.cs C# Silverlight source codeIn Silverlight 1 creating a render loop was a complicated process involving storyboards and timelines. Thankfully in Silverlight 2 we have the ability to attach a function to the Composition Target. Rendering event, which is called before the screen is drawn. This gives us the starting point for our render loop. In order to distribute this event to other game objects we create an enterFrame event object. Our game objects will attach themselves to this event object which will be triggered once every frame, allowing the game objects to update them.

In order to use the render loop we create a class called BaseObject. This class will simply be a base for the game objects, and will expose a function called enterFrame to any class that extends it. This class will be expanded later on to include user input and collision detection, but for now its only purpose is to provide an easy way to tap into the render loop.

BaseObject.cs C# Silverlight source codeMaking use of the BaseObject class is the AnimatedGameObject. This class will display an animated bitmap sprite on the screen.AnimatedGameObject.cs C# Silverlight source code

The images used to make up the amination have been embedded (this is done simply by including the image files in the Silverlight Visual Studio project), and then accessed using a neat little utility class called ResourceHelper which you can download from http://www.silverlightexamples.net/post/Load-Bitmap-Image-From-Resource-in-a-Single-Line-of-Code.aspx. These images are then applied to a Rectangle object, which has been added to the main application canvas.

Lastly we need a place to create these new AnimatedGameObjects. For this we will create the ApplicationManager. It is the purpose the the ApplicationManager to "oversee" the game.

ApplicationManager.cs C# Silverlight source codeAs you can see the Application Manager is a very simple class, with the startup Application Manager creating two new Animated Game Objects. The startup Application Manager function itself is called from the Application_Startup function from the automatically generated App.xaml.cs file.

private void Application_Startup(object sender, StartupEventArgs e){this.RootVisual = new Page();ApplicationManager.Instance.startupApplicationManager();}

So as a starting point we have our render loop and some base classes that allow us to easily update game objects with the render loop and display bitmap animations. Check out the online demo, and download the source code from the Sourceforge SVN repository.

Is it confusing visit http://www.softlogiccorp.com community to see more information on this topic or call 302 613 0469 (USA) for more assistance.



About the Author

SOFTLOGIC INC. is one of the leading RIA development center in USA offshore dedicated RIA developers

Related Topics:

16 Comments + Add Comment

  • Can I simply say what a relief to search out somebody who really knows what theyre speaking about on the internet. You undoubtedly know methods to carry a difficulty to gentle and make it important. Extra individuals have to learn this and perceive this facet of the story. I cant believe youre not more common because you positively have the gift.

  • Thank you for the auspicious writeup. It actually used to be a leisure account it. Look complicated to far introduced agreeable from you! By the way, how can we keep up a correspondence?

  • This is the perfect blog for anyone who wants to know about this topic. You know so much its almost hard to argue with you (not that I really would want…HaHa). You definitely put a new spin on a subject thats been written about for years. Great stuff, just great!

  • Romania is now the trendsetter for popular music

  • My goal is to start a diet plan and stick to it for me and my two boys that i love so much I’m 26 and weight is 360 pounds my blood pressure is 190/120,i know real high.My family has a bad history for heart attacks and high blood pressure and even stroke I fear that if I don’t do something now I’m not going to be here for my family. So please help me thank you so very much

  • Excellent story once again. Thanks;)

  • Dear webmaster…

    thanks for the hard work on this blog….

  • Great blog you have here, awesome stuff! Are you going to keep updating? Cause I will be the first one here to read it :D

  • A person necessarily lend a hand to make significantly articles I’d state. This is the first time I frequented your web page and thus far? I amazed with the research you made to create this actual put up incredible. Fantastic process!

  • Did you create this report all by yourself! ?

  • Awesome content, theme you used is very nice as well ~ Hope you keep updating, I will def be back to read up on more of your posts.

  • Excellent read, I just passed this onto a friend who was doing some research on that. And he actually bought me lunch since I found it for him smile Thus let me rephrase that: Thank you for lunch! “England and America are two countries separated by the same language.” by George Bernard Shaw.

  • I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post

  • *very nice post, i certainly love this website, keep on it

  • The following time I read a weblog, I hope that it doesnt disappoint me as a lot as this one. I mean, I know it was my choice to learn, but I really thought youd have something fascinating to say. All I hear is a bunch of whining about one thing that you can fix should you werent too busy on the lookout for attention.

  • Amazing blog! I dont consider Ive observed all of the angles of this topic the way in which youve pointed them out. Youre a true star, a rock star man. Youve got so much to say and know a great deal regarding the topic that i think you ought to just teach a class about itHaHa!


Contact Info

Gorden Web Design
Soap Lake, WA 98851
(509) 230-4576

Click Donation Button Below

If you like our website you can help us out with a donation.



Paypal Buttons Powered By Gorden Web Design