Thanks, I’m glad you liked the game.
95% of the graphics are photos. I composite 30 - 50 layers together in Photoshop to create each puzzle. I then run it through some filters to give it a bit of a hand-drawn look.
For connecting pieces together I created a 2-dimensional array called solution[][]. The first dimension is the piece number (in my case 1 - 28) and the second dimension is the side (left, top, right, bottom). I set it equal to the piece number that it connects to on that side. So for example if we had a simple 3x3 puzzle with pieces numbered as such:
1 2 3
4 5 6
7 8 9
I’d set my array for piece #1 like this
solution[1][1] = 0 -- Nothing on the left of piece 1 to connect to
solution[1][2] = 0 -- Nothing on the top of piece 1 to connect to
solution[1][3] = 2 -- Connect on the right to piece 2
solution[1][4] = 4 -- Connect on the bottom to piece 4
I have an event trigger for onTouch, phase == ended that uses the event.target piece (the one that was dragged) and compares its 4 possible side pieces’ x,y coordinates (+/- a threshold equal to about 10% of the piece size so the user doesn’t need to be spot-on).
If there is a match, the two pieces are added to a “group” (I put “group” in quotes because it is not the built in Corona group but one I created). I set the solution[][] for that piece’s side to 0 to avoid the piece repeatedly trying to connect.
The “group” is then iterated through on each drag so all the pieces move together as a single unit. The entire group is also iterated through for checking connecting pieces so any piece in the group can connect to any free piece. Also, all pieces in the group are brought to the front onTouch and on a successful connect of pieces.
Hope that helps you out. [import]uid: 22492 topic_id: 11948 reply_id: 45703[/import]