我正在C#和XNA开展文明游戏.我使用一个二维整数数组,填充一个循环,生成瓷砖,我做了很多研究,并一直无法找到一种方法来生成类似地形的地球.任何人都可以解释如何做到这一点或至少给我代码可以做到这一点,虽然我更喜欢和解释?谢谢.
我正在尝试创建一个景深后期处理,但不知道从哪里开始(除了渲染深度图,我目前正在).它的所有教程都是针对XNA3.1,实际上没有给你解释,或者是书的一部分.
那么,您是否可以通过详细的逐步过程来了解DOF的呈现方式?
我正在和XNA一起玩游戏.我有相机,背景和滚动课程准备好了.
我缺乏的是在摄像机位置改变时告诉滚动工作.那是否有声明?
喜欢:
if (cameraposition.X ""Increases"")
{
Scrolling.Update()
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
我有以下代码:
BlockTypes[,] BackupQuad = EditModeBlocks.ListOfBlocks; //Create Backup
for (int x = 0; x < 16; x++)
{
for (int y = 0; y < 16; y++)
{
//Translate each point to the opposite side
EditModeBlocks.ListOfBlocks[15 - x, y] = BackupQuad[x, y];
}
}
Run Code Online (Sandbox Code Playgroud)
首先它构成一个backup(BackupQuad),然后循环遍历备份数组中的每个"块".然后它从备份数组中读取块并将其重写为原始数组15-X.(我也尝试了16-x,但没有工作).它在很大程度上起作用,但它将一半复制到另一侧,删除那里的所有内容.

在一个不断崩溃的项目上工作。没有错误并显示出来,我的内存监视器告诉我一切正常,据我所见,我的代码中没有异常,只是停止工作,冻结。有没有办法在Visual Studio中查看函数调用的历史记录,以便我可以准确地确定程序在中断之前所做的最后一件事?
谢谢!
我是xna的新手,我正在制作一个RPG.当我尝试按项目构建时,我得到错误:
1)当前上下文中不存在名称"component":
if (component is DrawableGameComponent)
((DrawableGameComponent)component).Visible = true;
Run Code Online (Sandbox Code Playgroud)
2)当前上下文中不存在名称"content":
LoadContent(content);
Run Code Online (Sandbox Code Playgroud)
在"组件"的错误在发现GameScreen类和"内容"的错误在发现启动画面类.
为什么会发生这些错误?它们是什么意思?谢谢.
Game1.cs
namespace myRPG
{
/// <summary>
/// Default Project Template
/// </summary>
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
SpriteFont font;
//hold current state of the keyboard
KeyboardState keyboardState;
//hold previous state of the keyboard
KeyboardState oldKeyboardState;
//active screen will be set to either startScreen or actionScreen
GameScreen activeScreen;
StartScreen startScreen;
ActionScreen actionScreen;
CharScreen charScreen;
ClassScreen …Run Code Online (Sandbox Code Playgroud) 我正在创建一个太空入侵者类型的游戏并遇到错误.错误发生在Update函数内,两个for循环内.一个用于检查有多少外星人活着,一个用于检查外星人是否到达屏幕底部.
这是代码中的主要错误
if (rectShipBullet.Y + rectShipBullet.Height < 0)// Adding this will allow the player to fire a new bullet each time the player misses. If a minus symbol was used then the bullet would go off the screen far too early and not look realistic so the plus symbol is used instead.
ShipBulletVisible = "No";
int CountAliensAlive = 0;//Keeps track of how many aliens are alive.
for (int i = 0; i < rectSpaceInvader.Length; i++)
{
if (AlienAlive[i].Equals("Yes")) …Run Code Online (Sandbox Code Playgroud) 我得到了一些代码来检查玩家是否按下某个键.当玩家按下空格键时,精灵会上升.但我正试图在释放钥匙时将精灵设置回地面.这是我提出的代码:
keystate = Keyboard.GetState();
if (keystate.IsKeyDown(Keys.Right))
playerPosition.X += 2.0f;
else if (keystate.IsKeyDown(Keys.Left))
playerPosition.X -= 2.0f;
else if (keystate.IsKeyDown(Keys.Space))
{
if (keystate.IsKeyDown(Keys.Space))
playerPosition.Y -= 6.0f;
else if (keystate.IsKeyUp(Keys.Space))
playerPosition.Y += 6.0f;
}
Run Code Online (Sandbox Code Playgroud)
当没有按空格键时,我不希望精灵被移动.任何解决方案将不胜感激?
编辑:精灵确实向上移动,但永远不会下降!
所以这是我的第一个XNA项目,即我是一个完整的菜鸟.我正在制作一个基本的太空入侵者游戏,但我不能为如何为入侵者制作一个矩形阵列做出头脑或尾巴; 我目前所拥有的代码只是在一条长线中绘制它我看了其他答案,但到目前为止似乎都没有.
我有这个初始化:
InvaderArray = new Invader[5, 11];
int XPos = 200;
for (int rows = 0; rows < 5; rows++)
for (int cols = 0; cols < 11; cols++)
{
InvaderArray[rows, cols] = new Invader();
InvaderArray[rows, cols].SetXPos(XPos);
InvaderArray[rows, cols].SetYPos(100);
XPos = XPos + 50;
}
Run Code Online (Sandbox Code Playgroud)
这在Draw()方法中:
for (int rows = 0; rows < 5; rows++)
for (int cols = 0; cols < 11; cols++)
{
spriteBatch.Draw(Invader, InvaderArray[rows, cols].GetPos(), Color.White);
}
Run Code Online (Sandbox Code Playgroud)
我正在使用'Invader'类,如果这有帮助:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; …Run Code Online (Sandbox Code Playgroud)