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++;
     }
    };

  • 相关阅读:
    Idea主题下载
    使用plsql创建用户并授权(图形化界面)
    PLSQL Developer 没有64位版本 + 找不到 msvcr71.dll
    NOIp2017TG解题报告
    Restart
    NOIp2018RP++
    其他题
    Errors
    NOIpDairy
    Code Style for OI
  • 原文地址:https://www.cnblogs.com/JamyWong/p/1747908.html
Copyright © 2011-2022 走看看