Results 1 to 2 of 2
Hybrid View
-
August 31st, 2011, 04:53 AM #1
Position of a puzzle piece in Flash Jigsaw puzzle
I have a 4*4 grid. I have 16 MovieClips scattered around the grid. Each MovieClip is 40*40 and they are draggable. The user can drag and drop the MovieClips into the grid. Each clip has a correct position. For example for
clip 0 : x=0 , y=0
clip 1 : x=40, y=0
clip 2 : x=120 , y=0
clip 3 : x=160 , y=0
clip 15 : x=160 , y=160
The game finishes when all the clips are in correct position. So its easy to check for game over. Use a loop and ENTER_FRAME to monitor the positions of all clips.
There is a small problem I cannot solve. When the user drags a clip it will snap to position in the grid whether it is correct or not. The snappable positions will be multiples of 40 in this case. It is possible for two clips to snapped to a location and this has to be avoided. If I have put a clip at (40,120) I should not be able drop another MovieClip there. In effect I should be able to get some indication telling me that this position is occupied.
Using the indication I will make the MovieClip return to original position.
How can this can be achieved. The registration points of MovieClips are topleft.
-
August 31st, 2011, 08:08 AM #2
You can use arrays to store a 1 or 0 if that place is occupied or not. When its 0 then the slot is empty, when 1 then its already placed. When that placed piece is moved again that position is set to 0 again kind of thing.

Reply With Quote


Bookmarks