マウスから逃げる forked from: マウスから逃げる
- // forked from sake's マウスから逃げる
- /*
- マウスから逃げます。
- */
- package
- {
- import flash.display.BlendMode;
- import flash.display.Shape;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.filters.BlurFilter;
- import funnel.*;
- import funnel.gui.*;
- [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
- public class RunAwayFromMouse extends Sprite
- {
- private var num:int=500;
- private var firstPointX:Array=new Array();
- private var firstPointY:Array=new Array();
- private var fio:Fio;
- public function RunAwayFromMouse()
- {
- var config:Configuration = Fio.FIRMATA;
- fio = new Fio([1], config);
- for(var i:int=0; i < num; i++)
- {
- var circle:Shape=new Shape();
- circle.graphics.beginFill(Math.random() * 0xFFFFFF);
- circle.graphics.drawCircle(0, 0, Math.random() * 18 + 5);
- circle.graphics.endFill();
- circle.blendMode=BlendMode.ADD;
- circle.x=Math.round(Math.random() * stage.stageWidth);
- circle.y=Math.round(Math.random() * stage.stageHeight);
- circle.name="circle" + i.toString();
- circle.filters=[new BlurFilter(10, 10, 1)];
- addChild(circle);
- firstPointX[i]=circle.x;
- firstPointY[i]=circle.y;
- }
- addEventListener(Event.ENTER_FRAME, onFrame);
- }
- public function onFrame(e:Event):void
- {
- for(var i:int=0; i < num; i++)
- {
- var circle:Shape=getChildByName("circle" + i.toString())as Shape;
- //var theta:Number=Math.atan2(circle.y - mouseY, circle.x - mouseX);
- var theta:Number=Math.atan2(circle.y - fio.ioModule(1).analogPin(0).value * 465, circle.x - fio.ioModule(1).analogPin(0).value * 465);
- //var d:Number=1000 / Math.sqrt(Math.pow(mouseX - circle.x, 2) + Math.pow(mouseY - circle.y, 2));
- var d:Number=1000 / Math.sqrt(Math.pow(fio.ioModule(1).analogPin(0).value * 465 - circle.x, 2) + Math.pow(fio.ioModule(1).analogPin(0).value * 465 - circle.y, 2));
- circle.x+=d * Math.cos(theta) + (firstPointX[i] - circle.x) * 0.1;
- circle.y+=d * Math.sin(theta) + (firstPointY[i] - circle.y) * 0.1;
- }
- }
- }
- }
マウスから逃げる forked from: マウスから逃げる
- // forked from sake's マウスから逃げる
- /*
- マウスから逃げます。
- */
- package
- {
- import flash.display.BlendMode;
- import flash.display.Shape;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.filters.BlurFilter;
- [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
- public class RunAwayFromMouse extends Sprite
- {
- private var num:int=500;
- private var firstPointX:Array=new Array();
- private var firstPointY:Array=new Array();
- public function RunAwayFromMouse()
- {
- for(var i:int=0; i < num; i++)
- {
- var circle:Shape=new Shape();
- circle.graphics.beginFill(Math.random() * 0xFFFFFF);
- circle.graphics.drawCircle(0, 0, Math.random() * 18 + 5);
- circle.graphics.endFill();
- circle.blendMode=BlendMode.ADD;
- circle.x=Math.round(Math.random() * stage.stageWidth);
- circle.y=Math.round(Math.random() * stage.stageHeight);
- circle.name="circle" + i.toString();
- circle.filters=[new BlurFilter(10, 10, 1)];
- addChild(circle);
- firstPointX[i]=circle.x;
- firstPointY[i]=circle.y;
- }
- addEventListener(Event.ENTER_FRAME, onFrame);
- }
- public function onFrame(e:Event):void
- {
- for(var i:int=0; i < num; i++)
- {
- var circle:Shape=getChildByName("circle" + i.toString())as Shape;
- var theta:Number=Math.atan2(circle.y - mouseY, circle.x - mouseX);
- var d:Number=1000 / Math.sqrt(Math.pow(mouseX - circle.x, 2) + Math.pow(mouseY - circle.y, 2));
- circle.x+=d * Math.cos(theta) + (firstPointX[i] - circle.x) * 0.1;
- circle.y+=d * Math.sin(theta) + (firstPointY[i] - circle.y) * 0.1;
- }
- }
- }
- }
マウスから逃げる forked from: マウスから逃げる
- // forked from sake's マウスから逃げる
- /*
- マウスから逃げます。
- */
- package
- {
- import flash.display.BlendMode;
- import flash.display.Shape;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.filters.BlurFilter;
- [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
- public class RunAwayFromMouse extends Sprite
- {
- private var num:int=500;
- private var firstPointX:Array=new Array();
- private var firstPointY:Array=new Array();
- public function RunAwayFromMouse()
- {
- for(var i:int=0; i < num; i++)
- {
- var circle:Shape=new Shape();
- circle.graphics.beginFill(Math.random() * 0xFFFFFF);
- circle.graphics.drawCircle(0, 0, Math.random() * 18 + 5);
- circle.graphics.endFill();
- circle.blendMode=BlendMode.ADD;
- circle.x=Math.round(Math.random() * stage.stageWidth);
- circle.y=Math.round(Math.random() * stage.stageHeight);
- circle.name="circle" + i.toString();
- circle.filters=[new BlurFilter(10, 10, 1)];
- addChild(circle);
- firstPointX[i]=circle.x;
- firstPointY[i]=circle.y;
- }
- addEventListener(Event.ENTER_FRAME, onFrame);
- }
- public function onFrame(e:Event):void
- {
- for(var i:int=0; i < num; i++)
- {
- var circle:Shape=getChildByName("circle" + i.toString())as Shape;
- var theta:Number=Math.atan2(circle.y - mouseY, circle.x - mouseX);
- var d:Number=1000 / Math.sqrt(Math.pow(mouseX - circle.x, 2) + Math.pow(mouseY - circle.y, 2));
- circle.x+=d * Math.cos(theta) + (firstPointX[i] - circle.x) * 0.1;
- circle.y+=d * Math.sin(theta) + (firstPointY[i] - circle.y) * 0.1;
- }
- }
- }
- }
マウスから逃げる forked from: マウスから逃げる
- // forked from sake's マウスから逃げる
- /*
- マウスから逃げます。
- */
- package
- {
- import flash.display.BlendMode;
- import flash.display.Shape;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.filters.BlurFilter;
- [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
- public class RunAwayFromMouse extends Sprite
- {
- private var num:int=500;
- private var firstPointX:Array=new Array();
- private var firstPointY:Array=new Array();
- public function RunAwayFromMouse()
- {
- for(var i:int=0; i < num; i++)
- {
- var circle:Shape=new Shape();
- circle.graphics.beginFill(Math.random() * 0xFFFFFF);
- circle.graphics.drawCircle(0, 0, Math.random() * 18 + 5);
- circle.graphics.endFill();
- circle.blendMode=BlendMode.ADD;
- circle.x=Math.round(Math.random() * stage.stageWidth);
- circle.y=Math.round(Math.random() * stage.stageHeight);
- circle.name="circle" + i.toString();
- circle.filters=[new BlurFilter(10, 10, 1)];
- addChild(circle);
- firstPointX[i]=circle.x;
- firstPointY[i]=circle.y;
- }
- addEventListener(Event.ENTER_FRAME, onFrame);
- }
- public function onFrame(e:Event):void
- {
- for(var i:int=0; i < num; i++)
- {
- var circle:Shape=getChildByName("circle" + i.toString())as Shape;
- var theta:Number=Math.atan2(circle.y - mouseY, circle.x - mouseX);
- var d:Number=1000 / Math.sqrt(Math.pow(mouseX - circle.x, 2) + Math.pow(mouseY - circle.y, 2));
- circle.x+=d * Math.cos(theta) + (firstPointX[i] - circle.x) * 0.1;
- circle.y+=d * Math.sin(theta) + (firstPointY[i] - circle.y) * 0.1;
- }
- }
- }
- }
マウスから逃げる forked from: マウスから逃げる
- // forked from sake's マウスから逃げる
- /*
- マウスから逃げます。
- */
- /*--
- 元気玉
- ----*/
- package
- {
- import flash.display.BlendMode;
- import flash.display.Shape;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.filters.BlurFilter;
- [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
- public class RunAwayFromMouse extends Sprite
- {
- private var num:int=700;
- private var firstPointX:Array=new Array();
- private var firstPointY:Array=new Array();
- public function RunAwayFromMouse()
- {
- for(var i:int=0; i < num; i++)
- {
- var circle:Shape=new Shape();
- circle.graphics.beginFill(0x6699);
- circle.graphics.drawCircle(0, 0, Math.random() * 20 );
- circle.graphics.endFill();
- circle.blendMode=BlendMode.ADD;
- circle.x=Math.round(Math.random() * stage.stageWidth);
- circle.y=Math.round(Math.random() * stage.stageHeight);
- circle.name="circle" + i.toString();
- circle.filters=[new BlurFilter(10, 10, 1)];
- addChild(circle);
- firstPointX[i]=circle.x;
- firstPointY[i]=circle.y;
- }
- addEventListener(Event.ENTER_FRAME, onFrame);
- }
- public function onFrame(e:Event):void
- {
- for(var i:int=0; i < num; i++)
- {
- var circle:Shape=getChildByName("circle" + i.toString())as Shape;
- var theta:Number=Math.atan2(circle.y - mouseY, circle.x - mouseX);
- var d:Number=1000 / Math.sqrt(Math.pow(mouseX - circle.x, 2) + Math.pow(mouseY - circle.y, 2));
- //dの値は距離が近い程大きくなって、最後には、無限に近い速度で、画面の外へと飛んでいくので、画面の枠の外からどんどんでてくるように見える。
- circle.x+= -d * Math.cos(theta) //+ (firstPointX[i] - circle.x) * 0.1;
- circle.y+= -d * Math.sin(theta) //+ (firstPointY[i] - circle.y) * 0.1;
- }
- }
- }
- }
notice:




