How to flip an image in Xamarin Android?

874 views Asked by At

I'm creating Poker game. So initially I'm showing back face of playing cards and then I need to add flip animation on the cards to show the value of cards. I've searched the net but I didn't find anything that could have helped me. my code is as follows.

void LoadBacksideOfCards()
    {
        player1Card1.SetImageResource(Resource.Drawable.backside);
        player1Card2.SetImageResource(Resource.Drawable.backside);
        player2Card1.SetImageResource(Resource.Drawable.backside);
        player2Card2.SetImageResource(Resource.Drawable.backside);
        player3Card1.SetImageResource(Resource.Drawable.backside);
        player3Card2.SetImageResource(Resource.Drawable.backside);
        player4Card1.SetImageResource(Resource.Drawable.backside);
        player4Card2.SetImageResource(Resource.Drawable.backside);

        centerCard1.SetImageResource(Resource.Drawable.backside);
        centerCard2.SetImageResource(Resource.Drawable.backside);
        centerCard3.SetImageResource(Resource.Drawable.backside);
        centerCard4.SetImageResource(Resource.Drawable.backside);
        centerCard5.SetImageResource(Resource.Drawable.backside);
    }

And showing the cards using following code

void ShowCenterCardNumber(int cardNumber)
    {
        if (cardNumber == 3)
        {
            centerCard4.SetImageResource(DrawableImageMap[_shuffledCardsData.CenterCardsData[3].CardNumber + _shuffledCardsData.CenterCardsData[3].CardType]);
        }
        else
        {
            centerCard5.SetImageResource(DrawableImageMap[_shuffledCardsData.CenterCardsData[4].CardNumber + _shuffledCardsData.CenterCardsData[4].CardType]);   
        }

    }
    void ShowFirstThreeCenterCards()
    {
        centerCard1.SetImageResource(DrawableImageMap[_shuffledCardsData.CenterCardsData[0].CardNumber + _shuffledCardsData.CenterCardsData[0].CardType]);
        centerCard2.SetImageResource(DrawableImageMap[_shuffledCardsData.CenterCardsData[1].CardNumber + _shuffledCardsData.CenterCardsData[1].CardType]);
        centerCard3.SetImageResource(DrawableImageMap[_shuffledCardsData.CenterCardsData[2].CardNumber + _shuffledCardsData.CenterCardsData[2].CardType]);
    }

I want to add some flip functionality to make it more interactive to users. I'm using simple XML (without MONO Games). any help in this regard will be much appreciated.

1

There are 1 answers