/**
* Copyright ffffine ( http://wonderfl.net/user/ffffine )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/ghCq
*/
package
{
import flash.display.*;
import flash.events.*;
import idv.cjcat.stardust.common.clocks.*;
import idv.cjcat.stardust.twoD.renderers.*;
[SWF(width = "465", height = "465", backgroundColor = "0x000000" , frameRate = "30")]
/**
* StardustとFrocessingのお勉強
* いまいちStardustのパラメーターがよくわからない。
*
*/
public class FlashTest extends Sprite
{
private var _emmitter:MyEmitter;
public function FlashTest ():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
graphics.clear();
graphics.beginFill(0x000000);
graphics.drawRect(0,0,465,465);
graphics.endFill();
var clock:SteadyClock = new SteadyClock(6);
_emmitter = new MyEmitter(clock);
var renderer:DisplayObjectRenderer = new DisplayObjectRenderer(this);
renderer.addEmitter(_emmitter);
addEventListener(Event.ENTER_FRAME, xEnterFrame);
}
private function xEnterFrame(e:Event):void
{
_emmitter.step();
_emmitter.emitPoint.x -= (_emmitter.emitPoint.x - stage.mouseX) * 0.2;
_emmitter.emitPoint.y -= (_emmitter.emitPoint.y - stage.mouseY) * 0.2;
}
}
}
import flash.display.*;
import frocessing.color.*;
import frocessing.display.*;
import idv.cjcat.stardust.common.actions.*;
import idv.cjcat.stardust.common.clocks.*;
import idv.cjcat.stardust.common.initializers.*;
import idv.cjcat.stardust.common.math.*;
import idv.cjcat.stardust.twoD.actions.*;
import idv.cjcat.stardust.twoD.emitters.*;
import idv.cjcat.stardust.twoD.initializers.*;
import idv.cjcat.stardust.twoD.zones.*;
//Emitter
class MyEmitter extends Emitter2D {
public var emitPoint:CircleContour;
public function MyEmitter(clock:Clock) {
super(clock);
//initalizer
addInitializer(new DisplayObjectClass(Seed));
addInitializer(new Life(new UniformRandom(50,100)));
addInitializer(new Velocity(new LazySectorZone(0, 5)));
emitPoint = new CircleContour(0,0,100);
addInitializer(new Position(emitPoint));
addInitializer(new Scale(new UniformRandom(2,2)));
//addInitializer(new Rotation(new UniformRandom(0, 180)));
//Action
addAction(new Age());
addAction(new DeathLife());
addAction(new Accelerate(0.2));
addAction(new ScaleCurve(10, 1));
addAction(new Move());
}
}
//particleする対象
class Seed extends F5MovieClip2D {
public static var num:Number = 180;
private var koma:Boolean;
private var colorHSV:ColorHSV;
private var bmp:BitmapData;
private var bmp1:BitmapData;
private var bmp2:BitmapData;
public function Seed() {
}
public function setup():void {
num += 2;
colorHSV = new ColorHSV(num, 0.95, 1);
//ドット絵作成
bmp1 = new mapToDots(
[
[0,0,0,0,0,0,0,0,0,0,0],
[0,0,1,0,0,0,0,0,1,0,0],
[1,0,0,1,0,0,0,1,0,0,1],
[1,0,1,1,1,1,1,1,1,0,1],
[1,1,1,0,1,1,1,0,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,0],
[0,0,1,0,0,0,0,0,1,0,0],
[0,1,0,0,0,0,0,0,0,1,0],
[0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0]
]
).createBitmapData();
bmp2 = new mapToDots(
[
[0,0,0,0,0,0,0,0,0,0,0],
[0,0,1,0,0,0,0,0,1,0,0],
[0,0,0,1,0,0,0,1,0,0,0],
[0,0,1,1,1,1,1,1,1,0,0],
[0,1,1,0,1,1,1,0,1,1,0],
[1,1,1,1,1,1,1,1,1,1,1],
[1,0,1,1,1,1,1,1,1,0,1],
[1,0,1,0,0,0,0,0,1,0,1],
[0,0,0,1,1,0,1,1,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0]
]
).createBitmapData();
bmp = bmp1;
blendMode = "add";
noStroke();
imageSmoothing(false);
tint(colorHSV.value);
image(bmp, 0, 0);
loop();
}
public function draw():void {
if (frameCount % 5 == 0) {
if(koma){
bmp = bmp1;
koma = false;
} else {
bmp = bmp2;
koma = true;
}
}
tint(colorHSV.value);
image(bmp, 0, 0);
}
}
//Mapデータぶっこんでドット絵データ作るクラス
//[
//[0,0,0,0,0,0,0,0,0,0,0],
//[0,0,1,0,0,0,0,0,1,0,0],
//[1,0,0,1,0,0,0,1,0,0,1],
//[1,0,1,1,1,1,1,1,1,0,1],
//[1,1,1,0,1,1,1,0,1,1,1],
//[1,1,1,1,1,1,1,1,1,1,1],
//[0,1,1,1,1,1,1,1,1,1,0],
//[0,0,1,0,0,0,0,0,1,0,0],
//[0,1,0,0,0,0,0,0,0,1,0],
//[0,0,0,0,0,0,0,0,0,0,0],
//[0,0,0,0,0,0,0,0,0,0,0]
//]
//こんなの読み込んでドット絵にする。
class mapToDots {
public var map:Array = [];
public function mapToDots(Map:Array = null) {
if (map != null) { map = Map;}
}
public function createBitmapData():BitmapData
{
var width:uint = map[0].length;
var height:uint = map.length;
var bitmapdata:BitmapData = new BitmapData( width, height, true, 0x00FFFFFF);
for (var i:int = 0; i < width; i++)
{
for (var j:int = 0; j < height; j++)
{
if(map[j][i] == 1){
bitmapdata.setPixel32(i, j, 0xFFFFFFFF);
}
}
}
return bitmapdata ;
}
}