RSS | Twitter | Facebook
Home » ActionScript » motion » limit » 収束運動2 : ActionScript

収束運動2 : ActionScript

収束運動の2回目です。複数のクリップをステージに配置しています。

// 点オブジェクト
function PointClip(x, y, endX, endY, speed, limit) {
	this._x = x;
	this._y = y;
	// 収束の目標点
	var endX = endX;
	var endY = endY;
	// 収束スピード
	var speed = speed;
	// 許容誤差
	var limit = limit;
	// 収束処理
	this.onEnterFrame = function() {
		var diffX = (endX-this._x);
		var diffY = (endY-this._y);
		if (Math.abs(diffX)<limit && Math.abs(diffY)<limit) {
			this._x = endX;
			this._y = endY;
			this.onEnterFrame;
		} else {
			this._x += (endX-this._x)/speed;
			this._y += (endY-this._y)/speed;
		}
	};
}
for (var i = 0; i<100; i++) {
	var x = Math.ceil(Math.random()*200);
	var y = Math.ceil(Math.random()*200);
	var o = new PointClip(x, y, 100, 100, 20, 1);
	attachMovie('clip', 'ball'+i, i, o);
}

このページの上へ移動

  Yahoo!ブックマークに登録    Google  この記事をクリップ!  BuzzurlにブックマークBuzzurlにブックマーク

2008/3/4 火 | limit | 固定リンク |

コメントはまだありません。

コメントの投稿

改行と段落タグは自動で挿入されます。メールアドレスは表示されません。
利用可能な HTML タグ :
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite="">
<cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(必須)

(必須)


トラックバックURL

このページの上へ移動