I have the following initialization code in a script at the root of the hierarchy…
export const MAX_EMITTERS = 15;
parent.one("ready", () => {
// Allocate a pool of emitters to be used in touch events.
for ( let i = 0; i < MAX_EMITTERS; i++ ) {
// Instantiate particle emitter
let emitter : any = Z.Symbol("Particle Emitter");
emitter.nodes.Code.init(); // required
// Add to hierarchy so it's visible when activated.
symbol.nodes.Touch_Emitters.push( emitter );
}
});
Initially, I used on()
to handle the event, but the experience would be unresponsive as soon as it launched and the camera feed very sluggish as though the app was compute-bound. After changing the method to one()
, it works fine.
I couldn’t find any documentation specifically on the ready event, but the above suggests that it was firing repeatedly, thereby causing my initialization loop to run continuously and hog resources.
I’m just guessing about that, of course, so can anyone at Zappar shed light on exactly when the ready event fires and whether it’s just once per experience?
Things are working now, but this would be good to know for future reference.