내가총알 충돌
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);
}
}
}
충돌 검사 :
적 그렇지총알 촬영을한다 0
foreach (BeeAi bee in Bees)
{
{
if (bullet.position == bee.position)
bulCol = true;
}
}
if (bulCol == true)
bullets.Clear();
제발 도와주세요!
태그가 말하는 C 코드가 표시되지 않습니다. –
이것이 C? –
글 머리 기호가 'velocity'값만큼 증가하는 것처럼 보입니다. 그러면 '꿀벌'의 위치를 바로 건너 뛸 수 있습니까? –