Xna 4.0で2Dシューターを作っています
ゲームに弾丸があり、それを敵と衝突させようとしていますが、その位置が敵と等しいかどうかを確認しようとすると、一致しません
弾丸射撃:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
namespace Moba_Turtle1
{
class Bullet
{
Texture2D bulText;
float timer;
float interval = 2;
public bool shot = false;
public Vector2 velocity;
bool canChange = true;
public Vector2 position;
public Vector2 lastPosition;
Vector2 orgin;
public Bullet (Texture2D newText, Vector2 newPos)
{
bulText = newText;
position = newPos;
}
public void Update (GameTime gameTime)
{
if (Moba_Turtle1.Character.direction == true && canChange == true)
{
canChange = false;
velocity.X = 50f;
}
if (Moba_Turtle1.Character.direction == false && canChange == true)
{
canChange = false;
velocity.X = -50f;
}
position = position + velocity;
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(bulText, position, null, Color.White, 0f, orgin, 1.0f, SpriteEffects.None, 0);
}
}
}
衝突チェック:
foreach (BeeAi bee in Bees)
{
{
if (bullet.position == bee.position)
bulCol = true;
}
}
if (bulCol == true)
bullets.Clear();
助けてください!