Unity 2D Game Development QuickStart 1th creating a simple 2D game
Even now, many novice game developers, when it comes to unity, still think unity can only be used to make 3D games. In fact, when Unity released its 4.3 release in 2013, it started offering support for 2D games. For example, there are some unity tools dedicated to developing 2D games. Now that Unity has released version 4.5, the support for 2D Games has improved a lot. To illustrate Unity's support for 2D games, this chapter uses these tools that are native to unity to develop a simple 2D game. This article was selected from theQuick start of Unity 2D game development
1.1 Ground
In general, we think the "ground" is the goal of the elves, without this "ground" spirit will fall. So the first step in creating a 2D game in this chapter is to create a "ground" for the game elves. The specific steps to create are: This article is selected from theQuick start of Unity 2D game development
(1) Create a new game project, name it, and set it to 2D project, as shown in 1-1. You can see that the game project is named world.
Figure 1-1 New Game Project
(2) Prepare a picture that will be used as the "ground" of the 2D game, and then import it into Project view of the new game project, 1-2, as shown in this example, the "ground" picture, named platform.
Tip 1: An easy way to import resources into a game project is to drag the corresponding resource directly under Project view. This method can be dragged into one or more resources at a time.
Tip 2: The process of making the game, will continue to import the resources needed for the game, if not in advance to make planning, the import of more resources will be very "messy", not only look uncomfortable, find up will be very troublesome. Therefore, it is best to develop a good habit of classifying and storing resources. In this example, the imported "ground" picture is placed in the Assets\textures\scenery folder.
Figure 1-2 in Unity, in Project view, is an imported picture
(3) Select Platform in Project view, and Inspector view displays the properties of the picture, as well as a preview view of the picture, as shown in 1-3.
Figure 1-3 The properties of platform are shown in the Inspector View
For this picture, there are several properties that need to be explained briefly:
Q Texture Type: Represents the types of pictures, different types are used differently in the project. For 2D game projects, the system is set to the default sprite (2d\ugui), and the default setting is texture for 3D game projects;
Q Filter Mode: This property has a total of 3 options: Point, bilinear, and Trilinear. After setting up, the picture is used in the game, the quality or the picture effect rises in turn. The default setting is bilinear.
Q Max Size: Represents the maximum size of a picture. In the game, sometimes the picture is used in different sizes, and the corresponding scaling is done. The actual size of the picture platform used in this example is 397x221, in order to not affect the quality of the picture, to set the Max Size property to be greater than 397, and the closest attribute to 397 is 512.
Q format: Represents the formatting of the picture. Set to bits to indicate that this picture is not a compressed picture, and that it can represent a color of "trillions" (216x216x216). This article was selected from theQuick start of Unity 2D game development
(4) To use this image in the game, you can drag the picture directly into the scene or hierarchy view. Unity will add this image object to the current game scene, select the Picture object in the game scene, and then set its properties under the transform component in the Inspector view, as shown in 1-4,
Q Position: (0,0,0);
Q Rotation: (0,0,0);
Q scale: (1,1,1);
Figure 1-4 Picture objects added to the game scene, and their property settings
(5) "Ground" object has been added to the scene view of the game, but it can not "stand" any genie, that is, it will be like the presence of air, any genie standing on it, will be like stepping on the air as "whereabouts." So you need to add collider to the "ground" object, a total of 4 classes of this component, 1-5. Different types are suitable for objects of different shape shapes, because the shape of the "ground" object is irregular, this example chooses to use the Polygon Collider component. This article was selected from theQuick start of Unity 2D game development
To add this component to the ground object, select the object in the scene, and then click component| Physics 2d| Polygon Collider 2D command. After adding this component, looking at the "ground" object in the scene, it will find its surface "covered" with a green line, which is wrapped around the object, 1-6. This article was selected from theQuick start of Unity 2D game development
Figure 1-5 Class 4 Collider components Figure 1-6 added effect of polygon Collider
Unity 2D Game Development QuickStart 1th creating a simple 2D game