I have a simple game using UiKit dynamics implementation. The game has blocks (the ones in red) aligned with grids as shown in below picture.The blocks falls from top and rest in bottom grid
Say the bottom grid row is called with reference 1, I want to check in which grid reference the block is in. I am doing this by using CGGeomentry, CGRectContainsPoint([grid frame], and then assign the grid number i.e 1 to blocks. It works fine for the single block as using in above picture.
Now take a look at second picture.
Once the second block is stacked on top of first block, you can notice a clearance with grid row 2 and the second block. This clearance is getting increased once more blocks are stacked on top of each other. Because of this clearance, CGRectContainsPoint calculation gives wrong grid number for grid rows more than 6.
In other words, first block should be assigned with grid row 1, second block should be assigned with grid row 2. Since the blocks frame size and grid frame size are same, this should be true to block 10 or block 100. But because of this clearance, after some blocks, the grid assignments looks wrong, i.e, block 6 is getting grid number as 5.
I am using UIKit dynamics gravity behaviour to make the blocks fall from top and collision behaviour to determine collisions. I even set the elasticity property to 0.0 to reduce the bounciness.
My question is why I am getting this clearance when the grid frame size and block frame size are same. Shouldn't they fit in exactly? How can I get rid of this clearance?
You can see the clearance is getting more when more blocks are stacked in below picture
Thank you