TAILIEUCHUNG - Visual C# Game Programming for Teens phần 4

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

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.