Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on puzzle app in which i need to snap irregular shapes as they come in contact of one another as i am new to game development so i dont have any idea how to achieve this functionality in my app.Any suggestion would be highly appreciated.

share|improve this question

It's true that each image has an irregular shape, but you don't need to snap that shape. It also does have a bounding box, and you know where that bounding box should be in the solved puzzle. Note that those bounding boxes can collide but it doesn't matter at all! so you just need to check if the bounding box almost as it's rightful position, and if it is, you just need to move it to it's exact position and lock it.

share|improve this answer
Actually you don't need to use the bounding boxes, it's simpler to just use the position of the image, but yeah just store a list of where each piece is positioned relative to it's neighbor and snap to those target positions. – jhocking May 6 '13 at 12:56
Thanx a lot Gajoo.I got your idea .Could you provide some relevent code for the same. – Niks May 6 '13 at 12:58
@jhocking If rotation is allowed, you'll need more than just the one position, you'd need two corners or position and rotation. Otherwise, yes, just the position will work. – Byte56 May 6 '13 at 13:00
Actually the pieces are of different shapes such as triangles, parallelogram etc.Now i need to snap these pieces to crete a meaningful shape. – Niks May 6 '13 at 13:02
Yeah rotation is also possible. Pieces can rotate and can flip as well. – Niks May 6 '13 at 13:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.