昔よくホームページで見かけたもの
イージングの練習に一つ
昔、ネットサーフィンしていると、マウスポインタを要請の画像やキラキラした星が追いかけてくるサイトを結構みかけた。
それをふと思い出して作ってみた。
・・簡単な発想で作れるからいろんなホームページで使われていたのかな
♥0 |
Line 79 |
Modified 2011-05-24 00:01:01 |
MIT License
archived:2017-03-20 13:49:47
ActionScript3 source code
/**
* Copyright Nowloading_ ( http://wonderfl.net/user/Nowloading_ )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zJpt
*/
package {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
public class Throwing extends Sprite{
private var radius:int = 15;
private var ball2:Ball;
private var vx2:Number;
private var vy2:Number;
private var easing:Number = 0.18;
private var eggs:Array;
private var vex:Number;
private var vey:Number;
private var eggeasing:Number = 0.14;
public function Throwing(){
init();
}
private function init():void{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT
ball2 = new Ball(radius,0x00ff00);
ball2.x = Math.random()*stage.stageWidth;
ball2.y = Math.random()*stage.stageHeight;
addChild(ball2);
eggs = new Array();
for(var i:int = 0;i<3;i++){
var ball:Ball = new Ball(radius,Math.random()*0xffffff);
ball.x = ball2.x;
ball.y = ball2.y;
eggs[i] = ball;
addChild(eggs[i]);
}
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
private function onEnterFrame(e:Event):void{
vx2 = (mouseX-ball2.x)*easing;
vy2 = (mouseY-ball2.y)*easing;
ball2.x+=vx2;
ball2.y+=vy2;
vex = (ball2.x - eggs[0].x)*eggeasing;
vey = (ball2.y - eggs[0].y)*eggeasing;
eggs[0].x += vex;
eggs[0].y += vey;
for(var i:int=1;i<3;i++){
vex = (eggs[i-1].x - eggs[i].x)*(eggeasing+i*0.0);
vey = (eggs[i-1].y - eggs[i].y)*(eggeasing+i*0.02);
eggs[i].x += vex;
eggs[i].y += vey;
}
}
}
}
import flash.display.*;
import flash.geom.*;
class Ball extends Sprite{
public var radius:Number;
public var color:uint;
public var vx:Number =0;
public var vy:Number =0;
public function Ball(radius:Number = 40,color:uint = 0xff0000){
this.radius = radius;
this.color = color;
init();
}
public function init():void{
var matrix:Matrix = new Matrix();
matrix.createGradientBox( 50, 50, 0, x-20, y);
graphics.beginGradientFill(
GradientType.LINEAR,
[color, 0x0000ff],
[1, 1],
[0, 255],
matrix);
graphics.drawCircle(0,0,radius);
graphics.endFill();
}
}