python - 矩形中的文本 - Pygame

标签 python user-interface sdl pygame

你知道我是否可以在 Rect 中插入文本以及如何插入吗?

我创建了一个 Surface Objet,并在上面添加了文本,我认为这不是最好的方法。

最佳答案

我一直从 PyGame 转向,但根据原始 SDL 和 OpenGL 的经验,我几乎可以确认您正在做最好的方法。

类似于:

Text.position = rectangle.position + rectangle.size / 2
Text.position.X = Text.position.X - text.width / 2

也会为您居中。

关于python - 矩形中的文本 - Pygame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9775274/

相关文章:

c++ - SDL 无法显示图像?

c - 如何向字符串添加值?

java - 是否可以使用 Java 在 Netbeans 中创建可视化插件?

python - GAE 搜索 API : custom snippet length

python - 当我的脚本导入模块 pikepdf 和 pdfminer3 时如何修复 pyinstaller 'no module named...' 错误?

python - 将所有查询结果返回至 Alexa Skill

android - 如何通过 XML 布局显示 Android UI?

java - 到处都找不到符号错误

c++ - 在渲染 SDL_TTF 文本 C++ 时显示变量

python - 尝试使用 urllib3 和 json 获取烂番茄数据时出错(Python)