我正在使用 XNA 和 C#。
我从我的particleEmitter
. 如果粒子是静态的或不移动的,我可以很好地绘制粒子。当我有一个向量变量设置为 (x,y) 的固定位置时,它可以在屏幕上绘制。但是,如果我有一个向量变量被设置为在 x 或 y 轴上移动,它根本不会绘制。
声明的变量:
Vector2 shipPos;
float shipMovement;
ParticleEngine particleEngine;
还有一种方法可以加载有关向量应该发生的事情及其行为方式的内容:
public void loadEmitter(GameTime gameTime)
{
shipMovement = 2f;
shipPos.Y -= shipMovement;
particleEngine.EmitterLocation = new Vector2(shipPos.X,shipPos.Y);
}
我正试图particleEngine
追踪一艘船的运动。当我设置它发生时,我似乎无法做的是让它绘制。
其他信息: ParticleEngine
它本身就是一个类,基本上设置了一些关于我将要绘制的粒子应该如何表现的参数。我有其他屏幕与spritebatch
Begin
和End
电话。除此之外,这是我的主要课程的代码:
namespace PlanetDrill2
{
class LaunchScreen : Screen
{
Texture2D LaunchScreenTexture;
Texture2D shipLaunch;
Vector2 shipPos;
float shipMovement;
ParticleEngine particleEngine;
Vector2 smokePos;
public LaunchScreen(Game game, SpriteBatch batch, ChangeScreen changeScreen)
: base(game, batch, changeScreen)
{
}
protected override void SetupInputs()
{
base.SetupInputs();
}
public override void Activate()
{
base.Activate();
}
public void LaunchShip()
{
}
public void loadEmitter(GameTime gameTime)
{
shipMovement = 2f;
shipPos.Y -= shipMovement;
particleEngine.EmitterLocation = new Vector2(shipPos.X,shipPos.Y);
}
protected override void LoadScreenContent(ContentManager content)
{
LaunchScreenTexture = content.Load<Texture2D>("launchTest");
shipLaunch = content.Load<Texture2D>("shipLaunch");
List<Texture2D> textures = new List<Texture2D>();
textures.Add(content.Load<Texture2D>("smoketexture"));
particleEngine = new ParticleEngine(textures, new Vector2(0, 0));
base.LoadScreenContent(content);
}
protected override void UpdateScreen(GameTime gameTime, DisplayOrientation screenOrientation)
{
//if (gameTime.TotalGameTime.Seconds>10)
//{
// changeScreenDelegate(ScreenState.UMA);
//}
loadEmitter(gameTime);
particleEngine.Update();
base.UpdateScreen(gameTime, screenOrientation);
}
protected override void DrawScreen(SpriteBatch batch, DisplayOrientation screenOrientation)
{
batch.Draw(LaunchScreenTexture, Vector2.Zero, Color.White);
batch.Draw(shipLaunch, new Vector2(80, 450) +shipPos, Color.White);
particleEngine.Draw(batch);
base.DrawScreen(batch, screenOrientation);
}
protected override void SaveScreenState()
{
base.SaveScreenState();
}
} // end class LaunchScreen
} // end namespace PlanetDrill2