问题:
如果我的鼠标光标在窗口外,我的游戏运行,但如果我的光标在控制台内给我这个错误。
Traceback (most recent call last):
File "c:/Users/jackw/Desktop/New folder/main.py", line 36, in <module>
if event.type == pg.QUIT():
TypeError: 'int' object is not callable这是我的代码
import pygame as pg
from Config import *
from bin import *
# initialising pygame
pg.init()
class Game():
def background(self,background):
window.blit(background, (0,0))
# defining classes for use
g = Game()
# game loop
while isrunning:
# making sure the game is running on a constant clock
time.tick(fps)
# add background
g.background(gameback)
# setting up events
for event in pg.event.get():
# closing window event
if event.type == pg.QUIT():
isrunning = False
# input events
# show finished frame
pg.display.flip()
# Last code before closing the window
# closing the window
pg.quit()这个程序在macOS上运行得很好--我只在windows 10上得到这个错误。
发布于 2019-12-20 17:49:22
pg.QUIT是一个枚举值。基本上是个整数。您的代码由于某种原因添加了括号;这是无效的语法。仅用
if event.type == pg.QUIT:你编码的东西有点像
if event.type == 4():https://stackoverflow.com/questions/59429390
复制相似问题