ランダム運動2-1 : ActionScript

Pocket

ActionScriptでランダムにボールが落下するサンプルを作成しました。

function ParticleClip(target) {

	var target = target;

	this.execMotion = function(x, n) {
		for (var i = 0; i<n; i++);
			var container = target.createEmptyMovieClip("container"+i, i);
			var ball = container.attachMovie("ball", "ball", 0);
			container._x = Math.random()*300;
			container._rotation = Math.random()*2;
			container._y = 0;
			ball.onEnterFrame = function() {
				// Move the particle over time
				this._y += this.speed;
				this.speed++;
				if (this._y>300) {
					this._y = 0;
					this.speed = Math.random()*10+5;
					this._yscale = 100;
				}
			};
			ball.speed = Math.random()*10;
		}
	};
}

var obj = new ParticleClip(_root);
obj.execMotion(0, 100);

»ランダム運動3 : ActionScript
»ランダム運動2-2 : ActionScript
»ランダム運動2-1 : ActionScript
»ランダム運動1 : ActionScript

コメント

No comments yet.

Sorry, the comment form is closed at this time.