This site requires JavaScript, please enable it in your browser!
Greenfoot back
aconal
aconal wrote ...

2014/12/29

CARD GAME: PAIRS

aconal aconal

2014/12/29

#
I have 2 rows of cards with 8 cards in every row. The 8 cards of the first row are the same than the second´s row but in different order. If I press a button, all cards turn over until GreenfootDelay have finished and you can see where the pairs are. Later, if you click on a card, this turns. I would like to know wich card I´ve clicked to and compare it with the second´s row´s card wich I´ve clicked to and, if they are the same card, icrease the ranking.
danpost danpost

2014/12/30

#
You just need to keep track of the first row card clicked on. You can use an instance object reference field (a field that holds a reference to a Card object). It should not have an object (contain a 'null' value) unless a first row card is clicked on -- then you set it to that card and have the card flip up. When a second row card is clicked, compare its value with that of the card reference in the field -- then flip the cards back over, reset the field back to 'null' and display comparison results. Only allow first row card click when field is 'null' and only allow second row card click when field is not 'null'.
aconal aconal

2014/12/30

#
Ok, I will try it. Thanks!
aconal aconal

2015/3/10

#
It works, I´ll upload it soon. Thanks!
You need to login to post a reply.