Source SDK Game Development Essentials
上QQ阅读APP看书,第一时间看更新

Navigating in 2D

Navigating in 2D is a bit different than 3D. Each 2D window has scroll bars like any webpage or text document, but there are some tips and tricks that can streamline the process.

Moving around

You can zoom in a 2D view by scrolling up the scroll wheel. Scrolling the scroll wheel down will zoom out. If you do not have a scroll wheel on your mouse, the magnify tool will be your best friend.

Moving around

The magnify tool works just how you would expect it to: left-click to zoom in and right-click to zoom out.

Tip

The + and buttons on the keypad will also zoom in and out in 2D views if your cursor is inside one of them.

The minimum zoom (all the way out) is 0.01. The maximum zoom (all the way in) is 256. The current zoom amount is indicated in the bottom-right corner of the status bar, as shown in the following screenshot:

Moving around

Panning the view is as easy as holding the Space bar and dragging the screen around with the left mouse button. You can also pan the view by using the up, down, left, and right arrows on the keyboard or using the scroll bars located to the right and bottom of each window.

Selecting objects in 2D

Just like the 3D view, selecting a brush in 2D is as easy as left-clicking on the center X, or one of the brush's edges. A selected object in the 2D view will be highlighted in red and have a yellow dashed line as a bounding box.

Selecting objects in 2D

Just like the 3D view, multiple objects can be selected by holding Ctrl and left-clicking every object you want to select. Thankfully, the 2D view does not fall to the same selection pitfall as the 3D window, and clicking the void with Ctrl pressed will not deselect everything! Another way to select an object is to drag a selection box around it. Left-click and drag a selection box around the brush. Make sure the selection box surrounds the brush in at least two 2D views, and then hit Enter to select everything inside of that box. Objects that intersect with the box area will also be selected.

Tip

The bounding box you draw while clicking and dragging will follow the grid resolution. To get a more accurate bounding box for selecting objects, try decreasing the grid size with [, or hold Alt to ignore the grid completely.

The grid

The grid helps keep your brushes organized, and by default, objects snap to it—meaning one or more edges will forced to be aligned to it. The grid size is based on powers of 2 (1, 2, 4, 8, 16, 32, and so on), and ranges from 1 to 512. The main gridlines are white, while the origin of the map (the 0, 0, 0 point) is highlighted in green, and every 1024 units is highlighted in red. The default grid size is 64 units, but you may change this any time. To increase the grid size, press the ] key. To decrease the grid size, press the [ button. The size of the grid is indicated in the status bar at the bottom-right corner of the screen. Working with a grid will ensure that objects touch each other. If you're making the map boundaries without a grid and two objects aren't touching, you could easily create a leak.

It's good practice to stay with a grid size of 4, 8, or 16 for most of your level development. Only small details should be created with smaller grid sizes; once you're done, return to a larger grid size.

The grid