使用 MonoGame 進行遊戲開發的簡介Introduction to Game Development with MonoGame

這個多部分的逐步解說會示範如何使用 MonoGame 建立簡單的2D 應用程式。 其中涵蓋常見的遊戲程式設計概念,例如圖形、輸入、遊戲實體和物理。This multi-part walkthrough shows how to create a simple 2D application using MonoGame. It covers common game programming concepts, such as graphics, input, game entities, and physics.

本文說明用於製作跨平臺遊戲的 MonoGame API 技術。This article describes MonoGame API technology for making cross-platform games. 如需完整的平臺清單,請參閱MonoGame 網站For a full list of platforms, see the MonoGame website. 本教學課程將C#使用來執行程式碼範例,雖然 MonoGame 也F#能夠完全運作。This tutorial will use C# for code samples, although MonoGame is fully functional with F# as well.

MonoGame 是跨平臺的硬體加速 API,提供圖形、音訊、遊戲狀態管理、輸入,以及用於匯入資產的內容管線。MonoGame is a cross-platform, hardware accelerated API providing graphics, audio, game state management, input, and a content pipeline for importing assets. 不同于大部分的遊戲引擎,MonoGame 不會提供或強加任何模式或專案結構。Unlike most game engines, MonoGame does not provide or impose any pattern or project structure. 雖然這表示開發人員可以自由地組織其程式碼,但這也表示當第一次啟動新專案時,需要一些安裝程式碼。While this means that developers are free to organize their code as they like, it also means that a bit of setup code is needed when first starting a new project.

本逐步解說的第一節著重于設定空的專案。The first section of this walkthrough focuses on setting up an empty project. 最後一節涵蓋撰寫所有遊戲邏輯和內容,其中大部分都是跨平臺。The last section covers writing all of our game logic and content – most of which will be cross platform.

在本逐步解說結束時,我們將建立一個簡單的遊戲,讓播放程式可以透過觸控輸入來控制動畫字元。By the end of this walkthrough, we will have created a simple game where the player can control an animated character with touch input. 雖然這在技術上並不是一項完整的遊戲(因為它沒有任何獲勝或遺失的情況),但它會示範許多遊戲開發概念,並可做為許多遊戲類型的基礎。Although this is not technically a full game (since it has no win or lose conditions), it demonstrates numerous game development concepts and can be used as the foundation for many types of games.

以下顯示此逐步解說的結果:The following shows the result of this walkthrough:

遵循滑鼠後的範例遊戲字元動畫

MonoGame 和MonoGame and XNA

MonoGame 程式庫的目的是要以語法和功能來模擬 Microsoft 的「主要」程式庫。The MonoGame library is intended to mimic Microsoft’s XNA library in both syntax and functionality. 所有的 MonoGame 物件都存在於 MonoGame 中,可讓大部分的未修改的程式碼都能在中使用。All MonoGame objects exist under the Microsoft.Xna namespace – allowing most XNA code to be used in MonoGame with no modification.

熟悉的應用程式開發人員將已熟悉 MonoGame 的語法,而開發人員若要取得使用 MonoGame 的其他資訊,就能夠參考現有的線上的執行集區逐步解說、API 檔和討論。Developers familiar with XNA will already be familiar with MonoGame’s syntax, and developers looking for additional information on working with MonoGame will be able to reference existing online XNA walkthroughs, API documentation, and discussions.

逐步解說部分Walkthrough Parts