property pSpring -- spring factor property pFriction -- friction factor property pGravity -- gravity factor property pVx -- X velocity property pVy -- Y velocity property pMove -- should the sprite follow the mouse, or not -- -- Drag this behavior onto a sprite to apply a virtual spring from it to the mouse pointer. -- Ken Loge - http://diginoodles.com -- on beginSprite me pVx = 0 pVy = 0 pMove = FALSE end on getPropertyDescriptionList me list = [:] addProp list, #pSpring, [#comment: "Spring Strength:", #format: #float, #default: .1, #range: [#min: .1, #max: 1.0]] addProp list, #pFriction, [#comment: "Friction:", #format: #float, #default: .9, #range: [#min: 0, #max: 2.0]] addProp list, #pGravity, [#comment: "Gravity:", #format: #float, #default: 5.0, #range: [#min: 0, #max: 10.0]] return list end on exitFrame me if pMove then ax = (_mouse.mouseH - sprite(me.spriteNum).locH) * pSpring ay = (_mouse.mouseV - sprite(me.spriteNum).locV) * pSpring pVx = pVx + ax pVy = pVy + ay pVy = pVy + pGravity pVx = pVx * pFriction pVy = pVy * pFriction sprite(me.spriteNum).locH = sprite(me.spriteNum).locH + pVx sprite(me.spriteNum).locV = sprite(me.spriteNum).locV + pVy end if end on mouseUp if pMove = FALSE then pMove = TRUE else pMove = FALSE end if end