XNA平台开发游戏中文教程
windowsphone开发第一个xna应用

本文向你介绍为Windows Phone 创建一个基本的XNA 框架应用,完整的代码可注意:下面的过程以Visual Studio 2010 Express for Windows Phone 开发工具为准。
下面我们开始整个开发过程:一. 创建新项目请使用以下步骤创建新项目:1.2.从开始菜单中启动Visual Studio 2010 Express for Windows Phone ,如果出现了注册窗口,你可以注册或者以后再说。
3.从菜单File 中选择New Project 来创建一个新项目4.如下图所示的新建项目窗口中,展开左边的Visual C# 模板,然后选择 XNA GameStudio 4.0templates.5.选择 Windows Phone Game (4.0) 模板,填写项目名称(随便你填什么)你也可以在这里指定项目存放的路径6.点击确定按钮,将会提示选择Windows Phone 平台,在这里我们选择 Windows Phone7.17.点击确定后将创建一个新的项目,并在Visual Studio 中打开Game1.cs 文件的源码二. 添加内容在这部分中,我们将添加一些图片和声音文件到项目中。
1.首先确认Visual Studio 中的解决方案浏览器可见,如果你找不到可以从菜单中 View |Other Windows | Solution Explorer 中打开2.我们先添加图形文件,在这里我们使用的是 PhoneGameThumb.png 文件,该文件默认存放在WindowsPhoneGame1\WindowsPhoneGame1\WindowsPhoneGame1 目录下。
你也可以使用自己的图片文件,但这个图片的像素必须是64 * 64。
右击内容节点,在这里我们是 WindowsPhoneGame1Content (Content), 然后选择 Add | Existing Item. 找到并打开你的图形文件WindowsPhoneGame1\WindowsPhoneGame1\WindowsPhoneGame1\PhoneGam eThumb.png然后点击添加,这样图形文件就添加到项目中。
XNA教程

namespace WindowsGame1
{
///
/// This is the main type for your game
///
partial class Game1 : Microsoft.Xna.Framework.Game //Game1继承于 Microsoft.Xna.Famework.Game
在3D 游戏中,比如 Halo,sprite 逐渐演变为了用于增加3D 图形需视知觉道效2D果纹的理纹储理存。了在在讨X 论和3YD方图向形上时,每我个们像会素详的颜细色讲信解它。
现在,简单的把 sprite 认为是2D 图形就可以了。
息。也可以就把 Texture2D 认为是一张图片。XNA 直接支持
protected override void Draw() { // Make sure we have a valid device if (!graphics.EnsureDevice()) return; graphics.GraphicsDevice.Clear(Color.CornflowerBlue); graphics.GraphicsDevice.BeginScene(); // TODO: Add your drawing code here // Let the GameComponents draw DrawComponents(); graphics.GraphicsDevice.EndScene(); graphics.GraphicsDevice.Present(); } }
很简单,所有程序都需要一个入口点,这里就是程序开始运行的地方。在 main 方法中,我们创建了 Game1类的一个 实例,并且调用了它的 run 方法。 来看看类 Game1,大部分工作都在这里完成。打开 Game1.cs 文件: using System; using System.Collections.Generic;
xna rpg9教学

Creating a Role Playing Game with XNA Game Studio 3.0Part 9Adding a Pop Up MenuTo follow along with this tutorial you will have to have read the previous tutorials to understand much of what it going on. You can find a list of tutorials here: XNA 3.0 Role Playing Game Tutorials You will also find the latest version of the project on the web site. If you want to follow along and type in the code from this PDF as you go, you can find the previous project at this link: Eyes of the Dragon - Version 8In today's tutorial I'm going to be adding a pop up menu to the project. Quite often you need to get a yes or no answer from the player. Pop up menus are a good way to do that. What I will do is make a new class that will inherit from GameScreen. Go a head and add a new class to the project called PopUpScreen. As usual, I will give you the code and then explain it.using System;using System.Collections.Generic;using System.Linq;using System.Text;using Microsoft.Xna.Framework;using Microsoft.Xna.Framework.Graphics;using New2DRPG.CoreComponents;namespace New2DRPG{class PopUpScreen : GameScreen{ButtonMenu menu;Texture2D image;SpriteBatch spriteBatch;Rectangle imageRectangle;public PopUpScreen(Game game, SpriteFont spriteFont, Texture2D image, Texture2D buttonImage): base(game){this.image = image;spriteBatch =(SpriteBatch)game.Services.GetService(typeof(SpriteBatch));imageRectangle = new Rectangle();imageRectangle.X = (game.Window.ClientBounds.Width - image.Width) / 2; imageRectangle.Y =(game.Window.ClientBounds.Height - image.Height) / 2;imageRectangle.Width = image.Width;imageRectangle.Height = image.Height;string[] items = { "YES", "NO" };menu = new ButtonMenu(game, spriteFont, buttonImage);menu.SetMenuItems(items);Components.Add(menu);}public int SelectedIndex{get { return menu.SelectedIndex; }}public override void Draw(GameTime gameTime){spriteBatch.Draw(image, imageRectangle, Color.White);base.Draw(gameTime);}public override void Show(){base.Show();menu.Position = new Vector2((imageRectangle.Width -menu.Width) / 2 + imageRectangle.X,imageRectangle.Height - menu.Height - 10 +imageRectangle.Y);}}}Since this is a visual game component I needed to add using statements for the XNA framework and the XNA graphics classes. I also had to add a using statement for the CoreComponents so I can inherit this screen from GameScreen.This screen has only one game component, a ButtonMenu component. I didn't add the background image like I did with other screens because I want this background to float on top of the other screens and have the other screens visible but not updating. Otherwise this screen is just like the StartScreen component. There are four variables in this class: the ButtonMenu component, the image for the menu, a SpriteBatch object and a Rectangle object for where the image will be drawn on the screen.The constructor takes four parameters: the Game ojbect, a SpriteFont, an image for the pop up screen and an image for the button. The constructor then sets the image for the component and gets the SpriteBatch object that was added to the list of services. Next the constructor finds where to draw the pop up menu on the screen. It takes half the heigh of the screen minus half the height of the image and does the same for the width. There are two items in this menu, YES or NO. The constructor then creates the menu, sets the menu items and adds it to the list of components.There is one public property for this component. The property is used to get the selected item in the menu.I added an override of the Draw method because I want to draw the image for the pop up screen. All the Draw method does is draw the image of the pop up screen using the Rectangle that was created in the constructor.The only other thing I did in this component was override the Show method. Just like I did in the StartScreen, I set the location of the menu.Instead of giving you all the changes to the Game1 class, I will just give you what has changed and what is new. The first new thing is I added a variable for the pop up screen.PopUpScreen quitPopUpScreen;I of course created the new screen in the LoadContent method. This is the LoadContent method:protected override void LoadContent(){spriteBatch = new SpriteBatch(GraphicsDevice);Services.AddService(typeof(SpriteBatch), spriteBatch);Services.AddService(typeof(ContentManager), Content);normalFont = Content.Load<SpriteFont>("normal");createPCScreen = new CreatePCScreen(this, normalFont);Components.Add(createPCScreen);background = Content.Load<Texture2D>("titlescreen");startScreen = new StartScreen(this,normalFont,background,Content.Load<Texture2D>(@"GUI\buttonbackground"));Components.Add(startScreen);background = Content.Load<Texture2D>("helpscreen");helpScreen = new HelpScreen(this,normalFont,background,Content.Load<Texture2D>(@"GUI\buttonbackground"));Components.Add(helpScreen);actionScreen = new ActionScreen(this, normalFont, "tileset1");Components.Add(actionScreen);actionScreen.Hide();background = Content.Load<Texture2D>(@"GUI\quitpopupbackground");quitPopUpScreen = new PopUpScreen(this,normalFont,background,Content.Load<Texture2D>(@"GUI\buttonbackgroundshort"));Components.Add(quitPopUpScreen);quitPopUpScreen.Hide();startScreen.Show();helpScreen.Hide();createPCScreen.Hide();activeScreen = startScreen;}Before I could do that though, I had to add two new images to the Content folder. I added them in the GUI sub-folder. You can find them in the Graphics file. I also change the other image for the button to match the new, smaller button image. So, open the GUI sub-folder in the Content folder and add these images: buttonbackground.jpg, buttonbackgroundshort.jpg and quitpopupbackground.jpg. The pop up screen was created and added to the list of components just like the other screeens.Of course there had to be a change made to the Update method to call a method to handle the input for the screen. There is no real mystery, I think, so I will just give you the new Update method.protected override void Update(GameTime gameTime){newState = Keyboard.GetState();if (GamePad.GetState(PlayerIndex.One).Buttons.Back== ButtonState.Pressed)this.Exit();if (newState.IsKeyDown(Keys.Escape))this.Exit();if (activeScreen == startScreen){HandleStartScreenInput();}else if (activeScreen == helpScreen){HandleHelpScreenInput();}else if (activeScreen == createPCScreen){HandleCreatePCScreenInput();}else if (activeScreen == quitPopUpScreen){HandleQuitPopUpScreenInput();}oldState = newState;base.Update(gameTime);}As you can see, the only change in the Update method was to handle the input for the new screen if it is the active screen.To test the screen, I made a change to the HandleStartScreenInput method. Instead of exiting the game if the quit option is selected, I stop the start screen from updating by setting the Enabled property to false. I set the active screen to the pop up screen and show the pop up screen. This is the new HandleStartScreenInput method:private void HandleStartScreenInput(){if (CheckKey(Keys.Enter) || CheckKey(Keys.Space)){switch (startScreen.SelectedIndex){case 0:activeScreen.Hide();activeScreen = createPCScreen;activeScreen.Show();break;case 1:activeScreen.Hide();activeScreen = actionScreen;actionScreen.Show();break;case 2:activeScreen.Hide();activeScreen = helpScreen;activeScreen.Show();break;case 3:activeScreen.Enabled = false;activeScreen = quitPopUpScreen;activeScreen.Show();break;}}}There is one thing left to do to use this screen. I needed to create a method that would handle the input for the screen. I called it HandleQuitPopUpScreenInput. It is like the other methods to handle input for the other screens. This the code for the HandleQuitPopUpScreenInput method:private void HandleQuitPopUpScreenInput(){if (CheckKey(Keys.Enter) || CheckKey(Keys.Space)){switch (quitPopUpScreen.SelectedIndex){case 0:this.Exit();break;case 1:activeScreen.Hide();activeScreen = startScreen;activeScreen.Show();break;}}}As you can see, all it does is check the selected index of the menu. If it is zero, the yes index, the game exits. If it is one, then it hides the screen, sets the start screen as the active screen and shows the start screen.Well, that is all for this tutorial. I will get to writing another one soon. Keep on coming back to the blog or the web site and I will try and have new stuff on both of them.。
XNA游戏开发输入控制、碰撞检测、面向对象

●键盘输入XNA中的用户输入可以由多种设备组合而成:键盘、鼠标、Xbox 360手柄、Xbox 360周边设备和Windows Phone 7触摸屏和加速器。
其中鼠标输入在Xbox 360和Windows Phone 7上不可用。
在Microsoft.XNA.Framework.Input命名空间中。
Keyboard类来处理。
Keyboard类有一个叫做GetState的静态方法,用键盘状态(KeyboardState)结构的形式返回键盘目前的状态。
Keys[] GetPressedKeys() 返回一个在方法被调用时被按下的键的数组bool IsKeyDown(Keys key) 返回true或false,取决于方法调用时参数所代表的按键是否被按下bool IsKeyUp(Keys key) 返回true或falseif(Keyboard.GetState( ).IsKeyDown(Keys.A))// BAM!!! A is pressed!●鼠标输入Mouse类也有一个GetState方法,能以MouseState结构的形式从鼠标返回数据。
LeftButton ButtonState 返回鼠标左键的状态MiddleButton ButtonState 返回鼠标中键的状态RightButton ButtonState 返回鼠标右键的状态ScrollWheelValue int 返回自游戏开始后鼠标滚轮滚动刻度的累加量.要想知道滚轮滚动了多少,把当前帧的ScrollWheelValue和上一帧的进行比较.X int 返回鼠标光标相对于游戏窗口左上角的水平位置(坐标).如果鼠标光标在游戏窗口的左侧,这个值是负值;如果在游戏窗口右边,这个值大于游戏窗口的宽度.XButton1 ButtonState 返回某些鼠标上额外的按键的状态XButton2 ButtonState 返回某些鼠标上额外的按键的状态Y int 返回鼠标光标相对于游戏窗口左上角的垂直位置(坐标).如果鼠标光标在游戏窗口的上方,这个值是负值;如果在游戏窗口下方,这个值大于游戏窗口的高度.●碰撞检测碰撞检测在几乎任何游戏中都是很关键的一个部分。
Cocos2D—X for XNA游戏开发指南(下)《TweeJump》项目实战

Cocos2D—X for XNA游戏开发指南(下)《TweeJump》
项目实战
刘凯威
【期刊名称】《程序员》
【年(卷),期】2012(000)007
【摘要】上一期我们介绍了CoCOs2D-X for XNA相对于COCOs2D—X的一些
变化,本期以一款名为《TweeJump》的小游戏为例,介绍了Cocos2d开发中的
游戏背景的设置、游戏主逻辑、集成OpenXLive SDK等开发实践,并列举了一些Cocos2D中常见的API。
【总页数】5页(P87-91)
【作者】刘凯威
【作者单位】不详
【正文语种】中文
【中图分类】TP311.13
【相关文献】
1.基于Cocos2d的迷宫游戏的设计与实现 [J], 李爱军
2.构建基于XNA游戏开发平台的三维游戏引擎 [J], 肖承勇;向伟铭
3.跨平台游戏开发利器 Cocos2D—HTML5开源2D游戏引擎介绍 [J], 林顺
4.Cocos2D-X for XNA游戏开发指南(上) [J], 秦春林
5.不管风吹浪打胜似闲庭信步——XNA Studio日益复杂的游戏开发过程下的微软应对之道 [J], 沙鹰(翻译)
因版权原因,仅展示原文概要,查看原文内容请购买。
7第1章XNA介绍

XNA的注意事项为了完成这一个章节,这里有另外一些关于XNA框架和XNA Game Studio Express 的技巧和窍门。
如你所见,你知识能够开始编码和顺利工作,但是当你运行遇到问题,或者不知道如何解决一个特定的问题,依赖于浏览器的一个个书签总是有好处的。
另外,这一个章节部分讨论了.NET和C#的一些优点,而且检验XNA与Managed DirectX之间的不同。
重要的超链接只是一些给你书签的链接。
/directx/xna/在微软MSDN上的XNA开发者中心页与XNA Game Studio和XNA框架论坛,它是你在Internet上发现的最活跃的XNA论坛。
在这里,你也能下载最近的XNA版本。
阅读FAQ,并且看更新的内容。
/wiki/Microsoft_XNA进入Wikipedia关于XNA,经常更新并且包含许多其他主题的链接。
网页底部有一些有用的外部链接被罗列。
好的新站点,有大量的链接、指南和让你开始在XNA世界的技巧。
-另外一个新站点,有大量的新闻,和一些实在有用的瓷片引擎指南。
也包含许多你可能喜欢的游戏组件。
-博客形式的XNA新闻网站,也包含一些视频教程,并且聚焦在学习XNA和图形工具的技巧和窍门。
-作者的官方网站。
在这里,你能找我做的更多游戏,连同Rocket Commander XNA,XNA Shooter,或来自于本书的竞速游戏,和所有文档和我为此而制作的视频指南。
另外,我建议检验Rocket Commander视频指南,它在Coding4Fun相当流行。
C#有利于开发游戏吗?像那样的网站,不断有论坛贯穿讨论C++和C#之间的差别。
通常在一些回复之后,它们都终结于一个无意识的语言战争。
回到.Net早期(2002)我讨论过相当多的这些思路,但是当99.9%的程序员站在C++一边那就太郁闷的了,而且没有办法使人信服,因为他们甚至不真诚对你。
不计主观感觉的好恶,语言战争不真正的把C#当作一门语言,因为JAV A做为游戏编程平台是失败的,除了蜂窝电话游戏以外。
XNA

XNA概述什么是XNAXNA中的X表示能够在WindowsXbox和合作伙伴之间达到跨平台的强大的软件工具。
N表示“下一代(Next-generation)”,A表示“架构(Architecture)”。
XNA是基于DirectX的游戏开发环境,是微软对于Managed DirectX 的修正及扩充版本。
开发背景微软于8 月13 日发表针对业余创作者所设计的游戏开发套件「XNA Game Studio Express」,提供没有专门开发器材的一般PC Windows XP 使用者开发跨Xbox 360 与PC 平台游戏的管道.XNA是Microsoft的下一代软件开发平台,致力于帮助开发者更快地开发更好的游戏。
详细介绍XNA Game Studio Express 是专业跨平台整合型游戏开发套件「XNA Studio」的简化版,以「Visual C# Express 2005」为基础,并针对业余创作者加以改良,提供简易的开发环境与详细的教学文件. XNA Game Studio Express 中将包含以.NET Framework 2.0 为基础、并加入游戏应用所需之函式库所构成的XNA Framework;由一系列工具所构成、让开发者能以更简易的方式将3D 内容整合到游戏中的XNA Framework Content Pipeline;以及教导使用者如何进行游戏开发的入门说明教学文件与范例. 所有Windows 使用者都可以免费下载使用Windows 版XNA Game Studio Express,所开发出来的游戏将可以自由在Windows 平台上进行商业性贩售.至于Xbox 360 的部分,则必须加入微软「XNA Creator?s Club」会员,方可于零售版Xbox 360 主机(硬盘必备)上进行游戏的开发、测试与游玩. XNA Game Studio Express 在2006年8 月30 日释出测试版,并于同年底释出正式版.透过完整的函式库、工具与教学说明文件,简易的开发环境以及低廉的费用,XNA Game Studio Express 将可提供有意愿的非专业创作者实现跨Windows 与Xbox 360 平台游戏开发的需求,对游戏创作有兴趣的玩家不妨多多留意.版本目前最新版本为Microsoft XNA Game Studio 4.0 RTM版。
XNA

我因为他是三个的被播放Xbox 的儿子已开始显示编程中的兴趣特别编写游戏。
此提示我要下载XNA 游戏Studio,并深入它自己,您知道,以便我可以教他。
我已经总是想要编写自己的游戏有与之无关。
确实。
XNA 游戏Studio 3.0 添加能够为这意味着在Zune 现在是一个移动的开发平台的Zune 编写游戏。
因此公平,er,游戏的将放置项目。
如果您已经是一个XNA 开发人员,我可能会查看您已了解的一些概念。
但如果您是我一样,属于enthusiastic 有关但非常熟悉游戏开发,程序员阅读。
C That Is Sharp man,在Microsoft 我十五年职业大部分,我一直在系统和驱动程序开发人员。
我选择和需要的语言已被一个相当bare bones C++。
我很少收到使用MFC 和 Framework 运行库。
为止,我无法甚至拼写STL 得进行的利用。
这是我一天的工作。
但我关闭时,我喜欢使用C# 播放周围。
通常,我编写小应用程序为我的Windows Mobile 的设备和有时我的PC。
C++ 不会将我不存在很多本机的开发人员,但我仍然得到有点giddy 我编写C# 中时。
您可以获取大量使用非常几行代码。
我swear,C# 是因此更有趣它们应使其controlled 实体。
在娱乐类别XNA 游戏Studio 在steroids 上是如C#。
通过有团队已经完成了使游戏开发简单的一个惊人的作业。
Framework 是简单、硬盘的内容很大程度上处理的和它们已发布的示例旨在讲授游戏开发在各个方面的大量。
开始。
从此处可以下载免费XNA 游戏Studio 3.0。
如果您已使用Visual Studio 2008 的各种的认知之一,XNA 游戏Studio 将与其集成。
如果您没有Visual Studio 2008,不要烦恼。
XNA 游戏Studio 还使用免费Visual C# Express Edition。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
(一) XNA Build入门中文教程-Hello world
为配合XNA的推出,我们特地翻译和润色了XNA的HELLO WORLD例子,对于入门来说是不可多得的靓文. 另外我们群里会有更多资料(中文, 英文, 视频, 群友开发的XNA游戏例子等共享和交流信息) 欢迎一起研究和发展XNA, 在这里您也可以找到合作的对象呀(比如美工等).
Creating a Basic XNA Build Project 我们这个教程将向您演示如何使用XNA Build建立一个新的工程项目, 并为其添加一个任务(task), 并对这个任务(task)组件的参数和属性做一些设置, 最后就是编译XNA工程项目并查看编译报告.
整个教程包括以下步骤: 1. 建立一个全新的XNB Build项目 2. 给项目添加一个任务(task)组件. 3. 修改message任务(task)组件的属性. 4. 编译这个XNB Build项目 5. 最后是查看编译的报告
具体操作细节如下:
建立一个全新的XNB Build项目 按照下面的步骤创建XNA Build 项目 1. 启动Visual Studio 2. 选择 File -->New, 并按下 Project菜单. 3. 按下Project Types 面板的XNA Build Project 4. 为新项目输入一个项目名称.由于这次是HELLO WORLD演示,所以您可以把项目取名为HELLO WORLD(HELLO和WORLD之间可以有空格) 5. 按下OK. 现在你将能看到XNA Build标准的开发面板
给项目添加一个任务(task)组件 一个XNA Build项目包含一个或者多个按照设定顺序执行的任务(tasks)组件, 这些任务组件可以是由MSBuild提供的标准任务组件, 也可以是XNA Build提供的XNA特殊专用任务组件, 还可以是由您或者第三方提供的客户化组件. 所有的这些组件都会在XNA Build里按照功能分组并在左侧的Toolbox面板里显示候用. 请您按照下面的步骤给XNA项目添加任务(task)组件 1. 在左侧的 Toolbox窗口里选择XNA任务组件面板. 2. 把其中的Message 任务组件用鼠标拖到中间的设计面板上. 3. 选择 Message 任务组件的框图 (任务组件图). 现在右侧的属性窗口(Properties window)将显示出当前所选组件的相关属性. 如果您看不到属性窗口(Properties window), 请您按下F4即可显示. 4. 修改任务组件的名词.具体的操作方法是右键选择任务组件,并在弹出的菜单里选择Rename选项, 接着就可以输入Helloworld一词作为该组件的名称(注意,Hello和World之间不能右空格).
修改message任务(task)的属性 当您选择了一个任务组件,则该组件默认的属性值会显示在右侧的属性(Properties)窗口里, 这些属性值将用来告诉相应的任务组件做怎样的动作. 您也可以修改这些属性值,具体的操作步骤如下: 1. 用鼠标点击选择HelloWorld任务组件图. 属性(Properties)窗口将显示两个相应的属性: Importance 和 Text. 2. 在属性窗口上修改Text 属性的值为”HelloWorld”(注意,Hello和World之间不能右空格). 接着按下回车键即可.
编译这个XNB Build项目 现在我们这个XNA Build项目包含了一个任务组件. 接着请您按照下面的步骤编译这个项目,体验一下XNA Build的功能示例. 1. 选择 File --> Save HelloWorld 菜单. 2. 如果您没看到 Output 窗口, 请按下 View --> Output即可. 3. 接着请您选择 Build --> Build Solution 菜单. 编译开始了, 这样您就可以在Output窗口实时地看到编译状态了. 在这个教程粒子里,您应该可以在Output窗口看到”HelloWorld” 信息的输出.
最后是查看编译的报告 经过成功的编译后,您应该可以在设计窗口中央看到一个显示编译报告的新窗口. 你可以使用TAB键来回切换设计窗口和编译报告窗口.
在编译报告里我们可以注意到,在我们这次的演示里只使用了一个任务组件,而这个任务组件在编译过程中输出了”HelloWorld”信息.
(二)
Tutorial 2:基本构造和追加模型
我们这个教程将接着向您演示Tutorial 1的XNA建立的项目,是关于怎样创建一个资源组(asset group)并使他在任务中发挥用处
整个教程包括以下步骤: 1. 打开一个已有的XNA建立的项目 2. 在本项目上增加资源组(asset group) 3. 将刚建立的资源组(asset group)同现有的任务联系起来 4. 在组里添加标签 (items) 5. 浏览HelloWorld 任务里的道具修改。 建立XNA项目
浏览项目报告 运行一个现有的XNA项目 使用以下逐步的做法打开一个现有的XNA项目。
1. 首先执行Visual Studio 2. 在文件(File)菜单, 点击打开(Open), 和然后点击项目(Project/Solution)。 3. 找到您从Tutorial 1 保存HelloWorld 项目的路径, 并且选择HelloWorld.sln 文件。
4. 点击OK 现在, 与其它窗口一起,设计界面(design surface)中将出现并包含在先前教程中出现的的HelloWorld 任务(task)。
新增一个资源组(Asset Group)至Build中 要为一个特定的项目提供数据的输入,你可以指派一个代表资料输入的资源组(Asset Group)至这个项目中。以下提供每一步的指南。
1. 在Toolbox窗口中,按Design 项目板。 2. 拖拉资源组 (Asset Group) 项目至设计版面上。 3. 在Solution Explorer 标签上,指着Asset Group的图标按右键,再选Rename。
4. 输入 “ImageList” 作为新的名字,注意Image 和 List之间是没有空格的
新增一个对象至资源组(Asset Group) 用以下的几个步骤来新增档案至ImageList资源组项目中,这些档案将会在以后的过程中使用。
1. 在Solution Explorer板上,指着ImageList按右键。 2. 按Add,再按Existing Item。 3. 用Add Existing Item对话框来新增五个存放在C:\Program Files\XNA\Tutorials directory 的 .PNG档案
把资源组(Asset Group)结合至现有的项目 要在HelloWorld项目使用把输入了的数据,HelloWorld项目必须与ImageList资源组结合在一起。要产生此连结,需要使用一个Connector项目。按着以下步骤来进行结合。
1. 在Toolbox窗口中,按Design项目板。 2. 按Connector项目 3. 按右边的ImageList项目卷标,拖放到左边的HelloWorld项目卷标上,一个显示着HelloWorld项目中可以与ImageLIst结合的属性菜单就会出现。
4. 按Text。 5. 按在Design项目板内的Pointer,这可令预设的pointer重新工作。 一个connector已经在ImageList和HelloWorld项目中。现在,在ImageList中的内容就可以透过Text的属性传到HelloWorld中。
预览(View)HelloWorld 任务的modified properties 同HELLOWORLD消息任务的“Text”属性紧密相关的ImageList组(ImageList asset group)将取代具有典型“MSBuild”语法特征的工具创造出来的内容属性具有的"Text"属
性值。 预览(View)modified properties , 在设计面板上, 点击HelloWorld message任务shape。可以在Properties窗口观察到, Text property的价值被改变了从HelloWorld 到HelloWorld;@(ImageList) 。
创建XNA项目 这个演示里做了些必要的改动。在以下步骤里说明了怎样新建项目和新增加的内容。 1. 在文件(File)菜单, 点击保存(Save)HelloWorld 。 2. 在浏览View菜单, 如果你没看见输出(Output)窗口点击输出(Output) 3. 在Build菜单, 点击Build Solution. 4. 创建开始, 和您将看在窗口上实时显示创建状态(注:类似即时渲染)。在这种情况下, HelloWorld信息连同输入的文件的目录一起被显示。
浏览创建报告 在成功的创建后,你将注意到创建报告的面板出现主窗口 这时候设计面板是开放的 但是它被创建报告遮着。使用tabs located让起在顶层显示设计面板和创建报告 。从创建报告面板显示的每个的名字是在ImageList组文件(ImageList asset group. )。
(三)
指南 3: 定制任务 这个过程延续指南2中描述的如何建立XNA Build工程. 此过程将告诉你如何在XNA Build 系统中建立和添加一个定制的任务, 并且接下来还将告诉你如何在build pipeline
中进行这个任务
这个过程主要围绕下面各个步骤展开.
1. 安装 ConvertToJpegTask 任务 2. 打开一个已创建的XNA Build工程 3. 从设计界面中删除一个任务 4. 增加一个 ConvertToJpegTask 任务到当前项目 5. 操作转化进程
安装 ConvertToJpegTask XNA Build不需要借助XBOX360也可以进行各种有用的工作. 然而, 添加定制的任务对于一些特别的游戏工作室的特殊需要来说通常是必需的. XNA Build 对于定制的任务提供非常高扩展性的插件模型.安装定制的任务是一个将所有工具放置入一个目标目录的简单过程
创建一个被称为“MyCustomTasks”的子目录,它存在于C:\Program Files\MSBuild\Microsoft\XNA\Plugins directory中.
复制定制的任务集 (Microsoft.Xna.Utilities.ConvertToJpeg.dll) 到一个新的目录.这个集合被安置在C:\Program Files\XNA\Tutorials\.