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
Puzzler - Puzzle Maker
goMU LDM
NetDone() not registering in IE on the Mac
TurnPict
Tool Tips/Help popUp box ver 2.1
A Simple Back Button
Dave Client
Multiple-timer facility
MPEG / ActiveMovie ActiveX control
Making a simple game
 

 

 

Behavior Snow Falling

Added on 1/16/2002

 

Compatibilities:
D8_5

Rating:

Author: sbljx (website)

this is a chinese-version,if anyone cannot understand it or have other trouble,just tell in Forum, I will help.

Download PC Source
property SnowList,OldPic,MyImage,MySnowType,MySnow,MySpeed,SnowCount,SnowWidth,SnowHeight,SnowColor,UseCustomSnow,MySnowMember
property BlendSnow,tblend
on getBehaviorDescription
  tt="雪花飘落"
  tt=tt&return&return&"本行为适用于bitmap精灵"
  tt=tt&return&       "注意事项:"
  tt=tt&return&       "    当选用默认雪花时,默认雪花颜色不要设成纯白!"
  tt=tt&return&return&"    本行为你可以直接使用或修改源代码,如需转载或刊登、演示教学请著名版权作者!必要时请联系作者!"
  tt=tt&return&return&"          版权所有:   Sbljx"
  return tt
end getBehaviorDescription
------------
on beginSprite me
  OldPic=sprite(the currentspritenum).member.image.duplicate()
  MyImage=sprite(the currentspritenum).member.image
  MySnow=image(SnowWidth, SnowHeight, 16)
  case MySnowType of
    "矩形":MySnow.fill(MySnow.rect, [#shapeType: #rect, #lineSize: 0, #color: SnowColor])
    "圆形":MySnow.fill(MySnow.rect, [#shapeType: #oval, #lineSize: 0, #color: SnowColor])  
  end case
  if UseCustomSnow then MySnow=MySnowMember.image
    case BlendSnow of
      "渐显":tblend=0
      "渐隐":tblend=255
      "显隐显":tblend=255      
      "隐显隐":tblend=0
      "总显":tblend=255
    end case
  tr=rect(0,0,MySnow.width,MySnow.height)
  SnowList=[[#CurRect:tr,#NextRect:tr,#Pic:MySnow,#HChange:1,#CurrentBlend:255]]
  SnowList=[]
  repeat with i=1 to SnowCount
    tth=random(MyImage.width)
    ttv=random(MyImage.height)-MyImage.height
    SnowList.add([#CurRect:tr+rect(tth,ttv,tth,ttv),#NextRect:tr+rect(tth,ttv,tth,ttv),#Pic:MySnow,#HChange:1,#CurrentBlend:tblend])
  end repeat
  --
end

on exitFrame me
  FallSnow
end

on endSprite me
  sprite(the currentspritenum).member.image=OldPic
end
------
on FallSnow
  repeat with i=1 to SnowList.count
    if random(20)=1 then SnowList[i].HChange=-SnowList[i].HChange
    tspeed=MySpeed
    SnowList[i].CurRect=SnowList[i].NextRect
    if SnowList[i].CurRect[2]>MyImage.rect[4] then
      tr=rect(0,0,MySnow.width,MySnow.height)
      tth=random(MyImage.width)
      ttv=0
      SnowList[i].NextRect=tr+rect(tth,ttv,tth,ttv)
      SnowList[i].CurrentBlend=tblend
    else
      SnowList[i].NextRect=SnowList[i].NextRect+rect(SnowList[i].HChange,tspeed,SnowList[i].HChange,tspeed)
      
    end if
    case BlendSnow of
      "渐显":
        if SnowList[i].CurRect[4]>0 and SnowList[i].CurRect[4]          -- SnowList[i].CurrentBlend=255*(MyImage.height-SnowList[i].CurRect[4])/(MyImage.height*1.00)
          SnowList[i].CurrentBlend=255*(SnowList[i].CurRect[4])/(MyImage.height*1.00)
        end if
      "渐隐":
        if SnowList[i].CurRect[4]>0 and SnowList[i].CurRect[4]          SnowList[i].CurrentBlend=255*(MyImage.height-SnowList[i].CurRect[4])/(MyImage.height*1.00)
        end if
      "显隐显":
        if SnowList[i].CurRect[4]>0 and SnowList[i].CurRect[4]          SnowList[i].CurrentBlend=abs(255*(MyImage.height/2.00-SnowList[i].CurRect[4])/(MyImage.height*0.50))
        end if        
      "隐显隐":
        if SnowList[i].CurRect[4]>0 and SnowList[i].CurRect[4]          SnowList[i].CurrentBlend=255-abs(255*(MyImage.height/2.00-SnowList[i].CurRect[4])/(MyImage.height*0.50))
        end if  
      "总显":
        SnowList[i].CurrentBlend=255
    end case
    MyImage.copyPixels(OldPic,SnowList[i].CurRect,SnowList[i].CurRect)
    MyImage.copyPixels(SnowList[i].Pic,SnowList[i].NextRect, SnowList[i].Pic.rect,[#ink:36,#blendLevel: SnowList[i].CurrentBlend])  
  end repeat
end
-------
on getPropertyDescriptionList
  vPDList = [:]
  setaProp vPDList, #UseCustomSnow, [#comment: "自定义雪花",
    #format:#boolean, #default:false]
  setaProp vPDList, #MySnowMember, [#comment: "自定义雪花演员",
    #format:#Bitmap, #default:member(1)]
  setaProp vPDList, #MySnowType, [#comment: "默认雪花图案",
    #format:#string, #default:"圆形",#range: ["矩形","圆形"]]
  setaProp vPDList, #SnowWidth, [#comment: "默认雪花宽度",
    #format:#integer, #default:2,#range: [#min:2, #max:10]]  
  setaProp vPDList, #SnowHeight, [#comment: "默认雪花高度",
    #format:#integer, #default:2,#range: [#min:2, #max:10]]
  setaProp vPDList, #SnowColor, [#comment: "默认雪花颜色",
    #format:#color,#default:rgb(247,247,247)  ]
  setaProp vPDList, #MySpeed, [#comment: "向下飘落速度",
    #format: #float, #default:2, #range: [#min:0, #max:25]]
  setaProp vPDList, #SnowCount, [#comment: "雪花数目",
  #format: #integer, #default:30, #range: [#min:1, #max: 100]]
  setaProp vPDList, #BlendSnow, [#comment: "默认雪花图案",
    #format:#string, #default:"总显",#range: ["总显","渐显","渐隐","隐显隐","显隐显"]]
  return vPDList
end getPropertyDescriptionList

on isOKToAttach (me, aSpriteType, aSpriteNum)
  case aSpriteType of
    #graphic:
      return getpos([#bitmap], sprite(aSpriteNum).member.type) <> 0
    #script:
      return FALSE
  end case
end isOKToAttach

 


Contact

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

Send e-mail