3

I am starting to game development adding bitmap images in to array list how can implemented

for(int i =0;i<9;i++)
{
  resizedBitmap[i] = Bitmap.createBitmap(bitmapOrg, (i%3)*newWidth, (i/3)*newHeight,newWidth, newHeight);            
}

Given 9 images are storing array list display random order how can implemented its urgent

2
  • Its a jigsaw puzzle, right? :) Commented Oct 22, 2010 at 11:34
  • yes this puzzle game purpose can please send some source code related these link Commented Oct 22, 2010 at 11:48

1 Answer 1

2

There are a number of ways you can achieve what you are attempting to achieve. One such way is to ditch the array, and use an ArrayList instead.

ArrayList<Bitmap> mBitmaps = new ArrayList<Bitmap>(9);
for (int i = 0; i < 9; i++)
{
    mBitmaps.add(Bitmap.createBitmap(bitmapOrg, (i % 3) * newWidth, (i / 3) * newHeight, newWidth, newHeight));
}

Collections.shuffle(mBitmaps);

for (int i = 0; i < 9; i++)
{
    Bitmap bitmap = mBitmaps.get(i));

    //Do something
    //...
}
Sign up to request clarification or add additional context in comments.

2 Comments

I have 28 images with the names startimg01 to 28 respectively. How do I add those images particularlty?
If you are meaning that you want to call these images back by name as opposed to index, you can use a Map<String, Bitmap> instead of an array. To add: mBitmaps.put("img01", bitmap); To retrieve: Bitmap bitmap = mBitmaps.get("img01");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.