I am pretty new to programming and i am making a game where i have 27 'cards', i want to have 5 random 'cards' displayed on the canvas but next to each other. I already got the images loading in by using an array where i load them all. Here is that code:
private void initCards() {
for (int i = 01; i < 026; i++) {
int tempId = i;
Card tempCard = new Card(tempId);
int resourceId = getResources().getIdentifier("card" + tempId, "drawable", myContext.getPackageName());
Bitmap tempBitmap = BitmapFactory.decodeResource(myContext.getResources(), resourceId);
scaledCardW = (int) (screenW/5);
scaledCardH = (int) (scaledCardW*1.28);
Bitmap scaledBitmap = Bitmap.createScaledBitmap(tempBitmap, scaledCardW, scaledCardH, false);
tempCard.setBitmap(scaledBitmap);
deck.add(tempCard);
}
}
Now i want to draw 5 random bitmaps of the 26. All of them lined up. Been stuck here for a while and decided to ask.
I would appreciate all help given.
Kind Regards
Aucun commentaire:
Enregistrer un commentaire