Note that there are some explanatory texts on larger screens.

plurals
  1. PO'particleEngine' being drawn against a vector
    primarykey
    data
    text
    <p>I'm using XNA and C#.</p> <p>I have a problem with calling a vector variable from my <code>particleEmitter</code>. I can draw the particle just fine if it is static or not moving. And when I have a vector variable that is set to a fixed position of (x,y) it's okay and draws on the screen. But if I have a vector variable that has been set to move in the x or y axis it does not draw at all.</p> <p>Declared variables:</p> <pre><code>Vector2 shipPos; float shipMovement; ParticleEngine particleEngine; </code></pre> <p>And a method that loads stuff about what should happen with the vectors and the way it should behave:</p> <pre><code>public void loadEmitter(GameTime gameTime) { shipMovement = 2f; shipPos.Y -= shipMovement; particleEngine.EmitterLocation = new Vector2(shipPos.X,shipPos.Y); } </code></pre> <p>I'm trying to get <code>particleEngine</code> to trail the movement of a ship. What I can't seem to do is get it to draw when I set this up to happen.</p> <p><strong>Other info:</strong> <code>ParticleEngine</code> is a class in itself and basically sets some parameters about how the particles I will be drawing should behave. I have other screens with the <code>spritebatch</code> <code>Begin</code> and <code>End</code> calls. Other than that, here's the code for my main class:</p> <pre><code>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&lt;Texture2D&gt;("launchTest"); shipLaunch = content.Load&lt;Texture2D&gt;("shipLaunch"); List&lt;Texture2D&gt; textures = new List&lt;Texture2D&gt;(); textures.Add(content.Load&lt;Texture2D&gt;("smoketexture")); particleEngine = new ParticleEngine(textures, new Vector2(0, 0)); base.LoadScreenContent(content); } protected override void UpdateScreen(GameTime gameTime, DisplayOrientation screenOrientation) { //if (gameTime.TotalGameTime.Seconds&gt;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 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload