Here is an example from my code run at Add function
const handlePlayFoam = (e) => {
// Show foam effect by set opacity = 1
ecs.Material.set(world, schemaAttribute.cursor(eid).foamEffectGo,
{textureSrc: array[dataAttribute.cursor(eid).frame], opacity: 1})
const intervalId = world.time.setInterval(() => {
if (!dataAttribute.cursor(eid).isStop) {
if (dataAttribute.cursor(eid).frame % 2 === 0 && Math.random() >= 0.43) {
ecs.Material.set(world, schemaAttribute.cursor(eid).foamEffectGo,
{textureSrc: array[dataAttribute.cursor(eid).frame], opacity: 0})
} else {
ecs.Material.set(world, schemaAttribute.cursor(eid).foamEffectGo,
{textureSrc: array[dataAttribute.cursor(eid).frame], opacity: 0.9})
dataAttribute.cursor(eid).frame++
}
if (dataAttribute.cursor(eid).frame > array.length - 1) {
dataAttribute.cursor(eid).frame = 0
}
}
}, 14)
}
world.events.addListener(world.events.globalId, 'RemoveCountDown', handlePlayFoam)
When the handlePlayFoam callback function runs, a loop will start inside this callback. It is assigned to intervalId. However, I cannot use world.time.clearInterval(intervalId) to clear it. How can I stop it completely?