zoukankan      html  css  js  c++  java
  • flash 代码 雪花飘落


    var frameTime = 4;


    var sceneWidth = 400;  //屏幕宽度

    var sceneHeight = 400;  //屏幕高度

    var removeSnow = 100;  //雪花数量

    var speed = 40;  //雪花速度

    var distance = -0.3;

    this.onEnterFrame = function () {
     if (random (frameTime) == 0) {
      mc = this.snow.duplicateMovieClip ("snow"+i, i+100);     //snow为雪花。
      mc._x = random (sceneWidth);
      mc._xscale = mc._yscale=random (50)+50;
      mc._alpha = mc._xscale;
      mc._y = 0;
      mc.s = random (100);
      mc.onEnterFrame = function () {
       this._y += this._xscale/speed;
       this._x += random (2)-0.5+distance;
       if (targetMc.hitTest (this._x, this._y, true)) {        //targetMc为物体,雪花会放置与该物体上,然后溶化,消失。
        mc = _root.snow.duplicateMovieClip ("dusnow"+j, j);
        mc._x = this._x;
        mc._y = this._y;
        mc._alpha = this._alpha;
        mc._xscale = mc._yscale=this._xscale;
        mc.onEnterFrame = function () {
         if (this.t++>removeSnow) {
          this._alpha -= 5;
          if (this._alpha<0) {
           this.removeMovieClip ();
          }
         }
        };
        j++;
        this.removeMovieClip ();
       }
       if (this._x<0 || this._x>sceneWidth || this._y>sceneHeight) {
        this.removeMovieClip ();
       }
      };
      i++;
     }
    };

    var frameTime = 10;

    var sceneWidth = 400;

    var sceneHeight = 400;

    var speed = 40;

    var vibration = 20;

    this.onEnterFrame = function () {
     if (random (frameTime) == 0) {
      mc = this.snowMc.duplicateMovieClip ("snowMc"+i, i+100);
      mc._x = random (sceneWidth);
      mc._xscale = mc._yscale=random (50)+50;
      mc._alpha = mc._xscale;
      mc._y = 0;
      mc.s = random (100);
      mc.onEnterFrame = function () {
       this._y += this._xscale/speed;
       this._x += Math.sin (this.s++/vibration);
       if (this._y>sceneHeight) {
        this.removeMovieClip ();
       }
      };
      i++;
     }
    };

  • 相关阅读:
    检测ORACLE方法汇总数据块损坏
    DHot.exe 热点新闻
    无效 URI: 故障分析证书颁发机构/主机
    lucene两个分页操作
    求职技巧—2014六个秘诀二
    ubuntu下一个rootusername入口mysql,如何查看username和password,如何改变rootpassword
    LeetCodeOJ. Maximum Depth of Binary Tree
    基于用户的推荐协同过滤算法的算法
    《C++ Primer Plus》学习笔记10
    m_Orchestrate learning system---八、下拉列表(select标签)如何实现链接功能
  • 原文地址:https://www.cnblogs.com/JamyWong/p/1747908.html
Copyright © 2011-2022 走看看