らき☆すたOP
// write as3 code here..
package {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
public class LuckyStarOp extends Sprite {
private var starSize:Number = 200;
private var stars:Array = new Array();
private var vr:Number = 0;
private var vx:Number = 0;
private var vy:Number = 0;
private var vscale:Number = -0.1;
private var targetX:Number = stage.stageWidth / 2;
private var targetY:Number = stage.stageHeight / 2;
private var targetR:Number = 360 - (Math.PI / 10 * 180 / Math.PI);
private var initX:Number = 0 - 50;
private var initY:Number = stage.stageHeight + 50;
private var star1:LuckyStar1;
private var star2:LuckyStar1;
private var star3:LuckyStar1;
private var easing:Number = 0.2;
public function LuckyStarOp() {
init();
}
private function init():void {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
star1 = new LuckyStar1(starSize, 0x000000);
star1.x = initX;
star1.y = initY;
addChild(star1);
star2 = new LuckyStar1(0.7 * starSize, 0xffffff);
star1.addChild(star2);
star3 = new LuckyStar1(starSize, 0xf10481);
star1.addChild(star3);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void {
vx = (targetX - star1.x) * easing;
vy = (targetY - star1.y) * easing;
star1.x += vx;
star1.y += vy;
vr = (targetR - rotationToDegree(star1.rotation)) * easing;
star1.rotation += vr;
if (targetR - rotationToDegree(star1.rotation) < 1) {
if (star3.scaleX > 0.4) {
trace('stop');
star3.scaleX += -0.1;
star3.scaleY += -0.1;
} else {
trace('width: ' + star3.width);
if (star1.width > 30) {
star1.scaleX *= 0.7;
star1.scaleY *= 0.7;
}
}
}
}
private function rotationToDegree(rot:Number) {
if (rot < 0) {
return (360 + rot);
}
return rot;
}
}
}
import flash.display.Sprite;
class LuckyStar1 extends Sprite {
private var radius:Number;
private var color:uint;
private var scale:Number = 0.55;
private var scale2:Number = 0.515;
public function LuckyStar1(radius:Number = 40, color:uint = 0xff0000) {
this.radius = radius;
this.color = color;
init();
}
private function init():void {
graphics.beginFill(this.color);
var radian:Number;
var rad_center:Number;
radian = 0 / 5 * 2 * Math.PI;
graphics.moveTo(this.radius * Math.cos(radian), this.radius * Math.sin(radian));
// var ball:Ball = new Ball(5);
// addChild(ball);
// ball.x = this.radius * Math.cos(radian);
// ball.y = this.radius * Math.sin(radian);
rad_center = 1 / 5 * 2 * Math.PI;
radian = 2 / 5 * 2 * Math.PI;
graphics.curveTo(scale * this.radius * Math.cos(rad_center), scale * this.radius * Math.sin(rad_center), this.radius * Math.cos(radian), this.radius * Math.sin(radian));
rad_center = 3 / 5 * 2 * Math.PI;
radian = 4 / 5 * 2 * Math.PI;
graphics.curveTo(scale * this.radius * Math.cos(rad_center), scale * this.radius * Math.sin(rad_center), this.radius * Math.cos(radian), this.radius * Math.sin(radian));
rad_center = 0 / 5 * 2 * Math.PI;
radian = 1 / 5 * 2 * Math.PI;
graphics.curveTo(scale * this.radius * Math.cos(rad_center), scale * this.radius * Math.sin(rad_center), this.radius * Math.cos(radian), this.radius * Math.sin(radian));
rad_center = 2 / 5 * 2 * Math.PI;
radian = 3 / 5 * 2 * Math.PI;
graphics.curveTo(scale * this.radius * Math.cos(rad_center), scale * this.radius * Math.sin(rad_center), this.radius * Math.cos(radian), this.radius * Math.sin(radian));
rad_center = 4 / 5 * 2 * Math.PI;
radian = 0 / 5 * 2 * Math.PI;
graphics.curveTo(scale * this.radius * Math.cos(rad_center), scale * this.radius * Math.sin(rad_center), this.radius * Math.cos(radian), this.radius * Math.sin(radian));
graphics.endFill();
// graphics.lineStyle(1);
// graphics.drawCircle(this.x, this.y, this.radius * scale);
// graphics.drawCircle(this.x, this.y, this.radius * scale2);
graphics.beginFill(this.color);
radian = 1 / 5 * Math.PI;
graphics.moveTo(scale2 * this.radius * Math.cos(radian), scale2 * this.radius * Math.sin(radian));
rad_center = 1 / 5 * 2 * Math.PI;
radian = 3 / 5 * Math.PI;
graphics.curveTo(scale * this.radius * Math.cos(rad_center), scale * this.radius * Math.sin(rad_center), scale2 * this.radius * Math.cos(radian), scale2 * this.radius * Math.sin(radian));
rad_center = 2 / 5 * 2 * Math.PI;
radian = 5 / 5 * Math.PI;
graphics.curveTo(scale * this.radius * Math.cos(rad_center), scale * this.radius * Math.sin(rad_center), scale2 * this.radius * Math.cos(radian), scale2 * this.radius * Math.sin(radian));
rad_center = 3 / 5 * 2 * Math.PI;
radian = 7 / 5 * Math.PI;
graphics.curveTo(scale * this.radius * Math.cos(rad_center), scale * this.radius * Math.sin(rad_center), scale2 * this.radius * Math.cos(radian), scale2 * this.radius * Math.sin(radian));
rad_center = 4 / 5 * 2 * Math.PI;
radian = 9 / 5 * Math.PI;
graphics.curveTo(scale * this.radius * Math.cos(rad_center), scale * this.radius * Math.sin(rad_center), scale2 * this.radius * Math.cos(radian), scale2 * this.radius * Math.sin(radian));
rad_center = 0 / 5 * 2 * Math.PI;
radian = 1 / 5 * Math.PI;
graphics.curveTo(scale * this.radius * Math.cos(rad_center), scale * this.radius * Math.sin(rad_center), scale2 * this.radius * Math.cos(radian), scale2 * this.radius * Math.sin(radian));
graphics.endFill();
//this.rotation -= 90;
}
}