I’m developing card game with kivy where card are dragged to played card pile.when I click on card that is in played pile it will go in hand and adjust thier position.
happening
When I click first time on card it goes at correct position.
But next time doesnot go at correct position
For better clarity you can see result
I think problem originated from logic
You can see logic code
def onpass(self, nam, who='hcv'):
if nam in self.all_mon or who == 'go':
daf = []
for w in self.children:
if isinstance(w, DraggableCard):
daf.append(w.pos_hint)
if len(daf) < self.inhand:
for w in self.children:
if isinstance(w, DraggableCard):
w.initial_pos_hint['center_x'] -= .0355
anim = Animation(pos_hint=w.initial_pos_hint, duration=0.3)
anim.start(w)
anim = Animation(pos_hint={'center_x': daf[0]['center_x'] + .0355, 'center_y': daf[0]['center_y']}, rotate_value_angle=0, duration=0.3)
anim.bind(on_complete=lambda *args: self.change_to_drag(self.played_card[-1]))
anim.start(self.played_card[-1])
def change_to_drag(self,card):
pos = card.pos_hint
sour = card.source
self.remove_widget(card)
new_card = DraggableCard(initial_pos_hint =pos,source = sour,w=100,h=120)
new_card.pos_hint = pos
self.add_widget(new_card)
self.played_card.pop()
return new_card
Thanks for answer