参加WS举办的25行代码赛的作品终于想出来了!
代码如下:
i = 1;
k = 0.2;
function createMC(NAME, DEPTH, W, H, BGCOLOR, BGALPHA) {
mc = this.createEmptyMovieClip(NAME, DEPTH);
mc.beginFill(BGCOLOR, BGALPHA);
mc.lineTo(W, 0);
mc.lineTo(W, H);
mc.lineTo(0, H);
mc.lineTo(0, 0);
mc._x = random(Stage.width);
mc._y = Stage.height;
mc.onEnterFrame = function() {
this._x += ((Stage.width)/2-this._x)*k;
this._y += ((Stage.height)/2-this._y)*k;
this._xscale = Math.abs((Stage.width)/2-this._x)*1+100;
this._alpha = Math.abs((Stage.width)/2-this._x)*1;
Math.abs((Stage.height)/2-this._y)25 ? i=1 : i++;
}
setInterval(creatMove, 30);
FPS开24帧效果不错!
Flash 动画
点击下载此文件