嗨,我有这些向量:
Vector2 ground1p1 = new Vector2(0,430);
Vector2 ground1p2 = new Vector2(200,430);
Vector2 ground1p3 = new Vector2(0, 290);
Vector2 ground1p4 = new Vector2(280, 340);
我想把它们放在一个列表中,而不是这样做:
if (DetectPlayerAndGround1Collision2(playerPosition,ground1p1,player,ground1) == true)
{
hasJumped = false;
velocity.Y = 0f;
}
if (DetectPlayerAndGround1Collision2(playerPosition, ground1p2, player, ground1) == true)
{
hasJumped = false;
velocity.Y = 0f;
}
这是我在文字末尾写“向量”时的问题,没有任何事情发生,就像我没有声明为列表一样:
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
base.Initialize();
}
bool hasJumped = true;
Vector2 velocity;
Texture2D player;
Texture2D ground1;
List<Vector2> vectors = new List<Vector2>();
Vector2 playerPosition = new Vector2(30, 300);
Vector2 ground1p1 = new Vector2(0,430);
Vector2 ground1p2 = new Vector2(200,430);
Vector2 ground1p3 = new Vector2(0, 290);
Vector2 ground1p4 = new Vector2(280, 340);