Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Macromedia Director Game Development: From Concept to Creation
PDF Publishing in Multimedia Projects
Happy Hour Fonts
Get Rect of Vertexlist
Flash sending messages to Director
Fake-3D Motion
Text Services API v2.2
StreamStatus Indicator Bar
Echo Vibes
Cast Control
MediaMacros Xtras Mall
 

 

 

Behavior Ripple image when clicked using Imaging Lingo

Added on 7/11/2003

 

Compatibilities:
behavior D8_5 D9 Mac PC Shockwave

This item has not yet been rated

Author: Andrew Morton

This behaviour uses imaging Lingo to give a ripple effect when the image it is attached to is clicked on. For a larger image, increase the the values of nHoriz and nVert under the "choose number of parts" comment to get a smoother effect. Mess around with the values of t, tFactor and phaseInc to tune it if necessary. When testing, make sure that the cast member being affected is not visible in the cast or property inspector because Director remaking the thumbnail slows it down a lot.

property spriteNum, self, myMember, origImg, img, imgRect
property nHoriz, nVert, myOrig
property origPts, newPts
property wibbleCentre, wibble, t, tFactor, phase, phaseInc

on mouseDown
  wibbleCentre=the mouseLoc-point(self.rect.left, self.rect.top)
  wibble=true
  t=20
  tFactor=0.95
  phase=0
  phaseInc=-0.7
end mouseDown

on mouseUp
  wibbleCentre=the mouseLoc-point(self.rect.left, self.rect.top)
  wibble=true
  tFactor=0.8
  if t<10 then t=10.0
end mouseUp

on enterFrame
  if not(wibble) then exit
  if the stillDown then wibbleCentre=the mouseLoc-myOrig
  msx=wibbleCentre[1]
  msy=wibbleCentre[2]
  repeat with i=2 to nHoriz
    repeat with j=2 to nVert
      msxd=msx-origPts[i][j][1]
      msyd=msy-origPts[i][j][2]
      r=sqrt(msxd*msxd+msyd*msyd)/100
      theta=atan(msyd, msxd)
      disp=t*exp(-r*r*0.5)*sin(2*pi*r+phase)
      newPts[i][j]=origPts[i][j]+point(disp*cos(theta), disp*sin(theta))
    end repeat
  end repeat
  repeat with i=1 to nHoriz
    repeat with j=1 to nVert
      srcRect=rect(origPts[i][j], origPts[i+1][j+1])
      destQuad=[newPts[i][j], newPts[i+1][j], newPts[i+1][j+1], newPts[i][j+1]]
      img.copyPixels(origImg, destQuad, srcRect, [#useFastQuads:true])
    end repeat
  end repeat
  myMember.image.copyPixels(img, imgRect, imgRect)
  t=t*tFactor
  phase=phase+phaseInc
  if t<=0.1 then
    wibble=false
  end if
end enterFrame

on beginSprite
  self=sprite(spriteNum)
  myMember=self.member
  origImg=myMember.image.duplicate()
  img=origImg.duplicate()
  imgRect=origImg.rect
  myWidth=imgRect.width
  myHeight=imgRect.height
  myOrig=point(self.rect.left, self.rect.top)
  -- choose number of parts  
  nHoriz=4
  nVert=4
  origPts=[]
  repeat with i=1 to nHoriz+1
    origPts[i]=[]
    repeat with j=1 to nVert+1
      origPts[i][j]=point(myWidth*(i-1.0)/nHoriz, myHeight*(j-1.0)/NVert)
    end repeat
  end repeat
  newPts=duplicate(origPts)
  wibble=false
  phaseInc=-0.7
end beginSprite

on endSprite
  myMember.image.copyPixels(origImg, imgRect, imgRect)
end endSprite

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail