我有一个对话框,里面有一个标签,一次打印一个单词。所有这些都是在游戏中单击对象时调用的。你知道吗
我创建了一个名为blockclick
的标志,它在对象被单击时立即等于True
。当对话框完成打印时,blockclick=False
。我试图使它在blockclick == True
时,单击对象不会重新打开对话框或重置它,但这正是发生的事情,我不确定我做错了什么。你知道吗
我意识到我的代码可能很难理解(我不是最好的程序员),但希望你能看到我试图用blockclick
做什么。你知道吗
底部的treetext
函数是我猜测问题所在的地方(如果blockclick==False
,就什么都做)。你知道吗
class DialogueLabel(ButtonBehavior, Label):
def __init__(self, **kwargs):
super(DialogueLabel, self).__init__(**kwargs)
self.text2="empty string"
self.font_name='fonts/PressStart2P.ttf'
self.font_size=16
self.halign='center'
self.text_size=(Window.width*.75, Window.height*.25)
self.mipmp = True
self.line_height=2.5
self.center_x=(Window.width/2)
self.center_y=(Window.height/5)
self.markup = True
self.counter=0
self.blockclick=False
def example(self, *args):
self.counter += 1
self.blockclick=True
anim = Animation(pos_hint= {'top': .31}, duration=.3)
anim.start(messagebox)
if len(words) > self.counter:
self.text += words[self.counter] #might need to be self.counter-1
self.text += " "
elif len(words) < self.counter:
Clock.schedule_once(self.closeanimation, 3.5)
Clock.schedule_once(self.cleartext, 3.5)
Clock.schedule_once(lambda dt: messagebox.dismiss(), 4)
Clock.schedule_once(self.unlock, 3)
return False
def lock(self, dt):
self.blockclick=False
def closeanimation(self, dt):
anim2 = Animation(pos_hint= {'top': .0}, duration=.3)
anim2.start(messagebox)
def cleartext(self, dt):
self.text=""
newmessage=DialogeLabel
def treetext(*args):
if newmessage.blockclick==False:
newmessage.text=''
newmessage.counter=-1
newmessage.text2= "You ran into a tree. You are a moron"
messagebox.open()
global words
words=newmessage.text2.split(" ")
Clock.schedule_interval(newmessage.example, .2)
else:
pass
目前没有回答
相关问题 更多 >
编程相关推荐