diff --git a/src/game/make.ts b/src/game/make.ts index dfeb3160..526b3078 100644 --- a/src/game/make.ts +++ b/src/game/make.ts @@ -122,7 +122,6 @@ export function make(comps: CompList = []): GameObj { } obj.parent = this; calcTransform(obj, obj.transform); - this.children.push(obj); // TODO: trigger add for children obj.trigger("add", obj); _k.game.events.trigger("add", obj); diff --git a/src/kaplay.ts b/src/kaplay.ts index 47e382b5..18940580 100644 --- a/src/kaplay.ts +++ b/src/kaplay.ts @@ -366,7 +366,8 @@ const kaplay = < >( gopt: KAPLAYOpt = {}, ): TPlugins extends [undefined] ? KAPLAYCtx - : KAPLAYCtx & MergePlugins => { + : KAPLAYCtx & MergePlugins => +{ if (_k.k) { console.warn( "KAPLAY already initialized, you are calling kaplay() multiple times, it may lead bugs!", @@ -489,7 +490,10 @@ const kaplay = < game.root.use(timer()); - system("collision", checkFrame, [LCEvents.AfterFixedUpdate, LCEvents.AfterUpdate]) + system("collision", checkFrame, [ + LCEvents.AfterFixedUpdate, + LCEvents.AfterUpdate, + ]); function makeCanvas(w: number, h: number) { const fb = new FrameBuffer(ggl, w, h); @@ -1000,7 +1004,7 @@ const kaplay = < // TODO: this should only run once app.run( - () => { }, + () => {}, () => { frameStart(); @@ -1063,7 +1067,7 @@ const kaplay = < // clear canvas gl.clear( gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT - | gl.STENCIL_BUFFER_BIT, + | gl.STENCIL_BUFFER_BIT, ); // unbind everything @@ -1111,7 +1115,7 @@ const kaplay = < } } - //checkFrame(); + // checkFrame(); } } catch (e) { handleErr(e as Error); @@ -1157,7 +1161,7 @@ const kaplay = < } } - //checkFrame(); + // checkFrame(); frameStart(); for (const sys of _k.systemsByEvent[LCEvents.BeforeDraw]) { @@ -1516,6 +1520,7 @@ const kaplay = < downloadBlob, // plugin plug, + system, // char sets ASCII_CHARS, // dom @@ -1556,7 +1561,7 @@ const kaplay = < // export everything to window if global is set if (gopt.global !== false) { for (const key in ctx) { - (window[key]) = ctx[key as keyof KAPLAYCtx]; + ( window[ key]) = ctx[key as keyof KAPLAYCtx]; } } diff --git a/src/types.ts b/src/types.ts index d937c934..0628c527 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5385,6 +5385,17 @@ export interface KAPLAYCtx< * @group Plugins */ plug>(plugin: KAPLAYPlugin): KAPLAYCtx & T; + /** + * Runs a system at the specified events in the pipeline + * + * @param name The name of the system. Overwrites an existing system if the name has been used before. + * @param cb The function to run. + * @param when When to run the function. + * + * @since v4000.0 + * @group Plugins + */ + system(name: string, cb: () => void, when: LCEvents[]): void; /** * Take a screenshot and get the data url of the image. *