C # development Wpf/silverlight animation and games series Tutorials (Game Tutorial): (38)

Source: Internet
Author: User
Tags silverlight

C # development Wpf/silverlight animation and games series Tutorials (Game Tutorial): (38) transmission and switching between maps

Finally to the last section of the map processing, this section I will explain how to achieve the main role of the map through the transfer point between the transfer and map between the switch. The key to map conversion is to grasp and add: To remove all objects except the protagonist in the previous map, and then reload all the objects on the new map. In this tutorial example game, each map's information is recorded in detail in the Config.xml configuration file, including the surface layer of each map, the occlusion layer, the barrier layer, and so on, and then attach the transfer point information that will be explained to you later in this section; So, when the map is converted, We simply read and load the corresponding map data according to the configuration file.

The first step to achieve, first, create a new transport point control: Qxteleport, which contains some of the parameter class attributes that are used for transport, such as the description tip of the transfer point, the Map index key of the transport point, the map code to which the transfer point corresponds to, the new coordinates of the protagonist after the transfer point transmission, and orientation , and the transport point control comes with a dispatchertimer for the delivery point animation form rendering.

Next, we will add the transfer point information for each map configuration parameter:

<Teleports>
<Teleport Code="6" Key="10" To="1" ToX="530" ToY="1040" ToDirection="1" X="600" Y="600" CenterX="64" CenterY="50" SingleWidth="128" SingleHeight="100" Tip="东海龙宫" FrameNum="15"/>
</Teleports>

These parameters correspond to the map information and the attribute information of the transport point itself, in the logic of the example game in this section, I record the key value of the transfer point to an array of obstructions (the current value of the array is 0 or 1, representing both the obstacle and the non obstruction, and the number of the other 2-255 can be used for our other purposes). When judging the value of the current obstacle array as the key value of a transfer point, the transfer event of the transmission point is triggered, and the lead is transmitted to the map specified by the leading actor:

Transfer to the new map, through some logic before the map resources removed, because the current example of the overall structure of the game has become complex, in the new content is constantly added, it is particularly redundant, so the specific code is not listed, we can from the source of their own experience. In addition, a map can contain a number of transmission points responsible for the transfer between multiple maps, the same, we only need to add multiple nodes in the configuration file, the following is the second map of the transfer point configuration:

<Teleports>
 <Teleport Code="6" Key="10" To="0" …… Tip="云海仙境" ……/>
 <Teleport Code="6" Key="11" To="2"…… Tip="天龙港" ……/>
</Teleports>

Next, let's move the protagonist to the transfer point, where the screen will switch to the second map:

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.