如何防止画布中的对象模糊? [英] How can I prevent objects from being fuzzy in canvas?

查看:112
本文介绍了如何防止画布中的对象模糊?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在做一个只有一个盒子和一个角色的迷你游戏。

Currently, I'm doing a mini game which only has a box and a character.

这个角色可以自由移动。我这样做了它移动640px /秒。我用来获取每帧移动像素的公式是((currentFrameTimeMs - lastFrameTimeMs)* pxPerSecond)/ 1000 。实际值为((currentFrameTimeMs - lastFrameTimeMs)* 640)/ 1000 。这有效地使我的角色精确地移动640px / s。

The character can freely move around. I did so it moves 640px/second. The "formula" I use to get the pixels to move each frame is ((currentFrameTimeMs - lastFrameTimeMs) * pxPerSecond) / 1000. Actual values are ((currentFrameTimeMs - lastFrameTimeMs) * 640) / 1000. This effectively makes my character to move exactly 640px/s.

但问题是移动时,我认为它是模糊的。我已经检查了FPS,它远远高于60,但图像看起来仍然模糊。

But the problem is that when moving, I see it as "fuzzy". I've checked out the FPS, and it's very far above 60, yet the image still looks fuzzy.

有没有任何技术可以消除这种模糊性?我玩桌面游戏的对象移动得非常快,而且它们不会模糊,所以我想有一些技巧。

Is there any technique to remove that blurriness? I've played desktop games which have objects moving pretty fast, and they don't blur, so I suppose there's some trick for that.

推荐答案

问题解决了。

FPS出现问题,他们不到60岁。我使用了错误的方法(使用 requestAnimationFrame ,但计算错误。)

Problem was with FPS, they were under 60. I was using a wrong approach (with requestAnimationFrame, but wrong calculations).

这篇关于如何防止画布中的对象模糊?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆