Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
FFT
Frame Trigger-Alphamania
WinGroup Xtra
Get Rect of Vertexlist
Getting full error messages
MUSTARD
Yes/No Dialog Box
Password Protection in a Projector
Shockwave for Dummies With CDROM
Shockwave asking for Xtras
 

 

 

Behavior Sprite Stick To Mouse Cursor

Added on 9/8/2000

 

Compatibilities:
behavior D7 D8 Mac PC Shockwave

This item has not yet been rated

Author: KurtKoenig (website)

Make a sprite dragable using Lingo with an option to constrain to a rectangular shape

Download PC Source    Download Mac Source
--Make a sprite dragable using Lingo
--with an option to constrain to a rectangular shape.
--
--    Kurt Koenig * Belgium                 Useable in Director --> 7 and 8
--
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

property pStick, pStickNow, pWhenDown, pConstrain, pConstrainRect

on getPropertyDescriptionList me
  desclist = [:]
  
  addProp desclist, #pStickNow, [#comment: "Do you want the sprite to¬
  stick to the mouse cursor after being clicked?", #format: #Boolean, #default:FALSE]
  addProp desclist, #pWhenDown, [#comment: "Or do you want the sprite¬
  to stick, only when the mouse is down ?", #format: #Boolean, #default:FALSE]
  addProp desclist, #pConstrain, [#comment: "Enable if you want to constrain this spite¬
  to another(rectShape) sprite", #format: #Boolean, #default:FALSE]
  addProp desclist, #pConstrainRect, [#comment: "The number of the sprite that¬
  contains the rectangle shape castmember", #format: #integer, #default:""]
  
  return desclist
  
end getPropertyDescriptionList


on getBehaviorDescription me
  return "Put this behavior on a sprite to make it stick to the"&return&"¬
cursor while the mousedown, or after being clicked."&return&"¬
an option is included to constrain this sprite to"&return&"¬
a shape sprite"&return&&return&"¬
Kurt Koenig * Belgium"
  
end getBehaviorDescription


on getBehaviorTooltip me
  return "¬
Put this behavior on a sprite to make it stick to the"&return&"¬
cursor while the mousedown, or after being clicked."
end getBehaviorTooltip


on beginsprite me
  pStick = 0
  if pConstrain then
    sprite(me.spritenum).constraint = pConstrainRect
  end if
end beginsprite

on mouseup me
  if pStickNow then
    pDifference =  sprite(me.spritenum).loc - the clickloc
    if pStick = 1 then
      pStick = not pStickNow
    else
      pStick = 1
    end if
  end if
  if pStick then
    repeat while the mouseup
      sprite(me.spritenum).loc = the mouseloc + pDifference
      updatestage
    end repeat
  end if
end mouseup

on mouseupoutside me
  if pStickNow then
    pDifference =  sprite(me.spritenum).loc - the clickloc
    if pStick = 1 then
      pStick = not pStickNow
    else
      pStick = 1
    end if
  end if
  if pStick then
    repeat while the mouseup
      sprite(me.spritenum).loc = the mouseloc + pDifference
      updatestage
    end repeat
  end if
end mouseup

on mousedown me
  if pWhenDown then
    pDifference =  sprite(me.spritenum).loc - the clickloc
    repeat while the mousedown
      sprite(me.spritenum).loc = the mouseloc + pDifference
      updatestage
    end repeat
  end if
end mousedown

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail