I agree with Colin-

Below is a very old script I used for this very thing.


property spriteNum
property myLocZ

property myTarget
property tolerance -- how close to the target the piece must be to snap into place

property tracking -- boolean. Whether or not the piece is currently being dragged by the mouse. property mouseOffset -- The offset from sprite's loc to the mouseloc when the piece is being dragged.
property originalPosition  -- where the piece was before it was picked up

property placed

property cursorSprite  -- the spriteNum of the glove cursor
----------------------------------------------------------------------------------------------------------------

on getBehaviorDescription

 return "Jigsaw puzzle piece"

end

----------------------------------------------------------------------------------------------------------------

on beginSprite

 placed = FALSE

 myTarget = sprite(spriteNum).loc
 tolerance = 30

 tracking = FALSE

 cursorSprite = 15

end

----------------------------------------------------------------------------------------------------------------

on mouseDown

 if NOT placed then
   -- set the mouse tracking properties
   mouseOffset = sprite(spriteNum).loc - the clickLoc
   tracking = TRUE
   originalPosition = sprite(spriteNum).loc
-- move the piece to the top. Setting the locZ to the ticks
   sprite(spriteNum).locZ = the ticks
   sprite(cursorSprite).locZ = the ticks
 end if

end

----------------------------------------------------------------------------------------------------------------

on mouseUp

 if NOT placed then
   pieceLoc = sprite(spriteNum).loc
if computeDistance(myTarget, pieceLoc) < tolerance then sprite(spriteNum).loc = myTarget puppetSound 4, "dropped thud"
     placed = TRUE
sendSprite 1, #addAPiece else if inside(pieceLoc, sprite(6).rect) then
     sprite(spriteNum).loc = originalPosition
   end if
tracking = FALSE end if
end

----------------------------------------------------------------------------------------------------------------

on prepareFrame
 if tracking then
   sprite(spriteNum).loc = point(the mouseH, the mouseV) + mouseOffset
 end if

end

----------------------------------------------------------------------------------------------------------------

on computeDistance point1, point2

distance = sqrt(power((point1[1] - point2[1]),2) + power((point1[2] - point2[2]),2))

 return distance

end

----------------------------------------------------------------------------------------------------------------

on scramblePiece

 sprite(spriteNum).locH = random(243) + 38
 sprite(spriteNum).locV = random(281) + 103


end





   Thank you,

   Stephen Ingrum
   [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
   www.LeagueofDesign.com <http://www.leagueofdesign.com>
   214.324.1177 ext. 1#
   solutions in a Whole New League <http://www.leagueofdesign.com>





Michael Nadel wrote the following on 7/25/2005 12:23 PM:

I'm making a puzzle game where I have each sprite in the score twice. Once (underneath) the sprite's blend = 0 and above it (the sprite that you drag's) blend = 100. When the sprite you are dragging intersects the invisible sprite underneath, the invisible sprite becomes visible and the drag sprite is thrown off the stage.

My question is, the "intersect" function is too vague and too easy. I want that the user should be almost exactly on top of the invisible sprite in order for the puzzle piece to become visible. Is there another way to do this that would test if the user is approximately almost exactly within the rect of the invisible sprite?? (not "exactly", but "approximately exactly?")

Thanks for any help!

Michael Nadel
MediArt.Corp
"Creativity is more powerful than knowledge" -- Albert Einstein
***********************************************************************
Tel: (972-2) 5807-454
Email: [EMAIL PROTECTED]
Web: http://www.intelligineering.com/mediart/home.htm

[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[email protected]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to