快速移动的物体留下 "ghost" 条轨迹
Fast moving object leaves a "ghost" trail
我正在尝试在 Monogame 中高速绘制子弹。当我以大约 400px/sec "Which is quite slow" 但大约 1500px/sec 绘制它时,它开始 "duplicating" 或 "ghosting" 纹理。我是 Monogame 的新手,对图形方面的知识不多。
如何在不创建 "ghost" 效果的情况下以高速移动对象?
SpriteBatch 开始:
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullNone,
null, Global.Camera.GetViewTransformationMatrix());
绘制方法:
public override void Draw(SpriteBatch sb)
{
Vector2 origin = new Vector2(source.Width / 2, source.Height / 2);
Rectangle tRect = Bounds;
sb.Draw(
texture: TDTGame.GameAssets.Texture,
destinationRectangle: tRect,
sourceRectangle: source,
rotation: MathHelper.ToRadians(Rotation - 270f), //Set rotation to forward of the texture.
color: Color.White,
origin: origin,
layerDepth: 1f
);
}
编辑:
YouTube Link : here
子弹的移动:
float traveledDistance;
public override void Update(GameTime gt)
{
float deltaTime = (float)gt.ElapsedGameTime.TotalSeconds;
traveledDistance += Speed * deltaTime;
Position += Forward * Speed * deltaTime;
if (traveledDistance > Range)
{
Destroy();
}
}
这可能是低帧率造成的。帧速率越高,您的大脑就越不会注意到子弹的 "movement" 只是在随时间变化的多个位置绘制相同的图像 :)
如前所述,痕迹可能在你的眼睛里,而不是在屏幕上。如果你想克服这种效果,你可能想要跳过一些帧(可能完全从屏幕上删除项目符号或至少跳过移动)。
我正在尝试在 Monogame 中高速绘制子弹。当我以大约 400px/sec "Which is quite slow" 但大约 1500px/sec 绘制它时,它开始 "duplicating" 或 "ghosting" 纹理。我是 Monogame 的新手,对图形方面的知识不多。
如何在不创建 "ghost" 效果的情况下以高速移动对象?
SpriteBatch 开始:
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullNone,
null, Global.Camera.GetViewTransformationMatrix());
绘制方法:
public override void Draw(SpriteBatch sb)
{
Vector2 origin = new Vector2(source.Width / 2, source.Height / 2);
Rectangle tRect = Bounds;
sb.Draw(
texture: TDTGame.GameAssets.Texture,
destinationRectangle: tRect,
sourceRectangle: source,
rotation: MathHelper.ToRadians(Rotation - 270f), //Set rotation to forward of the texture.
color: Color.White,
origin: origin,
layerDepth: 1f
);
}
编辑:
YouTube Link : here
子弹的移动:
float traveledDistance;
public override void Update(GameTime gt)
{
float deltaTime = (float)gt.ElapsedGameTime.TotalSeconds;
traveledDistance += Speed * deltaTime;
Position += Forward * Speed * deltaTime;
if (traveledDistance > Range)
{
Destroy();
}
}
这可能是低帧率造成的。帧速率越高,您的大脑就越不会注意到子弹的 "movement" 只是在随时间变化的多个位置绘制相同的图像 :)
如前所述,痕迹可能在你的眼睛里,而不是在屏幕上。如果你想克服这种效果,你可能想要跳过一些帧(可能完全从屏幕上删除项目符号或至少跳过移动)。