I'm writing an Android game app with kivy, and want to make my drawn line disappear after x seconds after drawing it.
I've tried, read kivy.doc or google but couldn't find it or idk just being dumb.
py.
class Drawing(Widget):
def on_touch_down(self, touch):
with self.canvas:
touch.ud["line"] = Line(points=(touch.x, touch.y))
def on_touch_move(self, touch):
touch.ud["line"].points += [touch.x, touch.y]
#They are what I've found and tried...
def i_remove_widget(self):
self.remove_widget(self.Drawing)
Clock.schedule_once(self.i_remove_widget(), 1.5)
def on_touch_up(self, touch):
touch.ud["line"].self.remove = Clock.schedule_once(self, 1.5)
kv.
Screen:
Drawing
I expect my drawn line disappear in 1.5 seconds, but nothing happens
Something like this:
def on_touch_up(self, touch):
line = touch.ud['line']
def remove_line(*args):
self.canvas.remove(line)
Clock.schedule_once(remove_line, 1.5)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.