C # development Wpf/silverlight animation and games series Tutorials (Game Course): (ix)

Source: Internet
Author: User
Tags silverlight

C # development Wpf/silverlight animation and games series (Game Course): (ix) 2D game role on the map movement

This section will use the knowledge of the first two sections to the actual 2D game characters moving on the map, but also for the content of the front eight a comprehensive use of it.

Then start at the bottom of the map. First I add a map to the game window, where I also use the image control:

Image Map = new Image();
private void InitMap() {
 Map.Width = 800;
 Map.Height = 600;
 Map.Source = new BitmapImage((new Uri(@"Map\Map.jpg", UriKind.Relative)));
 Carrier.Children.Add(Map);
 Map.SetValue(Canvas.ZIndexProperty, -1);
}

I add a map picture of a 800*600 named Map.jpg to the Project Map folder, and then set its Canvas.ZIndex property to-1 so that it acts as a map background. With this map, we need to set the barrier to it:

As can be seen from the above picture, the ideal state, the obstacle for me to fill in the blue area, which is ideal for the setting of obstacles. But in practice, take this tutorial, because the gridsize is set to 20, then the obstacles we end up with will be this:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.