![]() This is a completely separate issue from the "smooth" motion. (If you're using fixed game time, you don't really need the elapsed time multiply, but I typically put it in there because I prefer to measure in units per second.) Tile Motion ![]() Now, every frame, just update Position to make the velocity work actively on it: //assuming you're using GameTime gameTime for the timing values Modify velocity instead in your keypresses: if (aCurrentKeyboardState.IsKeyDown(Keys.Right) = true & mPreviousKeyboardState != aCurrentKeyboardState)Įlse if (aCurrentKeyboardState.IsKeyDown(Keys.Left) = true & mPreviousKeyboardState != aCurrentKeyboardState)Įlse if (aCurrentKeyboardState.IsKeyDown(Keys.Up) = true & mPreviousKeyboardState != aCurrentKeyboardState)Įlse if (aCurrentKeyboardState.IsKeyDown(Keys.Down) = true & mPreviousKeyboardState != aCurrentKeyboardState) Instead of directly setting Position, set up a velocity: Vector2 velocity = Vector2.Zero Īlso define some sort of movement speed: const float speed = 10.0f You need quite a bit more in place than you have now.įirst off, as you already realized, setting the position directly is instant.
0 Comments
Leave a Reply. |