fix particles

This commit is contained in:
John Alanbrook 2024-09-09 18:55:07 -05:00
parent 8da89f1032
commit 0d5ce8f62c
6 changed files with 11 additions and 3 deletions

View file

@ -75,6 +75,7 @@ var sprite = {
// self?.anim_done?.();
// if (!self.loop) { self.stop(); return; }
}
if (self)
stop = self.gameobject.delay(advance, playing.frames[f].time);
}

View file

@ -380,6 +380,7 @@ dup(diff) {
this.clear();
if (this.stop instanceof Function) this.stop();
if (typeof this.garbage === 'function') this.garbage();
game.tag_clear_guid(this.guid);

View file

@ -48,6 +48,7 @@ emitter.spawn = function(t)
this.particles[par.id] = par;
par.time = 0;
this.spawn_hook?.(par);
par.life = this.life;
return;
}
@ -84,8 +85,8 @@ emitter.step = function(dt)
for (var p of Object.values(this.particles)) {
p.time += dt;
this.step_hook?.(p);
if (p.time >= p.life) {
if (this.kill_hook?.(p) || p.time >= p.life) {
this.die_hook?.(p);
this.dead.push(this.particles[p.id]);
delete this.particles[p.id];

View file

@ -363,6 +363,7 @@ Register.add_cb("gui_dbg", true);
Register.add_cb("hud_dbg", true);
Register.add_cb("draw", true);
Register.add_cb("imgui", true);
Register.add_cb("post", true);
var Event = {
events: {},

View file

@ -1118,6 +1118,9 @@ prosperon.render = function()
render.flush_text();
mum.style = mum.base;
prosperon.post();
check_flush();
profile.endframe();
profile.frame("imgui");

View file

@ -57,8 +57,9 @@ var song;
// Play 'file' for new song, cross fade for seconds
audio.music = function(file, fade = 0.5) {
if (!file) {
if (song)
if (song)
song.volume = 0;
return;
}
file = Resources.find_sound(file);
if (!fade) {