reset password
Author Message
lakerfan94
Posts: 143
Posted 21:53 May 03, 2016 |

I noticed that the Puzzle Board constructor has a parameter called "parentWidth". Do we really have to use it because I'm using the createScaledBitmap method and it takes in a width and height. From the instructions I read, I would think that the width and height passed to the createScaledBitmap method would be NUM_TILES right?

chuckh
Posts: 12
Posted 22:08 May 03, 2016 |

On mine, I did use parentwidth. My mistake was to mess to much with the code and then it was not working properly. I had to start from scratch and then finally I am back on track. So I did use parentWidth on mine and hope this helps.

lakerfan94
Posts: 143
Posted 22:27 May 03, 2016 |

Ok thanks. I'm just confused about how we divide the image into the tiles with the dimensions NUM_TILES x NUM_TILES.

Last edited by lakerfan94 at 22:29 May 03, 2016.
chuckh
Posts: 12
Posted 22:47 May 03, 2016 |

Well, it all depends on how you want to do it. There are many ways. You can just enter them manually but I created the code that includes two for loops. One loop is for the columns and the other is for the rows. Then there is an if statement for the 9th tile which should be null. The way you divide the images is just by adding the separate tiles.add(new PuzzleTile(bitmap......etc

On mine, I create a temporary bitmap which stretches out the thumb image with bitmap.createScaledBitmap then with that new bitmap i used it to create the divided individual 8 bitmaps and 1 null.

Sorry, work is calling me. I hope this helps.

msargent
Posts: 519
Posted 08:36 May 04, 2016 |

There is a Bitmap method that allows you to divide bitmaps into parts, using a starting x, y and a width and hight parameter. Check out the documentation for Bitmap on the Android developers site. http://developer.android.com/reference/android/graphics/Bitmap.html