Screen内建对象
参考资料:
https://pygame-zero.readthedocs.io/en/stable/builtins.html#screen
https://www.pygame.org/docs/ref/surface.html
---------------------------------------------------------------------------------------------------
Built-in Objects
Pygame Zero provides useful built-in objects to help you make games easily.
Pygame Zero提供各种有用的内嵌对象帮助开发。
Screen
The screen
object represents your game screen. /“screen”即“屏幕”对象,代表你的游戏屏幕。
It is a thin wrapper around a Pygame surface that allows you to easily draw images to the screen (“blit” them).
- class
Screen
surface
-
The raw Pygame surface that represents the screen buffer. You can use this for advanced graphics operations.
代表屏幕缓存。可以用它进行高级图像操作。
clear
()-
Reset the screen to black.
清屏。使屏幕恢复黑色。
fill
((red, green, blue))-
Fill the screen with a solid color.
给屏幕填充实色。用RGB函数定义颜色。也可以用单词,如“”white“”。
blit
(image, (left, top))-
Draw the image to the screen at the given position.
将图像绘制在指定位置。
blit()
accepts either a Surface or a string as itsimage
parameter. Ifimage
is astr
then the named image will be loaded from theimages/
directory.接受surface对象或者字符串来作为图像的变量。字符串指定的是图像的路径。
draw.
line
(start, end, (r, g, b))-
Draw a line from start to end.
按照起点及终点坐标、RGB来绘制直线。
例:screen.draw.line((350,400),(450,400),"black")
draw.
circle
(pos, radius, (r, g, b))-
Draw the outline of a circle.
绘制圆圈。
例: screen.draw.circle((300,250),60,"black")
参数:(圆心,半径,颜色)
draw.
filled_circle
(pos, radius, (r, g, b))-
Draw a filled circle.
绘制实心圆。
例:screen.draw.filled_circle((400,300),200,"white")
draw.
rect
(rect, (r, g, b))-
Draw the outline of a rectangle.
Takes a Rect.
draw.
filled_rect
(rect, (r, g, b))-
Draw a filled rectangle.
draw.
text
(text, [pos, ]**kwargs)-
Draw text.
There’s an extremely rich API for positioning and formatting text; see Text Formatting for full details.
draw.
textbox
(text, rect, **kwargs)-
Draw text, sized to fill the given Rect.
There’s an extremely rich API for formatting text; see Text Formatting for full details.