Bây giờ, ở đây là một chức năng rất quan trọng! Tại cốt lõi của nó, điều này về cơ bản là mã hoạt hình ma mà chúng ta đang vay mượn để làm cho công việc bảng gạch như một hình ảnh lớn duy nhất. | Building the Editor 123 adds mouse wheel support to scrollable controls DllImport private static extern IntPtr WindowFromPoint Point pt DllImport private static extern IntPtr SendMessage IntPtr hWnd int msg IntPtr wp IntPtr lp public bool PreFilterMessage ref Message m if 0x20a Point pos new Point 0xffff 16 IntPtr hWnd WindowFromPoint pos if hWnd hWnd hWnd null SendMessage hWnd return true return false Now here is a really important function At its core this is basically sprite animation code that we re borrowing to make the tile palette work as a single large image. When you select a tile the program figures out which tile you clicked on based on the dimensions of the palette image and known factors like the fact that there are five tiles across and that each tile is 32x32 pixels in size. This code is primarily of concern if we ever wanted to change the tile size to anything other than this size. public void setSelectedTile int sx selectedPaletteTile paletteColumns 33 int sy selectedPaletteTile paletteColumns 33 Rectangle src new Rectangle sx sy 32 32 Rectangle dst new Rectangle 0 0 32 32 dst src selectedBitmap 124 Chapter 6 Creating the Dungeon Editor Next up we have the core drawing functions used by the editor. A primary function drawTileNumber is used by the others and is therefore highly reusable. This function also handles the special data information Collidable Datal and the Tile values so if you wanted to add more information to the editor window this is where you can make those changes or additions . public void drawTileNumber int x inty int tile save tilemap data tilemap y mapSize x .tilenum tile draw tile i nt sx tile paletteColumns 33 i nt sy tile paletteColumns 33 int dx x 32 int dy y 32 Rectangle src new Rectangle sx sy 32 32 Rectangle dst new Rectangle