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
Video Mask
Pulse Blend a Sprite
Advanced Lingo for Games
Distance Sensitive Button
OpenAtLaunch
Pause Button
PDF Publishing in Multimedia Projects
Complete Idiots Guide to Macromedia Flash 5
ProFusion Xtra for Authorware and Director
Tri-State Button
 

 

 

Behavior Ripple Rain-Alphamania

Added on 6/10/1999

 

Compatibilities:
D6_5 D7 D8 Mac PC Script

Required Xtras:
Alphamania
Effector Set II for Alphamania

This item has not yet been rated

Author: MediaLab (website)

Requires Effector Set 2

property sNum
property speed -- how often do they fall?
property spriteHeight, spriteWidth -- dimensions of sprite
property lastRainTick -- last time a drop fell
property onlyWhileMouseOver -- only generate ripples while over, pauseEffect otherwise
property paused -- generate ripples or not

on getBehaviorDescription me
  return "This behavior will place random ripples on the sprite to generate a rain effect."
end

on getPropertyDescriptionList me
  set list = [:]
  addProp list, #speed, [#comment: "Speed:", #format: #integer, #default: 60, #range: [#max: 100, #min:1]]
  addProp list, #onlyWhileMouseOver , [#comment: "Only While Mouse Over", #format: #boolean, #default: FALSE]
  return list
end

on beginSprite me
  set sNum = the spriteNum of me
  set spriteWidth = the width of sprite sNum
  set spriteHeight = the height of sprite sNum
  set lastRainTick = 0
  ripple(sprite sNum)
  if onlyWhileMouseOver then
    if not rollover(sNum) then
      PauseEffect(sprite sNum, #ripple)
      exit
    end if
  end if
  Add(the actorList, me)
end

on endSprite me
  set pos =   getone(the actorList, me)
  if pos then
    deleteAt(the actorList, pos)
  end if
end

on stepFrame me
  set nextRainTick = lastRainTick + 101 - speed
  if the ticks >= nextRainTick then  -- time for another drop
    RainDrop(me)
    set lastRainTick = the ticks
  end if
end

on RainDrop me, h, v
  if integerP(h) then
    set x = h
  else
    set x = random(spriteWidth)
  end if
  if integerP(v) then
    set y = v
  else
    set y = random(spriteHeight)
  end if
  
  ripple(sprite sNum, [#xLocation: x, #yLocation: y])
end


on StopEffect me, sym
  -- removes this behavior from the actorList
  if not voidP(sym) then
    if sym <> #ripple then exit
  end if
  set pos =   getone(the actorList, me)
  if pos then
    deleteAt(the actorList, pos)
    PauseEffect(sprite sNum, #ripple)
  end if
end

on ResumeEffect me, sym
  -- adds this behavior to the actorList
  if not voidP(sym) then
    if sym <> #ripple then exit
  end if
  set pos =   getone(the actorList, me)
  if pos = 0 then
    Add(the actorList, me)
    ContinueEffect(sprite sNum, #ripple)
  end if
end

on mouseEnter me
  if onlyWhileMouseOver then
    ResumeEffect(me)
  end if
end

on mouseLeave me
  if onlyWhileMouseOver then
    StopEffect(me)
  end if
end

 


Contact

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

Send e-mail