パーティクル生成用
♥0 |
Line 62 |
Modified 2011-03-21 17:57:08 |
MIT License
archived:2017-03-20 01:00:59
ActionScript3 source code
/**
* Copyright Ryogo_Quberey ( http://wonderfl.net/user/Ryogo_Quberey )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/ddbb
*/
package {
import flash.display.Sprite;
import flash.events.Event;
[SWF(backgroundColor="0x000000")]
public class FlashTest extends Sprite {
private var particles:Array;
private var numParticles:uint = 20;
public function FlashTest() {
particles = new Array();
for(var i:int=0; i<numParticles; i++) {
var b:Ball = new Ball();
b.x = Math.random()*stage.stageWidth;
b.y = Math.random()*stage.stageHeight;
addChild(b);
particles.push(b);
}
addEventListener(Event.ENTER_FRAME, onEnter);
}
private function onEnter(e:Event):void{
graphics.clear();
for(var i:int = 0;i < numParticles;i++)
{
var b:Ball = particles[i];
b.x += b.vx;
b.y += b.vy;
if(b.x > stage.stageWidth)
{
b.x = 0;
}
else if(b.x < 0)
{
b.x = stage.stageWidth;
}
if(b.y > stage.stageHeight)
{
b.y = 0;
}
else if(b.y < 0)
{
b.y = stage.stageHeight;
}
}
}
}
}
import flash.display.Sprite;
class Ball extends Sprite
{
public var vx:Number = Math.random() +0.5;
public var vy:Number = Math.random() +0.5;
public var mass:Number = 3;
public var radius:Number = 30
public var color:uint = 0xFF0000;
public function Ball(r:Number = 10, c:uint = 0x11FFCC)
{
radius = r;
color = c;
graphics.beginFill(c);
graphics.drawCircle(0, 0, r);
graphics.endFill();
}
}