Flash Action實現(xiàn)小球沿不規(guī)則的路徑上移動_Flash教程

      編輯Tag賺U幣
      教程Tag:暫無Tag,歡迎添加,賺取U幣!

      推薦:使用Flash實現(xiàn)Bump Mapping的效果
      1.下面先來簡單的介紹一下什么叫作BumpMapping。BumpMapping又叫做凹凸貼圖,在現(xiàn)在的圖形處理以及游戲當(dāng)中非常流行(大家應(yīng)該都玩過Halflife-2或者Doom吧

      用了BitmapData.getPixel();來做的.原理:路徑為一像素的純色的不規(guī)則的曲線(如紅色),用getPixel();記錄曲線上的所有坐標(biāo).

      import flash.display.BitmapData;
      import flash.geom.Point;
      var pointArr:Array = ;
      var ypos:Number = 200;
      var curve:MovieClip = this.createEmptyMovieClip("curve", 10);
      with (curve) {
      lineStyle(1, 0xFF0000);
      moveTo(0, ypos);
      for (var i:Number = 0; i<550; i = 6) {
      lineTo(i, ypos i/10*Math.sin(i/20));
      }
      }
      var X:Number = curve._width;
      var Y:Number = ypos curve._height;
      var copyBitmap:BitmapData = new BitmapData(X, Y, true, 0);
      copyBitmap.draw(curve);
      var color:Number = Number(0xFF0000);
      for (var i:Number = 0; i<X; i = 10) {
      for (var j:Number = 0; j<Y; j ) {
      if (copyBitmap.getPixel(i, j) == color) {
      pointArr.push(new Point(i, j));
      break;
      }
      }
      }
      copyBitmap.dispose();
      var ball:MovieClip = this.createEmptyMovieClip("ball", 20);
      with(ball){
      lineStyle(20);
      moveTo(0, 0);
      lineTo(.2, 0);
      }
      this.onEnterFrame = function() {
      ball._x = pointArr[0].x;
      ball._y = pointArr[0].y-10;
      pointArr.shift();
      if (pointArr.length == 0) {
      delete this.onEnterFrame;
      trace("over");
      }
      };

      分享:小技巧:純AS的運動模糊效果
      importflash.filters.*;varblur:BlurFilter=newBlurFilter(blurX,blurY,1);varnum=10;for(vari=0;inum;i){scale=random(300);alpha=

      /所屬分類:Flash教程/更新時間:2008-03-05
      相關(guān)Flash教程