マウスポインタに追随
♥0 |
Line 28 |
Modified 2010-07-18 01:27:48 |
MIT License
archived:2017-03-20 13:26:02
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/9dqJ
*/
package {
import flash.display.Sprite;
import flash.events.*;
public class Sqrt extends Sprite {
public var maru:Sprite;
public var pointLength:Number;
public var nRadian:Number;
public function Sqrt() {
maru=new Sprite();
maru.graphics.beginFill(0x33a8ff);
maru.graphics.lineStyle();
maru.graphics.drawCircle(0,0,20);
maru.graphics.endFill();
addChild(maru);
maru.x=0;
maru.y=0;
stage.addEventListener(Event.ENTER_FRAME,enterFramer);
}
public function enterFramer(e:Event):void{
var nx:int=mouseX;
var ny:int=mouseY;
nRadian=Math.atan2(ny-maru.y,nx-maru.x);
pointLength=Math.sqrt(Math.pow(nx-maru.x,2)+Math.pow(ny-maru.y,2));
maru.x+=pointLength*Math.cos(nRadian)*0.06;
maru.y+=pointLength*Math.sin(nRadian)*0.06;
}
}
}