利用FOR循环画圆并随鼠标上下移动

利用FOR循环画圆并随鼠标上下移动


var circles:Array;

function MouseToy() {
	var a:Number;
	var b:Number;
	circles=[];
	for (var i:int = 0; i<30; i++) {
		a = 20*(1 + i / 2);
		b = 20*(0.5 + i /4);
		var c:Sprite=makeCircle(a,b);
		c.x=stage.stageWidth/2-a/2;
		c.y=stage.stageHeight/2-b/2;
		//c.scaleX=1+i/2;
		//c.scaleY=0.5+i/4;
		addChild(c);
		circles.push(c);
	}
	addEventListener(Event.ENTER_FRAME, onLoop);
}
function onLoop(evt:Event):void {
	circles[0].y += (mouseY - circles[0].y) / 4;
	for (var i:int = 1; i<circles.length; i++) {
		var pre:Sprite=circles[i-1];
		circles[i].y += (pre.y - circles[i].y) / 4;
	}
}
function makeCircle(a:Number,b:Number):Sprite {
	var s:Sprite = new Sprite();
	with (s.graphics) {
		lineStyle(1.5,Math.random ()*0xffffff);
		drawEllipse(0,0,a,b);
		//s.filters=[new GlowFilter(0xff0000,1,4,4,100,50,true)];
	}
	return s;
}
MouseToy();

你可能感兴趣的:(C++,c,C#)