So I have a card class, and a list that contains 5 cards, like so:
Then in the screen:
What I want to do here is, once I click a card, it gets removed from the card list, and disappearing from the screen. This is my current solution:
Then in the Play_Card label:
It works, but is there any other way to do it right in the button? Something similar to RemoveFromSet? Or just a shorter way to do it.
Code:
card = []
card.append(Card("card1, image=card1.png"))
...
...
card.append(Card("card5, image=card5.png"))
Code:
hbox:
for q in card:
$ cardImg = q.image
imagebutton:
idle cardImg
hover cardImg
action Call("Play_Card")
Code:
hbox:
for q in card:
$ cardImg = q.image
imagebutton:
idle cardImg
hover cardImg
action SetVariable("cardToDiscard", card.index(q)), Call("Play_Card")
Code:
label Play_Card:
python:
card.remove(card[cardToDiscard])