【发布时间】:2017-04-24 19:58:46
【问题描述】:
为什么这种情况不断发生?我研究它并了解它们会有所帮助。 代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Security.Policy;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Pratice
{
public class CharacterClass
{
public Texture2D texture;
public Vector2 position, velocity;
public Rectangle SourceRect;
public string path;
public bool HasJumped;
public CharacterClass()
{
HasJumped = false;
position = new Vector2();
texture = null;
}
public void Initialize()
{
}
public void LoadContent(ContentManager Content)
{
path = "Character/BlueAnvil";
texture = Content.Load<Texture2D>(path);
}
public void Update(GameTime gameTime)
{
position += velocity;
//input Controls
KeyboardState keyState = Keyboard.GetState();
if (keyState.IsKeyDown(Keys.A))
position.X -= 5f;
if (keyState.IsKeyDown(Keys.D))
position.X = 5f;
if (keyState.IsKeyDown(Keys.Space) && HasJumped == false)
{
position.Y -= 10f;
velocity.Y = -5f;
HasJumped = true;
}
if (HasJumped == true)
{
float i = 1;
velocity.Y += 0.15f*i;
}
if (position.Y + texture.Height >= 450)
HasJumped = false;
if (HasJumped == false)
velocity.Y = 0f;
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(texture, position, Color.White);
}
}
}
我需要得到这个修复,这样我才能记住它。了解如何做到这一点,我需要帮助才能做到这一点。所以我需要帮助,以了解我做错了什么。
【问题讨论】:
-
“我的团队希望我成为高级程序员”——您希望我们为您完成这项工作,是吗?
-
我不明白为什么这不起作用。我身体不明白。为什么代码不起作用?它应该在屏幕上放置一个精灵,但它会产生一个错误
-
您是否为自己寻找答案而烦恼?这个确切的问题之前已经回答过很多次了。