Presentation is loading. Please wait.

Presentation is loading. Please wait.

XNA 4.0 簡介 靜宜大學資工系 蔡奇偉 副教授 © 2011. 大綱 XNA 簡介 XNA Framework XNA Build XNA Game Studio 建立 XNA 4 的專案 方案的目錄結構 XNA Game Studio 4.0 參考手冊 Hello, XNA XNA Game.

Similar presentations


Presentation on theme: "XNA 4.0 簡介 靜宜大學資工系 蔡奇偉 副教授 © 2011. 大綱 XNA 簡介 XNA Framework XNA Build XNA Game Studio 建立 XNA 4 的專案 方案的目錄結構 XNA Game Studio 4.0 參考手冊 Hello, XNA XNA Game."— Presentation transcript:

1 XNA 4.0 簡介 靜宜大學資工系 蔡奇偉 副教授 © 2011

2 大綱 XNA 簡介 XNA Framework XNA Build XNA Game Studio 建立 XNA 4 的專案 方案的目錄結構 XNA Game Studio 4.0 參考手冊 Hello, XNA XNA Game Loop Add a Sprite 參考資料

3 XNA 簡介 Provided by Microsoft A set of tools with a managed runtime environment that facilitates computer game development and management. XNA: XNA is Not an Acronymed Xbox New Architecture cross(X)-platform, Next-generation Architecture Available on Windows, Xbox 360, and Windows Phone 7

4 System Requirement

5

6 XNA Framework Based on.NET Compact Framework 2.0 for Xbox 360 development.NET Framework 2.0 Runs on a version of the Common Language Runtime that is optimized for gaming to provide a managed execution environment. Only supports C# programming language Integrates with a number of tools to aid in content creation Supports both 2D and 3D game creation Allows use of the Xbox 360 controllers and vibrations

7 XNA Build A game asset pipeline describes the process by which game content are modified to a form suitable for use by the gaming engine. XNA Build is a set of game asset pipeline management tools. Helps identify the pipeline dependencies. Provides API access to enable further processing of the dependency data. The dependency data can be analyzed to help reduce the size of a game by finding content that is not actually used.

8 XNA Game Studio 版本發表日期 VC# & VS 版本 XNA Game Studio Express12/20062003 XNA Game Studio 2.012/20072005 XNA Game Studio 3.010/20082008 XNA Game Studio 3.106/20092008 XNA Game Studio 4.009/20102010 XNA Game Studio is an integrated development environment (IDE) for development of games.

9 XNA Indie Games Xbox 360 games written in XNA Game Studio can be submitted to the Creators Club community, for which premium membership is required, this costs US$49 for 4 months or US$99/year. All games submitted to the community are subjected to peer review by other creators. If the game passes review then it is listed on Xbox Live Marketplace. Creators can set a price of 80, 240 or 400 points for their game. The creator is paid 70% of the total revenue from their game sales as a baseline. Microsoft originally planned to take an additional percentage of revenue if they provided additional marketing for a game, but this policy was rescinded in March 2009, leaving the flat rate intact regardless of promotion.

10 新增專案

11 新增 XNA Windows Game 專案

12 指定專案名稱 專案名稱,也將是專案目錄、 名稱空間與執行檔的名稱

13 設定方案目錄之所在 方案目錄所在位置

14 指定方案名稱 方案名稱,亦為方案目錄 的名稱

15 為方案建立目錄

16 確定專案之建立

17 專案之 IDE 視窗

18 方案總管 程式專案內容專案

19 方案的目錄結構

20 XNA Game Studio 4.0 參考手冊

21 Hello, XNA // File: Program.cs using System; namespace xnatest { #if WINDOWS || XBOX static class Program { /// /// The main entry point for the application. /// static void Main(string[] args) { using (Game1 game = new Game1()) { game.Run(); } #endif } 定義在 Game1.cs 檔案中的類別

22 // File: Game1.cs using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; namespace xnatest { /// /// This is the main type for your game /// public class Game1 : Microsoft.Xna.Framework.Game 可能用到的系統類別庫 繼承並依需求改寫後頁所述的方法

23 錄目此為定設 graphics Handles the configuration and management of the graphics device spriteBatch Enables a group of sprites to be drawn using the same settings.

24 /// /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// protected override void Initialize () { // TODO: Add your initialization logic here base.Initialize(); } Initialize ()

25 /// /// LoadContent will be called once per game and is the place to load /// all of your content. /// protected override void LoadContent () { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here } LoadContent ()

26 UnloadContent () /// /// UnloadContent will be called once per game and is the place to unload /// all content. /// protected override void UnloadContent() { // TODO: Unload any non ContentManager content here }

27 Update () /// /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// /// Provides a snapshot of timing values. protected override void Update (GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); // TODO: Add your update logic here base.Update(gameTime); }

28 Draw () /// /// This is called when the game should draw itself. /// /// Provides a snapshot of timing values. protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here base.Draw(gameTime); }

29 XNA Game Loop Initialize() LoadContent () Game quit? Draw () UnLoadContent () Y Update () N Exit

30 Add a Sprite 把 sprite 所用的圖片檔放入 Content 目錄 1. 在 Content 目錄中建立 Images 子目錄 2. 在 Images 目錄中加入圖片檔 載入 Sprite 繪製 Sprite

31 在 Content 目錄中建立 Images 子目錄 - I

32 在 Content 目錄中建立 Images 子目錄 - II

33 在 Images 目錄中加入圖片檔 - I

34 在 Images 目錄中加入圖片檔 - II

35 圖片的屬性頁

36 定義一個 Texture2D 型態的資料成員

37 載入圖片並存入 texture 中

38 繪製 sprite

39 程式執行結果

40 參考資料 Microsoft XNA Wikipedia Microsoft XNA Wikipedia Microsoft DreamSpark List of colors


Download ppt "XNA 4.0 簡介 靜宜大學資工系 蔡奇偉 副教授 © 2011. 大綱 XNA 簡介 XNA Framework XNA Build XNA Game Studio 建立 XNA 4 的專案 方案的目錄結構 XNA Game Studio 4.0 參考手冊 Hello, XNA XNA Game."

Similar presentations


Ads by Google