|
@@ -49,8 +49,9 @@ class Editor extends h2d.Sprite {
|
|
var cedit : h2d.Interactive;
|
|
var cedit : h2d.Interactive;
|
|
var undo : Array<History>;
|
|
var undo : Array<History>;
|
|
var redo : Array<History>;
|
|
var redo : Array<History>;
|
|
- var currentFilePath : String;
|
|
|
|
|
|
+ public var currentFilePath : String;
|
|
public var autoLoop : Bool = true;
|
|
public var autoLoop : Bool = true;
|
|
|
|
+ public var moveEmitter(default,set) : Bool = false;
|
|
|
|
|
|
static var CURVES : Array<{ name : String, f : Curve -> Data.Value }> = [
|
|
static var CURVES : Array<{ name : String, f : Curve -> Data.Value }> = [
|
|
{ name : "Const", f : function(c) return VConst(c.min) },
|
|
{ name : "Const", f : function(c) return VConst(c.min) },
|
|
@@ -92,13 +93,7 @@ class Editor extends h2d.Sprite {
|
|
public dynamic function onTextureSelect() {
|
|
public dynamic function onTextureSelect() {
|
|
hxd.File.browse(function(sel) {
|
|
hxd.File.browse(function(sel) {
|
|
sel.load(function(bytes) {
|
|
sel.load(function(bytes) {
|
|
- var bmp = hxd.res.Any.fromBytes(sel.fileName, bytes).toBitmap();
|
|
|
|
- var t = h2d.Tile.fromBitmap(bmp);
|
|
|
|
- bmp.dispose();
|
|
|
|
- state.textureName = sel.fileName;
|
|
|
|
- curState = null; // force reload (if texture was changed)
|
|
|
|
- setTexture(t);
|
|
|
|
- buildUI();
|
|
|
|
|
|
+ changeTexture(sel.fileName, hxd.res.Any.fromBytes(sel.fileName, bytes).toTile());
|
|
});
|
|
});
|
|
},{
|
|
},{
|
|
defaultPath : currentFilePath,
|
|
defaultPath : currentFilePath,
|
|
@@ -108,6 +103,19 @@ class Editor extends h2d.Sprite {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function changeTexture( name : String, t : h2d.Tile ) {
|
|
|
|
+ state.textureName = name;
|
|
|
|
+ curState = null; // force reload (if texture was changed)
|
|
|
|
+ setTexture(t);
|
|
|
|
+ buildUI();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function set_moveEmitter(v) {
|
|
|
|
+ this.moveEmitter = v;
|
|
|
|
+ buildUI();
|
|
|
|
+ return v;
|
|
|
|
+ }
|
|
|
|
+
|
|
public dynamic function loadTexture( textureName : String ) : h2d.Tile {
|
|
public dynamic function loadTexture( textureName : String ) : h2d.Tile {
|
|
var bytes = null;
|
|
var bytes = null;
|
|
try {
|
|
try {
|
|
@@ -145,6 +153,12 @@ class Editor extends h2d.Sprite {
|
|
}
|
|
}
|
|
|
|
|
|
public dynamic function onSave( saveData ) {
|
|
public dynamic function onSave( saveData ) {
|
|
|
|
+ if( currentFilePath != null )
|
|
|
|
+ try {
|
|
|
|
+ hxd.File.saveBytes(currentFilePath, saveData);
|
|
|
|
+ return;
|
|
|
|
+ } catch( e : Dynamic ) {
|
|
|
|
+ }
|
|
if( currentFilePath == null ) currentFilePath = "default.p";
|
|
if( currentFilePath == null ) currentFilePath = "default.p";
|
|
hxd.File.saveAs(saveData, {
|
|
hxd.File.saveAs(saveData, {
|
|
defaultPath : currentFilePath,
|
|
defaultPath : currentFilePath,
|
|
@@ -181,6 +195,15 @@ class Editor extends h2d.Sprite {
|
|
getScene().addEventListener(onEvent);
|
|
getScene().addEventListener(onEvent);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ var time : Float = 0.;
|
|
|
|
+ public dynamic function onMoveEmitter(dt:Float) {
|
|
|
|
+ time += dt * 0.03 * 60;
|
|
|
|
+ var r = 1;
|
|
|
|
+ emit.x = Math.cos(time) * r;
|
|
|
|
+ emit.y = Math.sin(time * 0.5) * r;
|
|
|
|
+ emit.z = (Math.cos(time * 1.3) * Math.sin(time * 1.5) + 1) * r;
|
|
|
|
+ }
|
|
|
|
+
|
|
function onEvent( e : hxd.Event ) {
|
|
function onEvent( e : hxd.Event ) {
|
|
function loadHistory( h : History ) {
|
|
function loadHistory( h : History ) {
|
|
curState = h.state;
|
|
curState = h.state;
|
|
@@ -430,12 +453,24 @@ class Editor extends h2d.Sprite {
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="line">
|
|
<div class="line">
|
|
- <checkbox checked="${state.emitFromShell}" onchange="api.s.emitFromShell = this.checked"/> <span>Emit from Shell</span>
|
|
|
|
|
|
+ <div class="box">
|
|
|
|
+ <checkbox checked="${state.emitTrail}" onchange="api.s.emitTrail = this.checked"/> <span>Trail</span>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="box">
|
|
|
|
+ <checkbox checked="${state.randomDir}" onchange="api.s.randomDir = this.checked"/> <span>Rand. Dir</span>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="line">
|
|
|
|
+ <div class="box">
|
|
|
|
+ <checkbox checked="${state.emitLocal}" onchange="api.s.emitLocal = this.checked"/> <span>Local</span>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="box">
|
|
|
|
+ <checkbox checked="${state.emitFromShell}" onchange="api.s.emitFromShell = this.checked"/> <span>From Shell</span>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
<div class="line">
|
|
<div class="line">
|
|
- <checkbox checked="${state.randomDir}" onchange="api.s.randomDir = this.checked"/> <span>Random Dir</span>
|
|
|
|
|
|
+ <checkbox checked="${this.moveEmitter}" onchange="api.setMove(this.checked)"/> <span>Move Emitter</span>
|
|
</div>
|
|
</div>
|
|
- <!-- TODO : Bursts edition -->
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<h1>Particle</h1>
|
|
<h1>Particle</h1>
|
|
@@ -569,6 +604,7 @@ class Editor extends h2d.Sprite {
|
|
selectTexture : function() onTextureSelect(),
|
|
selectTexture : function() onTextureSelect(),
|
|
load : function() onLoad(),
|
|
load : function() onLoad(),
|
|
save : function() onSave(haxe.io.Bytes.ofString(curState)),
|
|
save : function() onSave(haxe.io.Bytes.ofString(curState)),
|
|
|
|
+ setMove : function(b) moveEmitter = b,
|
|
});
|
|
});
|
|
addChildAt(ui,0);
|
|
addChildAt(ui,0);
|
|
stats = cast ui.getElementById("stats");
|
|
stats = cast ui.getElementById("stats");
|
|
@@ -884,7 +920,7 @@ class Editor extends h2d.Sprite {
|
|
rebuildCurve();
|
|
rebuildCurve();
|
|
}
|
|
}
|
|
|
|
|
|
- public function setTexture( t : h2d.Tile ) {
|
|
|
|
|
|
+ function setTexture( t : h2d.Tile ) {
|
|
state.frames = [t];
|
|
state.frames = [t];
|
|
curTile = t;
|
|
curTile = t;
|
|
state.initFrames();
|
|
state.initFrames();
|
|
@@ -915,8 +951,14 @@ class Editor extends h2d.Sprite {
|
|
redo = [];
|
|
redo = [];
|
|
}
|
|
}
|
|
emit.speed = props.pause ? 0 : (props.slow ? 0.1 : 1);
|
|
emit.speed = props.pause ? 0 : (props.slow ? 0.1 : 1);
|
|
|
|
+ if( moveEmitter ) onMoveEmitter(ctx.elapsedTime);
|
|
var pcount = emit.count;
|
|
var pcount = emit.count;
|
|
- if( stats != null ) stats.text = hxd.Math.fmt(emit.time * state.globalLife) + " s\n" + pcount + " p\n" + hxd.Math.fmt(ctx.engine.fps) + " fps" + ("\n"+getScene().getSpritesCount());
|
|
|
|
|
|
+ if( stats != null )
|
|
|
|
+ stats.text = [
|
|
|
|
+ hxd.Math.fmt(emit.time * state.globalLife) + " s",
|
|
|
|
+ pcount + " parts",
|
|
|
|
+ hxd.Math.fmt(ctx.engine.fps) + " fps",
|
|
|
|
+ ].join("\n");
|
|
if( autoLoop && !emit.isActive() ) {
|
|
if( autoLoop && !emit.isActive() ) {
|
|
if( lastPartSeen == null )
|
|
if( lastPartSeen == null )
|
|
lastPartSeen = emit.time;
|
|
lastPartSeen = emit.time;
|