--- a/src/behavior.c Tue Aug 19 18:05:35 2025 +0200 +++ b/src/behavior.c Tue Aug 19 18:23:47 2025 +0200 @@ -68,6 +68,7 @@ behavior->data = args.data; behavior->interval = args.interval; behavior->last_execution = 0; + behavior->pause_while_hidden = args.pause_while_hidden; behavior->name = name; asc_dprintf("Create behavior: %"CX_PRIstr, CX_SFMT(behavior->name)); return behavior; @@ -80,8 +81,9 @@ } void asc_behavior_trigger(AscBehavior *behavior) { - assert(behavior->enabled); + if (!behavior->enabled) return; if (behavior->last_execution + behavior->interval > asc_context.total_nanos) return; + if (behavior->pause_while_hidden && asc_scene_node_is_hidden(behavior->node)) return; behavior->func(behavior); behavior->last_execution = asc_context.total_nanos; @@ -106,4 +108,18 @@ cx_foreach(AscBehavior*, behavior, iter) { behavior->enabled = false; } -} \ No newline at end of file +} + +void asc_behavior_pause_all_while_hidden(AscSceneNode *node) { + CxMapIterator iter = cxMapIteratorValues(node->behaviors); + cx_foreach(AscBehavior*, behavior, iter) { + behavior->pause_while_hidden = true; + } +} + +void asc_behavior_continue_all_while_hidden(AscSceneNode *node) { + CxMapIterator iter = cxMapIteratorValues(node->behaviors); + cx_foreach(AscBehavior*, behavior, iter) { + behavior->pause_while_hidden= false; + } +}