def move_animation(self, car, x1, y1, x2, y2, cost=1): animation = QPropertyAnimation(self, propertyName=b'pos') animation.setParent(self) animation.setTargetObject(car) animation.setDuration(cost * 1000) animation.setStartValue(QPoint(x1, y1)) animation.setEndValue(QPoint(x2, y2)) # animation.start() return animation
def move(self, car, px, py): animation = QPropertyAnimation(self, b'pos') animation.setParent(self) animation.setDuration(2000) animation.setTargetObject(car) animation.setStartValue(QPoint(100, 100)) animation.setEndValue(QPoint(100, 400)) animation.setLoopCount(1) # self.animation.finished.connect(self.animationFinished) animation.start()