这是一个简单的问题,但我无法在其他任何地方找到答案.
我是编程新手,我在C#中编写了一个完整的桌面游戏.我想用XNA代表它.我希望游戏打开简单的控制台应用程序(我已经拥有)和游戏可视化.
我的想法是让玩家在向XNA窗口发送数据之前轮到他,并让它读取数据并相应地更新它的图像.除了简单地接收数据并更新它的图形之外,XNA窗口不需要做任何其他事情.我只是想知道这是否可行,如果有更简单的方法,如果我应该使用Visual Studio Windows窗体应用程序而不是XNA.
提前致谢.
我有一个问题,我无法解决如何解决.
我在模型中进行了远程验证,如下所示:
[Required]
[Display(Name = "Social Security Number:")]
[Remote("IsSocialSecurityNumberValid", "Applicant", ErrorMessage = "Invalid.")]
public string SocialSecurityNumber { get; set; }
Run Code Online (Sandbox Code Playgroud)
但我想申请另一个验证,即:
[Remote("SocialSecurityNumberExists", "Applicant", ErrorMessage = "Already exists.")]
Run Code Online (Sandbox Code Playgroud)
但是mvc不允许我添加两个远程属性.我怎么能解决这个问题?
谢谢您的帮助.
我无法理解如何计算二维空间中移动圆的法线.我已经得到了我想要计算物体的速度法则(方向速度),但这就是我的大学代数思维过热的地方,任何我正在使用我所拥有的2d圈子中心点,半径,速度和位置.
最终我想要使用Vector2.Reflect方法从这个练习中获得更逼真的物理效果.
提前谢谢.
编辑:添加了一些代码尝试建议(没有用),可能误解了这个建议.在这里,我使用篮球和棒球,因此基地和篮子.我还有位置和速度,它被添加到位置以创建运动.
if ((Vector2.Distance(baseMid, basketMid)) < baseRadius + basketRadius)
{
Vector2 baseNorm = basketMid - baseMid;
baseNorm.Normalize();
Vector2 basketNorm = baseMid - basketMid;
basketNorm.Normalize();
baseVelocity = Vector2.Reflect(baseVelocity, baseNorm);
basketVelocity = Vector2.Reflect(basketVelocity, basketNorm);
}
basePos.Y += baseVelocity.Y;
basePos.X += baseVelocity.X;
basketPos.Y += basketVelocity.Y;
basketPos.X += basketVelocity.X;
basketMid = new Vector2((basketballTex.Width / 2 + basketPos.X), (basketballTex.Height / 2 + basketPos.Y));
baseMid = new Vector2((baseballTex.Width / 2 + basePos.X), (baseballTex.Height / 2 + basePos.Y));
Run Code Online (Sandbox Code Playgroud) 我对xna很新.我刚刚创建了一个透明背景(品红色)的精灵.问题是我的Rectangle正在读取整个精灵的坐标而不是可见的精灵.如何使它只读取可见的精灵.
myrectangle = new Rectangle(0, 0, box.Width, box.Height);
Run Code Online (Sandbox Code Playgroud)
我想将可见部分放在那个位置不透明.提前致谢.
我是一名经验丰富的开发人员,但对于图形/游戏编程来说,这是一个非常棒的人,所以请 - 向我解释一下,就像我是一个5岁的孩子.
我正在写一个简单的游戏,以学习游戏编程.我使用Paint.NET创建了一个*.png图像,并使图像透明50%.然而,当我加载图像时,它似乎没有任何透明度渲染.该对象看起来像纯色.(为了清楚起见,我试图让整个图像半透明或"透视",而不仅仅是制作一个透明背景的实体图像.虽然我也希望能够做到这一点.)
我很乐意展示任何可能有用的代码,尽管你可以假设我在这里没有做任何想法.例如,加载纹理:
var Texture = content.Load<Texture2D>("Gamepiece");
Run Code Online (Sandbox Code Playgroud)
并绘制它:
spriteBatch.Draw(Texture, Location, Color.White);
Run Code Online (Sandbox Code Playgroud)
我的begin语句使用默认值.我没有传递任何参数(无论如何我都不了解它们).
spriteBatch.Begin();
Run Code Online (Sandbox Code Playgroud) 我正在使用C#开发聊天程序,我使用ListBox管理昵称列表.但是,客户有昵称和州(在线,离开)
所以,为了管理状态,我想在ListBox中添加图像(在线 - 绿色圆圈,远离红色圆圈)(这是我的想法)
如何将图像添加到ListBox?请帮我.
谢谢.
我是XNA的新手,我开始遵循一个在屏幕上绘制图像的教程.我能够将我的图像移动到Content文件夹中,但是当我尝试在我的代码中使用它时,无法找到它.
我正在使用资产名称而我找不到我做错了什么.教程使用XNA 3.0,我使用的是Visual Studio 2010,不确定是否重要.
这是我的代码
public class Game1 : Microsoft.Xna.Framework.Game
{
Vector2 mPosition = new Vector2(0, 0);
Texture2D mSpriteTexture;
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
mSpriteTexture = Content.Load<Texture2D>("Face");
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{ …Run Code Online (Sandbox Code Playgroud) 我正在使用XNA 3.0并尝试创建一个精灵类,但我不确定如何处理它.我是否在精灵类中执行动画?我的代码也一直收到错误
Game1.cs
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
Sprite.Draw(spriteBatch);
base.Draw(gameTime);
}
Run Code Online (Sandbox Code Playgroud)
Sprite.cs
private static Texture2D rings;
Point rings_frameSize = new Point(75, 75);
Point rings_currentFrame = new Point(0, 0);
Point rings_sheetSize = new Point(6, 8);
int ms_elapsedRings = 0;
public static void setup_sprites(ContentManager Content)
{
rings = Content.Load<Texture2D>("Images/threerings");
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(rings,
new Vector2(0,0),
new Rectangle(rings_currentFrame.X * rings_frameSize.X, //X component of where to begin
rings_currentFrame.Y * rings_frameSize.Y, //Y component of where to begin
rings_frameSize.X, //cell …Run Code Online (Sandbox Code Playgroud) 我正在使用Libgdx:我有一个精灵应该在触摸屏幕时射球.touchPoint应该定义球的方向.我无法弄清楚如何以正确的方向旋转和拍摄.
public void update(float deltaTime) {
double angle = Math.toRadians(Math.atan2(position.y, position.x));
position.x = (float)Math.cos(angle) * position.x - (float)Math.sin(angle) * position.y;
position.y = (float)Math.sin(angle) * position.x + (float)Math.cos(angle) * position.y;
}
Run Code Online (Sandbox Code Playgroud)
球起飞,但射向错误.有没有办法使用Vector2.rotate函数?