用于生成等待一段时间的effect. * 该函数作用和delay类似, 不过该函数会考虑游戏暂停的情况
(ms: number)
| 8 | /** 用于生成等待一段时间的effect. |
| 9 | * 该函数作用和delay类似, 不过该函数会考虑游戏暂停的情况 */ |
| 10 | static *delay(ms: number) { |
| 11 | let acc = 0 |
| 12 | while (true) { |
| 13 | const { delta }: actions.Tick = yield take(actions.A.Tick) |
| 14 | acc += delta |
| 15 | if (acc >= ms) { |
| 16 | break |
| 17 | } |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | static *tween(duration: number, effectFactory: (t: number) => Effect) { |
| 22 | let accumulation = 0 |
no outgoing calls
no test coverage detected