Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 2 of 2

Thread: Position of a puzzle piece in Flash Jigsaw puzzle

Hybrid View

  1. #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.

  2. #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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012