Flash Action实现小球沿不规则的路径上移动_Flash教程
教程Tag:暂无Tag,欢迎添加,赚取U币!
推荐:使用Flash实现Bump Mapping的效果1.下面先来简单的介绍一下什么叫作BumpMapping。BumpMapping又叫做凹凸贴图,在现在的图形处理以及游戏当中非常流行(大家应该都玩过Halflife-2或者Doom吧
用了BitmapData.getPixel();来做的.原理:路径为一像素的纯色的不规则的曲线(如红色),用getPixel();记录曲线上的所有坐标.
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
相关Flash教程:
- 相关链接:
- 教程说明:
Flash教程-Flash Action实现小球沿不规则的路径上移动。