Hey guys,
I am using containers to split an image into square pieces. I have a 450 x 450 image which I am trying to split in 9 equal square pieces (all of them 150 x 150). Once I split them, my goal is to put those containers next to each other in the exact location so the image is reconstructed.
This is the code I am trying. However, each of the 9 containers only show the middle of the original image. So I end up with 9 square containers that all have the same view of the original image instead of each showing different part of the image. Any help/suggestion on how I can do that?
Thanks a lot.
Here is a 450x450 Image.
Code:
local x\_location = display.contentCenterX local y\_location = display.contentCenterY;local sizer=150;local y\_start=70; local startx=x\_location-sizer local starty=y\_location-sizer-y\_start local pic={} for p=1,9 do pic[p]=display.newImageRect('Sample\_2D.png',3\*sizer,3\*sizer);pic[p].x=0; pic[p].y=0; pic[p]:toBack() if pic[p].x\> 2\*sizer then pic[p].x= 0 pic[p].y=pic[p].y+sizer end end startx=x\_location-sizer starty=y\_location-sizer-y\_start local box={} for bx=1,9 do print(bx) box[bx] = display.newContainer(sizer,sizer);box[bx].x=startx;box[bx].y=starty; box[bx]:insert(pic[bx]) box[bx].anchorChildren = false startx=startx+sizer if startx\> x\_location+sizer then startx= x\_location-sizer starty=starty+sizer end end