forked from: BitmapDataで配列に格納すると高速化するよ
矢印がいっぱいなんだけど、高速なデモ
画質はディフォルトの StageQuality. で
矢印 1000個
@author Yasu
/**
* Copyright zsp ( http://wonderfl.net/user/zsp )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/laE4
*/
// forked from zsp002's forked from: forked from: BitmapDataで配列に格納すると高速化するよ
// forked from zsp002's forked from: BitmapDataで配列に格納すると高速化するよ
// forked from clockmaker's BitmapDataで配列に格納すると高速化するよ
// forked from clockmaker's 3D Flow Simulation with Field of Blur
// forked from clockmaker's 3D Flow Simulation
// forked from clockmaker's Interactive Liquid 10000
// forked from clockmaker's Liquid110000 By Vector
// forked from munegon's forked from: forked from: forked from: forked from: Liquid10000
// forked from Saqoosha's forked from: forked from: forked from: Liquid10000
// forked from nutsu's forked from: forked from: Liquid10000
// forked from nutsu's forked from: Liquid10000
// forked from zin0086's Liquid10000
package
{
/**
* 矢印がいっぱいなんだけど、高速なデモ
* 画質はディフォルトの StageQuality. で
* 矢印 1000個
* @author Yasu
*/
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import net.hires.debug.Stats;
import flash.text.TextField;
[SWF(width="465", height="465", backgroundColor="0xFFFFFF")]
public class Main extends Sprite {
private const NUM_PARTICLE:uint = 100;
private const CX:int = 233;
private const CY:int = 233;
private var particleList:Vector.<Arrow>;
private var tf: TextField;
private var t:int = 0;
public function Main() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.frameRate = 60;
addEventListener( Event.ENTER_FRAME, loop );
particleList = new Vector.<Arrow>();
Arrow.PreRender();
for (var i:int = 0; i < NUM_PARTICLE; i++) {
var theta :Number = i*2*Math.PI/NUM_PARTICLE;
var pvx :Number = Math.cos(theta)*5;
var pvy :Number = Math.sin(theta)*5;
var a : Arrow = new Arrow(233, 233 ,theta,2);
particleList.push(a);
addChild(a);
}
addChild(new Stats);
tf = new TextField();
tf.y = 120;
addChild(tf);
}
private function addArrow(x:Number,y:Number, deg:Number,spd:Number):void{
var a:Arrow = new Arrow(x,y,deg,spd);
particleList.push(a);
addChild(a);
}
private function generateArrow():void{
t++;
if (t%1==0){
addArrow(CX, CY, (t +(t /10)% 40 )*Math.PI*2/ 40 , 2)
}
if(t>100)addArrow(CX, CY, Math.PI/2 +t, 4);
if(t>200 && t%10==5){
for(var i:int = 0 ;i<=10; i++){
addArrow(CX, CY-100, Math.PI/2 + i/10 +t, 4);
}
}
if((t>400) && (t%20==0)){
for(var j:int= -10 ;j<=10; j++){
addArrow(CX, CY-200, Math.PI/2 + j/10 + (t%60 -20) /100, 4);
}
}
if( (t>500) &&( t%5 ==0)){
var tx:Number = Math.random() *456;
var tvy:Number = Math.random()*3 +1;
addArrow(tx, 0, Math.PI/2, tvy);
}
if((t>600) &&(t%4==0)){
var r:Number =Math.random() * 2*Math.PI;
addArrow(CX,CY,r, 4);
}
}
private function loop( e:Event ):void {
generateArrow();
var n:uint = particleList.length;
while(n--){
particleList[n].move();
if (particleList[n].dead){
removeChild(particleList[n]);
particleList.splice(n,1);
}
}
tf.text = ( "n=" +particleList.length);
}
}
}
import flash.display.*;
import flash.geom.*;
class Arrow extends Bitmap
{
private var rot:int = 0;
private var vx:Number = 0;
private var vy:Number = 0;
public var dead:Boolean = false;
private static const ROT_STEPS:int = 120;
private static var rotArr:Vector.<BitmapData> = new Vector.<BitmapData>(ROT_STEPS, true);
public static function PreRender():void{
// 矢印をプレレンダリング
var dummy:Sprite = new Sprite();
dummy.graphics.beginFill(0xFFFFFF, 1);
dummy.graphics.lineStyle(1, 0x0, 1);
dummy.graphics.moveTo(2, 4);
dummy.graphics.lineTo(8, 4);
dummy.graphics.lineTo(8, 0);
dummy.graphics.lineTo(20, 7);
dummy.graphics.lineTo(8, 14);
dummy.graphics.lineTo(8, 10);
dummy.graphics.lineTo(2, 10);
dummy.graphics.lineTo(2, 4);
var matrix:Matrix;
var i:int = ROT_STEPS;
while (i--)
{
matrix = new Matrix();
matrix.translate( -11, -11);
matrix.rotate( ( 360 / ROT_STEPS * i )* Math.PI / 180);
matrix.translate( 11, 11);
rotArr[i] = new BitmapData(22, 22, true, 0x0);
rotArr[i].draw(dummy, matrix);
}
}
public function Arrow(tx:Number, ty:Number, deg: Number, spd:Number){
x = tx;
y = ty;
vx = Math.cos(deg)*spd;
vy = Math.sin(deg)*spd;
rot = ((deg*120 /(2*Math.PI)) +120)%120;
dead = false;
}
public function calcRot():void{
var r:Number = Math.atan2(vy, vx);
this.rot = ((r*120 /(2*Math.PI)) +120)%120;
}
public function move():void{
x+= vx;
y+= vy;
if((x<-20) ||(465<x)||(y<-20) ||(465<y)) {
dead = true;
}
bitmapData = rotArr[rot];
}
}