TypeError: Required argument #39;dest#39; (pos 2) not found(TypeError:找不到必需的参数#39;DEST#39;(位置2))
本文介绍了TypeError:找不到必需的参数';DEST';(位置2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正尝试用pyGame制作射击游戏,但当我运行游戏时,它显示了pyGame窗口,但出现错误:
Traceback (most recent call last):
File "C:UsersNnamdiAppDataLocalProgramsPythonPython36-32game.py", line 26, in <module>
SCREEN.blit(text)
TypeError: Required argument 'dest' (pos 2) not found
以下是我的代码:
import pygame, sys
from pygame.locals import *
pygame.init()
ammo = "10" # you have ten ammo, use it wisely...
WIDTH = 600
HEIGHT = 600
SCREEN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption('Bomber')
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
DARKBLUE = (2, 9, 129)
YELLOW = (255, 255, 255)
SCREEN.fill(DARKBLUE)
pygame.display.flip()
basicfont = pygame.font.SysFont(None, 48)
text = basicfont.render('Bomber', True, (255, 0, 0), (255, 255, 255))
SCREEN.blit(text, dest)
is_running = True
while is_running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_running = False
pygame.quit()
希望您能帮忙。
推荐答案
您必须定义dest
变量。您还应该调用函数pygame.display.flip()
。例如:
import pygame, sys
from pygame.locals import *
pygame.init()
ammo = "10" # you have ten ammo, use it wisely...
WIDTH = 600
HEIGHT = 600
SCREEN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption('Bomber')
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
DARKBLUE = (2, 9, 129)
YELLOW = (255, 255, 255)
SCREEN.fill(DARKBLUE)
pygame.display.flip()
basicfont = pygame.font.SysFont(None, 48)
text = basicfont.render('Bomber', True, (255, 0, 0), (255, 255, 255))
dest = (100, 100)
is_running = True
while is_running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
is_running = False
SCREEN.blit(text, dest)
pygame.display.flip()
pygame.quit()
截图:
这篇关于TypeError:找不到必需的参数';DEST';(位置2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:TypeError:找不到必需的参数';DEST';(位置2)


猜你喜欢
- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01
- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01
- padding='same' 转换为 PyTorch padding=# 2022-01-01
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
- 沿轴计算直方图 2022-01-01
- pytorch 中的自适应池是如何工作的? 2022-07-12
- 如何将一个类的函数分成多个文件? 2022-01-01