简体   繁体   中英

XNA smooth animation at high speed for WP7

My 2d game has a sprite which is moving from top to bottom (travelling Y +ve direction), its smooth enough in 30 fps, as sprite's Y position adding 1 pixel in each frame (Y= Y+1px). Now the problem is when i want move the sprite in high speed, that is Y = Y + 10px, the motion looks no smooth at all since adding 10px in each frame. Would like to know, is there anyway i can acheive high speed with smooth animation.

Don't use frame based movement, if your game has a "hickup" suddenly your player, enemies etc. are not moving "realistically" but are slowed just because of your device. I advise you to use time based movement.

Currently I guess you have something like this:

Update(GameTime aTime)
{
    mPlayer.Position += mPlayer.Direction;
}

Now consider what happens if your game is running at 10FPS, 100FPS or 0 FPS. The movement is not consistent and thus not fluid. If you change that, so movement is based on the elapsed time instead, you get a much more consistent animation, something like:

Update(GameTime aTime)
{
    mPlayer.Position += aTime.Milliseconds * (Constants.PlayerWalkSpeed * mPlayer.Direction);
}

And finally if that isn't smooth enough you need to fake it, like adding motion blur, which is quite easy to do in 2D. Just store the last couple of old positions and draw the player sprite at these position with less alpha than the current one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM