Aego Русский

Waiting in coroutines

yield waits for a tween or a timer:

func Die() coroutine {
  yield tween.ToFloat(node, "SpriteRenderer.Tint.a", 0, 0.2, curve.OutQuad)
  node.Destroy()
}

func Spawner() coroutine {
  t := timer.New(2).Repeat(-1)
  for {
    yield t
    spawn()
  }
}

How waits resume:

There is no polling: a coroutine parked on a handle costs nothing until the handle wakes it.