获取ScreenClick方法上python turtle的返回值

2024-04-20 03:50:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用python制作一个海龟游戏。 我在main中有screen.onscreenclick(select_set)

选择设置功能如下所示:

def select_set(x,y):
    if x in range(-350, -200) and y in range(50,-170,-1):
        set = SET_1
    elif x in range(-80, 70) and y in range(50,-170,-1):
        set = SET_2
    elif x in range(190, 340) and y in range(50,-170,-1):
        set = SET_3

    return set

我想在另一个函数中使用set的返回值。有没有一种方法可以在不使用全局变量的情况下获取此集合值。我试过set = screen.onscreenclick(select_set),但不起作用


Tags: andin功能游戏ifmaindefrange