自己計測するパーティクル knd forked:1favorite:12lines:67license : MIT License modified : 2010-03-10 21:09:09 Embed Tweet package { import flash.display.Sprite; import flash.events.Event; [SWF(backgroundColor="0x0")] public class FlashTest extends Sprite { private var _particles:Array; public function FlashTest() { // write as3 code here.. _particles = []; for (var i:int = 0; i < 100; i++) { var p:Particle = new Particle(); _particles.push(p); addChild(p); } addEventListener(Event.ENTER_FRAME, loop); } private function loop(e:Event):void { for (var i:int = 0; i < 100; i++) { var p:Particle = _particles[i]; p.update(); if (p.x > 465 || p.x < -60) { p.init(); this.setChildIndex(p, 0); } if (p.y > 465 || p.y < -80) { p.init(); this.setChildIndex(p, 0); } } } } } import net.hires.debug.Stats; class Particle extends Stats { private var _x0:Number; private var _y0:Number; private var _theta0:Number; private var _theta:Number; public function Particle() { super(); _x0 =200; _y0 =180; _theta0 = 2 * Math.PI * Math.random(); _theta = 2.5 * Math.random(); } public function update():void { _theta += 0.01; var r:Number = _theta * 10; r *= r; x = _x0 + r * Math.cos(_theta + _theta0); y = _y0 + r * Math.sin(_theta + _theta0); } public function init():void { x = _x0; y = _y0; _theta = 0; _theta0 = 2 * Math.PI * Math.random(); } } Code Fullscreen Preview Fullscreen sw_lucchini matsumos osamX tsu_droid : おもろい zawa : シュール ish_xxxx : キンモー Hiiragi : その柔軟な発想が羨ましい・・・(笑 clockmaker : この発想はなかったwww nitoyon : netaet.hires.debug.Stats がパーティクルに nanlow : なんか好きw zahir : なんかもうカオス Nicolas : なんか吹いたw neta シュール setChildIndex Stats Math.PI addEventListener push Math.cos Event.ENTER_FRAME addChild Math.sin Math.random Event Array Sprite int Number sort new page view favorite forked pv959 forked from: 自己計測するパーティクル bkzen forked:0 favorite:2lines:85 (diff:72)