forked from: 某スペルカードの一部風 目コピ処理
東風谷早苗スペルカード「グレイソーマタージ」の☆の部分風な処理
かなり目コピなんで計算方法はムリがあるかも
クリックすると新しい☆が生成されます
/**
* Copyright uwi ( http://wonderfl.net/user/uwi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/yNFJ
*/
// forked from okoi's 某スペルカードの一部風 目コピ処理
//
// 東風谷早苗スペルカード「グレイソーマタージ」の☆の部分風な処理
// かなり目コピなんで計算方法はムリがあるかも
//
// クリックすると新しい☆が生成されます
//
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
[SWF(backgroundColor = "0x000000", frameRate = "60")]
/**
*
* @author okoi
*/
public class Main extends Sprite
{
private var patternList:Array = new Array();
private var moveBullet:Array = new Array();
private var _tf : TextField;
public function Main():void
{
_tf = new TextField();
_tf.textColor = 0xffffff;
addChild(_tf);
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
patternList.push( new Pattern(stage.stageWidth/2, stage.stageHeight/2) );
addEventListener(Event.ENTER_FRAME, EnterFrame );
stage.addEventListener(MouseEvent.MOUSE_DOWN, MouseDown);
}
private function EnterFrame(event:Event):void
{
var i:int = 0;
for ( i = 0; i < patternList.length; i++ )
{
var bullet:Bullet = patternList[i].Run();
if ( bullet != null )
{
addChild( bullet );
}
}
for ( i = patternList.length - 1; i >= 0; i-- )
{
if ( patternList[i].isEnd() )
{
// 待機リストから移動リストへ
for ( var j:int = 0; j < patternList[i].waitBullet.length; j++ ) moveBullet.push( patternList[i].waitBullet[j] );
patternList.splice( i, 1 );
}
}
// 弾移動
if ( moveBullet.length > 0 )
{
_tf.text = "";
for ( i = moveBullet.length - 1; i >= 0; i-- )
{
_tf.appendText("" + moveBullet[i].x + "\t" + moveBullet[i].y + "\n");
moveBullet[i]._xx += Math.cos( moveBullet[i].moveAngle / 180 * Math.PI);
moveBullet[i]._xy += Math.sin( moveBullet[i].moveAngle / 180 * Math.PI);
moveBullet[i].x = moveBullet[i]._xx;
moveBullet[i].y = moveBullet[i]._xy;
if ( moveBullet[i].x < -50 || moveBullet[i].x > stage.stageWidth + 50 || moveBullet[i].y < -50 || moveBullet[i].y > stage.stageHeight + 50 )
{
removeChild( moveBullet[i] );
moveBullet.splice( i, 1 );
}
}
}
}
private function MouseDown(event:MouseEvent):void
{
patternList.push( new Pattern(stage.stageWidth/2, stage.stageHeight/2) );
}
}
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
import flash.display.Sprite;
import flash.geom.Point;
//-----------------------------
// 弾幕パターンクラス
class Pattern {
private var end:Boolean = false;
private var count:int = 0;
private var defX:int = 0;
private var defY:int = 0;
private var gAngle:Number = 0; // 弾発生角度
private var target:Array = new Array();
private static const PATH_OBJ_NUM:int = 20; // 1辺に出す弾の数
private static const TARGET_NUM:int = 5;
private static const TARGET_ANGLE:Array = [ 270 + 72 * 3, 270 + 72 * 1, 270 + 72 * 4, 270 + 72 * 2, 270 ]; // パスの目標地点の角度
public var waitBullet:Array = new Array(); // 保持用バッファ
public function Pattern(_gx:int = 0, _gy:int = 0) {
count = 0;
defX = _gx;
defY = _gy;
gAngle = 0;
for ( var i:int = 0; i < 5; i++ )
{
target[i] = new Point( Math.cos( TARGET_ANGLE[i] * Math.PI / 180 ) * 100, Math.sin( TARGET_ANGLE[i] * Math.PI / 180 ) * 100 );
}
}
/**
* 弾発生処理
* @return
*/
public function Run() : Bullet {
var bullet:Bullet = new Bullet();
var targetNo:int = int(count / PATH_OBJ_NUM);
var targetRate:int = int(count % PATH_OBJ_NUM);
var p:Point;
// 弾の座標を出す
p = Point.interpolate( target[targetNo], target[(targetNo+(TARGET_NUM-1))%TARGET_NUM], targetRate / PATH_OBJ_NUM );
bullet._xx = p.x + defX;
bullet._xy = p.y + defY;
bullet.x = p.x + defX;
bullet.y = p.y + defY;
// 弾の移動角度を出す
bullet.moveAngle = -count / PATH_OBJ_NUM / TARGET_NUM * 720 + 135;
waitBullet.push( bullet );
count++;
if ( count == TARGET_NUM * PATH_OBJ_NUM ) end = true;
return bullet;
}
public function isEnd() : Boolean { return end; }
}
//-----------------------------
// 弾クラス
class Bullet extends Sprite {
public var moveAngle:Number = 0;
public var _xx : Number;
public var _xy : Number;
public function Bullet() {
super();
graphics.beginFill(0x5555FF);
graphics.drawCircle(0, 0, 5);
graphics.endFill();
graphics.beginFill(0xFFFFFF, 0.5);
graphics.drawCircle(0, 0, 3);
graphics.endFill();
}
}