Answer the question
In order to leave comments, you need to log in
kivy python collision logic?
Section of python code
class birds :
# Макет FloatLayot
display = ObjectProperty(None)
# Позиция птиц
x = (-40)
y = 800
x_final = 700
#Виджет Image
bird_only = Image()
def __init__ (self) :
Clock.schendule_interval (self.bird_only,10)
def bird (self) :
self.bird_only = Image (source = 'путь к изображению',size_hint = (None,None) ,size = (60,60),pos = (self.x,self.y)
self.display.add_widget(self.bird_only)
# Анимация
self.anim = Animation (x = self.x_final ,y = y ,d = 5)
self.anim.start(self.bird_only)
def delete_birds (self) :
if self.x > 650 :
self.display.remove_widget(self.bird_only)
, class birds :
# Макет FloatLayot
display = ObjectProperty(None)
# Позиция птиц
x = (-40)
y = 800
x_final = 700
#Виджет Image
bird_only = Image()
def __init__ (self) :
Clock.schendule_interval (self.bird_only,10)
def delete_birds (self) :
if self.x > 650 :
self.display.remove_widget(self.bird_only)
def bird (self) :
self.bird_only = Image (source = 'путь к изображению',size_hint = (None,None) ,size = (60,60),pos = (self.x,self.y)
self.display.add_widget(self.bird_only)
# Анимация
self.anim = Animation (x = self.x_final ,y = y ,d = 5)
self.anim.start(self.bird_only)
self.delete_birds()
Answer the question
In order to leave comments, you need to log in
Well, for starters, why delete and recreate individual birds when you can just "teleport" them to the other side of the screen?
In addition, if I understand correctly, delete_birds() will work for you immediately, without waiting for the end of the animation, since the start() method does not perform animation - it only plans its gradual execution during the further operation of the window. Use the on_complete event on your Animation object.
Details, as always, in the documentation .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question