何かウネウネ
勉強がてら適当な処理で作ったので
処理が激重いです
...
@author DefaultUser (Tools -> Custom Arguments...)
/**
* Copyright _mutast ( http://wonderfl.net/user/_mutast )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/nPi0
*/
package
{
//勉強がてら適当な処理で作ったので
//処理が激重いです
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.geom.Point;
import flash.utils.Timer;
/**
* ...
* @author DefaultUser (Tools -> Custom Arguments...)
*/
public class Test2 extends MovieClip {
var array:Array;
var array1:Array;
//ポイントスプリング
const spring1:Number = 0.03;
const spring2:Number = 0.4;
//減速
const jur1:Number = 0.6;
const jur2:Number = 0.5;
var timer:Timer;
var dil:int;
//コンストラクタ
public function Test2() {
array1 = new Array();
timer = new Timer(0);
stage.frameRate = 30;
for (var ii:int = 0; ii < 70; ii++) {
array = new Array();
var b0:Ball = new Ball(1,0);
b0.x = b0.y = b0.ex = b0.ey = 0;
addChild(b0);
var s:Sprite = new Sprite();
addChild(s);
array.push(s);
array.push(b0);
for (var i:int = 0; i < 5; i++) {
dil += 20;
var b:Ball = new Ball(2,dil);
b.x = b.y = b.ex = b.ey = 0;
addChild(b);
array.push(b);
}
array1.push(array);
}
timer.addEventListener(TimerEvent.TIMER, timerFunc);
timer.start();
addEventListener(Event.ENTER_FRAME, loop);
}
public function timerFunc(evt:TimerEvent):void {
var d:int = Math.random() * 200 + 200;
for (var i = 0; i < 70;i++) {
var ss:Sprite = array1[i][0];
var r:int = ss.rotation;
do {
var l:int = Math.random() * 50 + 10;
r += Math.random() * 190 - 95;
var dx:int = Math.cos(r * Math.PI / 180) * l;
var dy:int = Math.sin(r * Math.PI / 180) * l;
}while (ss.x + dx< 0 || ss.x + dx> stage.stageWidth || ss.y +dy< 0 || ss.y + dy > stage.stageHeight);
ss.rotation = r;
ss.x += dx;
ss.y += dy;
}
timer.delay = d;
}
public function loop(evt:Event):void {
for (var ii:int = 0; ii < 70;ii++) {
var b:Ball = array1[ii][1];
var p:Sprite = array1[ii][0];
var nx:Number;
var ny:Number;
b.ex += (p.x - b.x) * spring1;
b.ex *= jur1;
nx = int(b.ex + b.x);
b.ey += (p.y - b.y) * spring1;
b.ey *= jur1;
ny = int(b.ey + b.y);
var brot:Number = Math.atan2(ny - int(b.y), nx - int(b.x)) * 180 / Math.PI;
b.rotation = int(brot);
b.x = nx;
b.y = ny;
for (var i:int = 2; i <= 6; i++) {
var ball1:Ball = array1[ii][i - 1];
var ball2:Ball = array1[ii][i];
nx = 0;
ny = 0;;
ball2.ex += (ball1.x - ball2.x) * spring2;
ball2.ex *= jur2;
nx = int(ball2.ex + ball2.x);
ball2.ey += (ball1.y - ball2.y) * spring2;
ball2.ey *= jur2;
ny = int(ball2.ey + ball2.y);
brot = Math.atan2(ny - int(ball2.y), nx - int(ball2.x)) * 180 / Math.PI;
b.rotation = int(brot);
ball2.x = nx;
ball2.y = ny;
}
}
}
}
{
}
}
import flash.display.Sprite;
import flash.events.Event;
class Ball extends Sprite{
var sp:Sprite;
var ex:Number = 0;
var ey:Number = 0;
public function Ball(flg:int,num:int) {
if(flg == 1) {
sp = new Sprite();
sp.graphics.beginFill(0x000000);
sp.graphics.drawCircle(0, 0, 2.5);
sp.graphics.endFill();
sp.graphics.lineStyle(1, 0x000000, 1);
sp.graphics.moveTo(0, 0);
sp.graphics.lineTo(10, 5);
sp.graphics.moveTo(0, 0);
sp.graphics.lineTo(10, -5);
addChild(sp);
}else if (flg == 2) {
function func1(num:int):Sprite {
var sp:Sprite = new Sprite();
sp.graphics.beginFill(0x000000);
sp.graphics.drawCircle(0,0,num);
sp.graphics.endFill();
return sp;
}
var s:Sprite = func1(3);
addChild(s);
s.x = s.y = 0;
var s1:Sprite = func1(1);
var s2:Sprite = func1(1);
var s3:Sprite = func1(0.5);
var s4:Sprite = func1(0.5);
addChild(s1);
addChild(s2);
addChild(s3);
addChild(s4);
var rot:int = num;
addEventListener(Event.ENTER_FRAME,func2);
function func2(evt:Event):void {
rot = (rot + 10)%360;
var rad:Number = rot*Math.PI/180;
s1.x = s.x + 5;
s1.y = Math.cos(rad) * 10 + s.y;
s3.x = s.x + 7;
s3.y = Math.sin(rad) * 10 + s.y;
s2.x = s.x - 5;
s2.y = Math.cos(rad) * -10 + s.y;
s4.x = s.x - 7;
s4.y = Math.sin(rad) * -10 + s.y;
graphics.clear();
graphics.lineStyle(1.5, 0x000000, 1);
graphics.moveTo(s.x+2,s.y);
graphics.lineTo(s1.x,s1.y);
graphics.moveTo(s.x-2,s.y);
graphics.lineTo(s2.x,s2.y);
graphics.lineStyle(1,0x000000,1);
graphics.moveTo(s1.x,s1.y);
graphics.lineTo(s3.x,s3.y);
graphics.moveTo(s2.x,s2.y);
graphics.lineTo(s4.x, s4.y);
}
}
}
}