ベーシックパーティクル練習
♥0 |
Line 67 |
Modified 2010-07-08 00:14:44 |
MIT License
archived:2017-03-20 13:26:09
ActionScript3 source code
/**
* Copyright hacker_szoe51ih ( http://wonderfl.net/user/hacker_szoe51ih )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/5ROO
*/
package {
import flash.events.MouseEvent;
import flash.events.Event;
import flash.geom.Matrix;
import flash.geom.Transform;
import flash.display.Sprite;
public class FlashTest extends Sprite {
[SWF(width=465,height=465,backgroundColor=0,frameRate=30)]
//public var myBox:Particle;
public var array:Array;
public var max:int=300;
public var centerX:Number=stage.stageWidth/2;
public var centerY:Number=stage.stageHeight/2;
//public var nRadian:Number;
public function FlashTest() {
init();
}
public function init():void{
array=new Array();
for(var i:int=0; i<max; i++){
var particle:Particle=new Particle();
array.push(particle);
addChild(particle);
var rondomX:int=Math.random()*stage.stageWidth;
var rondomY:int=Math.random()*stage.stageHeight;
particle.x=rondomX;
particle.y=rondomY;
}
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
public function onEnterFrame(e:Event):void{
for(var i:int=0; i<array.length;i++){
array[i].x+=((array[i].x+array[i].vx)-array[i].x)*0.05;
array[i].y+=((array[i].y+array[i].vy)-array[i].y)*0.05;
if(array[i].x<0){
array[i].x=465;
}
if(array[i].x>465){
array[i].x=0;
}
if(array[i].y>465){
array[i].y=0;
}
if(array[i].y<0){
array[i].y=0465
}
}
}
}
}
import flash.display.*;
import flash.filters.*;
class Particle extends MovieClip{
public var clip:Sprite;
public var color:uint;
public var hankei:int;
public var vx:Number;
public var vy:Number;
public function Particle(){
vx=Math.floor(Math.random()*100+1)-50;
vy=Math.floor(Math.random()*100+1)-50;
color=Math.floor(Math.random()*0xffffffffff);
hankei=Math.floor(Math.random()*10)+1;
graphics.lineStyle(0,0,0);
graphics.beginFill(color);
graphics.drawCircle(0,0,hankei);
graphics.endFill();
}
}