How do I get a clicked object?
if(Greenfoot.mouseClicked(this))
{
//what you want the actor to do when clicked on
}
if (Greenfoot.mouseClicked(Card.class))
{
Card card = //(get clicked object);
currentValue = card.getCurrentValue();
}
//reference to the card
private Card card;
//you will most likely replace that with an array of cards if you have multiple ones, but first, let's take it simple
//creating the card and adding it to the world
addObject(card = new Card(), <x>, <y>);
//checking if a click on the card happened
if (Greenfoot.mouseClicked(card)) //I personally prefer mousePressed but that's obviously up to you
{
//…
}//reference to all cards in hand
private ArrayList<Card> cardsInHand = new ArrayList<Card>();
//whenever card x moves to the hand
cardsInHand.add(x);
//whenever card x is removed from the hand
cardsInHand.remove(x);
//check if any card is clicked
for (Card card : cardsInHand)
{
if (Greenfoot.mouseClicked(card))
{
//call card.getCardValue() here and do with it whatever you want
}
}