小白随笔5946

导航

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((redgreenblue))

Fill the screen with a solid color.

给屏幕填充实色。用RGB函数定义颜色。也可以用单词,如“”white“”。

blit(image(lefttop))

Draw the image to the screen at the given position.

将图像绘制在指定位置。

blit() accepts either a Surface or a string as its image parameter. If image is a str then the named image will be loaded from the images/ directory.

接受surface对象或者字符串来作为图像的变量。字符串指定的是图像的路径。

draw.line(startend(rgb))

Draw a line from start to end.

按照起点及终点坐标、RGB来绘制直线。

例:screen.draw.line((350,400),(450,400),"black")

draw.circle(posradius(rgb))

Draw the outline of a circle.

绘制圆圈。

例: screen.draw.circle((300,250),60,"black")

参数:(圆心,半径,颜色)

draw.filled_circle(posradius(rgb))

Draw a filled circle.

绘制实心圆。

例:screen.draw.filled_circle((400,300),200,"white")

draw.rect(rect(rgb))

Draw the outline of a rectangle.

Takes a Rect.

 

draw.filled_rect(rect(rgb))

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(textrect**kwargs)

Draw text, sized to fill the given Rect.

There’s an extremely rich API for formatting text; see Text Formatting for full details.

 

posted on 2021-09-29 11:24  小白随笔5946  阅读(212)  评论(0编辑  收藏  举报