本文介绍了游戏开发 - 避免闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用winforms开发一个类似于俄罗斯方块的游戏(C#和.netframework 2.0)。
winform有一个背景图片和一个以500ms为间隔向下移动(新的位置被分配)的图片框。

问题是当图片-box在图片框较早位置的位置向下移动表格的背景图像。如果我不使用任何背景图像,那么就不会有闪烁。



是否有任何图形加速器或任何类型的解决方案可以解决闪烁问题。

解决方案

用于这个的术语是 Double Buffering 。这个想法很简单 - 从2个窗格开始,但只显示一个窗格。绘制到隐藏窗格,并快速交换隐藏和可见窗格。漂洗并重复每一次转换(动画)。

幸运的是,你不必在.NET中处理这些细节,控件会为你做。这个SO问题将帮助你:


I am developing a tetris like game in winforms(C# and .netframework 2.0).The winform has an background image and a picture-box which move down(new Location is assigned) at an interval of 500ms.

The problem is when picture-box moves down the background image of form flickers at the point where the picture-box was earlier located. If i don't use any background image, then there is no flickering.

Is there any graphics accelerator or any kind of solution using which the flickering problem can be solved.

解决方案

The term used for this is Double Buffering. The idea is simple - start with 2 panes but only display one. Draw to a hidden pane, and quickly swap the hidden and visible panes. Rinse and repeat for every transition (animation).

Luckily, you dont have to deal with the nuts and bolts of this in .NET, controls do it for you. This SO question will help you: How to double buffer .NET controls on a form?

这篇关于游戏开发 - 避免闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 15:36